我有以下查询
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实例上不起作用。具体而言,我得到以下错误:
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)。预期的输出应为:
http://dbpedia.org/ontology/Building
http://dbpedia.org/ontology/ArchitecturalStructure
http://dbpedia.org/ontology/Place
http://dbpedia.org/ontology/d0:Location
代表&#34; Hospital&#34;
的所有超类答案 0 :(得分:5)
这是预期的行为。这部分查询:
OPTION (TRANSITIVE, t_distinct, t_in (?x), t_out (?type) )
不是标准的SPARQL 1.1,但它是Virtuoso特定的扩展名。
Jena是符合SPARQL 1.1的实现。
以下查询使用标准的SPARQL 1.1语法执行相同的操作,并且应该与Fuseki和Virtuoso一起使用(仅在dbpedia端点上测试并获得相同的结果):
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>)
}
使用的功能是&#34;属性路径&#34;。