Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何编写返回RDF列表的SPARQL构造查询?_Sparql_Rdf_Graph Databases - Fatal编程技术网

如何编写返回RDF列表的SPARQL构造查询?

如何编写返回RDF列表的SPARQL构造查询?,sparql,rdf,graph-databases,Sparql,Rdf,Graph Databases,假设我有以下用Turtle表示的RDF三元组: @prefix sorg: <http://www.schema.org/> . <https://example.com/Foo> sorg:hasPart ( "item1" "item2" "item3" ) . @前缀sorg:。 sorg:hasPart(“item1”“item2”“item3”)。 如何编写一个SPARQLCONSTRUCT查询来检索列表?如果不可能,我如何编写一个SELECT查询,以正确

假设我有以下用Turtle表示的RDF三元组:

@prefix sorg: <http://www.schema.org/> .

<https://example.com/Foo> sorg:hasPart ( "item1" "item2" "item3" ) .
@前缀sorg:。
sorg:hasPart(“item1”“item2”“item3”)。

如何编写一个SPARQL
CONSTRUCT
查询来检索列表?如果不可能,我如何编写一个
SELECT
查询,以正确的顺序返回列表元素?我找到了,但它似乎不能保证元素将按顺序返回。

这将为您进行构造-链接到原始属性以获取列表,以便您可以根据需要进行筛选等(只需将?事物和属性更改为您的用例)

前缀rdf:
构造{
事情清单。
?listRest rdf:第一个?头;
休息?尾巴。
}在哪里{
事情清单。
?列表rdf:rest*?列表rest。
?listRest rdf:第一个?头;
休息?尾巴。
}

问题是,WHERE部分是什么?主题是什么?还是主谓?或者只有谓词构造不一致,因为它缺少?list和?listRest之间的链接
prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

CONSTRUCT {
    ?thing <urn:prop:to:list> ?list .
    ?listRest rdf:first ?head ; 
       rdf:rest ?tail .
} WHERE {
    ?thing <urn:prop:to:list> ?list .

    ?list rdf:rest* ?listRest .
    ?listRest rdf:first ?head ;
       rdf:rest ?tail .
}