简体   繁体   English

Jena多个rdfs:标签

[英]Jena multiple rdfs:label

I'm new to Jena and Owl I was given an ontology. 我是Jena和Owl的新手,我获得了本体论。 I can open it with Protege 4.2 without any problems but when I try to open it with Jena I get: Exception in thread "main" org.apache.jena.riot.RiotException: {E201} Multiple children of property element . 我可以使用Protege 4.2打开它而没有任何问题但是当我尝试用Jena打开它时我得到: Exception in thread "main" org.apache.jena.riot.RiotException: {E201} Multiple children of property element

I have been looking a bit in my Ontology what it could be and I have noticed that some elements have more than one Label in a language for example: 我一直在我的Ontology中查看它可能是什么,我注意到一些元素在一种语言中有多个Label,例如:

<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>

Could this cause the problem? 这会导致问题吗? All the code I use works with other ontologies so I think it really comes from this ontology. 我使用的所有代码都与其他本体一起使用,因此我认为它实际上来自于这个本体。 Do you know what could cause this exception? 你知道什么可能导致这个例外吗?

Edit 编辑

So I got down to a minimized case and still get the same error: 所以我得到了一个最小化的案例,仍然得到同样的错误:

<?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>

Here is the java code: 这是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");
}

Does this help? 这有帮助吗? I really don't have any idea anymore... 我真的不知道了......

That's an OWL2 XML formatted file. 这是一个OWL2 XML格式的文件。 Jena does't support that format, but it does support OWL in RDF/XML. Jena不支持这种格式,但它确实支持RDF / XML中的OWL。

In other words it's expecting the wrong flavour of XML and getting confused. 换句话说,它期望XML的错误味道和混淆。

Try saving it in another format. 尝试以其他格式保存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM