0

第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}

这些查询中有什么问题,我错过了什么吗?

4

2 回答 2

3

根据我对 SPARQL 语法的理解,DELETE WHERE ... 速记不允许属性路径。但是,完整的形式 DELETE ... WHERE ... 有效,因此您可以这样做:

DELETE {?s ?p ?o}
WHERE {
    <http:o1> <http:hasContained>/<http:hasContained> ?s. ?s ?p ?o
}
于 2020-04-28T22:13:06.947 回答
2

我们一直在审查SPARQL 规范。在这个上。您能否验证以下版本是否适合您?

  delete { <http:o1> <http:hasContained>/<http:hasContained> ?s. ?s ?p ?o} where { <http:o1> <http:hasContained>/<http:hasContained> ?s. ?s ?p ?o}
于 2020-04-28T18:54:12.823 回答