-
Notifications
You must be signed in to change notification settings - Fork 163
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
Turtle writer does not respect namespaces in IRIs #4921
Comments
- SimpleValueFactory.createIRI(String, String) how actually properly respects the specified namespace and localname - TurtleWriter tries to use the namespace encoded in the IRI unless the localname contains characters which are not valid in prefixed notation - Added test
PR provided: #4922 |
Not seen this before. Can you point to where this is defined in the turtle specification? |
I have just ported code from Jena to RDF4J. In the Jena version, all IRIs I used were properly abbreviated when a namespace prefix was defined. Not so in RDF4J. I tracked this down to two issues:
Have a look at the provided test case. As far as I can see during a quick scan of the Turtle specs, they deal mostly with parsing the turtle format. However, what I am trying to fix here is the serialization. The current serialization done by RDF4J provides valid Turtle, but it is unnecessarily verbose. My change makes more effective use of the namespace prefix declarations, leading to a serialized form that is more compact and easier to read. |
- Added tests to check to which degree parsing a Turtle file with unconventional prefixes and serializing it back again results preserves format
- Commented out failing parts of new tests and refer to followup issue
- Fix RDFXML test by checking if a localname preference indicated by the IRI is valid in XML - if not, try to find an alternative representation
Current Behavior
The turtle writer does not consider the namespace provided by an IRI. Instead, it turns the IRI into a string and then tries to derive a namespace from that string and then looks up that namespace in the namespace table.
Expected Behavior
If the IRI defines a namespace, that should first be used to look up the prefix in the namespace table. Interpreting the IRI as a string should only be a fallback.
Steps To Reproduce
Version
4.3.9
Are you interested in contributing a solution yourself?
Yes
Anything else?
No response
The text was updated successfully, but these errors were encountered: