Reputation: 1
I am facing problem in retriveing multiple classes in range of an object property using sparql query in java code(Using Protege 3.4.8)
Result1_Layer =
"PREFIX uni:<http://www.owl-ontologies.com/Ontology1469701449.owl#>"
+"PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>"
+ "select ?range1 "
+ "where { uni:hasS_Layer "
+ "rdfs:range ?range1}";
I am getting output as:| range1 |
=========================================
| <http://www.w3.org/2002/07/owl#Thing> |
| _:b0 |
| rdfs:Resource |
-----------------------------------------
But the output should contain two classes:Usability,Reliabilty instead of b0. In ontology there is a object property hasS_Layer whose domain is Layer and range is intersection of Usability,Reliability This query retrieve correct result if in range there is only a single Class. Same query is working fine when I am using Protegy version 4.3.But in protege 3.4.8 its not showing correct output for multiple classes in range. Kindly help.
Upvotes: 0
Views: 911
Reputation: 22042
An OWL intersection, when represented in RDF, looks like this:
_:b0 a owl:Class;
owl:intersectionOf (ex:Usability, ex:Reliability) .
Or even more spelled out (if we expand the internal representation of an RDF collection):
_:b0 a owl:Class;
owl:intersectionOf _:b1 .
_:b1 rdf:first ex:Usability ;
rdf:rest _:b2 .
_:b2 rdf:first ex:Reliability ;
rdf:rest rdf:nil .
Your query returns the value of the rdfs:range
property, which is _:b0
- this is the anonymous class that corresponds to the intersection of the two classes.
If you wish to get back the classes that make up the intersection, you will need to do a different query, for example:
SELECT ?c
WHERE { uni:hasS_Layer rdfs:range ?r .
?r owl:intersectionOf/rdf:rest*/rdf:first ?c .
}
The owl:intersectionOf/rdf:rest*/rdf:first
is known as a path expression, and it queries for any resource ?r
that has an owl:intersection
property which connects to zero or more rdf:rest
properties, which in turn connects to an rdf:first
property. It's the values of the rdf:first
properties that we want.
Upvotes: 2