[xsl] Re: Spam:[xsl] removing space in a text node

Subject: [xsl] Re: Spam:[xsl] removing space in a text node
From: JBryant@xxxxxxxxx
Date: Wed, 16 Mar 2005 12:31:20 -0600
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:[xsl] 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

Current Thread