Search code examples
nestedsparqlrdf

Selecting nested locations in SPARQL


I'm using the below demonstration:

SELECT ?performer ?prefLabel ?date ?location WHERE    
{    
?art rdf:type etree:Concert.    
?art rdf:type mo:Performance.    
?art mo:performer ?performer.    
?art skos:prefLabel ?prefLabel.    
?art etree:date ?date.    
?art event:place ?location.    
}     
LIMIT 2

However I also wish to select the values of a named attribute '?place', for which there is a value contained in each entry of '?location', how do I adjust my query to do this?


Solution

  • I'm not sure I understand correctly what you mean in this phrase:

    named attribute '?place', for which there is a value contained in each entry of '?location'

    I guess you are looking for something like this:

    PREFIX mo: <http://purl.org/ontology/mo/>
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
    PREFIX etree: <http://etree.linkedmusic.org/vocab/>
    PREFIX event: <http://purl.org/NET/c4dm/event.owl#>
    
    SELECT ?performer ?prefLabel ?date ?location ?place WHERE 
    {    
        ?art a etree:Concert, mo:Performance ;   
             mo:performer ?performer ;    
             skos:prefLabel ?prefLabel ;    
             etree:date ?date ;    
             event:place ?location . 
        ?location etree:location ?place .   
    } LIMIT 2