Say that someone you know accidentally inserted some triples into an RDF database with a datatype of xsd:datetime instead of the proper xsd:dateTime. What's the simplest way to correct this?
I know I can do something like this to find the bad data:
select * where {
?s ?p ?o.
filter (datatype(?o)=xsd:datetime)
}
And I could take those results, fix them up in a text editor, delete the bad ones and insert the good ones... but I have to believe/hope there is an easier way.
A triple consisting of three elements. This class is an abstract implementation defining the basic API. It refers to the elements as 'left', 'middle' and 'right'. Subclass implementations may be mutable or immutable. However, there is no restriction on the type of the stored objects that may be stored.
A union is a type whose variables are allowed to store different type values at different times during execution.
With SPARQL 1.1 you can do this with a SPARQL Update command like so:
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)
}
Update Commands apply over specific graphs so you may have to issue this mutliple times adding a WITH <graph>
to the start of the command for each named graph you need to correct.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With