This documentation is for WSO2 Enterprise Service Bus version 4.8.1 . View documentation for the latest release.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
maxLevel3
minLevel3
locationtop
styleborder:1
locationtop
typeflat
separatorpipe

...

Syntax

Code Block
XML
XML
<xslt key="string" [source="xpath"]>
     <property name="string" (value="literal" | expression="xpath")/>*
     <feature name="string" value="true| false" />*
     <resource location="string" key="string"/>*
</xslt>

 


...

UI Configuration

Parameter NameDescription
Key Type

You can select one of the following options.

  • Static Key: If this is selected, an existing key can be selected from the registry for the Key field.
  • Dynamic Key: If this is selected, the key can be entered inimically in the Key field.
KeyThis specifies the registry key to refer the XSLT to. This supports static and dynamic keys.
Source

This determines the element to which the given XSLT transformation should be applied via an XPath expression. If the source element is not specified, the XSLT transformation is applied to the first child of the SOAP body.

Info
titleTip

You can click NameSpaces to add namespaces if you are providing an expression. Then the Namespace Editor panel would appear where you can provide any number of namespace prefixes and URLs used in the XPath expression. 

Properties of the XSLT mediator

This section is used to inject properties set in the mediation flow to the XSLT script as XSLT parameters. These are referred from the XSLT in transformation using the get-property(prop-name)XPath extension function.

Parameters relating to the properties are as follows.

  • Property Name: The name of the property to be passed into the transformations.
  • Property Type: This specifies whether the property is given as a static value or an XPath expression. 
  • Value/Expression - This defines the static value or the XPath expression.
  • Action - This field allows the property to be removed from the XSLT script if required.
Features of the XSLT mediator

This section is used to specify features to be enabled/disabled in the XSLT transformation. For example, adding the http://ws.apache.org/ns/synapse/transform/feature/dom feature turns on DOM-based transformations instead of serializing elements into byte streams and/or temporary files. This approach can improve performance but might not work for all transformations.

Parameters relating to the features are as follows.

  • Feature Name: The name of the feature to be enabled/disabled in the XSLT transformation.
  • Feature Value: This specified whether the feature is enabled or not. Select True to enable the feature or False to disable it.
  • Action: This allows you to remove the feature from the XSLT transformation if required.
Resources of the XSLT mediator

This section is used to import external XSLT scripts to the main XSLT scripts defined in the XSLT mediator. The XSLT scripts to be imported are first added as resources in the registry.

Parameters relating to the resources are as follows.

  • Location: The location where the XSLT script to be imported is saved as a resource.
  • Key: The registry key to which the XSLT should be referred. Browse for the relevant key in the Configuration registry or the Governance registry.
  • Action: This allows you to remove the imported XSLT script added as a resource if required.
Info
titleNote

You can also configure the Mediator using XML. Click switch to source view in the Mediator window.

...

Code Block
languagexml
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:param name="PARAM_NAME"></xsl:param>
      <xsl:template match="/">
         <orders xmlns="http://services.samples">
            <xsl:attribute name="id">
               <xsl:value-of select="$PARAM_NAME">
            </xsl:value-of></xsl:attribute>
         </orders>
      </xsl:template>
</xsl:stylesheet>

 


Example 3 - Adding XSLT imports as resources

...

Code Block
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:template match="//people/person" name="FILL_PPL"> 
        <client> 
            <firstname> 
                <xsl:value-of select="firstname"> 
            </xsl:value-of></firstname> 
            <lastname> 
                <xsl:value-of select="lastname"> 
            </xsl:value-of></lastname> 
            <age> 
                <xsl:value-of select="age"> 
            </xsl:value-of></age> 
            <country> 
                <xsl:value-of select="country"> 
            </xsl:value-of></country> 
        </client> 
    </xsl:template> 
</xsl:stylesheet>

 

xslt2.xslt

Code Block
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:includeimport href="xslt1.xslt" />
     <xsl:template match="/">
         <clients>
             <xsl:for-each select="//people/person">
                 <xsl:call-template name="FILL_PPL">></xsl:call-template>
             </xsl:call-template></xsl:for-each>
         </clients>
     </xsl:template>

</xsl:include></xsl:stylesheet> 

<xsl:include href="xslt1.xslt"> element indicates that the xslt1.xslt is included in xslt2.xslt.

...