XQuery Update Facility
The XQuery Update Facility is an extension of the XQuery language that enables parts of XML documents to be modified. In normal XQuery execution, the entire document is regenerated, and has to be stored back to its location. This could be inefficient when only small parts of the document need to be modified. With the Update Facility, only those parts of the document that need to be modified are updated.
The XQuery Update Facility is described as extensions to XQuery 1.0 and XQuery 3.1, in the following specifications, respectively:
The XQuery Update Facility in XMLSpy
The following points explain how XQuery Update works in XMLSpy:
•An update is carried out by an update expression. For example, an update expression can specify that a node in an XML document is renamed:
rename node /documents/doc-01 as "document-01"
•In practice, multiple update expressions are entered in a single document—the XQuery Update document.
•As each update expression in the update document executes, the result is not applied immediately, but is added to a Pending Updates List (PUL). As a result, the PUL contains the results of all the update expressions. All updates in the PUL are then applied all together at once.
•In XMLSpy, the PUL updates are applied in one of two ways:
(i) After being previewed by the user in the GUI. The advantage is that the update can be aborted if the preview shows undesirable results. Previewing is available on running the XQuery/Update Execution command, or on evaluating XQuery Update expressions in the XPath/XQuery output window. How to set the preview option is explained in the respective descriptions.
(ii) Directly and without any user intervention. The advantage is that the update is carried out silently without requiring user intervention. The direct application of updates (without a preview) is available on running the XQuery/Update Execution command, or on evaluating XQuery Update expressions in the XPath/XQuery output window. How to set the direct-update option is explained in the respective descriptions.
XMLSpy provides a powerful XQuery Update Preview feature, which enables you to preview the effect of update expressions on the active XML document and then apply it. This feature is described the section Previewing and Applying Updates.