Configuring the If condition in an If, Else if, and Else transform

You can use an If, Else if, and Else transform to control the flow of the data mapping between elements defined as a specific or a derived type in the input and output message assembly by setting conditions. To configure the If condition, you must connect an input element to an output element and select the core transform If.

Procedure

Complete the following steps to create and configure the If condition of an If, Else if, and Else transform:

  1. Connect the element Country in the input message assembly object located under SOAP_Domain_Msg > Body > SaveAddress > Person > Address to the element Address in the output message assembly object located under SOAP_Domain_Msg > Body > SaveAddress > Person.

    A Local map transform is automatically created.

  2. Connect the Local map condition to the output element Address.
  3. Change the Local map transform to an If transform by selecting the arrow facing down that is located on the right hand side of the Local map transform.
    1. Left-click the arrow located to the right of the Local map transform.

      The following figure shows graphically how to select the If transform.

      This figure shows the Local map transform with the arrow surrounded by a red circle.

    2. Select the If transform located within Core Transforms.

      The following figure shows graphically the list of core transforms available:

      This figure shows graphically the list of core transforms available.

      You get an If condition with a red exclamation mark connected to two input elements and one output element.

      Note: You will resolve these errors by completing the scenario

      The red exclamation mark on the left hand side of the If condition highlights multiple validation problems. One of the errors indicates that the If condition does not contain an expression. The second error informs you that you must define transformations for all the elements within the nested map associated with the If condition. This nested map is the map that you use to define how an address with a derived type CanadianAddress is mapped to the base address type Address.

      This figure shows the message map after you connect the address that has the CanadianAddress as its derived type to the If transform.

  4. Connect the address that has the CanadianAddress as its derived type to the If transform.

    The following figure shows the message map after you create the connection:

    This figure shows the message map with the element Country and the element Address of type CanadianAddress to an If condition, and a connection from the condition to the Address output element.

  5. Select the If condition, and then define the expression in the Condition tab under the Transform - If properties. Complete the following steps:
    1. Press Ctrl + spacebar to obtain the list of elements.

      The following figure shows the elements available for selection in the scenario:

      This figure shows the list of elements that area available when you press Ctrl+spacebar.

      Note: Although you can enter the XPATH expression directly, beware that depending on the steps you take to create your integration solution, the variable names that are generated are different from the element name in the schema file. The element name has an ID concatenated at the end of the name that is defined automatically by the tool.
    2. Select an element and double-click on it.
    3. Define the XPATH expression related to that variable.
    4. Repeat the following steps if your XPATH expression includes more than one input element.

    The condition is an XPath 2.0 expression, that you can define directly, or you can create through the XPath expression builder by clicking Edit.

    In the scenario, if you authored the message flow yourself, the expression will be similar but not exactly like $Country4 = 'Canada'.

    The following figure shows the properties tab for the If transform:

    This figure shows the properties tab for the If transform, and the XPath expression to set the condition.

Results

You now have defined and configured the If condition.

What to do next

Define the Else If condition of the If transform. For more information, see Configuring the Else If condition in an If, Else if, and Else transform.