Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设您认识的某个人不小心将一些三元组插入到数据类型为 xsd:datetime 而不是正确的 xsd:dateTime 的 RDF 数据库中。纠正这个问题的最简单方法是什么?
我知道我可以做这样的事情来找到坏数据:
select * where { ?s ?p ?o. filter (datatype(?o)=xsd:datetime) }
我可以获取这些结果,在文本编辑器中修复它们,删除坏的并插入好的......但我必须相信/希望有一种更简单的方法。
使用 SPARQL 1.1,您可以使用 SPARQL 更新命令执行此操作,如下所示:
DELETE { ?s ?p ?o } INSERT { ?s ?p ?o2 } WHERE { ?s ?p ?o . FILTER(datatype(?o) = xsd:datetime) BIND(STRDT(STR(?o), xsd:dateTime) AS ?o2) }
更新命令适用于特定的图,因此您可能需要多次发出此WITH <graph>命令,为您需要更正的每个命名图添加 a 到命令的开头。
WITH <graph>