【发布时间】:2015-07-17 18:20:22
【问题描述】:
我正在使用 org.openrdf.rio.trig.TriGWriter 来创建 SPARQL 更新查询。我的查询需要采用以下格式:
PREFIX ....
PREFIX ....
insert data{
graph <....../id>{}
graph <....../id>{}
graph <....../id>{}
}
但我现在得到的是:
PREFIX ....
PREFIX ....
insert data{
graph <....../id>
@prefix ...
@prefix ...
{....}
graph <....../id>
@prefix ...
@prefix ...
{....}
graph <....../id>
@prefix ...
@prefix ...
{....}
}
前缀与 TriGWriter.startRDF() 和 TriGWriter.endRDF() 调用有关。我想禁止所有 @prefix 行。我希望有一种干净的方法可以做到这一点,而一旦它们已经存在,就不会将它们弄出来。我正在查看 TriGWriter.closeActiveContext() 调用,但我没有得到好的结果。任何帮助将不胜感激。
这是生成我的 sparql 的代码:
def rdfWriter = new org.openrdf.rio.trig.TriGWriter(updateWriter);
rdfWriter.startRDF();
rdfWriter.handleNamespace("dc","http://purl.org/dc/terms/");
rdfWriter.handleNamespace("mrss","http://search.yahoo.com/mrss/");
rdfWriter.handleNamespace("xsd","http://www.w3.org/2001/XMLSchema#");
rdfWriter.handleNamespace("owl","http://www.w3.org/2002/07/owl#");
rdfWriter.handleNamespace("sesame","http://www.openrdf.org/schema/sesame#");
rdfWriter.endRDF();
updateWriter.getBuffer().setLength(resetLength);
it = map.entrySet().iterator();
while (it.hasNext())
{
Map.Entry pair = (Map.Entry)it.next();
rdfWriter.startRDF();
"""GRAPH <${camelContext.getRegistry().lookup('context')}content/${pair.getKey()}>""".writeTo(updateWriter);
def graph = pair.getValue();
graph.each{
rdfWriter.handleStatement(it);
}
rdfWriter.endRDF();
}
updateWriter.append("${lsp} }; ${lsp}");
【问题讨论】: