semsol / arc2

ARC RDF Classes for PHP
Other
332 stars 89 forks source link

Query (with UNION) on remote sparql endpoint. #46

Closed lordcoste closed 11 years ago

lordcoste commented 11 years ago

I can't make this query work:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
SELECT
    ?p
    ?genre
    MAX(?hometown) AS ?hometown
    MAX(?birthPlace) AS ?birthPlace
    ?birthDate
    ?activeYearsStartYear
WHERE
{
  {
    ?p rdf:type <http://schema.org/MusicGroup> .
    ?p rdfs:label "Francesco Guccini"@en .
    ?p dbpedia-owl:genre ?genre .
    OPTIONAL {?p <http://dbpedia.org/ontology/hometown> ?hometown }
    OPTIONAL {?p <http://dbpedia.org/ontology/birthPlace> ?birthPlace }
    OPTIONAL {?p <http://dbpedia.org/ontology/birthDate> ?birthDate }
    OPTIONAL {?p <http://dbpedia.org/ontology/activeYearsStartYear> ?activeYearsStartYear}
  }
  UNION
  {
    ?p rdf:type <http://schema.org/MusicGroup> .
    ?p foaf:name "Francesco Guccini"@en .
    ?p dbpedia-owl:genre ?genre .
    OPTIONAL {?p <http://dbpedia.org/ontology/hometown> ?hometown }
    OPTIONAL {?p <http://dbpedia.org/ontology/birthPlace> ?birthPlace }
    OPTIONAL {?p <http://dbpedia.org/ontology/birthDate> ?birthDate }
    OPTIONAL {?p <http://dbpedia.org/ontology/activeYearsStartYear> ?activeYearsStartYear}
  }
} LIMIT 1

The endpoint is: http://dbpedia.org/sparql/ As you can see here the query is working.

Am I doing something wrong? Thanks for your help.

lordcoste commented 11 years ago

I've forgotten: PREFIX foaf: <http://xmlns.com/foaf/0.1/>

Probably that was the problem ;)