I would like to add this assertion (from Protégé "Individual Description") with java owl-api :
person hasProperty only (ClassA or ClassB )
As :
<ClassAssertion>
<ObjectAllValuesFrom>
<ObjectProperty IRI=“#hasProperty”/>
<ObjectUnionOf>
<Class IRI=“#ClassA”/>
<Class IRI=“#ClassB”/>
</ObjectUnionOf>
</ObjectAllValuesFrom>
<NamedIndividual IRI=“#Person”/>
</ClassAssertion
How can I do it?
OWLClass c1 = factory.getOWLClass(":ClassA", prefix );
OWLClass c2 = factory.getOWLClass(":ClassB", prefix );
OWLObjectProperty p = factory.getOWLObjectProperty("hasProperty", prefix);
OWLObjectIntersectionOf u = factory.getOWLObjectUnionOf(c1, c2);
OWLClassExpression e = factory.getOWLClass(property, u);
manager.addAxiom(owlOntology, factory.getOWLClassAssertionAxiom(p, person, e));
factory.getOWLClass(property, u);
<- that's clearly wrong if you look at the Javadoc of this method! usefactory.getOWLObjectAllValuesFrom(p, u)
instead. – UninformedUsersaveOntology
method. – Ignazio