4

I have this query to return eras for philosophers that works:

PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX dbpprop: <http://dbpedia.org/property/>

SELECT ?philosopher ?era
WHERE {
   ?philosopher a  dbpedia-owl:Philosopher ;
       dbpprop:era ?era .
}

Example values of ?era returned are:

I would like to return only eras that are resources. I tried:

PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX dbpprop: <http://dbpedia.org/property/>

SELECT ?philosopher ?era
WHERE {
   ?philosopher a dbpedia-owl:Philosopher ;
                dbpprop:era ?era .
   ?era a <http://dbpedia.org/resource>
}

but this returns nothing. How can I filter out non-resource eras?

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
Michael West
  • 1,636
  • 16
  • 23

1 Answers1

4

Rather than adding an additional triple pattern you actually want to use a FILTER with the ISURI function e.g.,

PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX dbpprop: <http://dbpedia.org/property/>

SELECT ?philosopher ?era
WHERE {
   ?philosopher a dbpedia-owl:Philosopher ;
                dbpprop:era ?era .
   FILTER(ISURI(?era))
}
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
RobV
  • 28,022
  • 11
  • 77
  • 119
  • 1
    Perfect answer. Here is a link to the documentation on isURI and related functions. In this case it appears that all values are either URIs or Literals. http://www.w3.org/TR/sparql11-query/#func-isIRI – Michael West Jun 29 '13 at 22:42