Sign In/My Account | View Cart  
advertisement

Article:
 XSLT as Pretty Printer
Subject: This is so 1999...
Date: 2006-11-30 02:01:18
From: olegtkachenko

Why not just indent="yes" ? XSLT processors always knows better.


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


<xsl:output method="xml" indent="yes" encoding="UTF-8"/>


<xsl:template match="@*|node()">
<xsl:copy-of select="."/>
</xsl:template>


</xsl:stylesheet>


I can see at least 3 serious problems with your stylesheet:
1. You ignore xml:space="preserve"
2. Mixed content get screwed up
3. Processing instructions go /dev/null


Previous Message Previous Message   Next Message No Next Message


Titles Only Titles Only Newest First
  • This is so 1999...
    2006-12-01 08:18:44 HewWolff

    > Why not just indent="yes" ? XSLT processors always knows better.


    Good point. The problem with indent="yes" is that you get no guarantees about the resulting format. All you know is that the XSLT processor will probably put in some white space somewhere. Saxon doesn't do a very good job in my opinion (for example, it fails the diff test I described).



Sponsored By: