eiConsole v.18R2
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.)
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
Click “New” to open the Data Mapper and load “PeopleA.xml” for the Source and “PeopleG.xml” for the target:
Mapping Exercise
Repeat the mapping exercise from the previous tutorial or copy the resulting XSLT via the “XSLT View” tab:
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”:
Once the Neighbor element is added, it should look like this:
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:
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:
Our variable definition should now look like this:
Placing onto the Neighbors element
Next we’ll place our for-each onto the Neighbors element:
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
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”
Double-click on the if “test” attribute and change it to read:
Address/State = $currentState
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: