Using the Snap SPARQL Query view I do not find a way to query the transitive closure e.g. of the property ex:myontology#isPartOf so that I can infer that, since A isPartOf AB which isPartOf ABC which isPartOf ABCD then A isPartOf ABC and ABCD.
Any Help???
I tried SELECT ?x ?y WHERE { x <ex:myontology#isPartOf>+ ?y }
but it is an invalid syntax. My example ontology is the following:
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <ex:myontology> .
<ex:myontology> rdf:type owl:Ontology ;
owl:versionIRI <ex:myontology/0.1/> .
#################################################################
# Object Properties
#################################################################
### ex:myontology#hasPart
:hasPart rdf:type owl:ObjectProperty ;
owl:inverseOf :isPartOf .
### ex:myontology#isPartOf
:isPartOf rdf:type owl:ObjectProperty .
#################################################################
# Classes
#################################################################
### ex:myontology#concept
:concept rdf:type owl:Class .
#################################################################
# Individuals
#################################################################
### ex:myontology#A
:A rdf:type owl:NamedIndividual ,
:concept ;
:isPartOf :AB .
### ex:myontology#AB
:AB rdf:type owl:NamedIndividual ,
:concept ;
:isPartOf :ABC .
### ex:myontology#ABC
:ABC rdf:type owl:NamedIndividual ,
:concept ;
:isPartOf :ABCD .
### ex:myontology#ABCD
:ABCD rdf:type owl:NamedIndividual ,
:concept .
### ex:myontology#B
:B rdf:type owl:NamedIndividual ,
:concept ;
:isPartOf :AB .
### ex:myontology#C
:C rdf:type owl:NamedIndividual ,
:concept ;
:isPartOf :ABC .
### ex:myontology#D
:D rdf:type owl:NamedIndividual ,
:concept ;
:isPartOf :ABCD .
### Generated by the OWL API (version 4.5.9.2019-02-01T07:24:44Z) https://github.com/owlcs/owlapi```
Also how can I get results in their successive order (and not descending or ascending) using the transitive closure of isPartOf in SPARQL? i.e.
SELECT ?x ?y
WHERE {?x isPartOf+ ?y}
ORDER BY ?x (this part I am asking)
A isPartOf AB
A isPartOf ABC
A isPartOf ABCD
Thanks a lot
Nikos