protege - How to set the Ontology ID of an anonymous Ontology using the OWL API -


i have file containing ontology without ontology id (the ontology tag <ontology/> empty). used serialization format rdf/xml. goal serialize file, set ontology id , write file using owlapi. unfortunatly don't know how this. tried following:

ontology = ontologymanager.loadontologyfromontologydocument(new file("filename")); ontologymanager.setontologydocumentiri(ontology, iri.create("http://www.mydesirediri.com/abc")); ontologymanager.saveontology(ontology,new fileoutputstream(new file("outputfile"))); 

by running code, ontology-id not added ontology. instead of <ontology rdf:about="http://www.mydesirediri.com/abc"/> tag still emtpy. doing wrong?

thank you!

kind regards

owlontologymanager.setontologydocumentiri() setting document iri of ontology, not ontology iri itself. difference between 2 document iri resolvable url or file path (i.e., int can used parse ontology), while ontology iri symbolic name of ontology (it not need resolvable , can missing - case anonymous ontologies).

to set ontology iri, use:

//versioniri can null owlontologyid newontologyid = new owlontologyid(ontologyiri, versioniri); // create change set our version iri setontologyid setontologyid = new setontologyid(ontology, newontologyid); // apply change manager.applychange(setontologyid); 

after this, save ontology usual.


Comments