0

I am trying to create individuals and save them in OWL file. The OWL file was created in Protégé. The size of the file was 10KB but after trying to save the individuals in the ontology the size of the code becomes 7KB.

Then I tried to open the OWL file using Protégé but it will not open.

The code is:

String SOURCE = "http://www.semanticweb.org/ontologies/2012/9/untitled-ontology-19";
String NS = SOURCE + "#";

OntModel onto = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
onto.read("file:/home/tourism.owl", "RDF/XML");

OntClass place = onto.getOntClass(NS+"Mountains");
Individual am1 = onto.createIndividual(NS+Concept1, place);

FileOutputStream output = null;

try  {
  output = new FileOutputStream( "/home/tourism.owl ");     
} catch(Exception e) {}

onto.writeAll(output, "RDF/XML-ABBREV","xmlbase");
Borodin
  • 126,100
  • 9
  • 70
  • 144

2 Answers2

0

Have you checked that the new file does not contain the new information? It may have been written out in a more compact form that than the original file because you used the "RDF/XML-ABBREV" form.

PS "xmlbase" should be a URI.

AndyS
  • 16,345
  • 17
  • 21
0

Jena is purely RDF/XML based API for accessing Ontology or Models. Make a Note of these things: What is the format when you save your OWL file after editing it with Protege? Is it OWL/XML or RDF/XML?? Jena being RDF centric can read OWL files written in RDF/XML format, but cannot read OWL file written in OWL/XML syntax (specifically the OWL2 syntax). Similarly it can write a Model/OntModel from memory to OWL file or an RDF file but ALWAYS in either "RDF/XML" syntax or "N3" or "RDF/XML-ABBREV". And Since you are using "RDF/XML-ABBREV", which lists your triples in abbreviated format.. possibly that is the reason why your output file is decreasing in size.