Page tree
Skip to end of metadata
Go to start of metadata

 

An XSL template is a customized template. If you need to repeatedly perform a set of functions, you can create an XSL template defining those functions, and then later call that XSL template whenever required. For example, if you need to perform addition of two numbers at regular intervals, you can define the addition function in an XSL template. You can then call this XSL template whenever required. 
The XSL Template option enables you to manage XSL templates. You can add, update or delete an XSL template using this option. Once you have added an XSL template, you can use it to map elements. You can also define the scope of an XSL template while creating and saving it. Scope of an XSL Template is the context within which it is defined. An XSL template can be defined in any of the following scope:

  • Local: The XSL Templates defined within Local scope are available within the mapping activity, in which you have created the template.
  • Global: The XSL Templates defined within Global scope are available within all the mapping activities. Once you create a global template in a mapping activity, you can use it in all the mapping activities.
  • Group: The XSL Templates defined within Group scope are available only within the specific group.

 

 Creating XSL Template


You can create a XSL template using:

  • Mapping Rules: Enables you to use the predefined mapping functions.
  • XSL Rules: Enables you to define the XSL Template code to use the defined parameters.

Steps to Create an XSL template using the XSL Rules

  1. Click XSL Template option displayed next to mapping functions on the Mapping Functions Panel.
  2. Select Manage XSL Template option or click the Manage XSL Template  icon in the toolbar (Figure 511).

    Figure 511: Data Mapper

    The Manage XSL Template screen is displayed (see Figure 512).

    Figure 512: Manage XSL Template

  3. Enter the name of the new XSL template that you want to create in the Name field. This displays the XSL tags in the XSL Template area.
  4. Select the scope of the XSl Template. The default scope of an XSl Template is Local.

    If you want to save the template as the Global Template, select the Global radio button. This will save the XSL template as Global XSL template and can be used in any mapping activity. In the Parameters panel, the XSL template will be displayed under the folder hierarchy Templates/Global.

    If you want to save the template within the current user group, select the Group radio button. This will save the XSL template as Group XSL template and can be used in any mapping activity within the current user group. In the Parameters panel, the XSL template will be displayed under the folder hierarchy Templates/Group.

    You cannot change the scope of a XSL Template once you have saved the XSL template. The respective radio buttons become non-editable thereafter.

  5. Click the Add  button to add parameters for the new XSL template.
  6. Enter the name of the parameter you want to add in the Name field. It also generates the corresponding XSL in the XSL Template editor on the Manage XSL Template screen
  7. Click the Add  icon again to add the required parameters or press the Enter key to insert a new row. This will add a row immediately next to the row which is currently selected (see Figure 513).


    Figure 513: Manage XSL Template: XSL Rules

    If you need to delete any row, select the respective row and click the Delete  icon.

    You can also define variables as the parameters of the XSL Template. To add a global variable, refer to the section Using Global Variable.

  8. Enter the code for the function that you want to perform, for example, addition of two numbers, in the 'add here' line, in the XSL Template field. The syntax of the addition function would be:
    <xsl:value-of select ="$param1 + $param2"/>

    where:
    value-of is the syntax for the value to be returned
    param1 and param 2 are the defined parameters
  9. Once you have entered the code, click Local XSL template. This displays the saved template under the Templates list on the XSL Template screen. The new XSL template is also displayed under Templates in the Parameters Panel (see Figure 514).


Figure 514: Parameters Panel

On saving the template, XSL validation is performed. If XSL is invalid, then an alert message is displayed specifying the line number and reason for error.

The name and parameters of the new XSL template are also displayed under the Templates list in the Parameters Panel. You can edit or delete an XSL template from the Parameters Panel itself. 

To delete the active XSL template, click the Delete Template button.

To exit the screen at any time without saving the XSL Template, click the Close  button.


Once you have created a XSL template, you can use it to map elements. On the Manage XSL Template screen, by default the XSL Rules tab is selected. To create a XSL template using the Mapping Rules, click the Mapping Rules tab. 
 

Steps to create an XSL template using the Mapping Rules

  1. On the Manage XSL Template screen, click the Mapping Rules tab.
  2. Enter the name of the new XSL template that you want to create in the Name field.
  3. Select the scope of the XSL Template. The default scope of the XSL template is Local.
  4. Click the Add  icon to add parameters for the new XSL template.
  5. Enter the name of the parameter you want to add, in the Parameter Name field.
  6. Click the Add  icon again to add the required parameters or press the Enter key to insert a new row. This will add a row immediately next to the row which is currently selected.
  7. Select the required Mapping Function. For example, select the mapping function, Math > Add (see Figure 515).

    Figure 515: Manage XSL Template: Mapping Rules

  8. The respective mapping function (add symbol for this example) is displayed in the Mapping template.

    Figure 516: Mapping Template: Mapping Function Symbol

  9. Use the parameters that you have added in the previous steps.

    If you need to delete any row, select the respective row and click the Delete  icon.


  10. Click the Save  button to save the Local XSL template. This displays the saved template under the Templates list on the XSL Template screen. The new XSL template is also displayed under Templates in the Parameters Panel.


Figure 517: Parameters Panel

The name and parameters of the new XSL template are also displayed under the Templates list in the Parameters Panel. You can edit or delete an XSL template from the Parameters Panel itself. For details, refer to the  Managing a Global Variable from Parameter Panel section.

 

 

Map Elements using XSL Template


Steps to map elements using an XSL Template

  1. Ensure that the source and target schemas are loaded and all their elements are listed under their respective nodes.
  2. Ensure that the source and target elements to be mapped are selected and displayed in the Mapping Graph Area.
  3. Click the XSL template that you want to use for performing the required function, from the Templates list in the Parameters Panel. A Call XSL Template node is displayed in the Mapping Graph Area (see Figure 518).

    Figure 518: Call XSL Template Node

  4. Create a link from the output of the first Source element to the first input of the Call XSL Template node.
  5. Create a link from the output of the second Source element to the second input of the Call XSL Template node.
  6. Create a link from the output of the Call XSL Template function node to input of the Target element node (see Figure 519).

    Figure 519: Create Links between Nodes for Mapping Elements using XSL Template

  7. Click Apply Mapping (  ) button. This maps elements using the Call XSL Template function node.
  • No labels