Using XSL Template New

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:

  • Textual 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 Add Parameters icon from Parameters Panel and select XSL Template option.



  2. Manage XSL Template window will display.



  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 option. 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 option. 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 Parameters 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 Param to add the required parameters and click the Add Param icon again to insert a new row. This will add a row immediately next to the row which is currently selected.

     

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

     
  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 Save. The new XSL template is also displayed under Templates in the 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.