Skip to content
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

ttlser fails if a literal is a subject #16

Closed
tgbugs opened this issue Sep 12, 2017 · 2 comments
Closed

ttlser fails if a literal is a subject #16

tgbugs opened this issue Sep 12, 2017 · 2 comments

Comments

@tgbugs
Copy link
Owner

tgbugs commented Sep 12, 2017

import rdflib
from pyontutils.core import makeGraph
g = makeGraph('buggraph', graph=rdflib.Graph())
g.g.add((rdflib.Literal('UT OH'), rdflib.RDFS.comment, rdflib.Literal('This will end badly.')))
g.write()

Produces a key error since subject literals don't seem to make it into the global sort keys.

The default turtle serializer produces the following.

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

"UT OH" rdfs:comment "This will end badly." .
@tgbugs
Copy link
Owner Author

tgbugs commented Apr 9, 2020

Related to RDFLib/rdflib#895.

@tgbugs
Copy link
Owner Author

tgbugs commented Jul 16, 2022

The issue is in CustomTurtleSerializer._globalSortKey where, not surprisingly, a literal value is not ranked, because there should not be any literal values there. I'm ruling that this is not a bug because it is consistent with the RDF spec, even though it is not consistent with rdflib behavior. The current behavior is hard to debug, because a bad value can creep in e.g. via a parse because rdflib is too permissive, and only later will the error appear, however, since these are literals in the subject position, they shouldn't be particularly difficult to track down.

@tgbugs tgbugs closed this as completed Jul 16, 2022
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

1 participant