Skip to main content
Skip table of contents

Message Body XPath selector

Contents

 

Defining XPath

XML Messages passing through a route can be selected based on XPath. To define the XPath, select the route and click the Edit button in the Message Body XPath section in the Selectors property tab.


Figure 1: Opening Message Body XPath editor

This will launch an editor showing a list of namespaces and their prefixes. Add/Edit namespace prefixes from the table displayed here.


Figure 2: Dialog box showing namespace prefixes and the XPath launcher

Clicking the small button

 under XPath section launches an XPath editor. It displays the message body structure on the left and a canvas to build XPath on the right (see the figure above).

XPath Editor

XPath Editor can be used for specifying path expressions to identify nodes in an XML document and for specifying conditions. The list of elements from the schema provided are shown in the left panel of the editor. An element can be selected by dragging it to the right panel.


Figure 3: Xpath Editor with a sample schema

An XPath expression may consist of different constant values, functions or/and operators. These can be added by right clicking on the right panel and selecting the option required.


Figure 4: Adding a constant in the XPath Editor

Adding a Function

A function can be added by one of the following ways:

  • Right-click in the right side panel and select the Add Function option.
  • Select from the list available in the Palette tab present at the bottom of the left panel.


    Figure 5: Palette containing different XPath functions on the left and a sample XPath expression on the right

As per the connections made in the above figure, the string function: 'matches' takes two arguments and returns a boolean value.

Adding a Constant value

The types of constants are String, Boolean, Numeric, Date-Time, and Duration.

To add a boolean value, perform the actions below:

  1. Right-click in the right panel, go to Add Constant and select the Boolean Value.
  2. Select the desired boolean value (true/false) from the drop-down menu as shown in the figure below.


    Figure 6: Adding a boolean constant

Adding a Operator

To add an operator, perform the actions below:

  1. Right-click in the right panel and select Add Operator.
  2. Select the desired operator  from the drop-down menu as shown in the figure below.


    Figure 7: Adding an operator
Sample XPath using Add Operator

If an Add (+) operator is added and then two numeric constants to feed values (to pass arguments) to the operator, the Xpath expression looks similar to the figure displayed below.


Figure 8: Sample Xpath expression

Message Body XPath Selector 

After adding the constant values, functions or/and operators as required, click OK in the XPath editor; a new selector will be added to the route. The result of the XPath expression in Figure 5 is shown in the figure below.


Figure 9: Message Body XPath Selector as seen in the Properties panel for the route (result of XPath expression in Figure 5)

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.