|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Spam: removing space in a text node
One possibility is to not pick up the comma in the first place and then
place a new comma (and space) where you want it, thus:
<xsl:template match="field">
<xsl:for-each select="descriptiveWord">
<xsl:apply-templates select="."/>
<xsl:if test="not(position() = last())"><xsl:text>,
</xsl:text></xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="descriptiveWord">
<xsl:value-of select="normalize-space(.)"/>
</xsl:template>
Note that I added the normalize-space function to the descriptiveWord
template because the contents of those nodes have leading and trailing
spaces, which would also mess with your punctuation. Hence the space after
the comma within xsl:text.
I'm sure there are other ways, but this one works (just tested it with
Saxon 8).
HTH
Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)
"Peter Charles" <petefc@xxxxxxxxxxxxxxxxx>
03/16/2005 12:14 PM
Please respond to
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To
<xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
cc
Subject
Spam: removing space in a text node
Hello,
If I have the following structure:
<field name="c14alias" displayName="Created By">
<descriptiveWord> Malina </descriptiveWord> ,
<descriptiveWord> Mark </descriptiveWord>
</field>
Is there an easy way to remove the leading space from in front of the
comma
that sits between the descriptiveWord nodes?
Thanks
Peter
|
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
|

Cart








