Re: [xsl] Removing white space from XML file

Subject: Re: [xsl] Removing white space from XML file
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Thu, 12 Apr 2007 14:50:23 +0200
David Carlisle wrote:
I think if you set indent="no" in the xsl:output tag of your XSL, it
removes all the extra white spaces between the XML nodes (I tested
this a while ago, if my memory is right then it should work).

no, indent="no", which is the default behaviour in the xml output method, never removes white space, it simply tells the processor not to add any extra white space.

The poster was looking for <xsl:strip-space elements="*"/>and the XPath
normalize-space() function.

Perhaps this (but I think that xsl:strip-space is redundant here)?


<xsl:strip-space elements="*" />

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

<xsl:template match="text()">
   <xsl:value-of select="normalize-space(.)" />
</xsl:template>

Current Thread