Altova StyleVision 2024 Professional Edition

When the Builder button in the Edit XPath Expression dialog is clicked (see screenshot below), entry helper panes to help you build an XPath expression become visible. Double-click an entry in any of these entry helpers to enter it at the current cursor point in the XPath expression.

Click to expand/collapse

There are three entry helper panes:


A schema tree for entering element and attribute nodes in the XPath expression. If the Relative XPath check box is checked, then the location path to the selected node is entered relative to the context node (the node in the design within which the XPath expression is being built). The context node is shown below the schema tree pane. An absolute XPath expression starts at the document root, and is used for the selected node if the Relative XPath check box is unchecked.

An entry helper pane for operators and expressions. These include: (i) axes (ancestor::, parent::, etc), (ii) operators (for example eq and div), and (iii) expressions (for # in  # return #, etc). The items of the pane can be either listed alphabetically or grouped by functional category. Select the option you want by choosing Hierarchical or Flat from the dropdown menu in the title bar of the pane.

An entry helper with the functions of the active XPath version either listed alphabetically or grouped by functional category. Select the option you want by choosing Hierarchical or Flat from the dropdown menu in the title bar of the pane. The Names/Types option enables you to choose whether the arguments of functions are displayed as names or datatypes.


Features of the Builder


To view a text description of an item in either 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).

Signatures are listed using either the names or datatypes of the function's arguments and output. Select Names or Types from the dropdown menu in the title bar of the pane.

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 (the # symbol).

If (i) text is selected in the XPath expression's edit field, and (ii) an 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.


After you have entered a function in the expression, hovering over the function name displays the function's signature and a text description of the function. If different signatures exist for a function having the same name, 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.  


Building XPath expressions

The Edit XPath Expression dialog helps you to build XPath expressions in the following ways.


Context node and schema tree

The Selection text box in the Sources pane immediately shows you the context node. The expression will be inserted at a location within this context node, and it will be evaluated with this node as its context.


Inserting a node from the schema tree

In the Sources pane, the entire schema is displayed. Double-click a node in the schema tree to insert it in the XPath expression. If the Relative XPath check box is checked, the selected node will be inserted with a location path expression that is relative to the context node.


Namespace information

The schema tree in the Sources pane contains a Namespace item. Expanding this item displays all the namespaces declared in the stylesheet. This information can be useful for checking the prefixes of a namespace you might want to use in an XPath expression.


Inserting XPath axes, operators and expressions

The Select Operator/Expression pane lists the XPath axes (ancestor::, parent::, etc) , operators (for example, eq and div), and expressions (for # in  # return #, etc) for the XPath version selected as the XSLT version for the SPS. The display can be toggled between an alphabetical listing and a hierarchical listing (which groups the items according to functionality). To insert an axis, operator, or axis in the XPath expression, double-click the required item.


Inserting XPath functions

The Select Function pane lists XPath functions alphabetically or grouped according to functionality (click the respective icon at the top of the pane to switch between the two arrangements). Each function is listed with its signature. If a function has more than one signature, that function is listed as many times as the number of signatures. Arguments in a signature are separated by commas, and each argument can have an occurrence indicator (? indicates a sequence of zero or one items of the specified type; * indicates a sequence of zero or more items of the specified type). The arguments can be displayed as names or as datatypes; select Names or Types in the title bar of the pane.Each function also specifies the return type of that function. For example: => date ? indicates that the expected return datatype is a sequence of none or one date item. Placing the mouse over a function displays a brief description of the function. To insert a function in the XPath expression, double-click the required function.


Java and .NET extension functions can be used in XPath expressions, enabling you to access the functions of these programming languages. The Java and .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.


Intelligent editing during direct text entry

If you type an expression directly in the Expression text box, options that are available at that point are displayed in a popup (see screenshot below).




These include elements, XPath functions, and XPath axes. Go up and down the list of options using the Up and Down keys, and press Enter if you wish to select an option and enter it in the expression.


The Otherwise check box

The Otherwise toggle (see the red arrow in the screenshot below) adds an Otherwise branch to a conditional template as its last branch. Only one Otherwise branch may be present in a conditional template. When a conditional template is evaluated, the first branch to evaluate to true is executed. If no branch evaluates to true, then, the Otherwise branch is executed if present, otherwise the conditional template is exited without any of its branches being executed. Since the Otherwise branch is triggered only in the event that no preceding branch evaluates to true, it does not need to have a condition defined for it. As a result, when the Otherwise check box is selected, the entry field of the XPath expression is disabled.


Click to expand/collapse


For details of how to use the Otherwise condition, see Conditional Templates.


© 2018-2024 Altova GmbH