我想知道如何用 OWL/XML 语法解析文件

I want to know How to parse the file in OWL/XML syntax

我不知道怎么解析这个文件,有人能告诉我怎么解析吗? 该文件在下面。找了大概3天的解析方法

<?xml version="1.0"?>


<!DOCTYPE Ontology [
    <!ENTITY owl "http://www.w3.org/2002/07/owl#" >
    <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
    <!ENTITY owl2xml "http://www.w3.org/2006/12/owl2-xml#" >
    <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
    <!ENTITY ontology_people1 "http://www.okkam.org/ontology_people1.owl#" >
    <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
]>


<Ontology xmlns="http://www.w3.org/2006/12/owl2-xml#"
     xml:base="http://www.w3.org/2006/12/owl2-xml#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
     xmlns:owl2xml="http://www.w3.org/2006/12/owl2-xml#"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:ontology_people1="http://www.okkam.org/ontology_people1.owl#"
     URI="http://www.okkam.org/ontology_people1.owl">
    <SubClassOf>
        <Class URI="&ontology_people1;Address"/>
        <Class URI="&ontology_people1;Location"/>
    </SubClassOf>
    <Declaration>
        <Class URI="&ontology_people1;Address"/>
    </Declaration>
   ......
</Ontology>



<!-- Generated by the OWL API (version 2.2.1.1138) http://owlapi.sourceforge.net -->

不要沮丧。我认为您正在寻找 xml 解析器。您使用哪种语言?其他人已经实现了许多 xml 解析器。下面是一个使用 Java 的例子:https://www.mkyong.com/java/how-to-read-xml-file-in-java-dom-parser/

这可以使用 OWLAPI 加载的默认解析器进行解析。

这应该足够了:

import java.io.File;

import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;

public class Check {
    public static void main(String[] args) throws OWLOntologyCreationException {
        OWLOntologyManager manager=OWLManager.createOWLOntologyManager();
        OWLOntology o=manager.loadOntologyFromOntologyDocument(new File("filename.xml"));
    }
}