1

我正在尝试使用 SPIN API 运行模板。对于简单的模板,这很好用,但我对包含FILTERs.

出于验证目的,我在运行模板之前打印了模板的主体,而我看到的并不是我期望看到的:

Template t = SPINModuleRegistry.get().getTemplate("TheTemplatesURI", myModel);
System.out.printLn(t.getBody().toString());

它打印查询FILTER,但包含 4 行的子句如下所示:

FILTER <http://spinrdf.org/sp#notExists>([]) .

因此,当我尝试运行它时,查询会失败。

有谁知道如何spin:body从我的模型中检索全部内容?

4

1 回答 1

1

I now use a workaround.

The problem is that SPIN API only reads the FILTER queries properly (i.e. complete) if I put them as

NOT EXISTS {
    ?s ?p ?o .
    ...
}

instead of

FILTER NOT EXISTS {
    ?s ?p ?o .
    ...
}

If I manually run the templates that way, SPARQL will throw an exception because the proper way is to have FILTER. I now saved all my templates as NOT EXISTS in Topbraid Composer and add the FILTER bit via String.replace(...) after loading them via SPIN API. It may be ugly but at least it works.

于 2014-10-24T09:15:24.933 回答