Log out?

eiConsole Intermediate – Transformation / Data Mapping

eiConsole v.13.17R1
Tutorial & Interface

Using Variables

Overview

This interface and related tutorials demonstrate the use of the Data Mapper in Route configurations to transform between XML Formats. In this particular exercise, an existing Route (from “Data Mapping – Using Java Call-Outs“) is modified to transform a “PeopleA” XML format to the “PeopleG” XML format, which makes use of iteration, conditions, and variables to output “Neighbor” elements.

The tutorial covers the use of variables within the Data Mapper for storing and retrieving values within transformations. It expands on the concepts covered in “Data Mapping Using Java Call-Outs”, so users are expected to be familiar with that content.

How to Use This Example

Click the links below for the files you will need for this tutorial, then download the INTERFACE to get started. (Once logged into the eiConsole it immediately shows up in your “PIE” inbox for use.)

icon_sample-dataSample Data
icon_sample-dataSample Data
icon_downloadInterface Download

Note: if you are not logged in to the eiConsole, or have arrived at this page via a browser, you will be prompted to login before the interface downloads into your eiConsole “PIE” inbox. Or if you have not downloaded and installed a FREE eiConsole Trial you will have the opportunity to register after you click the Interface Download link. Once you are logged in the interface will automatically download into your “PIE” inbox. First, you’ll see a screen pop up indicating that a new product is ready for download. Select the Download Now button. Once you’ve downloaded the Interface you can drag it into your current Working Directory and begin.

Next, follow the tutorial and walk through it step-by-step. You may check your work against the provided Route (Sample Data).

Create and configure a new Route

Start by creating and configuring a new Route similar to the prior tutorial’s and create a new Format called “PeopleA XML to PeopleG XML” on the Target Transform stage:

using-variables-01-13-16-r3

Click “New” to open the Data Mapper and load “PeopleA.xml” for the Source and “PeopleG.xml” for the target:

using-variables-02-13-16-r3

Mapping Exercise

Repeat the mapping exercise from the previous tutorial or copy the resulting XSLT via the “XSLT View” tab:

using-variables-03-13-16-r3

Once again, a small change has been made to the Target format: the addition of the “Neighbors” element and its child “Neighbor” element. For each Person within the same State as any given Male or Female, we’ll put the concatenated First, Middle, and Last Names into a Neighbor element. Start by dragging “Neighbors” onto “Female” and “Male”:

using-variables-04-13-16-r3

Once the Neighbor element is added, it should look like this:

using-variables-05-13-16-r3

We’ll be using a “for-each” and “if” instruction to iterate over each Person once again, then conditionally place a Neighbor if the State matches. However, once we place the for-each, we’ll lose the context of the current Person it will be replaced by the Person we’re iterating over within the second for-each.

Create a variable

Create a variable by dragging XSLT Structures → Variable → variable onto the “Neighbors” element:

using-variables-06-13-16-r3

The created “variable” instruction has attributes for “name” and “select.” The “name” attribute defines the name of the variable to be referenced later. The “select” attribute is an expression which will be evaluated to be placed into the variable as its value.

media_1441907357237.png

We’ll set the name of our variable by double-clicking on the “name” attribute. We’ll be using “currentState” for our variable name:

using-variables-07-13-16-r3

Next we need to provide a value for our variable, which in this case will be the current Person’s State value. Drag-and-drop State from the Source onto the “select” attribute:

using-variables-08-13-16-r3

Our variable definition should now look like this:

media_1441907512253.png

Placing onto the Neighbors element

Next we’ll place our for-each onto the Neighbors element:

using-variables-09-13-16-r3

If we drag Person from the Source panel onto the for-each select, the Mapper will assume you’re wanting the current Person. We’ll need to manually modify the value by double-clicking it and changing it to read:

../Person

using-variables-10-12-15

Hit enter to save the value.

Next we’ll need to drag XSLT Structures → Flow Control → if onto the “for-each”:

Dragging onto the “for-each”

using-variables-10-13-16-r3

Double-click on the if “select” attribute and change it to read:

Address/State = $currentState

using-variables-11-13-16-r3

This will test to see if the current Person’s State matches the previously stored State. Now we’ll want to create a Neighbor element if the condition evaluates to true.

Creating a Neighbor Element

Drag Neighbor from the Target panel onto the if:

using-variables-12-13-16-r3

Next, repeat the concatenation from the “Data Mapping Using Functions” tutorial:

using-variables-13-13-16-r3

Finally, test the transformation:

using-variables-14-13-16-r3

If it matches the above, you are done. Congratulations. Move on to the next tutorial, Using Java Call-Outs.

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

Thanks!

Our editors are notified.

Close