SPARQL query to retrieve all objects and properties

Using Ontology , I want to create a SPARQL query so that I can get all the wines and their properties , as in the table below, consider that I do not know the property names a priori.

vin | rdf:type | vin:hasMaker | vin:hasSugar | ... ========================================================================== ... GaryFarrellMerlot | vin:Merlot | vin:Elyse | vin:Dry | ... -------------------------------------------------------------------------- ElyseZinfandel | vin:Elyse | vin:GaryFarrell | vin:Dry | ... ... 

Can someone tell me?

- EDIT

It is not possible to get the result of the query in the format I specified, but I can have it as follows:

 vin | property | value ================================================= GaryFarrellMerlot | rdf:type | vin:Merlot ------------------------------------------------- GaryFarrellMerlot | rdf:hasMaker | vin:Elyse ------------------------------------------------- ... 

With this selection (thanks cygri ):

 SELECT DISTINCT ?wine ?property ?value WHERE { ?o1 a ?class . ?wine a ?o1 . ?wine ?property ?value . } 

This will result in wines instead of wines (Merlot → GaryFarrellMerlot). The only problem is the wine, as well as the winery, regions, flavors, etc., and I only wanted wine and its properties. In addition, there is no such attribute vin: Merlot rdfs: subClassOf vin: Wine. Any clues?

+8
ontology sparql sesame
source share
1 answer

You can not. You must know in advance which columns you want in the query results.

Listing all the properties of wines is not very difficult:

 SELECT DISTINCT ?property WHERE { ?wine a vin:Wine . ?wine ?property ?value . } 

Then you need to write code that creates the final SPARQL query from the list of results.

+11
source share

All Articles