Scrubbing data using eXist
I had to scrub some private data in a few thousands of xml documents stored in an eXist database.
I used this:
update value expr with exprSingle
So, for e.g.
let $ssn-ids := $collection//u:PersonSSNID[. != '888888888'] update value $ssn-ids with '888888888'
The filter expression makes the xquery repeatable and precise.
Look up the update extensions here: http://exist-db.org/update_ext.html#N101B9 for more details and other update mechanisms. Quite useful.