RDFLib/rdflib — Issue #159: Graph().parse() and relative URIs and blank nodes
Author: gjhiggins
Created: 2012-02-20 08:34:06+00:00
State: open

danielmr...@gmail.com, 2011-05-16T09:41:20.000Z

What steps will reproduce the problem?

1. Parse xml from string and print results:

g1=rdflib.graph.ConjunctiveGraph()
g1.parse(data="""

""")

for s,p,o in g1:
print s,p,o

2. Parse the same xml from url:

g2=rdflib.graph.ConjunctiveGraph()
g2.parse("http://127.0.0.1:5000/test")

for s,p,o in g2:
print s,p,o

What is the expected output? What do you see instead?

I expect the output to be the same but the xml string does not contain a URI to attach the relative URIs to.

Result of the string parsing:

#John http://xmlns.com/foaf/0.1/knows owiEBRcs5
#John http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://xmlns.com/foaf/0.1/Person
#Mary http://xmlns.com/foaf/0.1/knows owiEBRcs5
#Mary http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://xmlns.com/foaf/0.1/Person
owiEBRcs5 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://xmlns.com/foaf/0.1/Person

Result of the uri parsing:

http://127.0.0.1:5000/test#John http://xmlns.com/foaf/0.1/knows owiEBRcs5
http://127.0.0.1:5000/test#John http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://xmlns.com/foaf/0.1/Person
http://127.0.0.1:5000/test#Mary http://xmlns.com/foaf/0.1/knows owiEBRcs5
http://127.0.0.1:5000/test#Mary http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://xmlns.com/foaf/0.1/Person
owiEBRcs5 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://xmlns.com/foaf/0.1/Person

What version of the product are you using? On what operating system?
rdflib trunk with python 2.6

I would like to add an option to g.parse() that allows to define a URI to add as a prefix for relative URIs.
Also it would be helpful to have a possibility to add a real URI to blank nodes, too.
What else does parse() need?

Comment 1 by danielmr...@gmail.com
Issue #137 also addresses parse() API

Comment 2 by danielmr...@gmail.com
Addition to the initial post here: one could pass the "publicID" -->
g.parse(data=data, publicID="http://127.0.0.1:5000/test")
gives the same result.

I just think that the documentation on that part could be better and would like to get feedback on what exactly is not well documented/the best interface