0
PREFIX dbo: <http://dbpedia.org/ontology/>

    SELECT * WHERE {
     ?x foaf:primaryTopic ?n .
     ?x rdf:type ?z .

    FILTER (regex(?x, '^http://en.wikipedia.org/wiki/Barack_Obama$')).
}
LIMIT 10    

when i call this request from http://dbpedia.org/snorql, it works. but when i try below

SELECT * WHERE {
 ?x foaf:primaryTopic ?n .
 ?x rdf:type ?z .
 ?x owl:activeYearsStartDate ?v .
 FILTER (regex(?x, '^http://en.wikipedia.org/wiki/Barack_Obama$')).
}    

it doesn't work. but why?

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
coenni
  • 437
  • 4
  • 14
  • What does "it doesn't work" mean ? You get an error message? You don't get the results that you expect? What? I *bet* that you don't get any results, since OWL doesn't define a property `owl:activeYearsStartDate`. – Joshua Taylor Oct 15 '14 at 14:43

1 Answers1

2

I expect that you meant

?x dbpedia-owl:activeYearsStartDate ?v .

rather than

?x owl:activeYearsStartDate ?v .

Also, using regex here is more expensive than it needs to be. You could check whether the string value of a URI is something in particular with

filter( str(?x) = "…" )

but even that is a lot more work than you need. If you want ?x to be <http://en.wikipedia.org/wiki/Barack_Obama>, just use it instead of ?x, or bind ?x to it with values:

SELECT * WHERE {
 <http://en.wikipedia.org/wiki/Barack_Obama> foaf:primaryTopic ?n .
 <http://en.wikipedia.org/wiki/Barack_Obama> rdf:type ?z .
 <http://en.wikipedia.org/wiki/Barack_Obama> owl:activeYearsStartDate ?v .
}    

SELECT * WHERE {
 values ?x { <http://en.wikipedia.org/wiki/Barack_Obama> }
 ?x foaf:primaryTopic ?n .
 ?x rdf:type ?z .
 ?x owl:activeYearsStartDate ?v .
}    

That still looks suspicious, though. Are you sure you didn't want <http://dbpedia.org/resource/Barack_Obama>? And the use of foaf:primaryTopic stuff really makes me think that you want something more like:

select * {
  ?x foaf:isPrimaryTopicOf <http://en.wikipedia.org/wiki/Barack_Obama> ;
     a ?type ;
     dbpedia-owl:activeYearsStartDate ?v
}
limit 10

SPARQL results

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353