sparql - DELETE WHERE 不使用属性路径序列 sparql
问题描述
第1部分:
这些是已经存在的三元组。
<http:o1> <http:name> "name"^^xsd:string
<http:o1> <http:place> "place"^^xsd:string
<http:o1> <http:hasContained> <http:o2>
<http:o2> <http:name> "name1"^^xsd:string
<http:o2> <http:place> "place2"^^xsd:string
<http:o2> <http:hasContained> <http:o3>
<http:o3> <http:name> "name3"^^xsd:string
<http:o3> <http:place> "place3"^^xsd:string
我想删除距离 o1 节点 2 个节点的节点属性。
delete where { <http:o1> <http:hasContained>/<http:hasContained> ?s. ?s ?p ?o}
我想出了这个查询来删除与 o3 节点相关的三元组。但是当我运行这个查询时,我遇到了一些错误。
Malformed query: Encountered " "/" "/ "" at line 1, column 731.
Was expecting one of:
"(" ...
"[" ...
<NIL> ...
<ANON> ...
"true" ...
"false" ...
<Q_IRI_REF> ...
<PNAME_NS> ...
<PNAME_LN> ...
<BLANK_NODE_LABEL> ...
<VAR1> ...
<VAR2> ...
<INTEGER> ...
<INTEGER_POSITIVE> ...
<INTEGER_NEGATIVE> ...
<DECIMAL> ...
<DECIMAL_POSITIVE> ...
<DECIMAL_NEGATIVE> ...
<DOUBLE> ...
<DOUBLE_POSITIVE> ...
<DOUBLE_NEGATIVE> ...
<STRING_LITERAL1> ...
<STRING_LITERAL2> ...
<STRING_LITERAL_LONG1> ...
<STRING_LITERAL_LONG2> ...
通过一些替代查询,我可以完成这项工作。
但是上述查询中的错误是什么?
为什么路径属性查询不适用于删除位置?
第2部分:
对于相同的三元组数据,删除所有使用的三元组的查询是
delete {?s ?p ?o} where { <http:o1> (<http:hasContained>/<http:hasContained>?)? ?s. ?s ?p ?o}
这不会从三重存储中删除任何数据。而通过使用构造,我可以使用相同的 where 子句检索数据。
construct {?s ?p ?o} where { <http:o1> (<http:hasContained>/<http:hasContained>?)? ?s. ?s ?p ?o}
这些查询中有什么问题,我错过了什么吗?
解决方案
根据我对 SPARQL 语法的理解,DELETE WHERE ... 速记不允许属性路径。但是,完整的形式 DELETE ... WHERE ... 有效,因此您可以这样做:
DELETE {?s ?p ?o}
WHERE {
<http:o1> <http:hasContained>/<http:hasContained> ?s. ?s ?p ?o
}
推荐阅读
- flutter - 如何在函数或类中传递变量引用?
- reactjs - ReactJS - 在页面加载时滚动到表格的行
- python-3.x - 如何在python中循环时间序列数据集?
- r - 如何轻松生成 10 次方的列表?
- html - 为什么我的 SVG 的圆圈没有完全显示?
- c++ - “codecvt_utf8_utf16”和“codecvt_utf8”从UTF-8转换为UTF-16的区别
- java - 不能在java中一起打印字符串和布尔值
- package - Julia:如何更新到最新版本的包(即 Flux)
- deep-learning - Gan损失很小,判别器损失巨大?
- java - 使用自定义绑定适配器绑定可绘制资源