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

RE: position in a conditional for-each

Subject: RE: position in a conditional for-each
From: Heather Lindsay <heather.lindsay@xxxxxxxxxxxxx>
Date: Wed, 3 Jan 2001 15:46:57 -0500
xsl conditional for each
hi,
	Try this instead.  The template for "COOLJEX_ATTRIBUTE[@key =
'true']" will only go through the elements that you want and the position()
function can be used to determine when the last element is reached.

<xsl:stylesheet ...>
<xsl:template match="whateverYouHaveHere">
Your other stuff here
<xsl:apply-template match="COOLJEX_ATTRIBUTE[@key = 'true']"/>
your other stuff here
</xsl:template>

<xsl:template match="COOLJEX_ATTRIBUTE[@key = 'true']">
	<xsl:value-of select="@name"/>
	<xsl:if test="position() != last()">
		<xsl:text>,</xsl:text>
	</xsl:if>
</xsl:template>

</xsl:stylesheet>

However, I believe you can also do this:
<xsl:for-each select="COOLJEX_ATTRIBUTE[@key = 'true'">
	<xsl:value-of select="@name"/>
	<xsl:if test="position() != last()">
		<xsl:text>,</xsl:text>
	</xsl:if> 
</xsl:for-each>


Good luck,
Heather

-----Original Message-----
From: James Piva [mailto:james.piva@xxxxxxxxxxxxxxx]
Sent: Wednesday, January 03, 2001 3:26 PM
  The problem is that I can't know when
	the last element to meet the condition
	has passed.I would like to omit trailing comma.

	<xsl:for-each select="COOLJEX_ATTRIBUTE">
        <xsl:if test="@key='true'"> 
	    <xsl:value-of select="@name"/>
	    <xsl:text> , </xsl:text> 
	  </xsl:if>
	</xsl:for-each>

 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.