1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| <?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="/" >
<table align='center' border="0">
<tr>
<td>
Total montant
</td>
<td align="right" width="20" ><hr />
<!-- <xsl:value-of select="sum(CompteRendu/Compte/@montant)" /> -->
<xsl:variable name="total_compte">
<xsl:call-template name="somme">
<xsl:with-param name="noeuds" select="CompteRendu/Compte"/>
<xsl:with-param name="attribut" select="'montant'"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="translate($total_compte, '.', ',')"/>
</td>
</tr>
</table>
</xsl:template>
<xsl:template name="somme">
<xsl:param name="total" select="0"/>
<xsl:param name="noeuds"/>
<xsl:param name="attribut"/>
<xsl:choose>
<xsl:when test="$noeuds">
<xsl:call-template name="somme">
<xsl:with-param name="total" select="$total + number(translate($noeuds[1]/@*[name()=$attribut], ',', '.'))"/>
<xsl:with-param name="noeuds" select="$noeuds/following-sibling::*[1]"/>
<xsl:with-param name="attribut" select="$attribut"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$total"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet> |
Partager