This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

FastXSLT Mediator

The FastXSLT Mediator is similar to the XSLT mediator, but it uses the Streaming XPath Parser and applies the XSLT transformation to the message stream instead of to the XML message payload. The result is a faster transformation, but you cannot specify the source, properties, features, or resources as you can with the XSLT mediator. Therefore, the FastXSLT mediator is intended to be used to gain performance in cases where the original message remains unmodified. Any pre-processing performed on the message payload will not be visible to the FastXSLT mediator, because the transformation logic is applied on the original message stream instead of the message payload. In cases where the message payload needs to be pre-processed, use the XSLT mediator instead of the FastXSLT mediator.

For example, if you are using the VFS transport to handle files, you might want to read the content of the file as a stream and directly send the content for XSLT transformation. If you need to pre-process the message payload, such as adding or removing properties, use the XSLT mediator instead.

In summary, following are the key differences between the XSLT and FastXSLT mediators:

XSLT MediatorFastXSLT Mediator

Performs XSLT transformations on the message payload.

Performs XSLT transformations on the message stream.

The message is built before processing. Therefore, you can pre-process the message payload before the XSLT transformation.The message is not built before processing. Therefore, any pre-processing on the message will not be reflected in the XSLT transformation.
The performance is slower than the FastXSLT mediator.The performance is faster than the XSLT mediator.

 

To enable the FastXSLT mediator, your XSLT script must include the following parameter in the XSL output.

omit-xml-declaration="yes"

For example:

 

<xsl:output method="xml" omit-xml-declaration="yes" encoding="UTF-8" indent="yes"/>

 

If you do not include this parameter in your XSLT when using the FastXSLT mediator, you will get the following error.
ERROR XSLTMediator Error creating XSLT transformer

The FastXSLT mediator is a conditionally content-aware mediator.



Syntax

<fastXSLT key="string"/>

 


UI Configuration

The parameters available to configure the FastXSLT mediator are as follows.

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 parameter.
  • Dynamic Key: If this is selected, the key can be entered dynamically in the Key parameter.
Key

This specifies the registry key to refer the XSLT to. This supports static and dynamic keys.

Tip

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. 


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


Example

<fastxslt xmlns="http://ws.apache.org/ns/synapse" key="transform/example.xslt"/>

In this example, the XSLT is specified by the key transform/example.xslt, which is used to transform the message stream.