使用sparql将rdf有序列表从图移到另一个 [英] moving a rdf ordered list from a graph to another with sparql
本文介绍了使用sparql将rdf有序列表从图移到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Fuseki数据集中的rdf知识图中有一个列表.我可以用类似的东西获取列表中的元素
I have a list in a rdf knowledge graph in a Fuseki dataset. I can get the elements of the list with something like
select ?webpage
where {
graph <http://datamusee.givingsense.eu/graph/webtracks>
{
?track <http://erlangen-crm.org/current/P16_used_specific_object> ?content.
?content rdf:rest*/rdf:first ?webpage .
}
}
但是我想将列表从webtracks图复制到另一个图
but I would like to copy the list from the webtracks graph to another graph
我找不到插入或通过构造导出数据然后再导入的方法.
I doen't find how to do it either with an insert or by exporting the data with a construct and then importing it.
推荐答案
基于示例数据:
:x :p (1 2 3) .
#-- The list start.
INSERT { GRAPH :g { ?a :p ?list } }
WHERE { ?a :p ?list }
;
#-- Copy triples in the list by INSERTing and DELETEing.
#-- ?z is an cons-cell element in the list
DELETE {
?z rdf:first ?head ; rdf:rest ?tail
}
INSERT {
GRAPH :g {
?z rdf:first ?head ; rdf:rest ?tail . }
}
WHERE {
?a :p ?list .
#-- Match each cons-cell in the list in ?z.
?list rdf:rest* ?z .
##-- For each cons-cell, get the head and tail.
?z rdf:first ?head ;
rdf:rest ?tail .
}
;
#-- Finally, optionally, remove the triple with the list.
DELETE { ?a :p ?list }
WHERE { ?a :p ?list }
这篇关于使用sparql将rdf有序列表从图移到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文