The short-term solution that works seems to be this:
<?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common"> <xsl:template match="/resultSet"> <xsl:variable name="foo"> <xsl:for-each select="result"> <n><xsl:value-of select="numCorrect div truthCorrect" /></n> </xsl:for-each> </xsl:variable> <xsl:value-of select="avg(exslt:node-set($foo)/n)" /> </xsl:template> </xsl:stylesheet>
where <xsl:value-of select="avg(exslt:node-set($foo)/n)" /> can be replaced by
<xsl:value-of select="sum(exslt:node-set($foo)/n) div count(result)" />
if you are using an XSLT engine that supports exslt extensions but does not have the non-standard avg function.
source share