eiConsole v.23R1
Tutorial & Interface
Using Functions
Overview
This tutorial will cover the use of XPath and XSLT functions in the Data Mapper to perform name concatenation for the Target format. This tutorial expands on concepts covered in “Data Mapping Using Conditions,” so users are expected to be familiar with that material.
How to Use This Example
Download the INTERFACE file and save it to your local disk.
Open the eiConsole, click on the File drop-down menu and select Import Working Directory/Route/Format. Highlight the name of the file to import and press the Import Selected button. The imported Interface will appear in your current Working Directory.
Next, follow the tutorial and walk through it step-by-step. Finally, you may check your work against the provided Route (Sample Data).
Creating and Configuring a Route
Begin by creating and configuring a Route as in the previous tutorial. Add a new Format named “PeopleA XML to PeopleD XML,” select it on the Target Transform stage, and uncheck “Use Direct Relay”:
Click “New” to open the Data Mapper. Load “PeopleA.xml” for the Source format and “PeopleD.xml” for the Target format:
Repeat the mapping exercise from the previous tutorial, with the exception of leaving the various “name” elements unmapped:
Mapping Name Values
Map “FullName” from the Target onto the “Female” and “Male” elements in the center:
We’ll map the First, Middle, and Last name values onto FullName, but we also want them to be separated with spaces. While we can do this using additional XSLT instructions, we can also make use of one of the many functions provided by XPath. Under XPath Functions → String, drag “concat(string, string+)” onto “FullName”:
After dropping the Concat Node onto the mapping, a dialog box will pop up asking you how many concat elements you wish to add. Select the number 3 and click OK.
This will create an XSLT instruction called “value-of” and populate it with a “concat” function call. “concat” accepts any number of arguments and concatenates their literal values together. The Data Mapper will create a “concat” entry in the mapping panel with the number of child elements you selected in the previous dialog. You can drag-and-drop values onto these children to concatenate their values together.
We’ll start by mapping “First” under “Name” onto the first element in the “concat” function:
Next, repeat this process for the “Middle” node under “Name”, dragging it onto the second “Value” element in the “Concat” function. Of course, we could do the same thing for “Last” as well, but drag & drop is not the only way to fill in this function. We can also do it manually.
To manually add a value, double-click on the last “Value” element in the “Concat” function. A text field will open in the node. Enter “Name/Last” in the text field, and don’t forget to hit enter when you’re done.
Now your “Concat” mapping should look like the next screenshot below, with First, Middle, and Last name mapped to it. There’s just one thing missing, though: there are no spaces between the words. If we executed the transformation now, the value assigned to “FullName” would be “FirstMiddleLast”, which is all a part of one word. We obviously don’t want that, but how do we add the spaces? We’ve filled up all three elements in the function.
Fortunately, there is another way to modify the function manually.
Adding more Parameters Manually
Double-click on the concat() “select” attribute to open its text box. In it, you see the raw XSLT code of the function: “concat(Name/First,Name/Middle,Name/Last)”. We need to add spaces between each word; to do this, add an additional element in between each word with the text’ ‘. When you are done, it should read:”concat(Name/First,' ', Name/Middle, ' ', Name/Last)
”
Don’t forget to press enter, and your function should now look like the screenshot below.
XSLT and XPath provide numerous other functions, all of which are available in the tool palette at the top of the Data Mapper screen. Test the mapping and you should see the following for output:
Congratulations! You’ve learned how to use XPath and XSLT functions in the Data Mapper. Next, move on to Using Tabular Mappings for more advanced training.