Previewing and Applying Updates

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  User Guide and Reference > XQuery > XQuery Update Facility >

Previewing and Applying Updates

If you wish to modify an XML document using XQuery Update, you can preview updates before applying them to the XML document and saving the modified document.

 

In the XPath/XQuery output window (screenshot below), you can enter one or more update expressions and then preview updates in the pending update list (PUL) that is displayed in the bottom pane (see screenshot below). If the PUL is as you want it, you can apply the updates to the document and then save the modified document. If you wish not to go ahead with the modifications in the PUL, you can choose either to not apply modifications or to not save the file.

XQUpdatePUL01

To create a PUL for an active XML file, do the following:

 

1.In the toolbar of the XPath/XQuery output window (screenshot above), select either the XQU 1.0 or XQU 3.0 icon (respectively for XQuery Update 1.0 or XQuery Update 3.0).
2.Enter one or more update expressions in the top pane of the window. For a description of update expressions and their syntax, see the section, Update Operations and Syntax.
3.In the toolbar's scan-location combo box, select the location to be scanned for the updates:
Open files: All files that are currently open in XMLSpy will be scanned
Current file: Only the currently active file is scanned. If the location selected for scanning is Current file, then the the Evaluate XPath/XQuery Expression on Typing toolbar icon is enabled
Project: The currently active project is scanned
Folder: You can select a folder to scan
4.To execute the update expression/s and display the PUL, click the Evaluate XPath/XQuery Expression toolbar icon.

 

XPath/XQuery output window toolbar

The following XPath/XQuery output window toolbar commands (framed in red in the screenshot below) are available. They are, from left to right:

XQUpdateXPXQWinTbar

The Show Header toggle specifies whether to show the file name of update locations or not.
The Show Complete Result toggle specifies whether to show the entire node content or only attributes of the node.
The Set XPath/XQuery Origin, if selected, sets the cursor location in the active file as the origin of relative XPath expressions. The expression is evaluated relative to this node.
Instead of manually entering the locator path expression of a node, you can let XMLSpy enter it for you. Do this as follows: (i) Place the cursor at the point in the XPath expression where you want to enter the locator path; (ii) Place the cursor in the start tag of the node you want to target; (iii) Click the Copies the XPath of the Current Selection to the Edit Field icon XPWinCreateXPFromSelLoc to enter the locator path in the expression. The locator path will be entered as an absolute path starting at the root node of the document.
The Validate XML File toggles on/off XML file validation.
The Evaluate XPath/XQuery Expression on Typing command is enabled when the parse-option is Current File. If the command is toggled on, the PUL is generated even as the update expression is being entered.
The Evaluate XPath/XQuery Expression command evaluates the update expression/s and generates the PUL.
The Scan Location combo box option is described above.

 

The Pending Update List (PUL) pane

The PUL pane shows all the updates that will be carried out. If the Show Header option has been toggled on in the window's toolbar, the locations of target files are displayed. The PUL display is divided into three vertical sections (see screenshot below): (i) the update action to carry out; (ii) the content of the target node to be updated; (iii) the update action result.

XQUpdatePULTbar

The following PUL pane toolbar commands are available:

 

The Next and Previous icons select, respectively, the next and previous messages to the currently selected message.
The Copy Line/s commands copy, respectively, the selected line and all lines to the clipboard.
The Find commands find text in the PUL pane.
The Clear command deletes all lines in the PUL pane.
The Collapse Multiline Results command collapses multiline update list items to single lines.
The Apply Update(s) command applies the pending updates to the target locations. On updating, the updates can be saved to file, or the updated file can be displayed (and subsequently saved manually or not). See the next option.
The Update Files Directly combo box allows you to select (i) whether files are updated silently on disk, or (ii) whether updated files are opened and made active. If the latter option is selected, non-active target files are made active. You then have the choice of saving the modified document or not.

 

Note:If one or more files have been updated directly on disk, a list of changed files is displayed. each item in the list shows the location of the file and is a clickable link to the file.

 


© 2019 Altova GmbH