我有一个 OWL 文件,其示例片段如下。
<owl:NamedIndividual rdf:ID="001">
<rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">some literal 1</rdfs:label>
<has_legislative_reference rdf:resource="#002"/>
<has_legislative_reference rdf:resource="#003"/>
<has_legislative_reference rdf:resource="#004"/>
<has_name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">some literal 2</has_name>
<has_name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">some literal 3</has_name>
<rdf:type rdf:resource="#some_class"/>
<has_englishkeywords>
<owl:NamedIndividual rdf:ID="005">
<rdf:type rdf:resource="#006"/>
<rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">some literal 4</rdfs:label>
</owl:NamedIndividual>
</has_englishkeywords>
</owl:NamedIndividual>
现在,我已经能够获取每个语句的第一级可用的所有文字,some literal 1
即some literal 2
和some literal 3
。但是我不知道如何获取some literal 4
.
PS:对于与主 OWL 命名空间处于同一级别的所有情况,我使用下面给出的方法,然后遍历每个NamedIndividuals
.
ResIterator namedIndividuals = m.listResourcesWithProperty(RDF.type, OWL.NamedIndividual);
OWL.NamedIndividual
定义为:
AnnotationProperty NamedIndividual = m_model.createAnnotationProperty("http://www.w3.org/2002/07/owl#NamedIndividual");
现在对于嵌套对象,我是否需要创建一个临时命名空间来读取嵌套文字?如果是,如何?或者有没有其他有效的方法来做同样的事情?任何指导表示赞赏。