[英]Jena Sparql and construct
CONSTRUCT
is an alternative SPARQL result clause to SELECT
. CONSTRUCT
是SELECT
的替代SPARQL结果子句。 Instead of returning a table of result values, CONSTRUCT
returns an RDF graph. CONSTRUCT
返回结果值表,而是返回RDF图。 For instance, running this query in the following Java code produces an HttpException: 406 Unacceptable
. 例如,在以下Java代码中运行此查询会产生
HttpException: 406 Unacceptable
。 But if instead of the CONSTRUCT
block, I choose SELECT ?x
, it's just fine. 但是如果不是
CONSTRUCT
块,我选择SELECT ?x
,它就好了。 Does Jena support CONSTRUCT
, and if so, how? Jena是否支持
CONSTRUCT
,如果支持,如何支持? Both queries are acceptable to the DBpedia endpoint . 这两个查询都可以被DBpedia端点接受。
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);
Jena supports CONSTRUCT
, but to get the result you need to call a different method, because execSelect
and ResultSet
are only for SELECT
queries. Jena支持
CONSTRUCT
,但要获得结果,您需要调用另一个方法,因为execSelect
和ResultSet
仅用于SELECT
查询。 Use this instead: 请改用:
Model results = qexec.execConstruct();
results.write(System.out, "TURTLE");
Model
is Jena's interface for accessing RDF graphs, see the javadocs for details. Model
是Jena用于访问RDF图的界面,有关详细信息,请参阅javadocs 。
ResultSetFormatter.out(System.out,results,query)找不到符号和标识符此时发生预期错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.