Hello there,

I have an ontology which has a datatype property hasLocation with a string
containing city names. This ontology is local and cannot be redefined. I
want to know which of those cities are in dbpedia but I am having troubles
with that query. Since the two models are not related to each other, I do
not know how to match the values.
I have tried this SPARQL in Virtuoso, I have defined as the default value
the local ontology and I am using the 3rd option "retrieve all missing
remote RDF data that might be useful"

PREFIX dbpres: <http://dbpedia.org/resource/>
PREFIX dbpprop: <http://dbpedia.org/property/>
PREFIX dbpedia: <http://dbpedia.org/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX vocab:<http://myexample.com/localOntology.rdf>

SELECT * WHERE {
  ?sub :location ?city .
  OPTIONAL { ?subdb a dbo:City .
  ?subdb dbpprop:officialName ?city . }
  FILTER( !bound(?city) )
}

It does not work because the officialName is optional, but if it is not,
nothing matches because the local ontology has nothing to do with dbpedia.
This one is another possibility, but I am afraid that would be inefficient
and it is not standard SPARQL although possible with Virtuoso. It would be
something like, probably with regex instead of =:

SELECT ?city WHERE {
  ?sub :location ?city .
  FILTER( true = (
    ASK { ?subdb a dbo:City . ?subdb dbpprop:officialName ?name . FILTER
(?name = ?city)}
  ) )
}

thanks in advanced,

LG





Reply via email to