Using Variables and XPath

In this section:

Using XPath in Designer

In this section:

How to:

XPath is a language that is mainly used to address parts of an XML document based on a path through the logical structure or hierarchy of the document. In Designer, XPath defines the path to the value or values in an XML document to use for a property or parameter. In Designer, XPath always starts from the root of the document.

Note: The XPath syntax used in Designer is based on a subset of the XPATH 1.0 specification, found at http://www.w3.org/TR/xpath.html.

The default axis is "child". Currently, this is the only axis available in Designer.

The XPath Specification

iIT Designer uses XPath in conjunction with iWay Service Manager.

Important: All iWay functions are available in iIT Designer. and can be used in conjunction with XPath statements. For more information on iWay functions, see the iWay Service Manager User’s Guide.

XPath populates values with data from Service Manager in one of three ways:

  • Decision node switch: Designer routes a document based on the value received from XPath.
  • Decision node test: Creates a True/False test against an XPath statement.
  • Configuration parameter: The value of the parameter is the value of the XPath.

The following are examples of location path parameters that use abbreviated syntax taken from section 2.5 of the XPath specification. This specification is found at http://www.w3.org/TR/xpath.html#path-abbrev.

para

Selects the para element children of the current position.

*

Selects all element children of the current position.

text()

Selects all text node children of the current position.

@name

Selects the name attribute of the current position.

para[1]

Selects the first para child of the current position.

para[last()]

Selects the last para child of the current position.

*/para

Selects all para grandchildren of the context node.

/root//para

Selects the para element descendants of the root element.

//user

Selects all the user descendants of the document root.

//olist/item

Selects all the item elements that have an olist parent.

.

Selects the current position.

.//para

Selects the para element descendants of the current position.

..

Selects the parent of the current position.

../@lang

Selects the lang attribute of the parent of the current position.

para[@type="warning"]

Selects all para children of the context node that have a type attribute with value warning.

para[@type="warning"][5]

Selects the fifth para child of the current position that has a type attribute with value warning.

para[5][@type="warning"]

Selects the fifth para child of the context node if that child has a type attribute with value warning.

chapter[title="Introduction"]

Selects the chapter children of the current position that have one or more title children with string-value equal to Introduction.

chapter[title]

Selects the chapter children of the current position that have one or more title children.

Building XPath Statements

Designer provides the XPath Builder tool as an easy method to construct XPath statements that can then be used in object definitions. This section explains how to build XPath statements with XPATH Builder.

The Designer XPATH Builder tool guides you through the process of creating an XPath statement. The major steps are:

  • Load an instance of an XML file.
  • Select the related elements and attributes that will make up the XPath statement.
  • If needed, add methods and operators.
  • Validate the XPath statement against a test document.
  • Approve to set the service XPath.

Procedure: How to Use XPATH Builder

To use XPATH Builder:

  1. Click the Launch XPATH Builder button on the ribbon toolbar menu.

    The XPATH Builder - Load a document instance dialog box opens, as shown in the following image.

  2. Click Load... to load a sample XML document that will be used in the process flow. From this document, you can browse the schema and build an XPath.

    The Select an XML file dialog box appears.

  3. Browse to the XML document you want to load and click Open.

    The XML file appears in the display pane of XPATH Builder.

  4. Click Next.

    The Build an XPath dialog box opens, as shown in the following image. Double click the element, attribute or attribute value you wish include in the statement.

  5. Expand the schema elements located in the left pane. These elements and attributes are those found in the XML document that you loaded earlier. Double-click the item you want to add to the XPath statement.

    The item appears in the XPath Expression field. The following image is an example of this dialog box with count selected in the center pane and the related expression appearing in the XPath Expression field. The values and occurrences of this element appear in the Description pane, in the bottom of the dialog box.

  6. Continue to add the elements and attributes needed to build the statement.
  7. Click Execute to validate the XPath statement on the server.

    The results appear on the top of the XPath builder dialog box.

  8. Click Finish.

The XPath statement is now available from the various object parameter selections.


iWay Software