XQuery/Inserting and Updating Attributes

Motivation
You want to insert or update attributes in a document.

(Note: The XQuery Update syntax below is specific to eXist and is not necessarily identical to that in the W3C XQuery Update spec. Full documentation of eXist's XQuery Update syntax can be found at http://exist-db.org/exist/apps/doc/update_ext.xml)

Example of Attribute Insert
To insert a new attribute with the name of "foo" and a value of "bar" you an use the following example:

This will add a foo="bar" attribute to the root element