Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.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
Sparql 删除WHERE查询中的可选三元组_Sparql - Fatal编程技术网

Sparql 删除WHERE查询中的可选三元组

Sparql 删除WHERE查询中的可选三元组,sparql,Sparql,我有一个资源http://example.com/entity/something的rdf:typeex:sometype,我想删除它。资源可能有或可能没有?某些内容。如果它ex:has

我有一个资源
http://example.com/entity/something
的rdf:type
ex:sometype
,我想删除它。资源可能有或可能没有
?某些内容
。如果它
ex:has
,我还想删除关系(当然,不是资源

前缀rdf:
前缀ex:
删除位置{
rdf:type ex:sometype;
有吗?什么。

这只适用于
ex:has?something
。我试图使用
optional{}
使第二个statement成为可选的,但它似乎不适用于
DELETE,其中

可以在一个请求中执行多个操作,以“;”分隔


删除其中的{rdf:type ex:sometype}
;
删除{ex:has?something}
第一个删除所有类型语句,第二个删除所有
ex:has
语句

通过分隔它们,删除类型语句并不依赖于匹配
ex:has


使用@AKSW提供的可选选项的完整删除表单也会起作用。

“似乎不起作用”不是一个有用的语句…什么不起作用?错误,意外的结果?此外,请小心:类似“我也想删除关系(当然,不是资源?什么的)。”这是一种误导,因为RDF数据集是一组三元组
(spo)
,因此,您只能删除三元组。如果还有其他三元组
(op1o2)
,则
o
仍将“存在”在数据集中。实际上,我猜您只能使用简单的三元组(请参阅)在简短的形式中,
DELETE WHERE
,因此,您应该尝试
前缀rdf:PREFIX ex:DELETE{rdf:type ex:sometype;ex:has?something.}其中{rdf:type ex:sometype;可选的{ex:has?something.}
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ex: <http://example.com/#>
DELETE WHERE {
       <http://example.com/entity/something> rdf:type ex:sometype ;
                 ex:has ?something .