Tutorial :How to add OWL:imports to a .owl file by jena


I am new to Jena. I want to create a new OntModel and need to imports some other ontology to this model.If I write it to file, I expect the file can show something like follow:

  <owl:Ontology rdf:about="">      <owl:imports rdf:resource="http://test.owl#"/>    </owl:Ontology>  

Right now, I dont know how to import other ontology to the model by jena. Can any one give me some advices?

Thank you


See jena's Ontology API (which sits over the RDF api) and in particular the imports section.

To make something like you want, try:

String base = "http://www.example.com/ont";  OntModel model = ModelFactory.createOntologyModel();  Ontology ont = model.createOntology("");  ont.addImport(model.createResource("http://test.owl#"));  model.write(System.out, "RDF/XML-ABBREV", base);  


<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#"      xml:base="http://www.example.com/ont">    <owl:Ontology rdf:about="">      <owl:imports rdf:resource="http://test.owl#"/>    </owl:Ontology>  </rdf:RDF>  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »