Mappings can be created within an ESB project in the Transformations folder. There are two options available for this purpose:
via the Project > Add XSL Stylesheet menu
via the New > XSL Stylesheet context menu
To create an XSL mapping
Right-click on the Transformations folder within the ESB project to open the context menu.
In the context menu, select New > XSL Stylesheet. A list of available templates will be displayed.
Select an empty or an already available template.
Enter a file name in File Name.
Select Finish to create the XSL mapping. The XSL mapping has been created and will be opened in the Mapping Editor.
Defining the source and target structure in the XSL mapping
In the first step, you define the source data structure of the transformation. That is, you fill the left pane (=source document pane) of the XSL mapping with source data.
In the Design view, there are several options:
Insert the XML source document (XML document or XML schema) from the Projects view via drag-and-drop into the Mapping Editor's source document pane. Alternatively, you can right-click in the source document pane of the XSL mapping and select Assign Input to choose a file to insert. All projects from the Projects view are available for selection.
The namespace xmlns:xs="http://www.w3.org/2001/XMLSchema" and xmlns:xs="http://www.w3.org/2001/XMLSchema" attribute allow the use of data types in conjunction with XPath 2.0. Both entries are only included in newly created XSL stylesheets that are not based on a template.
Right-click in the source document pane of the XSL mapping and select Paste Input to paste the content from the clipboard. Example: When debugging a process, you can copy the data from the Output view to the clipboard and paste it in the XSL mapping, or you can copy XML data from an editor and paste it in the mapping.
a. For using the XML output of an adapter operation, drag and drop an adapter that is used in a process in the source document pane of the XSL mapping. b. For using the input of an adapter operation, drag and drop an adapter that is used in a process in the stylesheet pane of the XSL mapping.
If several adapter operations are available, a dialog window opens for selection of the operation:
Select an adapter operation and click OK.
The XML source document will be displayed in a tree view.
In the next step, you create the basic structure of the target document in the XSL mapping. To do this, proceed as follows:
In the stylesheet pane, right-click on the root template ( template match="/") to open the context menu.
In the context menu, select XSL Element to open the XSL Element Creation Wizard.
Insert all required elements in the correct hierarchy. Example: The structure of the target document is an HTML skeleton (<html>, <body>) that contains a table (<table>) with a row (<tr>) having three header cells (<th>) and another row (<tr>) having three data cells (<td>).
If you already know the XML structure to be generated by the XSL mapping, you can assign an XML document or XML schema from the Projects view to the stylesheet pane via drag-and-drop. This structure can be used as target structure for your mapping.
When assigning an XML structure via drag-and-drop, a dialog will come up to ask how it shall be inserted:
Full XML structure including data inserts the complete XML document structure, including its element values and attribute values.
Virtual nodes (structure without data) inserts only the tree structure as virtual nodes into the stylesheet pane. The virtual nodes are created in the target structure only when double-clicking them or by defining a data mapping.
If you want to add text, select Add Other Nodes > Text from the context menu. Example: Insert a column label text into the table header cell elements.
Using data mapping: for-each
Use <xsl:for-each> to generate a target structure that repeats for each data row:
In the source document, select the node structure. Hold down the Shift key, and assign the structure via drag-and-drop to the target element to be repeated. A for-each element will be created. Example: Assign <Dataset> to the second <tr> element in order to generate HTML table rows dynamically.
Ensure that the for-each element is an immediate parent node of the second <tr> element.
Using data mapping: value-of
Use <xsl:value-of> to assign node contents from the source document to the target document:
Click the source node and connect it with the target node via drag-and-drop. Example: Connect the <CustomerName> element with the first <td> element, the <CompanyName> element with the second <td> element, and the <Address> element with the third <td> element.
Drag further mapping lines. For each data mapping, a line will be displayed.
Using data mapping: copy-of
Use <xsl:copy-of> to copy a node including all child nodes (elements, attributes, namespace definitions, etc.):
In the source document, select the node to be copied.
Hold down the Ctrl key and assign the node via drag-and-drop to the target node.
A copy-of element will be created.
Source view: Using XSLT functions
Example
You want to merge the contents of the ContactName and ContactTitle elements using the concat function.
Click the Source tab to display the XSL mapping in the source view.
Edit the XSLT syntax. Example: Replace the line <xsl:value-of select="ContactName"></xsl:value-of> by <xsl:value-of select="concat(ContactName, ', ',ContactTitle)"/>.
Changing the Output Format
In element <xsl:output>, modify the output format in attribute method="xml". Example: To generate an HTML 4.0 document, set method="html".
In element <xsl:output>, modify the output document's MIME type defined in attribute media-type="text/xml". Example: To generate an HTML 4.0 document, set mime-type="text/html".
Testing the XSL Mapping
If an input file is available, you can use the Mapping Editor's integrated preview function.
Save the mapping viaCtrl+S.
In the toolbar, click to test the XSL mapping locally. The transformation result is displayed in the Output view.
Using XSL Mappings in Technical Processes
Drag the XSL mapping file from the Projects viewinto an opened technical process via drag-and-drop. Example: Insert it between the XML document and the Stop component.
If necessary, define parameters within the property Component Parameters. These will be passed to the XSL mapping during the process execution, see Parameterizing Process Components.
JavaScript errors detected
Please note, these errors can depend on your browser setup.
If this problem persists, please contact our support.