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

Re: Count all the elements of a column

Subject: Re: Count all the elements of a column
From: "Jorge A. Salido" <jorgesalido@xxxxxxxxx>
Date: 14 Nov 2002 14:11:32 -0600
cadreemploi
Hi

You have to use a recursive template in order to accumulate the number.
Do something like:

(you have to set up the number of agents in the total parameter - count
them with the count function)

<xsl:template name="sum">
	<xsl:param name="current" select="1"/>
	<xsl:param name="counter" select=""/>
	<xsl:param name="total" select="0"/>
	<xsl:choose>
		<xsl:when test="$current = $total">
			<xsl:value-of select="$counter + //agent[$current]/codenet"/>
		</xsl:when>
		<xsl:otherwise>
			<xsl:call-template name="sum">
				<xsl:with-param name="counter" select="$counter +
//agent[$current]/codenet"/>
				<xsl:with-param name="current" select="$current + 1"/>
				<xsl:with-param name="total" select="$total"/>
			</xsl:call-template>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>


On Thu, 2002-11-14 at 11:55, Yann Verlynde wrote:
> sorry I use this xml file structure:
> <agent id="058">
> 
> <datenaissance>27/02/1977</datenaissance>
> 
> <sexe>F</sexe>
> 
> <cadreemploi>emploi8</cadreemploi>
> 
> <codenet>8</codenet>
> 
> <specialite>specialite8</specialite>
> 
> <discipline>discipline8</discipline>
> 
> <datedebut>8/01/1977</datedebut>
> 
> </agent>
> 
> <agent id="059">
> 
> <datenaissance>27/02/1977</datenaissance>
> 
> <sexe>M</sexe>
> 
> <cadreemploi>emploi9</cadreemploi>
> 
> <codenet>9</codenet>
> 
> <specialite>specialite9</specialite>
> 
> <discipline>discipline9</discipline>
> 
> <datedebut>9/01/1977</datedebut>
> 
> </agent>
> 
> 
> 
> My table is constructed by a for-each tag and I want to sum all codenet
> Attribute
> 
> 
> 
> Thanks
> 


 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.