Re: To Remove White after the End of Element for Each CDATA element !!!

Note CDATA sections are not elements, and XSLT does not see them, so
your input is equivalent to the input below which does not use
CDATA. This would be much easier in XSLT2, but in XSLT1 you just need a
small recursive loop to strip off the trailing space.



<x>
<WOOD>
        <WORK>
            <DONE>A B FL  3432
                     </DONE>
        </WORK>
</WOOD>
<WOOD>
        <WORK>
            <DONE>C C FT  1111
                     </DONE>
        </WORK>
</WOOD>
<WOOD>
        <WORK>
            <DONE>T T RT  2323
                     </DONE>
        </WORK>
</WOOD>
</x>




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

<xsl:template match="/">
<xsl:apply-templates select="/x/WOOD/WORK/DONE"/>
</xsl:template>

<xsl:template match="DONE">
<xsl:text>
[</xsl:text>
<xsl:call-template name="x"/>
<xsl:text>]</xsl:text>
</xsl:template>

<xsl:template name="x">
<xsl:param name="s" select="."/>
<xsl:variable name="l" select="substring($s,string-length($s))"/>
<xsl:choose>
<xsl:when test="$l=' ' or $l='&#10;'">
<xsl:call-template name="x">
  <xsl:with-param name="s"
  select="substring($s,1,string-length($s)-1)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$s"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>




$ saxon wood.xml wood.xsl
<?xml version="1.0" encoding="utf-8"?>
[A B FL  3432]
[C C FT  1111]
[T T RT  2323]



-- 
http://www.dcarlisle.demon.co.uk/matthew

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Received on Thursday, 18 December 2003 09:07:59 UTC