CONSTRUCT
是替代SPARQL結果子句SELECT
。 CONSTRUCT
不是返回一個結果值表,而是返回一個RDF圖。例如,在以下Java代碼中運行此查詢會生成HttpException: 406 Unacceptable
。但如果不是CONSTRUCT
區塊,我選擇SELECT ?x
,這很好。 Jena是否支持CONSTRUCT
,如果有,如何?這兩個查詢都可以被DBpedia endpoint接受。Jena Sparql和構造
PREFIX : <http://dbpedia.org/resource/>
PREFIX onto: <http://dbpedia.org/ontology/>
CONSTRUCT {
:France onto:anthem ?x
}
WHERE
{
:France onto:anthem ?x .
}
Query query = QueryFactory.create("the query goes here");
QueryExecution qexec = QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql", query);
ResultSet results = qexec.execSelect();
ResultSetFormatter.out(System.out, results, query);
完美工作,write方法做所有的工作對我來說,THX – blueomega 2010-06-05 09:32:15