Hello everyone,
I am stuck with a problem which seems stupid but I cannot find out the solution... With XLST, I need to sum a list of values calculated by a template. So I stored these values in a tree structure (a list of "Number" elements contained in a root element "Numbers"). But whatever I try to do with this self-made list, it will return either nothing, 0 or an error...
Does someone know what I am doing wrong ?
<!-- create the tree fragment -->
<xsl:variable name="_subTotals">
<Numbers>
<xsl:for-each select="List">
<xsl:variable name="_Size">
<xsl:call-template name="GetSize">
<xsl:with-param name="_value" select="@value"/>
</xsl:call-template>
</xsl:variable>
<Number>
<xsl:value-of select="$_Size"/>
</Number>
</xsl:for-each>
</Numbers>
</xsl:variable>
<!-- this returns an error: expression must result into a node-set -->
<xsl:message terminate="no">
<xsl:value-of select="sum($_subTotals/Numbers/Number)"/>
</xsl:message>
<!-- transform the tree fragment into a node-set
<xsl:variable name="_Total" select="msxsl:node-set($_subTotals)"/>
<!-- returns nothing -->
<xsl:for-each select="$_Total/Numbers/Number">
<xsl:message terminate="no">
<xsl:value-of select="@value"/>
</xsl:message>
</xsl:for-each>
<!-- returns 0 -->
<xsl:value-of select="sum($_Total/Numbers/Number)"/>