我正在尝试使用以下命令查找带有RDF的自引用循环:
SELECT ?sbj
# query pattern
WHERE {
?sbj skos:broader+ ?sbj .
}
当我在这些RDF三元组上运行时:
http://www.example.com/Concept/0001 http://www.w3.org/2004/02/skos/core#broader http://www.example.com/Concept/0002
http://www.example.com/Concept/0002 http://www.w3.org/2004/02/skos/core#broader http://www.example.com/Concept/0003
http://www.example.com/Concept/0003 http://www.w3.org/2004/02/skos/core#broader http://www.example.com/Concept/0001
我明白了:
http://www.example.com/Concept/0003
http://www.example.com/Concept/0001
http://www.example.com/Concept/0002
http://www.example.com/Concept/0002
http://www.example.com/Concept/0003
http://www.example.com/Concept/0001
http://www.example.com/Concept/0001
http://www.example.com/Concept/0002
http://www.example.com/Concept/0003
如果我在这些RDF三元组上运行相同的查询:
http://www.example.com/Concept/0001 http://www.w3.org/2004/02/skos/core#broader http://www.example.com/Concept/0002
http://www.example.com/Concept/0002 http://www.w3.org/2004/02/skos/core#broader http://www.example.com/Concept/0003
http://www.example.com/Concept/0003 http://www.w3.org/2004/02/skos/core#narrower http://www.example.com/Concept/0001
我明白了:
http://www.example.com/Concept/0003
http://www.example.com/Concept/0002
http://www.example.com/Concept/0003
我预计它会返回空白。
看起来像skos:更广泛的+似乎允许skos以外的属性:更广泛,更像是任何*,skos:更广泛,任何*或者其他......是正确的行为吗?
我用的是:
Jena: VERSION: 2.6.4
Jena: BUILD_DATE: 2010-12-12T16:56:15+0000
ARQ: VERSION: 2.8.7
ARQ: BUILD_DATE: 2010-12-12T14:07:48+0000
答案 0 :(得分:0)
为了提供一个最小的工作示例,这里有两个与问题中的数据文件相对应的数据文件。
data1.n3:
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix : <http://www.example.com/Concept/> .
:0001 skos:broader :0002 .
:0002 skos:broader :0003 .
:0003 skos:broader :0001 .
data2.n3:
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix : <http://www.example.com/Concept/> .
:0001 skos:broader :0002 .
:0002 skos:broader :0003 .
:0003 skos:narrower :0001 .
使用Jena的命令行ARQ工具,似乎问题已在更高版本的Jena / ARQ中得到解决。
$ arq --version
Jena: VERSION: 2.10.0
Jena: BUILD_DATE: 2013-02-20T12:04:26+0000
ARQ: VERSION: 2.10.0
ARQ: BUILD_DATE: 2013-02-20T12:04:26+0000
$ arq --query query.sparql --data data1.n3
---------
| sbj |
=========
| :0002 |
| :0001 |
| :0003 |
---------
$ arq --query query.sparql --data data2.n3
-------
| sbj |
=======
-------