I am trying to parse OWL2 file by using OWL API. But I have a problem when I am trying to parse label <SubClassOf></SubClassOf>
. Please see the example below.
<?xml version="1.0"?>
<Ontology xmlns="http://www.w3.org/2006/12/owl2-xml#"
......>
<SubClassOf>
<Class URI="&ontology_people1;Address"/>
<Class URI="&ontology_people1;Location"/>
</SubClassOf>
......
</Ontology>
The content between <SubClassOf> and </SubClassOf>
are written in order.
The child class is written on the first line and parent class is written on the second line. But I parse it and print in the console. Their order is inverse. Meanwhile, others are not inverse. My code is on the below.
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
File file = new File("src/main/resources/dataSet/PR/person1/ontology_people1.owl");
OWLOntology o = manager.loadOntologyFromOntologyDocument(file);
List<OWLAxiom> subClassOf = o.axioms()
.filter(axiom -> axiom.getAxiomType().toString().equals("SubClassOf"))
.collect(Collectors.toList());
for (OWLAxiom owlAxiom : subClassOf) {
Stream<OWLEntity> owlEntityStream = owlAxiom.signature();
owlEntityStream.forEach(entity->System.out.println(entity.getIRI()));
System.out.println("**************");
}
Why?