Interesting XSLT Recipe - Computing line totals
You might have run into a requirement where you need to compute the total value of all items in a purchase order. Consider the PO XML shown below.
<xsl:variable name="itemVar" select="/tns:po/tns:Items/tns:item"/>
<xsl:template match="/">
<tns:poSummary>
<tns:totalValue><xsl:value-of select="sum(for $i in $itemVar return ($i/tns:price * $i/tns:qty))"/></tns:totalValue>
</tns:poSummary>
</xsl:template>
</xsl:stylesheet>