I've and OWL file and I can explore it and navigate through classes and properties but I can't retrieve correct range of ObjectProperty. This is part of my OWL file:
<owl:ObjectProperty rdf:about="&aat;aat2209_located_in">
<rdfs:label xml:lang="en">located in</rdfs:label>
<rdfs:label xml:lang="it">si trova in</rdfs:label>
<rdfs:comment xml:lang="en">The property defines a relationship between places or places and things</rdfs:comment>
<rdfs:comment xml:lang="it">La proprietà definisce la relazione tra luoghi o tra luoghi e cose</rdfs:comment>
<rdfs:domain>
<owl:Class>
<owl:unionOf rdf:parseType="Collection">
<rdf:Description rdf:about="&dbpedia-owl;Artwork"/>
<rdf:Description rdf:about="&dbpedia-owl;Cave"/>
</owl:unionOf>
</owl:Class>
</rdfs:domain>
<rdfs:range>
<owl:Class>
<owl:unionOf rdf:parseType="Collection">
<rdf:Description rdf:about="&lodmt;ArchaeologicalSite"/>
<rdf:Description rdf:about="&dbpedia-owl;Building"/>
</owl:unionOf>
</owl:Class>
</rdfs:range>
</owl:ObjectProperty>
And this is part of my code to explore OWL file
...
OntModel inf = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF);
InputStream in =getClass().getResourceAsStream("/"+DATA_IRI);
inf.read(in, "");
OntClass obj = inf.getOntClass(uri);
ExtendedIterator<OntProperty> propIter = obj.listDeclaredProperties(false);
if(propIter.hasNext()){
while (propIter.hasNext()) {
Set<PropertyModel> properties = new HashSet<PropertyModel>();
final OntProperty ontProperty = (OntProperty) propIter.next();
ExtendedIterator<? extends OntProperty> eqProp = ontProperty.listEquivalentProperties();
if(eqProp.hasNext()){
while (eqProp.hasNext()) {
OntProperty property = (OntProperty) eqProp.next();
PropertyModel propModel = new PropertyModel();
propModel.setLabel(property.getLocalName());
propModel.setUri(property.getURI());
propModel.setRange(property.getRange().getLocalName());
properties.add(propModel);
}
}
...
Everytime I call property.getRange()
I've this result: http://www.w3.org/2002/07/owl#Thing.
Anyone help me?
It's ever so much easier if you provide complete but minimal data to work with. In this case, I've modified your data to be the following, which is complete in that it's a loadable RDF document, and minimal in that it only contains the object property declaration and the range axiom.
The following code loads it and shows the range(s) of the property:
The output for me is
owl:Thing and rdfs:Resource are there because anytime you have
x located_in y
, you can be sure thaty
is an owl:Thing and an rdfs:Resource, sincelocated_in
is an object property. The other one,-3e020093:146a7247e66:-7ffb
, is the identitifier of the RDF blank node that is the OWL union class expression.Why aren't other classes returned?
Based on the following comment, it sounds like a bit more discussion is needed.
You asked for the range(s) of a particular object property that you declared. In OWL, a range of a property p is any class D such that "if p(x,y), then D(y)". That is, in RDF terms, if you a property p's has D as a range, then whenever there is a triple
x p y
, then you can also infer the tripley rdf:type D
. This is the rule:The range that you're asking about is a union class. An instance of the rule for your class would be like:
It would not make sense to infer that
or that
because that's more information than you have in
x located_in y
. For analogy, consider this example:From those, I can infer that x is either soup or salad, but I can't infer which particular one. Thus "soup or salad" is a range of hasAppetizer, but neither soup nor salad alone is.