[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Spam: removing space in a text node

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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.