2012-04-02 39 views
0

我有這個貓頭鷹文件。 #indelivers是#ipInDelivers的一個子類。我想知道的是如何找到這個類的#isPartOfMibDef資源,在這種情況下是#IP-MIB。用Apache Jena訪問貓頭鷹超類的限制

<owl:ObjectProperty rdf:about="#isPartOfMibDef"/> 

<owl:ObjectProperty rdf:about="#hasSyntax"/> 

<owl:Class rdf:about="#Counter32"> 
    <rdfs:subClassOf rdf:resource="#SYNTAX"/> 
</owl:Class> 

<owl:Class rdf:about="&owl;Thing"/> 

<owl:Class rdf:about="#mibObjects"> 
    <rdfs:subClassOf rdf:resource="&owl;Thing"/> 
</owl:Class> 

<owl:Class rdf:about="#IP-MIB"> 
    <rdfs:subClassOf rdf:resource="#mibDefs"/> 
</owl:Class> 

<owl:Class rdf:about="#ipInDelivers"> 
    <owl:equivalentClass> 
     <owl:Class> 
      <owl:intersectionOf rdf:parseType="Collection"> 
       <owl:Restriction> 
        <owl:onProperty rdf:resource="#hasSyntax"/> 
        <owl:allValuesFrom rdf:resource="#Counter32"/> 
       </owl:Restriction> 
       <owl:Restriction> 
        <owl:onProperty rdf:resource="#isPartOfMibDef"/> 
        <owl:allValuesFrom rdf:resource="#IP-MIB"/> 
       </owl:Restriction> 
      </owl:intersectionOf> 
     </owl:Class> 
    </owl:equivalentClass> 
    <rdfs:subClassOf rdf:resource="#mibObjects"/> 
</owl:Class> 

<owl:Class rdf:about="#aliases"> 
    <rdfs:subClassOf rdf:resource="&owl;Thing"/> 
</owl:Class> 

<owl:Class rdf:about="#indelivers"> 
    <rdfs:subClassOf rdf:resource="#aliases"/> 
    <rdfs:subClassOf rdf:resource="#ipInDelivers"/> 
</owl:Class> 

我到目前爲止的代碼是這樣的:

String NS = "http://namespace.com/owl#"; 
InputStream is = FileManager.get().open(this.owlPath); 
OntModel ontology = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF,null); 
    ontology.read(is,""); 

Reasoner reason = ReasonerRegistry.getOWLMicroReasoner(); 
InfModel info = ModelFactory.createInfModel(reason,ontology); 

OntClass alias = this.ontology.getOntClass(NS+"indelivers"); 
OntClass superClass = alias.getSuperClass(); 

我試圖訪問在超最GET-和列表的功能,但我似乎無法找到任何地方的#isPartOfMibDef

回答

0

你的命名空間應該是:

String NS = "http://namespace.com/owl#"; 
+0

是的,我知道,這只是OP中的一個錯字。 – andersem 2012-04-10 15:08:35

0

這爲我工作。雖然我的貓頭鷹類「會話」沒有交集。

OntClass cl1 = model.getOntClass(nsPrefix + "session"); 
    OntClass cl = cl1.getSuperClass(); 
    for (StmtIterator i = model.listStatements(cl, null, (RDFNode) null); i.hasNext();) { 
     Statement stmt = i.nextStatement(); 
     logger.info(" - " + PrintUtil.print(stmt)); 
    }