I have a problem when I get the results of a SPARQL query executed on a simple turtle model. In the model on which the query is executed, I have a prefix which is called "ex1" and another prefix "op" which comes from an imported ontology. However, after I execute the query, the results contain the "op" prefix, but change the name of "op" to "ns1". Is this because I have an imported ontology into the one on which the query is executed or is there a bug in rdflib when parsing/loading a model into a Graph?
Asked
Active
Viewed 342 times
0
-
Prefixes only exist in *serializations*. RDF itself doesn't have any concept of prefixes, just IRIs. It's *nice* when software preserves them, because it's nice for us (humans), but it doesn't actually make a difference in the data. I'm not posting this as an answer, yet, because it doesn't actually answer *why* rdflib does what it does; maybe there's an option to preserve namespace prefixes from imports somewhere. But, at any rate, renaming a prefix isn't an *RDF bug*, though it *could* be an rdflib bug, if rdflib tries to *not* change prefixes. – Joshua Taylor Oct 27 '14 at 00:19
-
But, [RDFLib: Namespace prefixes in XML serialization](http://stackoverflow.com/q/4427607/1281433) may provide a workaround. – Joshua Taylor Oct 27 '14 at 00:21
-
Actually, it occurs to me: if you're even if you're reading the RDF serialization of an OWL ontology, rdflib might not be an OWL aware tool (I honestly don't know, offhand), and you should check whether it's actually reading the imported documents or not. – Joshua Taylor Oct 27 '14 at 12:28
-
Thanks for your reply, Joshua. I will try to rename them manually, as in the link suggested by you. I find it quite annoying as after I am constructing another turtle file using a CONSTRUCT query, I get "ns1" as a prefix. The new file needs to be used somewhere else, where the "op" ontology would be quite important. I had a look a JENA Apache within Java, it doesn't do the same thing. – Dragos Popescu Oct 27 '14 at 12:55
-
Is RDFlib actually reading the imported ontology? – Joshua Taylor Oct 27 '14 at 13:18
-
As far as I can see, it does. I am trying to build a simple testing environment. But for the tests I will just use the namespace I think. – Dragos Popescu Oct 30 '14 at 13:20
-
Can you check that? As far as I can see from looking at RDFlib, I don't see where it does any OWL-specific processing. If you load `foo.owl` which imports `bar.owl`, do you actually see content from `bar.owl` in the resulting graph? – Joshua Taylor Oct 30 '14 at 13:23
-
I am sorry for this late reply. I thought you meant if it knows the namespaces for the imported ontology. It cannot see the content from the imported ontology. – Dragos Popescu Nov 17 '14 at 23:37
-
Do you have any advice for plotting the data from the turtle files into a visualizer? I am thinking of using matplotlib and networkx packages for this:) – Dragos Popescu Nov 17 '14 at 23:39
-
Did you ever get this resolved? – Joshua Taylor Jan 20 '15 at 17:30