Transforming with XSLT
When you want to transform an XML message using XSLT, use Camel's XSLT Component. This is similar to the Transforming inline with XQuery recipe except that there is no XSLT Expression Language, so it can only be used as an endpoint.
This recipe will show you how to transform a message using an external XSLT resource.
Getting ready
The Java code for this recipe is located in the org.camelcookbook.transformation.xslt
package. Spring XML files are located under src/main/resources/META-INF/spring
and prefixed with xslt
.
How to do it...
In a Camel route, add the xslt
processor step into the route at the point where you want the XSLT transformation to occur. The XSLT file must be referenced as an external resource, and depending on where the file is located, prefixed with either classpath:
(default if not using a prefix), file:
, or http:
.
In the XML DSL, this is written as:
<route> <from uri="direct:start"/> <to uri="xslt:book.xslt"...