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

Re: XSTL - Help / Easy one!

Subject: Re: XSTL - Help / Easy one!
From: Mike Brown <mike@xxxxxxxx>
Date: Tue, 5 Feb 2002 19:56:04 -0700 (MST)
xstl last
Ragan, Mitch wrote:
> How can I remove the "trailing coma" on this XSLT output
> with our using an "if" statement: 
> 
>   XSLT:
>   <xsl:template match="Portfolio/Stock">
> 	<xsl:apply-templates select="Symbol"/>,
>   </xsl:template>

You're going to get 9 zillion answers, all variations of:

<xsl:template match="Portfolio/Stock">
   <xsl:apply-templates select="Symbol"/>
   <xsl:if test="position() != last()">,</xsl:if>
</xsl:template>

But they'll probably neglect to mention that you should do it
like this

<xsl:template match="/">
  <xsl:apply-templates select="Portfolio/Stock"/>
</xsl:template>

<xsl:template match="Stock">
   <xsl:apply-templates select="Symbol"/>
   <xsl:if test="position() != last()">,</xsl:if>
</xsl:template>

so you can ensure that position() and last() work as expected,
returning numbers that are relative to the set of Stock elements
that have been selected for processing, rather than the set of
all children of the parent element or root node, as the built-in
templates would otherwise cause to be processed.

   - Mike
____________________________________________________________________________
  mike j. brown, fourthought.com  |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  personal: http://hyperreal.org/~mike/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.