Xml 解析内容的顺序与此相反

Xml 解析内容的顺序与此相反,xml,semantic-web,owl,Xml,Semantic Web,Owl,我正在尝试使用OWLAPI解析OWL2文件。但当我试图解析标签时,我遇到了一个问题。请参见下面的示例 ...... 和之间的内容是按顺序编写的。 子类写在第一行,父类写在第二行。但我解析它并在控制台中打印。它们的顺序是相反的。与此同时,其他人并非相反。我的代码在下面 OWLOntologyManager=OWLManager.createOWLOntologyManager(); File File=new文件(“src/main/resources/dataSet/PR/person

我正在尝试使用OWLAPI解析OWL2文件。但当我试图解析标签
时,我遇到了一个问题。请参见下面的示例



......

之间的内容是按顺序编写的。 子类写在第一行,父类写在第二行。但我解析它并在控制台中打印。它们的顺序是相反的。与此同时,其他人并非相反。我的代码在下面


OWLOntologyManager=OWLManager.createOWLOntologyManager();
File File=new文件(“src/main/resources/dataSet/PR/person1/ontology_people1.owl”);
OWLOontology=manager.loadOntologyFromOntologyDocument(文件);
列表子类f=o.axioms()
.filter(axiom->axiom.getAxiomType().toString().equals(“子类”))
.collect(Collectors.toList());
for(OWLAxiom OWLAxiom:子类){
Stream owletitystream=owlAxiom.signature();
owletitystream.forEach(entity->System.out.println(entity.getIRI());
System.out.println(“****************”);
}


为什么?

这是因为
signature()
方法不是您需要使用的。公理的签名是该公理中出现的一组实体,其定义独立于公理类型。在本例中,主要特征是签名中实体的顺序与公理的语义无关

要可靠地访问子类和超类,请使用如下代码:

    List<OWLSubClassOfAxiom> subClassOf = OWLAPIStreamUtils.asList(o.axioms(AxiomType.SUBCLASS_OF));
    subClassOf.forEach(x->{
        System.out.println( x.getSubClass());
        System.out.println( x.getSuperClass());
        });
List subassof=OWLAPIStreamUtils.asList(o.axioms(axiotype.SUBCLASS_OF));
forEach子类(x->{
System.out.println(x.getSubClass());
System.out.println(x.getSuperClass());
});

@Ignazio对不起,你已经帮了我很多次了,我知道你是OWL API的作者,你能再帮我一次吗?非常感谢。
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("**************");
        }
    List<OWLSubClassOfAxiom> subClassOf = OWLAPIStreamUtils.asList(o.axioms(AxiomType.SUBCLASS_OF));
    subClassOf.forEach(x->{
        System.out.println( x.getSubClass());
        System.out.println( x.getSuperClass());
        });