2. Enterprise Integration Patterns

transform

Version

Applies an XSLT stylesheet to the body of a request or response and replaces the body with the transformation result. Every string-valued Exchange property is passed to the stylesheet as an XSLT parameter of the same name; declare a matching xsl:param in the stylesheet to read it. Set such a property beforehand, e.g. with setProperty. See tutorials/xml/35-XSLT-Transformation-to-json.yaml.

Explanation:

customer2person.xsl declares a matching xsl:param and reads it as $company:

 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:param name="company"/>
   <xsl:template match="/customer">
     <person>
       <company><xsl:value-of select="$company"/></company>
     </person>
   </xsl:template>
 </xsl:stylesheet>
 

Example Configuration

api:
port: 2000
flow:
- setProperty:
name: company
value: predic8
- transform:
xslt: customer2person.xsl
api:
   port: 2000
   flow:
     - setProperty:
         name: company
         value: predic8
     - transform:
         xslt: customer2person.xsl

Syntax

transform:
xslt: <string>
transform:
  xslt: <string>

Attributes

NameRequiredDefaultDescriptionExamples
xsltfalse-Location of the XSLT stylesheet that will be applied to request and response.strip.xslt

Can be used in