Creating XPath expressions
Many message flow nodes provide properties that can be specified using an XPath 1.0 expression, for example properties to set data locations for Monitoring or Security where this language is used to form a path expression to locate incoming message body elements. The Mapping node supports XPath 2.0 functions and expressions.
About this task
Other less common node property fields support the entry of general XPath 1.0 expressions that support a wider range of the language to perform more complex evaluations in the integration node's XPath 1.0 runtime engine.
The XPath Expression builder provides a tree view of a message, and supports the automatic generation of an XPath 1.0 path expression, through the selection of an element within the tree.
The Schema Viewer section provides a tree view of the input message. To visually build your XPath expression follow these steps:
Procedure
- Add the relevant node to your message flow
- In the Properties viewer, enter the correlation name, or
press Ctrl + Space to use content assist, or press Edit to use the
Expression editor. Content assist is also invoked by simply typing
$
in cell-based property fields. See Correlation names for further information on correlation names. - Expand the tree, navigate to the field for which you want
to build an expression, and click to select it. A field is either an element, or an attribute.Double-click the field to add it to the XPath expression. You can also drag fields, functions, and operators to the desired location in the XPath expression when using the XPath Expression builder.
- To set conditions, enter them as you would a normal XPath Expression.
Results
- In the XPath Expression pane if you are using the XPath Expression
builder.
The Expression builder dialog is an optional aid for generating expressions that, when complete, form the value in a node's property field.
If you do not use the Expression builder dialog, the expressions entered manually are validated using the property editor.
- In the Property field if it is in the node itself.
Example
$Root/XMLNSC/getEmployeeInfo/Emp[isManager=true()]
.$Root/XMLNSC/
: The body section of the message; that is, the last child of root. This example assumes that the XMLNSC domain is being used./getEmployeeInfo
: The name of the operation in the interface./Emp
: The name of the input message type.[isManager=true()]
: Checks whether theisManager
field is set to true.
For more information on XPath 1.0, see W3C XPath 1.0 Specification.