Using an existing XSL style sheet

You can use an existing XSL style sheet to perform your transformation if you want to reuse a transformation, or if you have a complex transformation that's easier to write as an XSL style sheet.

Note: When you use an existing XSL style sheet, you will need to manage the style sheet yourself. If you refactor your XSL Transformation primitive, or an XML map, you will need to manually update the XSL style sheet.
Avoid editing an XSL style sheet that was generated from an XML map, because if you change the XML map in the XML mapping editor, the XSL style sheet will be automatically generated, and your changes will be lost. If you want to customize a generated stylesheet, you must delete the following line in the generated XSL to prevent the code from being overwritten:
<!-- generated xmxFile="..." md5sum="..." -->

Follow these steps to use an existing XSL style sheet, and optionally edit it.

  1. The style sheet must exist in the mediation module's project directory before you can select it. Switch to the Physical Resources view and create or copy the XSL style sheet into the mediation module project.
  2. In the mediation flow editor, select the XSL Transformation primitive, and click the Details page in the Properties view. Click the Browse button. All the available XSL style sheets (xsl), and XML maps (xmx) are listed in the Mapping File Selection dialog. OK.
  3. Select the style sheet. XSL style sheet icon
  4. Select the XSL mapping root. This is the part of the message that is available to the transformation, both the input and output messages. Select an option in the list:
    • / to transform the complete message.
    • /body to transform the message body
    • /headers to transform the message headers
    • /context to transform the message context

    Note: When you select /, /headers or /context as the root, you need to explicitly map all the message sections in the XML Mapping editor using the Match Mapping menu option. Otherwise, you may get errors at runtime. See the example below for more information.

  5. The XSL style sheet now appears in the Mapping file field. To make changes to this file, click Edit to launch the XSL Editor.

Example:

The picture below shows the mapping between the source and target message for the TransformToDelayed primitive in the XML Mapping editor. The root property was set to /, so the complete message is displayed in the editor. The input message operation getQuote has a parameter named request that takes a business object that has an attribute whose name is symbol. The output message operation has a parameter symbol of type String. The mapping shown is between the symbol attribute of the input message to the symbol of the output message.


Picture of TransformToDelayed primitive in the XML Mapping editor

Since the root was set to /, all the message sections in the mapping editor must be explicitly mapped. Click on the top level element (smo) of the source and target, right-click, and select Match Mapping, as shown in the picture below:

Picture of match mapping in the XML Mapping editor

For more information, see Rational® Application Developer topic Mapping between XML files

Related concepts
XML mapping tips

Feedback
(C) Copyright IBM Corporation 2005, 2006. All Rights Reserved.