Skip to content

XML qname parses correctly but is not serialized correctly. #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jamsden opened this issue Apr 17, 2018 · 4 comments
Open

XML qname parses correctly but is not serialized correctly. #228

jamsden opened this issue Apr 17, 2018 · 4 comments

Comments

@jamsden
Copy link

jamsden commented Apr 17, 2018

Error: Invalid character "." cannot be in XML qname for URI: http://jazz.net/xmlns/prod/jazz/rtc/ext/1.0/com.ibm.team.apt.attribute.acceptance
at Serializer.qnameMethod (/Users/jamsden/GitHub/rdflib.js/lib/serializer.js:913:17)
at Serializer.subjectXMLTreeMethod (/Users/jamsden/GitHub/rdflib.js/lib/serializer.js:819:13)
at Serializer.statementListToXMLTreeMethod (/Users/jamsden/GitHub/rdflib.js/lib/serializer.js:736:22)
at Serializer.statementsToXML (/Users/jamsden/GitHub/rdflib.js/lib/serializer.js:931:16)
at Object.serialize (/Users/jamsden/GitHub/rdflib.js/lib/serialize.js:27:29)

According to https://www.w3.org/TR/REC-xml/#NT-Name, NCName can contain ".". So the serializer should handle these QNames.

@jamsden
Copy link
Author

jamsden commented May 21, 2018

For the syntax of a QName, https://www.w3.org/TR/REC-xml/ says that a local name for a qname is a Name less colon. A Name is defined here: https://www.w3.org/TR/REC-xml/#NT-Name. There's almost nothing illegal in that set of characters except colon, control characters, and unassigned code points (and as far as I can see the latter are merely discouraged, not illegal).

@jamsden
Copy link
Author

jamsden commented Apr 12, 2025

I see this is still open. https://www.w3.org/TR/xml-names11/#NT-NCName explicitly states that "." is included in NCName which is part of a Prefix.

The fix is simple: In rdflib/src/serializer.js:196:
Change:
__Serializer.prototype._notQNameChars = '\t\r\n !"#$%&'()*.,+/;<=>?@[\]^{|}~'; to: __Serializer.prototype._notQNameChars = '\t\r\n !"#$%&\'()*,+/;<=>?@[\\]^{|}~';
(i.e., remove . from the _notQNameChars)

Any chance this could get addressed?

@bourgeoa
Copy link
Member

bourgeoa commented Apr 13, 2025

Thanks for reopening.
But there are other consequences that make some tests fail on serializing text/turtle
see #686

As also some consequence like #647

@jamsden
Copy link
Author

jamsden commented Apr 23, 2025

@bourgeoa: Understood. But it seems like anything that relies on considering valid QNames as invalid would be incorrect and should also be addressed.

Otherwise, is this something that could be addressed in a future release or do I need to fork?

IBM Engineering Workflow Manager (formerly Rational Team Concert) makes heavy use of prefixes that contain dots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants