Reputation: 2618
I need to add a number of values, depending on the content of each item. for example.
<links>
<test element="32"/>
<test element="17"/>
<test element="13"/>
<test element="11"/>
<test element="9"/>
<test element="8"/>
<test element="7"/>
<test element="7"/>
</links>
Total element: 8, sum of the values of each element: 104, the value a show is this(104).
<xsl:template match="//x:span[@class='ws-filter-count']">
<xsl:variable name="countProduct" select="normalize-space(translate(text(), '()', ''))" />
<xsl:variable name="sum" select="number(0)"/>
<test element="{$countProduct}" />
</xsl:template>
This sum:
Will this only be done with call-template?, recursive, correct?. Thanks.
Upvotes: 0
Views: 71
Reputation: 2585
If I understood correctly what you want to achieve:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" version="1.0"/>
<xsl:template match="links">
<xsl:value-of select="sum(test/@element)"/>
</xsl:template>
</xsl:stylesheet>
<links>
<test element="32"/>
<test element="17"/>
<test element="13"/>
<test element="11"/>
<test element="9"/>
<test element="8"/>
<test element="7"/>
<test element="7"/>
</links>
104
Upvotes: 1