SPARQL/Update and RDF collections

FYI: A user was asking on jena-dev about deleting lists:

http://tech.groups.yahoo.com/group/jena-dev/message/41798


He wants to delete lists (which in this case are compound data structures)

Accessing lists is not possible on SPARQL 1.0 pattern matching so you can't delete them either without something like property paths (or a property function that evaluates to find all list members but that's not going to common across implementations).

He came up with:

PREFIX f: <uri:f#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
DELETE {
  f:foo f:hasList ?list.
  ?node rdf:first ?member.
  ?node rdf:rest ?node2
}
WHERE {
  f:foo f:hasList ?list.
  ?list rdf:rest* ?node.
  ?node rdf:first ?member.
  ?node rdf:rest ?node2
}

RDF containers (Bag, Alt, Seq) can be done with 

  { <container> ?p ?o . FILTER (regex(str(?p), "http://www.w3.org/1999/02/22-rdf-syntax-ns#_\\d+$")) }

(string concat would be nice!)

 Andy

Received on Wednesday, 14 October 2009 18:05:41 UTC