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

util.from_n3() is broken wrt. Literals with datatypes #502

Closed
joernhees opened this issue Jul 27, 2015 · 0 comments · Fixed by #503
Closed

util.from_n3() is broken wrt. Literals with datatypes #502

joernhees opened this issue Jul 27, 2015 · 0 comments · Fixed by #503
Assignees
Labels
bug Something isn't working in-resolution parsing Related to a parsing.
Milestone

Comments

@joernhees
Copy link
Member

In [1]: import rdflib
INFO:rdflib:RDFLib Version: 4.2.1-dev

In [2]: rdflib.util.from_n3('"42"^^<http://www.w3.org/2001/XMLSchema#integer>')
WARNING:rdflib.term:<http://www.w3.org/2001/XMLSchema#integer> does not look like a valid URI, trying to serialize this will break.
Out[2]: rdflib.term.Literal(u'42', datatype=rdflib.term.URIRef(u'<http://www.w3.org/2001/XMLSchema#integer>'))

problem here is that the < is passed into URIRef() as part of the URI.

In [3]: rdflib.util.from_n3('"42"^^xsd:integer')
Out[3]: rdflib.term.Literal(u'42', datatype=rdflib.term.URIRef(u'xsd:integer'))

problem is that standard xsd datatypes aren't resolved correctly but instead passed into URIRef() as is.

In [4]: rdflib.util.from_n3('"42"^^http://www.w3.org/2001/XMLSchema#integer')
Out[4]: rdflib.term.Literal(u'42', datatype=rdflib.term.URIRef(u'http://www.w3.org/2001/XMLSchema#integer'))

In [5]: rdflib.Literal(42) == rdflib.util.from_n3('"42"^^http://www.w3.org/2001/XMLSchema#integer')
Out[5]: True

this is actually invalid n3 but the only thing that returns the expected Literal

More fun (round-tripping):

In [6]: rdflib.util.from_n3(rdflib.Literal(42).n3()).n3()
WARNING:rdflib.term:<http://www.w3.org/2001/XMLSchema#integer> does not look like a valid URI, trying to serialize this will break.
Out[6]: u'"42"^^<<http://www.w3.org/2001/XMLSchema#integer>>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working in-resolution parsing Related to a parsing.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant