Question

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?

Was it helpful?

Solution

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))
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top