Summary
Using the Trace mode in SketchPath its possible to either step through complex XPath expressions one location-step at a time, or select any part of an expression to instantly view it in context. Nested functions can be evaluated just by clicking on the function name within the expression.
This mode is particularly effective when debugging expressions with a large number of nested or chained predicates.
A further benefit of this mode is that, if a location path is selected in the expression, the element or attribute name can quickly be modified by simply selecting an alternative from the dynamically populated 'Source Nodes' list in the 'Assist Pane'.
Enhancements for XPath 2.0
The XPath Tracer has been completely rewritten so that, as well as supporting XPath 1.0, it also supports all the enhanced features of XPath 2.0 such as Range Variables (e.g. For $var in /abc return $var/def), and constructs such as /abc/concat(def, ' : ')
Starting XPath Trace Mode
To start the Trace mode, either double-click on the expression part to view, click 'Trace' on the expression toolbar or press <F10>. Once in Step mode, the current location step in the XPath expression is highlighted in yellow.
Navigating the expression
To move to different parts of the expression simply click the required part. To show the result of a predicate use the <left> and <right> cursor keys to select predicates adjacent to location paths.
Using the Track Bar control
The XPath Trace location can also be controlled through the 'Track Bar' control. Clicking this directly, or dragging the Track Bar pointer with the mouse provides an alternate method to navigate parts of the expression.
(Above) The expression toolbar
As a new part of an XPath expression is selected, the following happens:
The first node of any nodeset result is selected within all the active panes in SketchPath
The results pane is populated with the result list
The total number of hits is updated in the toolbar
The Element Tree node 'hits' are highlighted
The 'Selected XPath' display above the XPath Editor shows the sub-expression being evaluated
The 'Source Nodes' list is populated according to that context of the selected expression part
Modifying an expression in Trace Mode
Manual re-typing of the expression is inhibited whilst in Trace mode, however the Assist pane provides a powerful way of modifying location paths. Any axes, element or attribute selected in the expression can be modified by selecting an alternative from the 'Source Nodes' list in the Assist pane.
Finishing XPath Trace Mode
To quit Trace Mode, click the 'Trace' button on the expression toolbar or press <Escape> when the expression editor is selected.
