I can’t save any writing update to my RDF/XML OWL file using Protege. Each time I close the application I then lose all of my editing.
I’ve used the JENA library to read this file in the following way:
OntModel model = ModelFactory.createOntologyModel (OntModelSpec.OWL_DL_MEM,null);
model.setNsPrefix(“”, ns);
FileInputStream fis = new FileInputStream(this.sourceFile);
model.read(fis,ns);
I tried to fix this issue by:
FileOutputStream fos = new FileOutputStream(this.sourceFile);
model.writeAll(fos, "RDF/XML-ABBREV","xmlbase");
model.close();
But my file gets blanked and is finally empty.
If I try to rename the output file instead it works OK (being careful to avoid the output file matches the input file).
In the end, my question is: How can I update my OWL file?
I would say that you need to be sure that you close both streams properly. In particular, you should close
fisbefore openingfosto the same file name.By the way,
"xmlbase"is not a valid base URI for writing a model. If you don’t want to use a base URI to generate relative URI’s in the body of the output document, passnullfor that argument.