Tutorial & Interface
Using Identity Transforms
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 Templates”) is modified to transform a “PeopleA” XML format to the “PeopleH” XML format using an “identity transform.” Identity transforms allow users to make discrete changes to a document without remapping it in its entirety. This tutorial expands on concepts from “Data Mapping Using Templates,” 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.)
|Sample File 1||Sample File 2||Interface 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 import the selected components.
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. Load “PeopleA.xml” as the Source format and “PeopleH.xml” as the Target format:
Our Source and Target formats are very similar in this case. The only difference is that the Target format’s “Vehicle” element is condensed into a single tag, which is a concatenation of Make and Model. In previous tutorials, we handled such mappings by completely mapping the Source and Target formats along with all of their elements. However, there’s a concept in XSLT called an “identity transform”, which is a template that matches and copies all elements, attributes, and text recursively, as-is. Any templates added in addition to this template are the “exceptions to the rule”; their elements are handled according to those added templates.
Start by dragging Custom → Uncategorized → “Identity Template” onto the “stylesheet” element:
This template’s expression matches all attributes (@), all child elements (*), and all Nodes (node()). The “|” part of the expression is a “join” between the two halves (@* and node()).
The “copy” element under the template copies the current Node, while the “apply-templates” and expression underneath recursively evaluate all child nodes of the current node.
If you were to run the transform now, you would see that the result document is identical to the source document; the identity transform creates a perfect copy.
Making Changes to the Mapping
To make changes to the mapping, we need only create templates for the elements we wish to alter. To change the handling of Vehicle, drag it from the Source onto the stylesheet:
If you were to run the transform now, you would see that the result document is identical except that the “Vehicle” elements are all missing; we’ve given “Vehicle” special handling, but have not created a new Vehicle element in its stead. Drag “Vehicle” from the Target format onto the “Vehicle” template:
Our mapping will now create a copy of the document with an empty Vehicle element. We are copying all nodes which are not Vehicle.
Concatenating our Make and Model
Now we just need to concatenate our Make and Model. Drag the “concat” function from the tool palette onto the Vehicle element and modify the expression to combine the Make and Model (separated by a space, of course):
If we now execute our transform, we should see only the Vehicle element altered:
Identity transforms are an extremely useful tool in transformation. They allow you to make discrete, tactical modifications to a document without needlessly replicating mapping. In the eiConsole, they are most frequently used on the Target Transform stage to “tweak” a previously transformed document so that it conforms to minor changes required by a particular target system.
This concludes this tutorial. Move on to the next Tutorial “Using Keys for De-Duplication”.