Debug Mode Expand/Collapse All Print this Topic Previous Page Up One Level Next page

Home >  User Guide and Reference > Interface and Environment > The Graphical User Interface (GUI) > Output Window: XPath/XQuery >

Debug Mode

The Debug Mode of the XPath/XQuery Window enables you to debug an XPath/XQuery expression in the context of the active file.




Switch to Debug Mode by clicking the Debug Mode button. Note that, in Evaluate Mode, the Debug Mode button is enabled only when the Where option is set to Current File. This is because debugging is carried out only in the context of the active file.
Debug Mode has two panes: (i) the pane in which the expression is entered, and (ii) the results pane. These panes can be divided from each other horizontally or vertically. To switch between these layouts, use the Horizontal/Vertical Layout button.
The Results pane has three tabs: Result, Variables, and Call Stack. When the height of the Results pane is not sufficient to display the names of the three tabs, the names are hidden and only the tabs' icons are displayed. Hovering over an icon displays the name of the tab.



Click to expand/collapseButtons in this section


Debug Mode

Switches between Debug and Evaluate Modes


Horizontal/Vertical Layout

Switches between horizontal and vertical layouts



Switches to the Result tab of the Results pane



Switches to the Variables tab of the Results pane


Call Stack

Switches to the Call Stack tab of the Results pane


Debugging steps

The broad steps for debugging an XPath/XQuery expression are as follows:


1.Make the XML file on which you wish to run the expression the active file.
2.Enter the XPath/XQuery expression in the expression pane.
3.Set any breakpoints or tracepoints you want. A breakpoint is a point at which the evaluation is paused. A tracepoint is a breakpoint at which the evaluation result of that node is recorded, thus providing a traceable path through the evaluation.
4.Start the Debugger, or use the Step Into/Out/Over functionality to go step-by-step through the evaluation.


These steps are described in more detail below.


Starting, stopping, and restarting the debugger

When the debugger is stopped, only the Start Debugger button is enabled. After the Debugger has been started and before it stops, the Stop Debugger and Restart Debugger buttons are enabled.


Click to expand/collapseButtons in this section


Start Debugger (Alt+F11)

Starts the debugger. The debugger evaluates the expression through to the end. It pauses only at breakpoints


Stop Debugger

Exits the evaluation, and stops the debugger


Restart Debugger

When the evaluation is paused (for example, at a breakpoint), restarts the evaluation from the beginning


Stepping in, out, and over evaluation steps

The Step functionality enables you to go step-by-step through the evaluation. Each click takes you through the corresponding step of the evaluation.


Click to expand/collapseButtons in this section


Step Into (F11)

Proceeds through the evaluation, one step at a time. This is a detailed stepping through the evaluation


Step Out (Shift+F11)

Steps out of the current evaluation step, and goes to the "parent" step


Step Over (Ctrl+F11)

Steps over "descendant" steps





As the evaluation progresses, the expression step that is currently being processed is highlighted in the expression and the corresponding result is displayed in the Result tab (see screenshot above). While Step Into provides the most detailed debugging by stopping at every step, Step Out and Step Over provide a quicker way to track the expression's evaluation.



Click to expand/collapseXQuery expression for trying the Step Into, Step Out, and Step Over functionality

declare function local:plus($a$b) {

            $a + $b



declare function local:loop() {

            for $i in 1 to 10

            return (local:plus($i$i+1), local:plus($i+1, $i+2))






Breakpoints and tracepoints

Breakpoints are points where you want the Debugger to stop after it has been started with Start Debugger. They are useful if you wish to analyze a specific part of the expression. When the Debugger stops at he breakpoint, you can check the result and could then use the Step Into functionality to display the results of the next steps of the evaluation. To set a breakpoint, place the cursor in the expression at the point where you want the breakpoint, and click the Insert/Remove Breakpoint (F9) toolbar button. The breakpoint will be marked with a dashed red overline (see screenshot below). To remove a breakpoint, select it and click Insert/Remove Breakpoint (F9).




Tracepoints are breakpoints at which the results are recorded and displayed in the Traces tree of the Result tab (see screenshot above). This enables you to see all the evaluation results of particular parts of the expression. For example, in the screenshot above, tracepoints have been set on $a, $b, local:plus($i, $i+1), and local:plus($i+1, $i+2); tracepoints are indicated by blue overlines. When the Debugger is at the expression part that is highlighted in the screenshot and when the value of $i is 1, then, in the Result tab, the values of the expression nodes at the tracepoints $a, $b, local:plus($i, $i+1) are displayed for this value of $i. To set a tracepoint, place the cursor in the expression at the point where you want the tracepoint, and click the Insert/Remove Tracepoint (Shift+F9) toolbar button. The tracepoint will be marked with a dashed blue overline (see screenshot below). To remove a tracepoint, select it and click Insert/Remove Tracepoint (F9).


If both a breakpoint and a tracepoint are set on a part of the expression, then the overline is composed of alternating red and blue dashes (see the local:plus($i, $i+1) and local:plus($i+1, $i+2) function-calls in the screenshot above).


Result tab of the Results pane

The Result tab (see screenshot above) contains icons that provide navigation, search, and copy functionality. These icons, starting from the left, are described in the table below. The corresponding commands are also available in the context menu of result list items.



What it does

Next, Previous

Selects, respectively, the next and previous item in the result list

Copy the selected text line to the clipboard

Copies the value column of the selected result item to the clipboard. To copy all columns, toggle on the Copying includes all columns command (see below)

Copy all messages to the clipboard

Copies the value column of all result items to the clipboard, including empty values. Each item is copied as a separate line

Copying includes all columns

Switches between copying (i) all columns, or (ii) only the value column. The column separator is a single space


Opens a Find dialog to search for any string, including special characters, in the result list

Find previous

Finds the previous occurrence of the term that was last entered in the Find dialog

Find next

Finds the next occurrence of the term that was last entered in the Find dialog


Clears the result list

Collapse multi-line results to a single line

If the value column of a result item contains multi-line text (text that includes newline character/s), you can toggle between a multi-line and single-line display


Variables and Call Stack

The Results pane contains, in addition to the main Result tab, a Variables tab and Call Stack tab (screenshots below).


During debugging, the Variables tab displays the variables of the current step and their values (see screenshot below).




The Call Stack tab displays the various processor calls up to that point in the debugging. The most recent calls are on top, and the current call is highlighted in both panes (see screenshot below).




© 2019 Altova GmbH