3 ms·
Just in case you're using XSL still, you could use <xsl:key/> to let you quickly do subtotals by summing the node set of items that match whatever grouping leve
by spdustin 12y ago
Just in case you're using XSL still, you could use <xsl:key/> to let you quickly do subtotals by summing the node set of items that match whatever grouping level you're on when you emit the last item in the group.
<xsl:key name="items-by-order" match="item" use="../@orderid"/>
...snip...
<!-- Union current item node with last item node of the order - if it's the same, the count will be one -->
<xsl:if test="count(. | key('items-by-order', ../@orderid)[last()]) = 1">
<xsl:value-of select="sum(key('items-by-order', ../@orderid))"/>
</xsl:if>
Running totals would be similar, except that your apply-templates for the item group would include a select that restricts the available nodes to the key() function's result, and you would sum current node with preceding nodes.