开发者

Updating OWL issue with JENA library and Protege

开发者 https://www.devze.com 2023-01-30 00:30 出处:网络
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 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:

FileOutputS开发者_如何学JAVAtream 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 fis before opening fos to 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, pass null for that argument.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号