Hello Leyla,

> 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) )
> }

I'm afraid that
?sub :location ?city .
and
FILTER(!bound(?city))
is "contradictory enough" to guarantee an empty result set. Pair of
variables should work better:

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

A variant with subquery is possible as well, but the syntax is
Virtuoso-specific:

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

Best Regards,

Ivan Mikhailov
OpenLink Software
http://virtuoso.openlinksw.com



Reply via email to