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:
...
- Click XSL Template option displayed next to mapping functions on the Mapping Functions Panel.
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
- 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.
Select the scope of the XSl Template. The default scope of an XSl Template is Local.
Info 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.
Info You cannot change the scope of a XSL Template once you have saved the XSL template. The respective radio buttons become non-editable thereafter.
- Click the Add button to add parameters for the new XSL template.
- 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
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 RulesInfo If you need to delete any row, select the respective row and click the Delete icon.
Info You can also define variables as the parameters of the XSL Template. To add a global variable, refer to the section Using Global Variable.
- 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 - 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).
...
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 XSL Rules
- On the Manage XSL Template screen, click the Mapping Rules tab.
- Enter the name of the new XSL template that you want to create in the Name field.
- Select the scope of the XSL Template. The default scope of the XSL template is Local.
- Click the Add icon to add parameters for the new XSL template.
- Enter the name of the parameter you want to add, in the Parameter Name field.
- 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.
Select the required Mapping Function. For example, select the mapping function, Math > Add (see Figure 515).
Figure 515: Manage XSL Template: Mapping Rules
The respective mapping function (add symbol for this example) is displayed in the Mapping template.
Figure 516: Mapping Template: Mapping Function Symbol
- Use the parameters that you have added in the previous steps.
Info If you need to delete any row, select the respective row and click the Delete icon.
- 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.
...