Search code examples
rdfsparqlsemantic-webdbpedia

Get all ontologies and values for a specific prefix


If I run this query:

SELECT ?subject
WHERE { <http://dbpedia.org/resource/Oslo> dcterms:subject ?subject. }

I get this:

enter image description here

Which is correct. But I want all values in dbprop. So this part:

enter image description here

So a pseudo code that doesn't work would be:

SELECT ?properties
WHERE { <http://dbpedia.org/resource/Oslo> dbprop:* ?properties. }

Expected result would be then each property (like dbpprop:aprRecordHighC) and it's value (like 25.400000).

Is that possible?


Solution

  • Yes, it is possible. If you want all the properties and values given the "Oslo" resource, you should issue the following query:

    SELECT ?property ?value
    WHERE { <http://dbpedia.org/resource/Oslo> ?property ?value. }
    

    If you only want the dbprop properties, you can add a filter:

    SELECT ?property ?value
    WHERE { <http://dbpedia.org/resource/Oslo> ?property ?value 
    FILTER regex(str(?property), "http://dbpedia\\.org/property/")}
    

    I have tried both of these queries in the dbpedia endpoint and they worked.

    You can find more information in the SPARQL specification: http://www.w3.org/TR/rdf-sparql-query/#func-str

    Edit: apparently, from the comments I see that this question has been answered previously here