XPath Expression Evaluator

www.altova.com Expand/Collapse All Print this Topic Previous Page Up One Level Next page

Home >  User Reference > Edit XPath Expression Dialog >

XPath Expression Evaluator

Clicking the Evaluator button in the Edit XPath Expression dialog switches the dialog to Evaluator mode (see screenshot below). The dialog in this mode has two panes: the Evaluation Context pane and the Results pane.


Click to expand/collapse


The XPath expression and its evaluation

The XPath expression in the XPath Expression text box can be edited, and the expression can be evaluated. The results of the evaluation are displayed in the Results pane. In the screenshot above, for example, the result of evaluating the XPath expression count(newsitem) is displayed as the integer 4.


You can use the functions of the Java and .NET programming languages in the XPath expression. The Using Java and Using .NET buttons at the bottom of the dialog, pop up info boxes with explanations about how to use Java and .NET extension functions in XPath expressions. For more information about this, see the Extension Functions section of this documentation.


Using Builder mode and switching to Evaluator mode for the results

If you wish to use entry helpers to build the XPath expression, you can switch to Builder mode (by clicking the Builder button), build the expression in Builder mode, then switch to Evaluator mode to see the results of the evaluation.


When is the XPath expression evaluated?

Evaluation is carried out in two mutually exclusive situations:


Evaluate on typing: If this check box is selected, the XPath expression is evaluated: (i) with every keystroke used to edit the expression, and (ii) when the mode is switched from Builder mode to Evaluator mode.
Evaluate now: This button is enabled when the Evaluate on Typing option is not checked. Click it to evaluate the expression.


The Evaluation Context pane

The Evaluation Context pane shows the structure and contents of the currently assigned Working XML document. Nodes in the document tree can be expanded or collapsed by clicking the respective icons of individual nodes.


The icons above the pane display or hide the following XML syntactic constructs: (i) processing instructions, (ii) comments, (iii) attributes, (iv) text nodes. You can therefore see the entire XML document structure, together with the text contents of nodes, but you can also hide certain constructs if you wish to reduce clutter in the pane.


Changing the context node for evaluation purposes

You can change the context node of the XPath expression by clicking the node in the document tree that you want as the new context node. If the Evaluate on Typing option is checked, then the result will appear immediately in the Results pane.


This feature is useful for checking results with different context nodes. Note, however, that the actual context node for the expression will be the context node within which the current design component is being created. At runtime, the actual context node will be used, not the context node used in the Evaluator.


Remembering the selected context

If you check this option (located below the Evaluation Context pane) and close the dialog by clicking OK, the last selected context node will be remembered when the dialog is re-opened. If this option is not selected, then the context node in Evaluator mode will be the actual context node of the design component in the document.


This option is useful if you are in the process of testing an XPath expression and wish to save it with a specific context node till you complete your testing. Note, however, that at runtime, the actual context node will be used, not the context node saved in the Evaluator.




© 2019 Altova GmbH