[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Stylesheet to remove comments and insignificant whites
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" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml"/> <xsl:template match="@* | * | text() | processing-instruction()"> <xsl:copy> <xsl:apply-templates select="@* | * | text() | processing-instruction()"/> </xsl:copy> </xsl:template> <xsl:template match="text()"> <xsl:if test="not(normalize-space(text()) = ' ')"> <xsl:copy/> </xsl:if> </xsl:template> </xsl:stylesheet> 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. Thanks, Scott 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|