Saving Variables
In SketchPath, variables allow one to reuse the results of other XPath expressions within the current expression. An expression is saved by clicking the 'Run XPath' button after the current expression has already been evaluated. As a convienience, Double-Clicking on a specific part of the Element Tree view or the Nodes Pane will also save a corresponding variable.
Note: The XPath 1.0 standard itself does not provide for variables, instead this is implemented by the 'host' language such as XSLT. The SketchPath implementation actually substitutes in the expression in place of the variable name rather than a value or a 'result tree'. Because of this there are some subtle differences from the XSLT implementation. Care must also be taken to ensure that no circular variable references occur within an expression.
Groups
XPath expressions in SketchPath are arranged in groups. For convienience, each new expression is auto-assigned a name and a group, both the name and the group can be renamed when required, from the Expression Manager
Creating a new group

A new group for variables is created by clicking the 'New Group' button on the Variables Pane, a new group name is then generated. This name can be edited and then saved by clicking the 'Ok' button or pressing 'Enter' on the keyboard.
Why use groups?
Once you're managing a significant number of variables, grouping them together in named groups allows a related set of variables to be viewed and managed more effectively.
Changing the selected group
A variable group is selected from the dropdown list in the variables pane. Once a group is selected from the drop-down list it becomes the 'Current Group'. Only those variables in the Current Group wil be displayed. Importantly, the Current Group also controls the variables that may be used in an XPath expression, and therefore those that are shown in the 'IntelliList' when a variable name is expected in the context of the expression.
Viewing all variables
To provide a 'global' view of variables, select 'All Groups' from the drop-down list. All variables will then be displayed in the variables list and will be available for use in an XPath expression. Variable names only need to be unique within each group. If 'All Groups' is selected then any variables that are overriden due to non-unique names are displayed as 'greyed out'.
Note: Expressions that are de-selected as variables (by unchecking the $ Field in Expression Manager) are not shown in the Variables pane.
Fields shown in the Variables Pane
The Variables pane allows any combination of the Value, XPath or Comments for an expression to be displayed alongside the variable names by checking/unchecking these column items on the Column dropdown menu.
Checking the Variable [In Results Mode]
To quickly resolve the value/path of an XPath variable embedded in an expression, select the variable name in the list. The corresponding variable entry will be shown in the XPath variable pane, and if the XPath variable represents a nodeset, the first node in that nodeset will be selected in the raw XML Editor view and Element Tree, in all modes except Browser mode.
Browser Mode
In Browser mode, selecting a variable results in the XPath expression being re-inserted into the Expression Editor and the expression is re-evaluated against the source, as if it had been typed. This allows all nodes in the nodeset returned by the variable to be represented, as opposed to just the first node in the Results Mode'
Referencing a Variable within an XPath expression
To use a variable within an expression, use $variablename in the context where a value or variable is valid. The IntelliList can be used to insert a variable and is populated with available variable names once the '$' character is inserted.
Refreshing Cached Expression Result Values
An attempt is automatically made to refresh the cached values of all XPath expressions if a new XML source file is opened, or the 'Refresh' button on the toolbar is clicked.
This feature can be exploited to analyse a number of XML source files by running the same set of XPath expressions automatically against each file that is opened, and may be of particular use in combination with the XML Package feature.
The cached values are also refreshed whenever 'Reload Source XML' is selected.
Moving and Expanding the Variables Pane
To move and expand the Variables Pane, click the 'Grid View' tab, as shown in the Screenshot below. The 'orientation' can also be switched between horizontal and vertical by clicking on the Variables Pane bar.
