Integration Engine Solutions to Connect Anything to Anything

Log out?

eiConsole v.24R1
Tutorial & Interface

eiConsole – Data Mapping & Transformation

Using Conditions

Note: The Quick Start, Foundation, and Topology tutorials should be completed before proceeding with the Data Mapping & Transformation Tutorials.


In this tutorial, we’ll cover using XSLT’s conditional statements to map Person elements to Male or Female elements based on Gender. This tutorial expands on concepts covered in Data Mapping – Using Iteration, so you are expected to be familiar with that material before proceeding with this tutorial.

Before You Begin

Zip File IconUsing Conditions
Working Directory

Download the file with the sample Working Directory and unzip it on your computer to a convenient place. In our case, it’s c:\Users\{USER _NAME}\PilotFish eiConsole Working Directories\Using Conditions where {USER_NAME} is the user’s name.

Open the eiConsole, browse to your Using Conditions directory and open it. The fully configured Data Mapping – Using Conditions route is included in the Working Directory. Your Route File Management screen will open, as shown below.

Next, use the tutorial and walk through it step-by-step. You may check your work against the Route sample data at the end.

Let’s begin. First, double-click on the Data Mapping – Using Conditions route.

Creating and Configuring a New Format

Start by creating and configuring a new Format. Name it PeopleA XML to PeopleC XML

Uncheck Use Direct Relay and click New to open the Data Mapper.

Then, using the XML Format Reader, read “PeopleA.xml” as the Source. You can find it in c:\Users\{USER _NAME}\PilotFish eiConsole Working Directories\Using Conditions\data. The “PeopleC.xml” is also here. Select XML from the Format Reader.

Click the Read Format button.

Then read the “PeopleC.xml” as the Target and select XML from the Format Reader.

Click the Read Format button.

Now your Data Mapper should look like below.

Begin by mapping People from the Source onto the stylesheet element and People from the Target onto People in the center:

Using XSLT Structures → Flow Control, drag a for-each instruction onto the People element from the Target in the panel, then drag Person from the Source onto its @select attribute:

If you review the Target format, you’ll see that instead of the Person elements from before, we now have Female and Male elements. The child elements of these are the same, but their names differ. We’ll want to conditionally create either a Male or a Female element based on a given Person’s Gender from the Source. There are various ways to do this, but we’ll use the most straightforward: XSLT’s choose/when/otherwise instructions.

Handling Conditions

XSLT has three ways of handling conditions: 1) the if instruction, 2) the choose when, and 3) the otherwise instructions, and predicates (“where” clauses on expressions). There is no else or else if in XSLT, so if is only useful for evaluating single expressions unless each subsequent expression has the added complication of testing its prior if instruction’s expression, as well. For this tutorial, we’ll use the choose method. First, drag choose from the XSLT Structures → Flow Control palette menu onto the for-each element:

This will create a choose element in the mapping with a single when element and an otherwise element:

A choose instruction can have one or more when elements; if you require more, simply drag the “when” palette item onto an existing “choose.” Our mapping only makes use of a single case. However, we’ll test if Gender is “Female” and use the “otherwise” to default to “Male.” Drag “Gender” from the Source onto the “when” instruction’s “@test” attribute:

This will establish the basis of our test expression. However, as-is, “@test” will have only the value of Gender for its expression, which isn’t a particularly useful test. We’ll need to modify it. Double-click on “@test” in the mapping to edit it:

You can use the ellipse “” button to open an XPath Expression Editor, but for this case, we’ll simply type our expression in. Modify it to read:

Gender = 'Female'

Then press enter to save the changes. Clicking elsewhere will revert the expression to its previous value:

Next, drag the “Female” element from the Target onto “when”:

Mapping the Elements

Map the Female element’s child elements, then map the Person element in the Source’s corresponding elements onto the Female element in the center:

Map “Male” from the Target onto “otherwise” and repeat the mapping exercise (Source to Mapping):

Testing the Mapping

Go to the Testing tab…

… and click the green arrow icon to begin testing.

You should end up with the males and females separated in the center panel. Click on the View Results button for more convenient checking results.

That’s it; you’re done. You’ve just learned how to use XSLT’s conditional statements!

This is a unique website which will require a more modern browser to work! Please upgrade today!