Search code examples
owlontologyprotege

Empty result when using properties Pizza.owl


I'm trying to run the following SPARQL query in Protege 4.3 (on Pizza.owl), but I get an empty result:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
SELECT ?pizzaInstance ?pizzaClass ?toppingInstance
WHERE {
?pizzaClass rdfs:subClassOf :NamedPizza .
?pizzaInstance rdf:type ?pizzaClass .
?pizzaInstance :hasTopping ?toppingInstance .
}

This only happens when I run queries involving properties. With the same prefixes the following query works - and returns NamedPizza:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
SELECT ?pizzaInstance 
WHERE {
?pizzaInstance rdfs:subClassOf :Pizza .
}

What is wrong with the first query?


Solution

  • I finally understood what I was doing wrong. This query returns individuals for pizzaInstance, and none of the individuals in my ontology had a topping. When I queried for hasCalorificContentValue instead of hasTopping I got the desired results:

    PREFIX pz: <http://www.semanticweb.org/ontologies/2017/11/Ontology1512823737278.owl#>
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    PREFIX owl: <http://www.w3.org/2002/07/owl#>
    PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    SELECT ?pizzaClass ?pizzaInstance ?calorificInstance
    WHERE {
    ?pizzaClass rdfs:subClassOf pz:NamedPizza .
    ?pizzaInstance rdf:type ?pizzaClass.
    ?pizzaInstance pz:hasCalorificContentValue ?calorificInstance.
    }
    

    enter image description here

    The query becomes meaningful when you check the raw owl file (Example-MargheritaPizza is of type MargheritaPizza and is involved in the datatype property hasCalorificValue):

    <owl:NamedIndividual rdf:about="&Ontology1512823737278;Example-MargheritaPizza">
            <rdf:type rdf:resource="&Ontology1512823737278;MargheritaPizza"/>
            <hasCalorificContentValue rdf:datatype="&xsd;int">263</hasCalorificContentValue>
        </owl:NamedIndividual>
    

    Here is a good tutorial, hope this helps someone.