How to read ontology file with owl:imports in JENA?

我的梦境 提交于 2019-12-11 10:57:26

问题


I have an owl file that import some other ontologies from other owl files. I tried to follow JENA API Documentation to deal with it, but could not succeed. What am I missing?

The codes I used are above:

e-GovSecAOnto.owl imports:

<owl:Ontology rdf:about="">
    <owl:imports rdf:resource="http://www.ida.liu.se/~iislab/projects/secont/Security.owl"/>
    <owl:imports rdf:resource="http://www.unifiedcloud.org/2009/2/26/uci.owl"/>
    <owl:imports rdf:resource="http://wwwsemanticweb.org/ontologies/Portaria141.owl"/>
</owl:Ontology> 

ont-policy.rdf:

    <?xml version='1.0'?>

<!DOCTYPE rdf:RDF [
    <!ENTITY jena    'http://jena.hpl.hp.com/schemas/'>

    <!ENTITY rdf     'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
    <!ENTITY rdfs    'http://www.w3.org/2000/01/rdf-schema#'>
    <!ENTITY xsd     'http://www.w3.org/2001/XMLSchema#'>
    <!ENTITY base    '&jena;2003/03/ont-manager'>
    <!ENTITY ont     '&base;#'>
]>

<rdf:RDF
  xmlns:rdf ="&rdf;"
  xmlns:rdfs="&rdfs;"
  xmlns     ="&ont;"
  xml:base  ="&base;"
>

<DocumentManagerPolicy>
    <processImports rdf:datatype="&xsd;boolean">true</processImports>
    <cacheModels    rdf:datatype="&xsd;boolean">true</cacheModels>
</DocumentManagerPolicy>

<OntologySpec>
    <altURL rdf:resource="file:///C:/Users/usuario/Documents/Visual Studio 2013/WebSites/FrameworkBeta/Repository/Ontologies/Portaria141/Portaria141_V1.owl"/>
    <language rdf:resource="http://www.w3.org/2002/07/owl"/>
    <publicURI rdf:resource="http://wwwsemanticweb.org/ontologies/Portaria141.owl"/>
</OntologySpec>

<OntologySpec>
    <altURL rdf:resource="file:///C:/Users/usuario/Documents/Visual Studio 2013/WebSites/FrameworkBeta/Repository/Ontologies/CloudComputing/uci.owl"/>
    <language rdf:resource="http://www.w3.org/2002/07/owl"/>
    <publicURI rdf:resource="http://www.unifiedcloud.org/2009/2/26/uci.owl"/>
</OntologySpec>

</rdf:RDF>

ReadOntology():

OntDocumentManager dm = new OntDocumentManager(dmFileName);
OntModelSpec modelSpec = new OntModelSpec( OntModelSpec.RDFS_MEM );
modelSpec.setDocumentManager(dm);
OntModel m = ModelFactory.createOntologyModel(modelSpec);

m.read(FileManager.get().open(@"C:\Users\usuario\Documents\Visual Studio 2013\WebSites\FrameworkBeta\Repository\Ontologies\e-GovSecAOnto\e-GovSecAOnto.owl"), NS);

来源:https://stackoverflow.com/questions/29850654/how-to-read-ontology-file-with-owlimports-in-jena

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!