我想直接從Oracle數據庫的SPARQL查詢中輸出一個RDF/XML文件。 查詢工作正常,因爲我已驗證ResultSet對象中的結果。如何在耶拿將SPARQL查詢轉換爲RDF文件?
但是,我不確定如何從那裏繼續。我想我想爲每個QuerySolution創建一個Statement,然後將它添加到Model中。但是我找不到一種方法來實現它,因爲我找不到獲取謂詞值的方法。
任何幫助,將不勝感激,以及暗示我是否走在正確的道路。
QueryExecution qe = QueryExecutionFactory.create(query, oracleSemModel) ;
ResultSet results = qe.execSelect();
Model model = ModelFactory.createDefaultModel();
while (results.hasNext())
{
QuerySolution result = results.next();
Resource subject = result.getResource("s"); // get the subject
Property predicate = result.getProperty("p"); // <-- THIS FUNCTION DOESN'T EXIST
RDFNode object = result.get("o"); // get the object
Statement stmt = ResourceFactory.createStatement(subject, predicate, object);
model.add(stmt);
}
model.write(System.out, "RDF/XML-ABBREV");
也許我很困惑 - 但結果沒有一個主語和謂語...初始查詢一樣。 – Randy 2013-03-12 20:28:55