假设我有下面的Turtle声明:
@prefix : <http://example.org#> .
:ls :list (:a :b :c)
有没有办法获得元素在集合中的位置?
例如,使用以下查询:
PREFIX : <http://example.org#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?elem WHERE {
?x :list ?ls .
?ls rdf:rest*/rdf:first ?elem .
}
我得到了:
--------
| elem |
========
| :a |
| :b |
| :c |
--------
但是我想要一个查询来获得:
--------------
| elem | pos |
==============
| :a | 0 |
| :b | 1 |
| :c | 2 |
--------------
有可能吗?
发布于 2013-07-08 21:46:03
我已经找到了一种使用ARQ中的属性函数库来完成此任务的方法。正如Steve Harris所说,这是非标准的。
PREFIX : <http://example.org#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX list: <http://jena.hpl.hp.com/ARQ/list#>
SELECT ?elem ?pos WHERE {
?x :list ?ls .
?ls list:index (?pos ?elem).
}
https://stackoverflow.com/questions/17523804
复制相似问题