gjhiggins/rdflib — Issue #172: Graph().parse() and relative URIs and blank nodes
Author: gjhiggins
Created: 2011-10-19 01:35:23+00:00
State: open

Originally filed by danielmr...@gmail.com on 2011-05-16T09:41:20

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?