RE: [xsl] reccursive sum ?

Subject: RE: [xsl] reccursive sum ?
From: "Ricaud Matthieu" <matthieu.ricaud@xxxxxxx>
Date: Tue, 2 Mar 2004 14:59:45 +0100
Thanks Andrew for this example.
Someone on a Forum send me something in this way :

<xsl:template match="LISTE-ME">
	<xsl:for-each select="ME">
		ME <xsl:value-of select="@id"/> :
		<xsl:call-template name="NbreDevoirsME">
			<xsl:with-param name="MEid" select="."/>
		</xsl:call-template>
		 devoirs <br/>
		<xsl:call-template name="total">
			<xsl:with-param name="TheNodes" select="ME"/>
		</xsl:call-template>
	<xsl:for-each/>
</xsl:template>

<xsl:template name="total">
	<xsl:param name="TheNodes"/>
	<xsl:choose>
		<xsl:when test="not($TheNodes)">
			<xsl:value-of select="0"/>
		</xsl:when>
		<xsl:otherwise>
			<xsl:variable name="FallowingsNodesSum">
				<xsl:call-template name="total">
					<xsl:with-param name="TheNodes" select="$TheNodes[position()!=1]"/>
				</xsl:call-template>
			</xsl:variable>
			<xsl:variable name="nbDevoirs">
				<xsl:call-template name="NbreDevoirsME">
					<xsl:with-param name="MEid" select="$noeuds[1]"/>
				</xsl:call-template>
			</xsl:variable>
			<xsl:value-of select="$FallowingsNodesSum+$nbDevoirs"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template name="NbreDevoirsME">
	<xsl:param name="MEid"/>
	<xsl:variable name="MEfile">
		<xsl:value-of select="$MEid">.xml
	</xsl:variable>
	<xsl:value-of select="count(document($MEfile)/ME/FOURN/DEVOIR"/>
</xsl:template>

Thanks philemon_siclone on
http://www.developpez.net/forums/viewforum.php?f=25


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


Current Thread