Log out?

Exercise 5.9 – Templates

Purpose:

To practice building an XSLT mapping in the Data Mapper using XSLT templates.



Steps:

  1. Create a Route
    1. From the eiConsole File Management screen, select the “Add Route” button.
    2. In the dialog that appears, enter the name “Templates” and select “OK”.
    3. The Route should now appear in the table on the screen. Double click it to open it.


  2. Document Source System
    1. Select the “Source System” stage in the “Route Editing Grid”. The configuration panel will appear at the bottom.
    2. Change the “System Name” to “People XML File”
    3. Select the “Choose Source Icon” button, and scroll down to select one of the XML icons


  3. Configure the Listener
    1. Select the “Listener” stage in the “Route Editing Grid”. The configuration panel will appear at the bottom.
    2. Select “Directory / File” from the “Listener Type” selection box. Optionally, click the “…” button to open the Module Search Dialog, which provides a faster way to find the module you’re looking for.
    3. Assign a polling directory, using the “…” button to open the file chooser. The polling directory should NOT be the directory with all the sample files, since files will be moved/deleted by the listening process.


  4. Add Source Format and Open Data Mapper
    1. Select the “Source Transform” stage in the “Route Editing Grid”. The configuration panel will appear at the bottom.
    2. Click the “Add Format” button. In the dialog that appears, name the format “Templates”, and click “OK”. The transformation configuration panel will appear below.
    3. On the right hand side, in the XSLT “To XML” configuration panel, uncheck the “Use Direct Relay” button. The options in that panel will now be enabled.
    4. Click the “New” button beneath the checkbox to open the “Data Mapper”.


  5. Load Source and Target Formats
    1. Use the “Open Source Format” button above the “Source Format” panel to open the “Select Format” dialog. Choose “XML” from the “Format Reader” selection box.
    2. Click the “Add” button, and in the File Chooser navigate to where the the sample files are located. Choose the file called “people.xml”. Click “OK”, and then click “Read Format”.
    3. Use the “Open Target Format” button above the “Target Format” panel to re-open the dialog. From the “XML Format Reader”, re-open the File Chooser and select the file called “robot.xml” (NOT the plural “robots.xml”). Click “OK”, and then click “Read Format”.
    4. The source and target format panels should now be populated.


  6. Add Identity Template
    1. In the top extension panel, type “Identity Template” into the “Filter by Pattern” box. The “Identity Template” Node should appear.
    2. Drag the “Identity Template” node from the top panel onto the center mapping, and drop it onto the “Stylesheet” node.


  7. Add Named Template
    1. In the top extension panel, type “Named Template” into the “Filter by Pattern” box. The “Named Template” node should appear.
    2. Drag the “Named Template” node from the top panel onto the center mapping, and drop it onto the “Stylesheet” node. It should appear below the “Identity Template” in the center panel.
    3. Double click on the “template[@name:?]” node that has just been populated in the center mapping panel. A text field shold appear. Type “GenerateRobot” into it. Press enter to save the changes. The node should now be renamed to say “GenerateRobot”.
    4. Drag the root “Robot” node from the target format on the right onto the center mapping panel, and drop it onto the “GenerateRobot” node.
    5. Drag the “Type” node, a child of “Robot”, from the target format on the right onto the center mapping panel, and drop it onto the “Robot” node.
    6. Right click on the “Type” node in the center mapping panel. Select “Add Text Constant” from the popup menu. Enter “Generated Robot” into the dialog box that appears, and click “OK”.


  8. Add Regular Template
    1. In the top extension panel, type “Template” into the “Filter by Pattern” box. The “Template” node should appear.
    2. Drag the “Template” node from the top panel onto the center mapping, and drop it onto the “Stylesheet” node. It should appear below the “Identity Template” in the center panel.
    3. Double click on the “template[@match:?]” node that has just been populated in the center mapping panel. A text field should appear. Type “/People/Person” into it. Press enter to save changes. The node’s name should now have changed to be “/People/Person”.
    4. In the top extension panel, type “Call Template” into the “Filter by Pattern” box. The “Call Template” node should appear.
    5. Drag the “Call Template” node from the top panel onto the center mapping, and drop it onto the “/People/Person” node.
    6. A dialog box should appear, called “Choose named template”. The “GenerateRobot” template should be in the list in the dialog. Select it, and click “OK”.
    7. The “Call Template” node should now be on the center panel, below the “/People/Person” node, and it should have the name “GenerateRobot” on it.


  9. Save Mapping
    1. Now that the mapping is complete, select the button with a floppy disk icon from the top toolbar to save changes. When prompted for a name, use the default, “transform”.
    2. Click the “X” button in the top right corner to close the “Data Mapper” and return to the “Route Editing Grid”.


  10. Configure the Transport
    1. Select the “Transport” stage in the “Route Editing Grid”. The configuration panel will appear at the bottom.
    2. Select “Directory / File” from the “Transport Type” selection box. Optionally, click the “…” button to open the Module Search Dialog, which provides a faster way to find the module you’re looking for.
    3. Select the “Target Directory”, using the “…” button to open the file chooser.
    4. Set “robots-output” as the “Target File Name”.
    5. Set “xml” as the “Target File Extension”.


  11. Document the Target System
    1. Select the “Target System” stage in the “Route Editing Grid”. The configuration panel will appear at the bottom.
    2. Change the “System Name” to “People-Robot XML File”
    3. Select the “Choose Target Icon” button, and scroll down to select one of the XML icons


  12. Prepare to Test
    1. In the menu bar at the top, select “Route” -> “Testing Mode”. Make sure the changes to the Route are saved.
    2. Copy the file called “people.xml” from the “Samples” directory provided into the directory chosen as the polling directory.


  13. Perform the Test
    1. At the top of the “Testing Mode” screen, select the “Execute Test” button.
    2. If the “Route” was configured successfully, all the Stages should light up with green checkmarks.
    3. In the OS File Explorer, open the directory selected as the “Target Directory”. The file “robots-output.xml” should be there, with the transformed contents produced by the XSLT.
    4. The XML file should have a root node called “People”, and a series of “Robot” Nodes. Each “Robot” node should have one child node, called “Type”, that simply says “Generated Robot”.


  14. Output Files
    1. Compare the results from the exercise with the following example output files to see if they are correct.
      1. robots-output.xml


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

Thanks!

Our editors are notified.

Close