JavaRanch Home
 
Front Page FAQs Ranchers Categories Recent Changes To Do Upload

How To Pretty Print Xml With Xsl   



This is how: Note(s) - Have only tried this with xalan.


<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xalan="http://xml.apache.org/xslt">

    <xsl:output method="xml" encoding="UTF-8" indent="yes" xalan:indent-amount="2"/>
    <xsl:strip-space elements="*"/>

    <xsl:template match="*">
        <xsl:copy>
            <xsl:copy-of select="@*" />
            <xsl:apply-templates />
        </xsl:copy>
    </xsl:template>

</xsl:stylesheet>

This doesn't support CDATA.


XmlFaq CategoryCodeSamples
Front Page FAQs Ranchers Categories Recent Changes To Do Upload
Last Edited: 16 September 2007 What's Changed?
 
Copyright © 1998-2008 Paul Wheaton | Home | Contact Us | Privacy | Register