I'm using the OWL API for OWL 2.0 and there is one thing I can't seem to figure out. I have an OWL/XML file and I would like to retrieve the annotations for my object property assertions. Here are snippets from my OWL/XML and Java code:
OWL:
<ObjectPropertyAssertion>
<Annotation>
<AnnotationProperty abbreviatedIRI="rdfs:comment"/>
<Literal datatypeIRI="http://www.w3.org/2001/XMLSchema#string">Bob likes sushi</Literal>
</Annotation>
<ObjectProperty IRI="#Likes"/>
<NamedIndividual IRI="#UserBob"/>
<NamedIndividual IRI="#FoodSushi"/>
</ObjectPropertyAssertion>
Java:
OWLIndividual bob = manager.getOWLDataFactory().getOWLNamedIndividual(IRI.create(base + "#UserBob"));
OWLObjectProperty likes = manager.getOWLDataFactory().getOWLObjectProperty(IRI.create(base + "#Likes"));
OWLIndividual sushi = factory.getOWLNamedIndividual(IRI.create(base + "#FoodSushi"));
OWLObjectPropertyAssertionAxiom ax = factory.getOWLObjectPropertyAssertionAxiom(likes, bob, sushi);
for(OWLAnnotation a: ax.getAnnotations()){
System.out.println(a.getValue());
}
Problem is, nothing gets returned even though the OWL states there is one rdfs:comment. It has been troublesome to find any documentations on how to retrieve this information. Adding axioms with comments or whatever is not an issue.
if(ax.isAnnotated()) { … }block get executed? That is, isas.isAnnotated()returning true? As it stands, the issue could lie with it returning false, or withax.getAnnotations()returning an empty iterable. It will help to determine which is happening. - Joshua Taylorax.isAnnotated()does return false and theSet<OWLAnnotations>is empty. I have removed the if-statement to avoid confusion. Thanks. - VimKinfactory.getOWLObjectPropertyAssertionAxiom(…), are you creating a new axiom, as opposed to retrieving one from the ontology? What happens if you useOWLOntology#getObjectPropertyAssertionAxiomsto find the axiom that you're looking for, and check whether that oneisAnnotated? - Joshua Taylor