问题
I have almost the same requirement expresed in this question: Get all nodes in a transitive relation
I am using Protege 3.4.8. This is an Owl-Lite project. I have a transitive property "contains", which is defined as an object property of type Node Node has descendants of type A, B and C
I have individuals that link to each other through contains property like this:
A contains B contains C
When I run the following SPARQL query:
SELECT ?A ?B
WHERE
{
?A :contains ?B
}
I get :
A1 B1
B1 C1
Due to transitive nature of contains, I'd expect to get
A1 C1
too. What am I doing wrong here? The question I've linked to includes Jena in the answer, would it make a difference to do this on a Jena model?
回答1:
Ok,
Further searches led me to this page: http://opentox.org/data/documents/development/RDF%20files/JavaOnly/query-reasoning-with-jena-and-sparql
The following quote from this page (probably) explains the reasons behind the behaviour I'm seeing:
"For our purposes SPARQL queries could be executed either directly through the SPARQL query panel in Protege or from inside a JAVA application using the specialised Jena library methods. Both approaches are able to handle queries concerning explicit object and property relations but Jena libraries have the advantage of using a reasoner. Thus queries executed using Jena library methods can return results taking in account also the transitive and inferred relations."
回答2:
SPARQL is a RDF query language, so not all SPARQL engines should implement the OWL entailment (i.e., use OWL semantics for evaluating the query). Further details at http://www.w3.org/TR/sparql11-entailment/
Not sure which implementation is actually using Protege under the hood...
来源:https://stackoverflow.com/questions/12090299/sparql-query-results-in-protege-does-not-recognize-transitive-property