This request returns all pizzas with mushroom topping:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX pizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
SELECT ?pizza
WHERE {
?pizza rdfs:subClassOf+ pizza:Pizza .
?pizza rdfs:subClassOf [
a owl:Restriction ;
owl:onProperty pizza:hasTopping;
owl:someValuesFrom pizza:MushroomTopping
]
}
but I want to list all pizzas with VegetableTopping, which is a subclass of PizzaTopping. Additonally MushroomTopping is a subclassof VegetableTopping. The following query doesn't provided the intended results:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX pizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
SELECT ?pizza
WHERE {
?pizza rdfs:subClassOf+ pizza:Pizza .
?pizza rdfs:subClassOf [
a owl:Restriction ;
owl:onProperty pizza:hasTopping;
owl:someValuesFrom pizza:VegetableTopping
]
}
As said by UninformedUser in the comments, you have to make the topping a variable value, and then state that the variables binds to all subclasses of
VegetableToppingusing therdfs:subClassOf*property path.