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?

Était-ce utile?

La 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))
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top