我是 Jena 和 Owl 的新手,我得到了一个本体。我可以用 Protege 4.2 打开它而没有任何问题,但是当我尝试用 Jena 打开它时,我得到:
Exception in thread "main" org.apache.jena.riot.RiotException: {E201} Multiple children of property element
。
我一直在我的本体中寻找它可能是什么,我注意到某些元素在一种语言中具有多个标签,例如:
<AnnotationAssertion>
<AnnotationProperty abbreviatedIRI="rdfs:label"/>
<AbbreviatedIRI>atc:A02BX02</AbbreviatedIRI>
<Literal xml:lang="no" datatypeIRI="&rdf;PlainLiteral">Sukralfat</Literal>
</AnnotationAssertion>
<AnnotationAssertion>
<AnnotationProperty abbreviatedIRI="rdfs:label"/>
<AbbreviatedIRI>atc:A02BX02</AbbreviatedIRI>
<Literal xml:lang="no" datatypeIRI="&rdf;PlainLiteral">antepsin</Literal>
</AnnotationAssertion>
<AnnotationAssertion>
<AnnotationProperty abbreviatedIRI="rdfs:label"/>
<AbbreviatedIRI>atc:A02BX02</AbbreviatedIRI>
<Literal datatypeIRI="&xsd;string">sucralfate</Literal>
</AnnotationAssertion>
<AnnotationAssertion>
<AnnotationProperty abbreviatedIRI="rdfs:label"/>
<AbbreviatedIRI>atc:A02BX02</AbbreviatedIRI>
<Literal xml:lang="no" datatypeIRI="&rdf;PlainLiteral">sukralfat</Literal>
</AnnotationAssertion>
这会导致问题吗?我使用的所有代码都适用于其他本体,所以我认为它确实来自这个本体。你知道什么可能导致这个异常吗?
编辑
因此,我采用了最小化的情况,但仍然遇到相同的错误:
<?xml version="1.0"?>
<!DOCTYPE Ontology [
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY xml "http://www.w3.org/XML/1998/namespace" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
]>
<Ontology xmlns="http://www.w3.org/2002/07/owl#"
xml:base="http://www.ebi.ac.uk/Rebholz-srv/atc/public/ontologies/atc.owl"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
ontologyIRI="http://www.ebi.ac.uk/Rebholz-srv/atc/public/ontologies/atc.owl">
<Prefix name="" IRI="http://www.ebi.ac.uk/Rebholz-srv/atc/public/ontologies/atc.owl#"/>
<Prefix name="atc" IRI="http://www.legemiddelverket.no/Legemiddelsoek/Sider/Default.aspx#"/>
<Prefix name="owl" IRI="http://www.w3.org/2002/07/owl#"/>
<Prefix name="rdf" IRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
<Prefix name="xml" IRI="http://www.w3.org/XML/1998/namespace"/>
<Prefix name="xsd" IRI="http://www.w3.org/2001/XMLSchema#"/>
<Prefix name="rdfs" IRI="http://www.w3.org/2000/01/rdf-schema#"/>
<Declaration>
<Class abbreviatedIRI="atc:J"/>
</Declaration>
<AnnotationAssertion>
<AnnotationProperty abbreviatedIRI="rdfs:label"/>
<AbbreviatedIRI>atc:J</AbbreviatedIRI>
<Literal datatypeIRI="&xsd;string">ANTIINFECTIVES FOR SYSTEMIC USE</Literal>
</AnnotationAssertion>
</Ontology>
这是java代码:
InputStream in = FileManager.get().open(filename);
if (in == null) {
throw new IllegalArgumentException("File: " + filename + " not found");
}
model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
model.read(in, null);
try {
in.close();
} catch (IOException e) {
System.err.println("Couldn't close the inputStream");
}
这有帮助吗?我真的没有任何想法了......