0

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)).}";
Eman Kh
  • 5
  • 4

1 Answers1

1

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/") .
}
Artemis
  • 3,271
  • 2
  • 20
  • 33
  • I don't see how this answers the question about the "Unexpected End of Stream", which is the real problem, since filtering based on prefix has already been described elsewhere, e.g., [Exclude results from DBpedia SPARQL query based on URI prefix](http://stackoverflow.com/questions/19044871/exclude-results-from-dbpedia-sparql-query-based-on-uri-prefix). As an aside, I think recommending the regex solution is not great advice, since a regular expression matcher is almost certainly more expensive than strstarts, which doesn't need any regular expression logic. – Joshua Taylor May 30 '15 at 19:08
  • You should see the comment. That is why I asked what s/he wanted to do. – Artemis May 30 '15 at 19:22