Nav

XSLT Transformer Reference

Overview

You can use the XSLT Transformer to transform XML data using XSLT.

A XSLT transformer, unless configured otherwise, transforms XML data based on the default XSL template file.

General Tab

Use the General tab to specify the return class, encoding, MIME type, and XSL transformation file.

For the XSL template file, you can browse to this file or enter the full path to the file.

XSLTGeneral

Advanced Tab

Use the Advanced tab to optionally configure additional properties.

XSLTAdvanced

Transformer Pool: You can set Max Idle and Max Active values for the transformers pool. Because XSL transformation is expensive, and because Mule pools transformers for better throughput, you may want to set limits on the transformer pool when using XSLT transformers. Use Max Idle to set the maximum number of transformer instances that remain idle in the pool. Use Max Active to set the maximum number of XSLT transformers that are pooled at any given time. The default value for Max Idle is 2 and the default value for Max Active is 5.

URI Resolver: Change how the XSL output is validated. If not set, Mule uses a default resolver that checks for resources on the local file system and classpath.

Transformer Factory: If set, this is the fully qualified class name of the javax.xml.TransformerFactory instance to use. If not specified, Mule uses the default JDK factory TransformerFactory.newInstance().

Content Properties: Click the green plus icon plus to add a key. This example shows the title and rating for a CD music listing service, which is listed in the code example in the next section.

Code Example

xslt-transformer-ref-flow

The following code example shows using XSLT to process music CD listings.


         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
        xmlns:spring="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http
http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/xml
http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd">
    <http:listener-config name="HTTP_Listener_Configuration" host="localhost"
    port="8081" doc:name="HTTP Listener Configuration"/>
    <flow name="xsltFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
        <mulexml:xslt-transformer name="xslt" xslFile="./conf/xsl/cd-listing.xsl">
            <mulexml:context-property key="title" value="#[header:ListTitle]"/>
            <mulexml:context-property key="rating" value="#[header:ListRating]"/>
        </mulexml:xslt-transformer>
    </flow>
</mule>