If I have a regular model that was loaded with N-triples, and those N-triples
represented an OWL ontology, how could I write it back out such that I would
see everything in OWL XML?
What I did was something similar to:
Model curModel = FileManager.get().loadModel(file);
OntModel asOwl = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
asOwl.add(curModel);
FileWriter fstream = new FileWriter(filePath);
BufferedWriter out = new BufferedWriter(fstream);
grandSchema.write(out);
The resulting XML is expressed in pure RDF/XML:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" >
<rdf:Description rdf:about="http://example.org/unnamed0">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Ontology"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/unnamed0#Uncle">
<owl:equivalentClass rdf:resource="http://example.org/unnamed0#XXX"/>
<rdfs:subClassOf rdf:resource="http://example.org/unnamed0#Person"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
</rdf:Description>
...
but should look more like the following OWL (created by opening the output file
with Top Braid Composer and saving it back out):
<owl:Class rdf:about="http://example.org/unnamed0#Uncle">
<owl:equivalentClass>
<owl:Class rdf:about="http://example.org/unnamed0#XXX"/>
</owl:equivalentClass>
<rdfs:subClassOf>
<owl:Class rdf:about="http://example.org/unnamed0#Person"/>
</rdfs:subClassOf>
</owl:Class>