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:
- Connect the element Country in the
input message assembly object located under to the element Address in the
output message assembly object located under .
A Local
map transform is automatically created.
- Connect the Local map condition
to the output element Address.
- 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.
- Left-click the arrow located to the right of the Local
map transform.
The following figure shows
graphically how to select the If transform.
- Select the If transform located
within Core Transforms.
The following
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.
- 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:
- Select the If condition, and then
define the expression in the Condition tab
under the Transform - If properties. Complete
the following steps:
- Press Ctrl + spacebar to obtain
the list of elements.
The following figure shows the
elements available for selection in the scenario:
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.
- Select an element and double-click on it.
- Define the XPATH expression related to that variable.
- 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:
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.