任何人都可以在任何文档(无论是W3C,virtuoso,语义网页,还是您自己的自定义代码等)中指向SPARQL中的有效 UPDATE语句?
它必须与WHERE规范一起完成,并且在一个查询中更新多个三元组.
谢谢.
编辑/示例:
这里是我当前的代码,其中有更换的所有当前值的目标dc:creator,dc:title并dc:description用INSERT子句中指定的人.这个查询在逻辑和语法方面都是正确的吗?
WITH GRAPH <http://127.0.0.1:3000/dendro_graph>
DELETE
{
:teste dc:creator ?o0 .
:teste dc:title ?o1 .
:teste dc:description ?o2 .
}
INSERT
{
:teste dc:creator "Creator%201" .
:teste dc:creator "Creator%202" .
:teste dc:title "Title%201" .
:teste dc:description "Description%201" .
}
WHERE
{
:teste dc:creator ?o0 .
:teste dc:title ?o1 .
:teste dc:description ?o2 .
}
Run Code Online (Sandbox Code Playgroud)
Jee*_*tra 15
我仍然不完全清楚你想要实现的目标,以及为什么你提供的示例更新不是你想要的,但如果目标是更新替换给定主题的三元组,你可以做一些事情像这样:
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix ex: <http://example.org/>
DELETE {?s ?p ?o}
INSERT {?s ex:title "foo" ;
ex:description "bar" ;
rdf:type ex:FooBar .
}
WHERE { ?s ?p ?o .
FILTER (?s = ex:subject1)
}
Run Code Online (Sandbox Code Playgroud)
上述操作将删除所有现有三元组ex:subject1作为主题,并插入新标题,描述和类型.
或者,如果您不喜欢过滤器,您也可以像这样制定上述内容:
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix ex: <http://example.org/>
DELETE {ex:subject1 ?p ?o}
INSERT {ex:subject1 ex:title "foo" ;
ex:description "bar" ;
rdf:type ex:FooBar .
}
WHERE {
ex:subject1 ?p ?o .
}
Run Code Online (Sandbox Code Playgroud)
如果您只想删除给定主题的特定属性(而不是具有该主题的所有三元组),则可以像这样修改操作:
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix ex: <http://example.org/>
DELETE {ex:subject1 ex:title ?t ;
ex:description ?d ;
rdf:type ?c .
}
INSERT {ex:subject1 ex:title "foo" ;
ex:description "bar" ;
rdf:type ex:FooBar .
}
WHERE {
ex:subject1 ex:title ?t ;
ex:description ?d ;
rdf:type ?c .
}
Run Code Online (Sandbox Code Playgroud)
在SPARQL中,更新表示为DELETE,后跟INSERT:
http://www.w3.org/TR/2010/WD-sparql11-update-20100126/#t413
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
WITH <http://example/addresses>
DELETE { ?person foaf:firstName 'Bill' }
INSERT { ?person foaf:firstName 'William' }
WHERE
{ ?person a foaf:Person .
?person foaf:firstName 'Bill'
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13091 次 |
| 最近记录: |