Attempting to run the query without the singleton will result in an error: We see that the node was placed after the only other existing node residing on the same level (the Marketing node) by default.
Instead, we want the Accounting node to be the first node under the Salaries node.
It is possible for an update to modify the document supplied as the context item, or a document read using the function, or even a document constructed dynamically by the query itself.
When using the various APIs, the general policy is that updated documents are never written automatically to disk.
But we’re getting a little ahead of ourselves here.
Let me introduce you to the 5 basic XQUF operations.
You may notice that we designated a singleton (single node value) representation of ' for Expression 2 (the Salaries destination node).
This is because the insert keyword requires that Expression 2 be a single node.
Even though there is only one Salaries node, the singleton is still required.
Saxon-EE supports use of the update extensions to XQuery defined in the W3C Recommendation
Update is available only in Saxon-EE, and is supported only if explicitly requested.