[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Count all the elements of a column
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|