I. XSLT 1.0 solution
This transformation finds the sum and average of all numbers except those with the minimal value -- works for a nodeset of numbers of any length:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:variable name="vMin">
<xsl:for-each select="/*/num">
<xsl:sort data-type="number"/>
<xsl:if test="position()=1">
<xsl:value-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="vNumsWithoutMin" select="/*/num[not(.=$vMin)]"/>
<xsl:variable name="vSumWithoutMin" select="sum($vNumsWithoutMin)"/>
<xsl:template match="/*">
<xsl:apply-templates select="$vNumsWithoutMin"/>
<xsl:value-of select="concat(' = ', $vSumWithoutMin)"/>
average = <xsl:value-of select=
"$vSumWithoutMin div count($vNumsWithoutMin)"/>
</xsl:template>
<xsl:template match="num">
<xsl:value-of select="."/>
<xsl:if test="not(position()=last())">
<xsl:text> + </xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
When this is applied on the provided XML document:
<root>
<num>10</num>
<num>12</num>
<num>8</num>
</root>
the wanted, correct result is produced:
10 + 12 = 22
average = 11
II. XSLT 2.0 solution
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output method="text"/>
<xsl:variable name="vMin" select="min(/*/num/number(.))"/>
<xsl:variable name="vNumsSansMin"
select="/*/num[not(number() eq $vMin)]/number(.)"/>
<xsl:variable name="vAvgSansMin"
select="avg($vNumsSansMin)"/>
<xsl:template match="/*">
<xsl:sequence select=
"(for $i in 1 to count($vNumsSansMin)
return
($vNumsSansMin[$i],
if(not($i eq count($vNumsSansMin)))
then ' + '
else ()
)
),
' = ', sum($vNumsSansMin)
"/>
average = <xsl:sequence select="$vAvgSansMin"/>
</xsl:template>
</xsl:stylesheet>