Skip to main content Skip to complementary content

Talend ESB Transformation Policy

The Transformation policy allows to apply XSLT transformation to message payloads. The implementation is based on CXF interceptors.

Policy

To enable the Transformation via the Service Registry, upload the following Transformation policy to the Service Registry and attach it to a service:

<wsp:Policy Name="wspolicy_xslt" xmlns:wsp="http://www.w3.org/ns/ws-policy">
            <wsp:ExactlyOne>
            <wsp:All>
            <tpa:Transformation xmlns:tpa="http://types.talend.com/policy/assertion/1.0"
            path="etc/responseTransformation.xsl"
            appliesTo="provider"
            message="response"
            type="xslt"/>
            </wsp:All>
            </wsp:ExactlyOne>
            </wsp:Policy>
  • The type parameter only supports the xslt value. The "xslt" activates the XSLT transformation using a xslt script. For more information about the XSLT feature of Apache CXF, see http://cxf.apache.org/docs/xslt-feature.html.

  • The appliesTo parameter supports following values: consumer/provider/always/none.

  • The message parameter currently supports following values: request/response/all/none.

XSLT path settings

The path attribute can also be specified through the context properties:

"org.talend.esb.transformation.xslt-path"

If the context properties are specified, they overwrite the corresponding policy attributes.

The path attribute can contain:

  • HTTP URL's (for example: http://example.org/xsl/requestTransformation.xsl),

  • Path to an XSL file, relative to the Talend Runtime Container(for example: etc/requestTransformation.xsl ) or an absolute path,

  • Classpath path to the XSL file.

Dependencies

When running a participant in servlet-container or as a standalone application, the following dependency should be used in the participant's pom.xml file:

pom.xml for servlet-based or standalone participants

<dependency>
            <groupId>org.talend.esb.policies</groupId>
            <artifactId>transformation-policy</artifactId>
            <version>${project.version}</version>
            </dependency>

When running a participant in the Talend Runtime Container, in the Require-Bundle section of Felix bundle plugin, the transformation-policy bundle should be mentioned:

OSGi environment pom.xml

<plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <configuration>
            <instructions>
            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
            <Require-Bundle>
            ...
            transformation-policy
            </Require-Bundle>
            </instructions>
            </configuration>
            <extensions>true</extensions>
            </plugin>

XSLT examples

Here is an example of XSLT identity transformation that transforms a document to itself (which means, no transformation is performed):

<?xml version="1.0" encoding="utf-8"?>
            <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
            
            <xsl:template match="node()|@*">
            <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
            </xsl:copy>
            </xsl:template>
            </xsl:stylesheet>

Here is an example of template which changes a message value to another value:

<?xml version="1.0" encoding="utf-8"?>
            <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
            
            <xsl:template match="node()|@*">
            <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
            </xsl:copy>
            </xsl:template>
            
            <xsl:template match="LastName/text()[.='Icebear']">Panda</xsl:template> 
            
            </xsl:stylesheet>

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!