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.


Top of page

x
The XPath Specification

Designer uses XPath in conjunction with iWay Service Manager.

Important: All iWay functions are available in 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:

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.


Top of page

x
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:


Top of page

x
Procedure: How to Use XPATH Builder

To use XPATH Builder:

  1. Select XPATH Builder from the Tools menu, or from the properties of a process object.

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

  2. Click Load XML File 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 Open 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. An example of a loaded XML file appears in the following image.

  4. Click Next.

    The Build an XPath dialog box opens, as shown in the following image. The XPath field will display the items you choose as you build the statement. The elements and attributes of the XML document you loaded appear in the left pane. These are the items you will use to build the XPath statement. The right pane displays the selected element, and attribute value and occurrence in the document.

  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 field. The following image is an example of this dialog box with batch selected in the left pane and the related expression appearing in the XPath field. The values and occurrences of this element appear in the right pane.

  6. Continue to add the elements and attributes needed to build the statement.
  7. When the XPath statement is complete, click Next.

    The Select Methods dialog box opens. This dialog box provides two tabs, Methods and Operators. The following image shows the Select Methods dialog box, which displays the methods that you can add to your statement.

    Important: All iWay functions are available for use. For example,

    _SUBSTR _SUBSTR(XPATH(/SWIFTMT543/_543/A/_20C/REFERENCE__), 1, 8)

    would return the middle 8 characters of a 10-character XPath result from a SWIFT message. For more information on iWay functions, see the iWay Service Manager User’s Guide.

    The following image shows the Select Methods dialog box with the Operators tab selected. This dialog box, shown in the following image, displays a list of operators that you can add to your statement.

  8. To add methods and operators to the XPath statement, double click the item you want to add.
  9. Click Next.

    The XPath Validation dialog box opens, as shown in the following image. This dialog box displays the XPath statement in a field named XPath.

  10. Click Validate to validate the XPath statement on the server.

    The results appear in the Validation pane beneath the XPath statement, as shown in the following image. The results that appear in this pane are from the server.

  11. Click Finish.

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


iWay Software