Altova XMLSpy 2024 Professional Edition

The Expression Builder (or Builder Mode) is switched on/off by clicking the Builder Mode icon of the main toolbar icSwitchToExpBuilder. (see screenshot below). The Expression Builder can be switched on in both modes (Evaluation Mode and Debugging Mode). It has two entry-helper panes: (i) for operators and expressions; and (ii) for functions (see screenshot below). The items in both panes can be shown either grouped hierarchically or as a flat list. Select the option you want in the dropdown list at the top right of each pane (see screenshot below). In the screenshot, both panes show their items in hierarchical groups.


Features of the Expression Builder:


To view a text description of an item in either entry-helper pane, hover over the item.

Each function is listed with its signature (that is, with its arguments, the datatypes of the arguments, and the datatype of the function's output).

If more than one signature exists for a single function name, each signature is listed as a separate function. (These variants are known as overloads of that function name.) In the screenshot above, for example, the contains function is shown twice: once for each of its two signatures.

Arguments are listed by their names (if any) or by their datatypes. Select the option you want from the dropdown list in the title bar of the Functions pane (circled in green in the screenshot above).

Double-clicking an item in any of the panes (operator, expression, or function), inserts that item at the cursor location in the expression. Functions are inserted with their arguments indicated by placeholders (# symbols).

If (i) text is selected in the expression's edit field, and (ii) an operator, expression or function that contains a placeholder is double-clicked to insert it, then the text that was selected is inserted instead of the placeholder. This is a quick way to insert long text (such as a path expression) into an operator, expression, or function.

You can insert the path to a node in the active document by selecting that node and then clicking the button Copy the XPath of the current selection of the window's main toolbar.



After you have entered a function in the expression, hovering over the function name in the Expression pane displays the function's signature and a text description of the function. If more than one signature exists for a function, these are indicated with an overload factor at the bottom of the display. If you place the cursor within the parentheses of the function and press Ctrl+Shift+Spacebar, you can view the signatures of the various overloads of that function name (see screenshot below).



Open and save XPath/XQuery snippets from/to file

You can save an XPath/XQuery expression, or longer snippets, that you have entered in the XPath/XQuery Window, together with the current settings of the window, to an XQuery file, and you can load XPath/XQuery snippets from an XQuery file. To carry out these two functions, click their respective icons (Save Snippet or Load Snippet), which are located in the window's toolbar.


After an XPath/XQuery snippet has been saved to file, it can be loaded into the XPath/XQuery Window of any XMLSpy instance (version 2022 and later). This is useful if you want to use the snippet on another machine, or pass it to another user, or even use it yourself later on the same machine. When the expression is loaded in the XPath/XQuery Window from an XQuery file, the settings of the window will automatically switch to the window settings that were saved to the file with the snippet.


Save snippet to file

To save an XPath/XQuery expression or snippet to a file, do the following:


1.Define the window settings: (i) the evaluation language; (ii) the Where field setting; and (iii) in the case of the Where field having been set to Project, whether external folders are to be skipped or not.

2.Enter the XPath/XQuery expression or snippet you want to save.

3.Click Save Snippet.

4.In the Save As dialog that appears, select the file, or enter the name of a new file, to which you want to save the snippet, and click Save.


The snippet will be saved to the file, with the window settings being saved as a comment in the first line of the file. Given below is the listing of a saved snippet file.


(: {"language":"XQuery3","where":"CurrentFile"} :)

for $i in //para[count(*)=0] return $i


Note:If you like, you can edit this file, including the comment line that contains the window settings.


Load snippet from file

To load an XPath/XQuery snippet from a file, do the following:


1.In the tab where you want to load the expression, click Load Snippet.

2.In the Open dialog that appears, browse for the XQuery file from which you want to load the snippet and click Open.


The snippet will be loaded and the settings of the XPath/XQuery Window will change to those defined in the XQuery file. If no settings are stored in the file, then the settings in the XPath/XQuery Window will not change. If the Where setting is incorrectly set, then the window setting will default to Current File.


© 2018-2024 Altova GmbH