[xsl] Stylesheet to remove comments and insignificant whitespace

Subject: [xsl] Stylesheet to remove comments and insignificant whitespace
From: "Scott Moore" <puffandtoot@xxxxxxx>
Date: Fri, 28 Feb 2003 09:18:20 -0500
I'm in the process of creating a stylesheet which removes all comments from
the source document but keeps everything else.  I would also like to remove
all insignificant whitespace, but seem to be having problems in that
particular area.  So far, here's my feeble attempts:

<xsl:stylesheet version="1.0"
 <xsl:output method="xml"/>

 <xsl:template match="@* | * | text() | processing-instruction()">
   <xsl:apply-templates select="@* | * | text() |

 <xsl:template match="text()">
  <xsl:if test="not(normalize-space(text()) = ' ')">

The source documents are mostly pretty printed, so I believe the carriage
returns may be the root of the problem.  Is there any way to make this work
within a stylesheet?  I'm using Xalan 2.4.1 for the transformation.


P.S. I am aware that the above test may remove some significant whitespace
(e.g., <xsl:text> </xsl:text>).  I'm not worried about that right now, but
will add the proper tests once I get the above working (e.g., checking for
sibling elements of the text node).

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread