开发者

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 开发者_如何学Gogive 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);

Result:

<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>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜