Jena上带有OPTION(TRANSITIVE)的SPARQL查询错误 [英] SPARQL Query Error with OPTION(TRANSITIVE) on Jena

查看:120
本文介绍了Jena上带有OPTION(TRANSITIVE)的SPARQL查询错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下查询

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?type
WHERE
{
   {
      SELECT *
      WHERE
      {
           ?x rdfs:subClassOf ?type .
      }
   }
   OPTION (TRANSITIVE, t_distinct, t_in (?x), t_out (?type) ) .
   FILTER (?x = <http://dbpedia.org/ontology/Hospital>)
}

当我将其发送到Virtuoso端点时,它工作正常,但不适用于我的Jena实例.具体来说,我得到以下错误:

It works fine when i send it to Virtuoso endpoint but does not work on my Jena instance. In specific i get the following error:

INFO  [1] 400 Parse error: 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?type
WHERE
{
   {
      SELECT *
      WHERE
      {
           ?x rdfs:subClassOf ?type .
      }
   }
   OPTION (TRANSITIVE, t_distinct, t_in (?x), t_out (?type) ) .
   FILTER (?x = <http://dbpedia.org/ontology/Hospital>)
}
Lexical error at line 12, column 39.  Encountered: " " (32), after : "OPTION" (17 ms)

如果这是Virtuoso特有的功能,我希望知道与* Jena/Standard SPARQL一起使用的该查询的等效项.预期输出应为:

In case this a Virtuoso specific function, I would appreciate to know an equivalent for this query that would work with *Jena/Standard SPARQL). The expected output should be:

http://dbpedia.org/ontology/Building
http://dbpedia.org/ontology/ArchitecturalStructure
http://dbpedia.org/ontology/Place
http://dbpedia.org/ontology/d0:Location

代表医院"的所有超类

推荐答案

这是预期的行为.查询的这一部分:

This is the expected behavior. This part of the query:

OPTION (TRANSITIVE, t_distinct, t_in (?x), t_out (?type) ) 

不是标准的SPARQL 1.1,而是Virtuoso特定的扩展.

is not standard SPARQL 1.1 but it is a Virtuoso specific extension.

Jena是SPARQL 1.1兼容的实现.

Jena is a SPARQL 1.1 compliant implementation.

以下查询使用标准SPARQL 1.1语法执行相同的操作,并且应与Fuseki和Virtuoso一起使用(仅在dbpedia端点上进行了测试,并获得了相同的结果):

The following query does the same thing using standard SPARQL 1.1 syntax, and should work with both Fuseki and Virtuoso (just tested on the dbpedia endpoint and got the same result):

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?type
WHERE
{
  {
   SELECT *
   WHERE
    {
       ?x rdfs:subClassOf+ ?type .
    }
  }
  FILTER (?x = <http://dbpedia.org/ontology/Hospital>)
}

使用的功能是属性路径".

The feature used is the "property path".

请参见 http://www.w3.org/TR/sparql11-query/

这篇关于Jena上带有OPTION(TRANSITIVE)的SPARQL查询错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆