Skip to content

Commit e442624

Browse files
committed
Optimize rdf:ID handling
1 parent 089bb99 commit e442624

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ This project adheres to [Semantic Versioning](http://semver.org/) and
55
[Keep a CHANGELOG](http://keepachangelog.com).
66

77

8+
## Unreleased
9+
10+
Elixir versions < 1.14 and OTP version < 23 are no longer supported.
11+
12+
### Added
13+
14+
- optimization of `rdf:ID`/`rdf:nodeID` handling
15+
16+
17+
[Compare v1.2.0...HEAD](https://github.com/rdf-elixir/rdf-xml-ex/compare/v1.2.0...HEAD)
18+
19+
20+
821
## v1.2.0 - 2024-08-07
922

1023
This version upgrades to RDF.ex v2.0.

lib/rdf/xml/decoder/element_node.ex

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,16 @@ defmodule RDF.XML.Decoder.ElementNode do
242242
end
243243
end
244244

245-
defp nc_name(name) do
246-
# TODO: NCNames are actually more restrictive; see https://www.w3.org/TR/REC-xml-names/#NT-NCName
247-
if String.match?(name, ~r/^[a-zA-Z_]/) and not String.contains?(name, ~w[: /]) do
248-
{:ok, name}
249-
else
245+
# TODO: NCNames are actually more restrictive; see https://www.w3.org/TR/REC-xml-names/#NT-NCName
246+
defp nc_name(<<c, _::binary>> = name) when c in ?a..?z or c in ?A..?Z or c == ?_ do
247+
if String.contains?(name, ~w[: /]) do
250248
{:error, %RDF.XML.ParseError{message: "invalid NCName #{name}"}}
249+
else
250+
{:ok, name}
251251
end
252252
end
253+
254+
defp nc_name(name) do
255+
{:error, %RDF.XML.ParseError{message: "invalid NCName #{name}"}}
256+
end
253257
end

0 commit comments

Comments
 (0)