Source Transformation / Data Mapping
You will need to download sample files to do this tutorial. If you have not done so yet, please click this LINK.
Note: The Tutorials in eiConsole Foundation, 1-13, are modular and are designed to be used in the sequence presented.
Next, the eiConsole’s Data Mapper opens. We’ll use the Data Mapper to define the logical mapping between the flat file source and the XML standard target. When you open the Data Mapper you will see 3 panels. The panel on the left will represent the logical structure of the source data. The panel on the right will represent the logical structure of the target data. The panel in the middle will be used to generate the logical mapping between the two.
To load in the Source format, choose the Open source format icon.
Select the Flat File and double click. This will allow you to leverage the file specification created in the File Spec Editor to populate the tree on the left-hand side of the screen.
Navigate to your Getting-Started-Project Working Directory.
Select the formats folder. Underneath that folder, you will find the FlatFileToXML folder.
Select the FlatFileToXML folder and double click to open. This contains the file specification that you created in the previous stage. Select FlatFileSpec.xml and click Open.
To expand the tree, double click on the Record node.
To do the same with the Target format, choose the Open Target format icon on the right.
Navigate to c:\Program Files\PilotFish Technology\Samples\data\ folder or the location of the sample folder of your distribution. Select it and double click to open. Next double click the data folder.
The tree on the right now represents the logical structure of the XML format that you would like to output.
Double click the nodes including Picture+, Photographer and LocationTaken to fully expand the tree. You’ll need the tree fully expanded to do your mapping.
You’ll now create the mapping between the two. To start this mapping, select the “Mapping” tab in the Data Mapper, then you’ll need to create the structural format of the output. To do this, you want to create one logical structure for each inbound Data Element, which is the root element of the XMLized flat data.
To begin, drag and drop the XCSData element (Source, left column) onto the stylesheet XSLT element (center panel). The blue XCSData element will now appear below the stylesheet element, as shown above.
Note: The red V that appears on your node, indicating a mapped element.
Note: You’ll want to drag and drop your element on top of the style sheet element so that you see the gray bar above it and then release. If you make a mistake, you can delete mapping elements by right-clicking and selecting “Delete” from the context menu.
Now you will have a number of records in the inbound file, each of which needs to be mapped to a picture element in the XML output. To handle this looping structure, use the XSLT palette (above the main mapping panel).
Select the Flow Control tab in the XSLT palette. Drag and drop the for-each element onto the PhotoAlbum element. You’ll now see the blue for-each element added to the mapping.
Note: The XSLT palette of structures and functions at the top allows you to do anything you can do by programming via the eiConsole’s drag & drop process.
Next, include 2 phone numbers for the Photographer: home and work. Drag and drop PhoneNumber onto Photographer twice. Notice that they appear at the end of your mapping.
Click the Record node, in the Source panel to expand the tree. The first information to map falls under Picture in the mapping (center panel). You will map Photo-Name to Title. Drag and drop Photo-Name from the source format (left panel) onto Title in the mapping. You will see the blue element appear underneath the green Title and blue Photo-Name elements.
There are 2 phone number elements to map: Home and Work. First you will need to scroll down to the bottom of the center panel to have access to the elements. Next, drag and drop the Home-Phone element from the source to the first PhoneNumber in the map and the Work-Phone element from the source to the second PhoneNumber in the map. Your mapping should now look like the above.
You have now mapped values from the source onto values from the target. There are several text constants that need to be added to clarify the meaning of various fields. For example, Title is unmapped. Scroll up in the center panel. Right click on Title and select Add Text Constant from the drop-down.
Now, scroll down to the PhoneNumber section of the mapping. You will see the type attribute, which is used to indicate the type of phone number that each PhoneNumber element represents. Double click the first PhoneNumber type attribute. In the Value text-box enter
'H' to represent Home (use caps and make sure you use single quotes) and hit enter/return.
When the Save File dialogue opens enter “PhotoAlbumFlatXMLToStandardXML” and click OK.
Now you are ready to move on to the next step. The Route Stage. Next, click the Return to Console icon at the very top.