Example: Creating a Template Rule

As an example, let us create a template rule for an existing map, as shown below:

This example seeks to create a single template that processes the Address information in the source ShipTo and BillTo elements to create the Address in the ShippedTo and BilledTo elements in the target. The following steps illustrate the process:

  1. Right-click the Address node under the ShipTo or BillTo node in the source pane, and select New Template Rule from the context menu that appears.

    The New Template Rule dialog appears. The Match Node is pre-populated with the path to the Address node that you selected in the source pane. This match string is specific to the Address element under ShipTo, but we need to create a template that will process any Address field in the source document.

  2. Modify the Match Node string to contain only the name Address. This will match all Address nodes in the source document irrespective of where they appear in the document.

  3. Select the Select nodes to generate in template option. The target schema tree appears.

    When the template rule is invoked, we would like to create the Address element in the target, along with its children.

  4. Select the Address node under the ShippedTo or the BilledTo element, as both elements have identical structures.

  5. To select the children of the Address node, press and hold down the Shift key, and click the Zip element, which is the last child of the Address element. This selects the Address element and all its children.

  6. Click OK to create the template rule.

    As the rule is not yet invoked anywhere in the map, a warning icon appears against the template, and the nodes that the template creates have question mark (?) icons against them.