How to read ontology file with owl:imports in JENA

2019-08-10 02:22发布

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);

0条回答
登录 后发表回答