Using the XSLT Transformer in Mule ESB

The following example shows how to use the XSLT Transforrmer in Mule ESB. We’ll transform an XML in the payload to another with a different structure.

For this example we’ll use the XSLT transformation described here.

All we need is an input XML like this:

Reservation.xml

Github

We want to transform it into an output like this:

ReservationInfo.xml

It’s the same data with different structure.

To get this, we need to run an XSL transformation in Mule ESB using the XSLT Transformer.

xsltTransformation-config.xml

Github

We need to tell the XSLT Transformer where the XSL transformation is located in our project (line 26).

Transformation.xslt

Github

You might get a warning in Mule’s console, telling you that you are running an XSLT 1.0 in an XSLT 2.0 processor, but its OK, the transformation will work.

You can find the project in Github here.

Here is the source code of the project.

Enjoy!

3 comments: On Using the XSLT Transformer in Mule ESB

  • Hi
    I am trying to use something similar to add an element to incoming message. But in doing so, mule is adding namespaces to the copied element.

    Following is my transformer code:

    which adds a uuid to the request element as follows:

    ?xml version=”1.0″ encoding=”UTF-8″?>

    12345

    CallerId
    SoapUI
    CallerId
    1.0
    1.0
    SOAPUI
    bff3e1d6-ecdd-41ae-8807-ec04085a2b54

    But it also adds the namespace for mule & uuid.

    Any idea what could be a work around??

    /A

  • I am using the XSLT transformer to transform XML, to XML2 – there are no errors but the transformed xml is not having any xml tags but only the data values.
    Is there any configuration missing ?

  • I have noticed you don’t monetize your page, don’t waste your traffic, you can earn extra bucks every month because you’ve got hi quality content.
    If you want to know how to make extra bucks, search
    for: best adsense alternative Wrastain’s tools

Leave a reply:

Your email address will not be published.

Copyright © 2016 Marco Tello.