XPath Basics

This product uses XPath (XML Path Language) to specify and process elements of data schema. These data schema are either process variables or input schema for an activity. You can also use XPath to perform basic manipulation and comparison of strings, numbers, and boolean.

To use XPath in the product, you need to be familiar with the basic XPath concepts. However, to learn more about XPath when building complex expressions refer to the XPath specification from http://www.w3.org/

Addressing Schema Elements

All data source and activity input are represented as an XML schema. The data is represented as a schema tree regardless of where the data is derived from or its format. The data can either be simple (strings, numbers, boolean, and so on), or it can be a complex element. Complex elements are structures that contain other schema elements, either simple elements or other complex elements. Both simple and complex elements can also repeat. That is, they can be lists that store more than one element of the type specified.

XPath is used to specify which schema element you refer to. For example, the following schema might be available for an activity’s input.

Schema Elements in Data Source


The data source area of the example Input tab shows the output schema of the activities in the process. There are two output schema, each a root node in the data source area: Read-Shipping-Costs-file and Parse-Shipping-Costs-file. Each of these schema has its own associated structure, for example, Read-Shipping-Costs-file has a set of simple values and Parse-Shipping-Costs-file has simple data and other complex data.

To reference a particular data item in any of these schema, start with the root node and then use slashes (/) to indicate a path to the desired data element. For example, if you want to specify the region attribute in the destination complex element that is in the Parse-Shipping-Costs-file node, use the following syntax:

$Parse-Shipping-Costs-file/destination[<< Filter >>]/region

The path starts with a dollar ($) sign to indicate it begins with a root node and continues with node names using slashes, like a file or directory structure, until reaching the desired location name.

Namespaces

Some schema elements need to be prefixed with their namespace. The namespace is automatically added to elements that require this element when creating mappings on the Input tab of an activity or when dragging and dropping data in the XPath builder.

Search Predicates

An XPath expression can have a search predicate. The search predicate is used to locate a specific element in a repeating schema element. For example, the $Parse-Shipping-Costs-file/destination/region item is a repeating element. To select only the first item in the repeating element, specify the following:

$Parse-Shipping-Costs-file/destination[1]

The [1] specifies the first element of a repeating item. Sub-items can also be examined and used in a search predicate. For example, to select an element whose destinationID is equal to "3A54", specify the following:

$Parse-Shipping-Costs-file/destination["3A54"]

See the online documentation available in the XPath Builder for a list of the available operators and functions in PATH.

You can also use the Custom XPath Function Wizard to create your custom XPath function group. For more information, see Creating Custom XPath Functions in the TIBCO BusinessWorks™ Container Edition Bindings and Palettes Reference guide.