I’ve been trying to get the sum (total) value for elements in different nodes, but after a week messing around with example after example I am no step closer to the solution.
All I get is the different values listed in a string rather than the sum.
The selection used to get the values is:
<xsl:for-each select="//workgroups/workgroup/agentstatus/status">
<xsl:if test="key='Available, No ACD'">
<xsl:value-of select="sum(value)"/>
</xsl:if>
</xsl:for-each>
This returns 111 rather than the expected value 3
What do I do wrong here?
This is xml version=”1.0″ encoding=’utf-8′
Try this:
The looping’s taken care of by the way XSLT works, so you don’t need to specify a for each or an if statement – it’s all implied by the xpath statement.
If this doesn’t work please can you post a copy of the XML you’re running it on and I’ll then update the xpath as required.