Defining an XPath conditional expression for a structural transform (ForEach)

Configure the Filter Inputs section in the Properties view of the ForEach transform to define the conditional expression that determines whether the transform is applied in a message map.

About this task

The ForEach transform can only have one primary input connection. Additional connections to the ForEach transform must be of type Supplement.

Procedure

Complete the following steps to define a conditional expression on a ForEach transform:

  • Select Allow empty input if you want the ForEach transform to execute at least one.

    If you select this option, the transformations that you define in the ForEach transform nested map will execute once regardless of the conditional expression.

  • Define the XPath expression that determines whether the ForEach transform is applied in the map.
    Note: Always use content assist to select the name of the input elements that you use to define the XPath expressions.

    The conditional expression applies to all the indexes that you configure in the Cardinality tab of the ForEach transform properties view.

Results

The input element is evaluated against the condition. If the condition evaluates to true, the transform is applied to the input element.

Example

This example shows how to define an XPath expression that checks the value of a string element:
  • The ForEach transform has a primary connection wired from the repeating element Address.
  • The ForEach transform has a secondary connection wired from the mandatory element BusinessUnit. This element can be set to nil. This element is not used to calculate the value of the output element.
  • The ForEach transform should only execute if the BusinessUnit element is not empty.

The XML schema for the mandatory element is the following:

<element name="BusinessUnit" type="string" nillable="true"></element>

The XML schema for the repeating element is the following:

<xsd:element form="qualified" name="Address" type="mqsistr:Address" maxOccurs="unbounded" minOccurs="0" />

This figure shows the transform with the primary and supplementary connections from the input elements.

The XPath expression that you define is the following:

$BusinessUnit != ''

What to do next

Deploy and test the message map. For more information, see Troubleshooting a message map.