<points>
<semaine>
<jour>1</jour>
<jour>3</jour>
<jour>2</jour>
<jour>1</jour>
</semaine>
<semaine>
<jour>2</jour>
<jour>8</jour>
<jour>20</jour>
</semaine>
<semaine>
<jour>1</jour>
<jour>3</jour>
</semaine>
</points>
|
|
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:apply-templates select="*/*"/>
</xsl:template>
<xsl:template match="*">
<xsl:text>Il y a </xsl:text>
<xsl:call-template name="comptage">
<xsl:with-param name="total">0</xsl:with-param>
<xsl:with-param name="index_courant">1</xsl:with-param>
</xsl:call-template>
<xsl:text> points cette semaine.
</xsl:text>
</xsl:template>
<xsl:template name="comptage">
<xsl:param name="total"/>
<xsl:param name="index_courant"/>
<xsl:choose>
<xsl:when test="$index_courant = count(*) + 1">
<xsl:value-of select="$total"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="un_nombre"><xsl:value-of select="*[position() = $index_courant]"/></xsl:variable>
<xsl:call-template name="comptage">
<xsl:with-param name="total"><xsl:value-of select="$total + $un_nombre"/></xsl:with-param>
<xsl:with-param name="index_courant"><xsl:value-of select="$index_courant + 1"/></xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
|