Do you want to use XSLT 1.0 or 2.0?
Are you aware that even XSLT/XPath 1.0 has a function named 'sum'
http://www.w3.org/TR/xpath#function-sum so you might simply be able to use
Code:
<xsl:value-of select="sum(foo)"/>
where foo is the name of the elements you want to sum up.