I am using OWL API to get the range of a data property as follows:
OWLDataProperty dataProperty = ontologyManager.getOWLDataFactory().getOWLDataProperty("http://schema.mobivoc.org/powerInKW");
Set<OWLDataPropertyRangeAxiom> ranges = ontology.getOWLOntology().getDataPropertyRangeAxioms(dataProperty);
for (OWLDataPropertyRangeAxiom range : ranges) {
String rangeString = range.getRange().getDataRangeType().getIRI().getIRIString();
}
The property "http://schema.mobivoc.org/powerInKW"
has the range xsd:Double
. But the above code is returning owl:DataType
. While I agree that xsd:Double
is an instance of owl:DataType
, how to get the actual range, in this case owl:DataType
?
You have getDataRangeType()
in your code, which moves you from the range to its type. But what you want is the range, so skip that method and just use the range. You can create a visitor to navigate the different ranges, or you can cast to OWLDatatype for plain datatypes.