No results when running a SPARQL on an rdf document
I'm new to SPARQL querys and I'm using twinkle SPARQL to run a query on an rdf document that contians:
<defaultNamespac:courses rdf:ID="Cources">
<defaultNamespac:course rdf:resource="#Course1"/>
<defaultNamespac:course rdf:resou开发者_如何学Crce="#Course10"/>
<defaultNamespac:course rdf:resource="#Course2"/>
<defaultNamespac:course rdf:resource="#Course3"/>
<defaultNamespac:course rdf:resource="#Course4"/>
<defaultNamespac:course rdf:resource="#Course5"/>
<defaultNamespac:course rdf:resource="#Course6"/>
<defaultNamespac:course rdf:resource="#Course7"/>
<defaultNamespac:course rdf:resource="#Course8"/>
<defaultNamespac:course rdf:resource="#Course9"/>
</defaultNamespac:courses>
The Query is as follows:
SELECT ?x ?course
WHERE {?x <file:/F:/Stuff/Muaz/GUC/Met.rdf#courses>
?course }
the problem is that no results are returned (only the x and course is displayed). Whats wrong? I'm getting on my nervous, Please help me as soon as you can. Thank you very much!
PS: What datatypes can be returned by the query? (only strings or numbers ?!)
Just a quick guess Is it defaultNamespac or defaultNamespace ? witn an e at the end.
If that is not the error try to run the query:
SELECT * WHERE { ?s ?p ?o }
If I had the following RDF file, with some defaultNamepac define :
<rdf:RDF
xmlns:contact="http://www.w3.org/2000/10/swap/pim/contact#"
xmlns:defaultNamespac="http://foo.bar"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<defaultNamespac:courses rdf:about="file:///Users/msalvadores/kk.rdf#Cources">
<defaultNamespac:course rdf:resource="file:///Users/msalvadores/kk.rdf#Course1"/>
<defaultNamespac:course rdf:resource="file:///Users/msalvadores/kk.rdf#Course10"/>
<defaultNamespac:course rdf:resource="file:///Users/msalvadores/kk.rdf#Course2"/>
<defaultNamespac:course rdf:resource="file:///Users/msalvadores/kk.rdf#Course3"/>
<defaultNamespac:course rdf:resource="file:///Users/msalvadores/kk.rdf#Course4"/>
<defaultNamespac:course rdf:resource="file:///Users/msalvadores/kk.rdf#Course5"/>
<defaultNamespac:course rdf:resource="file:///Users/msalvadores/kk.rdf#Course6"/>
<defaultNamespac:course rdf:resource="file:///Users/msalvadores/kk.rdf#Course7"/>
<defaultNamespac:course rdf:resource="file:///Users/msalvadores/kk.rdf#Course8"/>
<defaultNamespac:course rdf:resource="file:///Users/msalvadores/kk.rdf#Course9"/>
</defaultNamespac:courses>
</rdf:RDF>
Then the result of the above query would be, like the image shows:
In my case wih namespace xmlns:defaultNamespac="http://foo.bar"
if I wanted to run exactly your query then I'd had to use the namespace ...
SELECT ?x ?course
WHERE {?x <http://foo.bar#courses> ?course }
My advice is that to avoid these errors try always to set namespaces.
精彩评论