Reputation: 5
i have this my rdf file and i try to get all triples from specific namespace 'ns1'
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:ns1="http://www.w3.org/TR/rdf-schema/#"
xmlns:property="http://www.SyrianDNA.com/property#"
xmlns:info="http://www.SyrianDNA.com/info#">
<rdf:Description rdf:about="http://www.SyrianDNA.com/resource/monuments">
<ns1:be rdf:resource="http://www.SyrianDNA.com/resource/Syria"/>
<ns1:refer rdf:resource="http://www.SyrianDNA.com/resource/glass"/>
<property:subjectType>thing</property:subjectType>
<property:location>syria</property:location>
<info:Title>umayyad_architecture</info:Title>
<info:Img_URL>
http://en.wikipedia.org/wiki/Umayyad_architecture#/media
/File:110409_046.jpg</info:Img_URL>
<info:Page_URL>
http://en.wikipedia.org/wiki/Umayyad_architectureeee</info:Page_URL>
</rdf:Description>
</rdf:RDF>
i try this sparql query but throw an exception "Unexpected End of Stream while trying to tokenise from the following input:
String q = @"PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dc:<http://purl.org/dc/elements/1.1/>
PREFIX ns1:<http://www.w3.org/TR/rdf-schema/#>
PREFIX property:<http://www.SyrianDNA.com/property#>
PREFIX info:<http://www.SyrianDNA.com/info#>
SELECT ?s ?o ?p
where { ?s ?p ?o
" +
" FILTER((\"http://www.w3.org/TR/rdf-schema/#\")<STR(?s)).}";
Upvotes: 0
Views: 77
Reputation: 3301
The problem is writing FILTER((\"http://www.w3.org/TR/rdf-schema/#\")<STR(?s))
. You can't have a string that is bigger than a namespace. If you want to filter based on a namespace you need to see what the instances that you are filtering start with and then write something like:
select distinct *
where{
?s ?p ?o
filter(STRSTARTS(str(?s), "http://www.w3.org/TR/rdf-schema/"))
}
Or even a regular expression:
select distinct *
where{
?s ?p ?o
FILTER regex(str(?s), "^http://www.w3.org/TR/rdf-schema/") .
}
Upvotes: 1