2013-04-07 81 views
1

我有一個我在TopBraid中加載的RDF文件,我也從Web導入了一些RDF文件。最後,我保存了基本文件並檢查其代碼,以確保它包含導入語句。Jena無法從導入的RDF文件加載數據

<owl:Ontology rdf:about=""> 
    <owl:imports rdf:resource="http://www.bbc.co.uk/nature/life/Bird"/> 
    <owl:imports rdf:resource="http://www.bbc.co.uk/nature/life/Animal"/> 
    <owl:imports rdf:resource="http://www.bbc.co.uk/nature/life/Chordate"/> 
    <owl:imports rdf:resource="http://www.bbc.co.uk/nature/kingdom"/> 
    </owl:Ontology> 

所以,這就是文件,當我執行下面的SPARQL,我得到的結果:

PREFIX wo:<http://purl.org/ontology/wo/> 
SELECT * 
WHERE { 
    ?subject wo:kingdom ?object . 
} 

然而,當我使用的是耶拿相同的文件,我很老的任何結果,似乎耶拿不考慮進口:

// Open the bloggers RDF graph from the filesystem 
     InputStream in = new FileInputStream(new File("/home/noor/TBCMEWorkspace/bbc/index.rdf")); 

     // Create an empty in-memory model and populate it from the graph 
     Model model = ModelFactory.createMemModelMaker().createFreshModel(); 
     model.read(in,null); // null base URI, since model URIs are absolute 
     in.close(); 

     // Create a new query 
     String queryString = "PREFIX wo:<http://purl.org/ontology/wo/>" + 
      " SELECT * " + 
      " WHERE { " + 
      " ?subject ?x ?object . " + 
      " } "; 

     Query query = QueryFactory.create(queryString); 
     // Execute the query and obtain results 
     QueryExecution qe = QueryExecutionFactory.create(query, model); 
     ResultSet results = qe.execSelect(); 

     // Output query results 
     ResultSetFormatter.out(System.out, results, query); 

     // Important - free up resources used running the query 
     qe.close(); 

有如何使耶拿考慮進口任何方式?

回答

2

一個普通的耶拿模型不會加載導入的OWL模型,但OntModel會。基本的Jena模型設計用於處理RDF(即包括OWL,但也包括RDF的其他用途),而來自本體API的OntModel專門用於與OWL和其他本體一起使用。

+0

偉大的人,它工作:) – Noor 2013-04-08 09:31:47