I have an ontology created in protege 4. I need to add a data property to an owl individual of my ontology using OWL API 4. i am new to java / owl api so to my understanding. i used following code:-
OWLNamedIndividual myowlIndl = df.getOWLNamedIndividual(":test", pm);
OWLDataProperty indlName = df.getOWLDataProperty(":strVal", pm);
OWLDataPropertyAssertionAxiom dataPropertyAssertion = df.getOWLDataPropertyAssertionAxiom(indlName, myowlIndl,"hello world");
AddAxiom addAxiom1 = new AddAxiom(myowlOntology, dataPropertyAssertion);
myontologyManager.applyChange(addAxiom1);
but this code do not "Update" already existing owl individual "test" but create a new one.
How to rectify this?
Use the full IRI instead of a shortened version, it is hard to tell from this code whether the namespace is the correct one (":test" is ambiguous, since we cannot see how the prefix manager resolves it, and we cannot see the ontology). Also, make sure to save the ontology after the call to applyChange().