Log out?

eiConsole Intermediate – Transformation / Data Mapping

eiConsole v.13.17R1
Tutorial & Interface

Creating a Simple Mapping

Overview

In this tutorial, we’ll cover using the Data Mapper to create XSLT to map between one format of XML and another. This tutorial expands on the concepts covered in “Using Transformers,” so users are expected to be familiar with that material.

Synopsis

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 “Training – Creating a Simple Route”) is modified to transform a “PeopleA” XML format to a “PeopleB” XML format.

Core Concepts:

  • Routes
  • Formats
  • Transformers
  • Directory / File Listener
  • Directory / File Transport
  • eiConsole Testing Mode
  • XSLT Transformer
  • Data Mapper
  • Format Readers
  • XML Format Reader

How to Use This Example

Click the links below for the files you will need for this tutorial, then DOWNLOAD 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

If you are not logged in to the eiConsole, you will be prompted to login before the interface downloads into your eiConsole “PIE” inbox.If you have not downloaded and installed a FREE eiConsole 90-Day Trial you will have the opportunity to register via a simple process after you click DOWNLOAD INTERFACE. Once you are logged in the interface will automatically download into your “PIE” inbox.

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

Creating a new Route and configuring a Directory/File Listener / Transport pair.

creating-simple-mapping-01-13-16-r3

You can configure XSLT at either the Source or Target Transform. The reasons for choosing one or the other are usually due to topographical concerns. For this tutorial, it does not matter which we use, so we’ll just arbitrarily choose the Target Transform.

Select this stage and add a new Format. We’ll call this PeopleA XML to PeopleB XML:

creating-simple-mapping-02-13-16-r3

To use XSLT, uncheck the Use Direct Relay option:

creating-simple-mapping-03-13-16-r1

You now have a variety of options available to you. You can type in the name of an existing XSLT file, browse to one, edit a selected one, specify if you wish to cache the XSLT, enable 2.0 support, and even select which XSLT engine to use. Using the defaults for these options is more than sufficient for most transformations regardless of complexity.

Editing a new Mapping

As we have no existing XSLT document to edit, simply clicking the New button with no document selected will open the Data Mapper to edit a new mapping:

creating-simple-mapping-04-13-16-r1

This will open the Data Mapper:

creating-simple-mapping-05-13-16-r3

The Data Mapper makes use of three main panels. On the left side of the screen is a tree representing the Source format. The right side of the screen is a tree representing the Target format. The middle panel represents the mapping logic, also organized into a tree. At the bottom-center of the screen are tabs for switching between Mapping, XSLT, and Testing modes.

Loading in the Source and Target formats

The first thing you’ll typically do when creating a new mapping is to load in the Source and Target formats you’ll be working with. To do this for each panel, click the Open Source Format button at the top. We’ll start by loading the Source format:

creating-simple-mapping-06-12-15

This will raise a dialog allowing you to pick from a list of Format Readers. Format Readers are components that generate a format structure from some source, be it an XML file, schema file, File Specification, database, etc. For this tutorial, we’ll use the XML, which allows us to use an XML sample file to infer a structure from:

creating-simple-mapping-07-13-16-r3

Next, we’ll need to add our sample file. Click Add and browse to PeopleA.xml, which should have been provided with this tutorial:

creating-simple-mapping-08-13-16-r3

Next, click Read Format. You’ll be asked if you want to use the sample file loaded for testing. Select Yes. You should now have a Source panel that resembles this:

creating-simple-mapping-08(2)-12-15

Reading our Target format

We’ll now wish to read our Target format. Select the same button on the Target panel at the right side of the screen, select the XML again. You should see the previous sample listed; click Remove to remove it. Click Add and this time, browse to PeopleB.xml:

creating-simple-mapping-09-13-16-r3

Click Read Format, select Yes, and then review the Target format panel:

creating-simple-mapping-09(2)-12-15

For this mapping, there’s not a significant difference between the two formats except for one detail: the Source format has a “People” root element, and the “Person” elements underneath it repeat. Our Target has only the one Person. We’ll simply be directly mapping the first Person in the Source to the only Person in the Target.

Constructing the Mapping

The first thing to do in constructing the mapping itself is to provide a “template” match. This is some element from the Source which we’ll match against and take some set of actions against. Select the “People” element from the Source and drag-and-drop it onto the “stylesheet” element in the center:

creating-simple-mapping-11-13-16-r3

This will create a “People” template in the center:

creating-simple-mapping-12-12-15

Creating a Person from the Target

In XSLT, this is creating an instruction called a “template” with an attribute called “match” containing the XPath expression for the People element in the Source. It effectively means, “when I encounter some People element, run these instructions.” The action we want to take is to create a Person from the Target; effectively, we want to say, “When I encounter some People element, I want to create a single Person element.” To do this, drag “Person” from the Target format onto “People” in the center:

creating-simple-mapping-12a-13-16-r3

If we were to test this mapping against our Source sample, we’d get an XML output with only a “Person” element. We’ll now want to create the various elements shown in the Target format. Drag-and-drop each onto the “Person” in the center. Note that child elements will need to be dragged onto the respective parents. For example, “First” should be dragged onto “Name” instead of onto “Person”:

creating-simple-mapping-13-13-16-r3

The center mapping should look exactly like this:

creating-simple-mapping-15-12-15

Providing Values

If we were to run this transformation now, we’d get a single Person element with lots of empty child elements. What we need to do now is to provide each of these with values. To populate the “@id” attribute, drag the corresponding “@id” attribute from the Source format onto it:

creating-simple-mapping-16-13-16-r3

Continue this for each of the values. Note that you will not drag “Name” onto the center “Name” – only it’s child elements (so “First” onto “First”). When you’re finished, it should look something like this:

 creating-simple-mapping-17-12-15

We have two other sections to investigate now. First, click the XSLT View tab at the bottom of the screen:

creating-simple-mapping-18-12-15

This will change the mapping panel to show the underlying XSLT:

creating-simple-mapping-19-13-16-r3

Making changes directly to the XSLT view

You can make changes directly to the XSLT view and they will show up in the Mapping (GUI) view. This particular editor features auto-completion, auto-formatting, and a few other useful features for doing manual editing. Next, click the “Testing” tab:

creating-simple-mapping-20-12-15

This will open the Testing mode for the Data Mapper:

creating-simple-mapping-21-12-15

This is made up of three panels. The first is the Source sample which, if you used the XML Format Builder, should already have our “PeopleA.xml” file loaded for testing. The second panel is the “Results” panel, which shows the results of the transformation. Finally, the “Output” panel shows any messages from the XSLT engine, such as errors or warnings.

Executing the Transformation

To execute the transformation, click the “Execute Transformation” button:

creating-simple-mapping-22-12-15
The “Results” panel will change to show the results of the transformation:
creating-simple-mapping-23-12-15

We’ve now completed our basic mapping. Save the mapping using the “Save” button or menu item (we’ll name ours “Simple Mapping”) and close the Data Mapper to return to the eiConsole.

Reviewing the before and after

From the eiConsole, switch to the Testing Mode, execute a test and review the before-and-after. Our before:

creating-simple-mapping-24-12-15

And our resulting “after”:

creating-simple-mapping-25-13-16-r2

As you can see, performing mappings is simply a matter of dragging and dropping between the Source and Target formats. Use the “Using Iteration” tutorial, to review the complexity and functionality a bit through iteration.

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

Thanks!

Our editors are notified.

Close