DocUpdateTracking
From SPARQL Working Group
Construction from Template Using Blank Nodes
A commercial in-house document management tool built on Mulgara keeps some stats of updates on a document through various interfaces. After the document IDs have been loaded into the system, the tracking information is initialized with empty data. The initializing data is constructed from a template and created for every document that doesn't have tracking data already on it.
Since this is done in Mulgara, the updates are currently performed with TQL. This syntax is:
INSERT SELECT ?doc <ex:updates> ?blank1 ?doc <ex:updates> ?blank2 ?blank1 <rdf:type> <ex:PublicUpdates> ?blank1 <ex:count> "0"^^xsd:integer ?blank2 <rdf:type> <ex:AdminUpdates> ?blank2 <ex:count> "0"^^xsd:integer ?blank2 <ex:details> ?blank3 ?blank3 <rdf:type> <rdf:List> ?blank3 <rdf:first> <ex:data/create> ?blank3 <rdf:rest> <rdf:nil> FROM <graph> WHERE ?doc <rdf:type> <ex:Document> MINUS ?doc <ex:updates> ?u INTO <graph>;
In this syntax, any unbound variables in the template will create new blank nodes. Note that a new set of blank nodes is required for each binding on the ?doc variable.
Something equivalent in SPARQL Update might be:
INSERT { ?doc ex:updates _:xxx, _:yyy . _:xxx a ex:PublicUpdates; ex:count "0"^^xsd:intetger . _:yyy a ex:AdminUpdates; ex:count "1"^^xsd:intetger . ex:details _:zzz. _:zzz a rdf:List; rdf:first ex:data/create; rdf:rest rdf:nil . } WHERE { ?doc a ex:Document OPTIONAL { ?doc ex:updates ?u } FILTER (!bound(?u)) }