2016-05-14 32 views
1

我有一個.owl文件是這樣的:OWLAPI:獲取IRI在AnnotationAssertion

... 

<ClassAssertion> 
    <Class IRI="http://timbus.teco.edu/ontologies/DIO.owl#BusinessProcess"/> 
    <NamedIndividual IRI="#bf1badca"/> 
</ClassAssertion> 

... 

<AnnotationAssertion> 
    <AnnotationProperty abbreviatedIRI="rdfs:label"/> 
    <IRI>#bf1badca</IRI> 
    <Literal datatypeIRI="http://www.w3.org/2001/XMLSchema#string">Remove_old_books</Literal> 
</AnnotationAssertion> 

我想獲得,是針對在聲明中指定的個人IRI類名(BusinessProcess)註釋斷言(#bf1badca)

我有下面的代碼可以訪問在註釋文字的值:

 OWLOntologyWalker walker = new OWLOntologyWalker(Collections.singleton(ontology)); 

     OWLOntologyWalkerVisitor visitor = new OWLOntologyWalkerVisitor(walker) { 

      @Override 
       public void visit(OWLAnnotationAssertionAxiom axiom) { 
       OWLLiteral val = (OWLLiteral)axiom.getValue(); 
       System.out.println(val.getLiteral()); 
       // Prints 'Remove_old_books' 
       } 

     }; 

如何訪問註釋斷言的IRI領域,我.e,值#bf1badca?

回答

1

IRI字段是註釋公理的主題,可以用getSubject()方法檢索。

您可以使用OWLDataFactory獲得匹配OWLIndividual並致電getOWLNamedIndividual()

+0

非常感謝! – luispcosta