Adding User XSLT
eMapper also allows the user to customize the output of the transformation by adding custom xslt code to the generated XSLT. XSLT code snippets can be added before and after the beginning tag<> of an element and before and after the end tag </> of an element in the XSLT. By enabling this, eMapper allows further refinement on the auto-generated output.
As an example, consider a case where the eMapper generates an output that contains elements not required by the user. In this example, the eMapper generates an output which contains elements that is not mapped. The mapping has an output structure in which the parent element is not mapped but the child elements are mapped, Fiorano eMapper does not generate the if conditions around this unmapped parent element as a result of which this element is generated in the output.
To avoid the generation of unmapped elements in the output, there should be an if condition around <unmapped> element in XSLT whose condition is OR of both the child nodes' if conditions.
Under such conditions, the User XSL feature can be used to customize the output and avoid the generation of unmapped tags.
To provide a user defined XSL, perform the following actions:
- Right-click the <unmapped element> in the output structure and select the User XSL option from the shortcut menu as shown in Figure 1.
Figure 1: Selecting the User XSL option from the context menu
- A dialog box appears which contains the xslt script. The xslt script displayed in this dialog box is partially editable. The editable regions, are marked by comments <!--User code starts here-->_ and _<!--User code ends here--> at the beginning and ending respectively.
Figure 2: Editing the user xslXSL snippets can be added in the following four places:
- just above <element>
- just below <element>
- just above </element>
- just below </element>
- Add the required if code snippet in these regions.
Click the OK button and the User XSL is saved for the element. It is denoted by the icon next to the element/node in the structure.
Figure 3: Node with User XSL defined
- The XSL can be tested it using Test option as described in the Testing the Transformation section.
It is advised that the users add any namespace prefixes used in defining the User-xsl to the Namespace Prefixes table in the XSLT Properties dialog (Refer Managing XSLT Properties section) to avoid issues due to changing namespace prefixes in Input/Output structures.