unique grouping-subtotaling problem
I'm trying to get a count for each unique element and a subtotal for an attribute("s"). The total count of each unique element is working fine, however, the summarization of the attribute is not. It seems to just take one instance of the attribute value rather than summing all of them up within the element group.
Here is the XML
<USAGE-LOG-2.0>
<SEARCH>
<T s="3"/>
</SEARCH>
<VW_COVER>
<T s="2"/>
</VW_COVER>
<VW_COVER>
<T s="5"/>
</VW_COVER>
<VW_COVER>
<T s="5"/>
</VW_COVER>
<VW_COVER>
<T s="7"/>
</VW_COVER>
<VW_COVER>
<T s="3"/>
</VW_COVER>
<REFRESH_WDOC>
<T s="4"/>
</REFRESH_WDOC>
<CR_WDOC>
<T s="9"/>
</CR_WDOC>
<CR_WDOC>
<T s="7"/>
</CR_WDOC>
<RUN_SCRIPT>
<T s="8"/>
</RUN_SCRIPT>
</USAGE-LOG-2.0>
Here is the xsl
<xsl:output method="html" />
<xsl:key name="gis" match="USAGE-LOG-2.0/*" use="name()"/> <xsl:template match="node()"> <table>
<xsl:for-each
select="//*[generate-id(.)=3Dgenerate-id(key('gis',name(.))[1])]">
<xsl:sort select="name()"/>
<tr><td>
<xsl:value-of select="name(.)" /></td><td><xsl:value-of select="count(key('gis', name(.)))" /> </td><td>
<xsl:variable name="responsetime">
<xsl:for-each select="T">
<accum>
<xsl:value-of select="@s"/>
</accum>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="sum(msxsl:node-set($responsetime)/accum)"/>
</td></tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
Here is what it returns:
CR_WDOC 2 9
REFRESH_WDOC 1 4
RUN_SCRIPT 1 8
SEARCH 1 3
VW_COVER 5 2
Here is what I expected to get:
CR_WDOC 2 16
REFRESH_WDOC 1 4
RUN_SCRIPT 1 8
SEARCH 1 3
VW_COVER 5 22
|