Reputation: 65
Jena cannot process OWL format files, so I used Protégé to create an ontology, saved it as RDF/XML, but the file ended with .owl
. The following code will read the ontology using owl-full language.
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
model.read(fileInputStream, null); // sometimes it could be read(fileInputStream, "RDF/XML")
Shouldn't I use RDFS somewhere?
Upvotes: 1
Views: 870
Reputation: 3136
Protege is meant to work mostly with OWL, that's why you have a .owl
extension to the file. Nonethless, if you saved it as "RDF/XML" in Protege, it generates a valid RDF document that you should then be able to open with tools capable of processing plain RDF (like Jena). A small hack is to replace the .owl
by a .rdf
extension.
What I suggest for you to understand your issue:
Open your .owl
file with a text editor. You should see some RDF/XML inside.
Validate the content of the file in order for you to see that the content is really serialised in really RDF. You can for instance use an online tool like http://www.w3.org/RDF/Validator/ to do that.
If you don't like the RDF/XML format, you can convert it into turtle, with a tool such as http://www.rdfabout.com/demo/validator/ for instance (I think Jena provides some methods to do that too).
Save the triples in a file with the .rdf
extension, it should be readable by RDF tools now.
Upvotes: 2