Tuesday, February 2, 2016

Xml to HTML Transformation using XSLT Transform in Mulesoft

Its pretty easy to transform Xml to HTML using Mulesoft's XSLT transform ..

Following is snapshot from my mule's config file ..















The Java component is used to provide following xml as an input :

<?xml version="1.0"?>
<catalog>
    <book id="bk101">
        <author>Gambardella, Matthew</author>
        <title>XML Developer's Guide</title>
        <genre>Computer</genre>
        <price>44.95</price>
        <publish_date>2000-10-01</publish_date>
        <description>An in-depth look at creating applications 
      with XML.</description>
    </book>
</catalog>
Following is the xsl code :
<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" />
    <xsl:template match="catalog">
        <html>
            <body>
                <h2>My Book Collection</h2>
                <table border="1">
                    <tr bgcolor="#9acd32">
                        <th>Book</th>
                        <th>Genre</th>
                    </tr>
                    <xsl:for-each select="book">
                        <tr>
                            <td>
                                <xsl:value-of select="title" />
                            </td>
                            <td>
                                <xsl:value-of select="genre" />
                            </td>
                        </tr>
                    </xsl:for-each>
                </table>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>

We can notice that the output method is selected as html.











Once the flow is executed I can see the final html file being created in the output folder. 
I am using file:outbound-endpoint to write the contents in the output file ..



10 comments :

  1. Thanks Nasreen, may I have your email I'd please ..

    ReplyDelete
  2. Thanks for providing very useful information Mulesoft online training

    ReplyDelete
  3. Thanks for writing such a good article, I stumbled onto your blog and read a few post. I like your style of writing…
    Mulesoft Online Training Banglore

    ReplyDelete
  4. awesome post presented by you..your writing style is fabulous and keep update with your blogs..

    Mulesoft online training india

    ReplyDelete

  5. thanks for posting such a nice blog it really useful and anybody can understand it kindly update more details about
    The article was very clear mulesoft Online Training

    for more Info
    Python Online Training
    ServiceNow Online Training Bangalore
    tableau online training

    ReplyDelete
  6. the blog is good and Interactive it is about Introduction To Xml to HTML Transformation using XSLT Transform in Mulesoft it is useful for students and Mulesoft Developers for more updates on Mulesoft follow the link

    mulesoft Online Trainig

    For more info on other technologies go with below links

    Python Online Training

    tableau online training hyderabad

    ServiceNow Online Training

    ReplyDelete
  7. I must appreciate you for providing such a valuable content for us. This is one amazing piece of article. Helped a lot in increasing my knowledge.mulesoft training in bangalore

    ReplyDelete