Я немного коснулся вашего кода, и теперь он работает как положено :
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:for-each select=
"/testResults/httpSample[not(@lb = preceding::*/@lb)]">
<xsl:variable name="lab" select="@lb" />
<xsl:variable name="count" select="count(../httpSample[@lb = current()/@lb])" />
<xsl:variable name="failureCount" select="count(../httpSample[@lb = current()/@lb][attribute::s='false'])" />
<xsl:variable name="successCount" select="count(../httpSample[@lb = current()/@lb][attribute::s='true'])" />
<xsl:variable name="successPercent" select="$successCount div $count" />
<xsl:variable name="totalTime" select="sum(../httpSample[@lb = current()/@lb]/@t)" />
<xsl:variable name="averageTime" select="$totalTime div $count" />
<xsl:message>
times:
<xsl:for-each select="../httpSample[@lb = current()/@lb]">
<xsl:if test="not(position() = 1)">,</xsl:if>
<xsl:value-of select="@t"/>
</xsl:for-each>
</xsl:message>
<xsl:variable name="minTime">
<xsl:call-template name="min">
<xsl:with-param name="nodes" select="../httpSample[@lb = current()/@lb]/@t" />
</xsl:call-template>
</xsl:variable>
Min time: <xsl:value-of select="$minTime"/>
</xsl:for-each>
</xsl:template>
<xsl:template name="min">
<xsl:param name="nodes" select="/.." />
<!-- Broken when we get here -->
<xsl:choose>
<xsl:when test="not($nodes)">NaN</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$nodes">
<xsl:sort data-type="number" />
<xsl:if test="position() = 1">
<xsl:value-of select="number(.)" />
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Когда это преобразование применяется к предоставленному документу XML :
<testResults>
<httpSample t="758" lt="0" ts="1330176857546"
s="false" lb="/app1/"
tn="space Guest Users 2-4" dt="text"
by="1446"/>
<httpSample t="213" lt="0" ts="1330176858088"
s="false" lb="/app2/"
tn="space Logged In Users 1-28" dt="text"
by="1446"/>
<httpSample t="153" lt="0" ts="1330176858088"
s="false" lb="/app2/"
tn="space Logged In Users 1-28" dt="text"
by="1446"/>
<httpSample t="113" lt="0" ts="1330176858088"
s="false" lb="/app2/"
tn="space Logged In Users 1-28" dt="text"
by="1446"/>
<httpSample t="153" lt="0" ts="1330176858149"
s="false" lb="/app3/"
tn="space Logged In Users 1-29" dt="text"
by="1446"/>
<httpSample t="340" lt="0" ts="1330176857967"
s="false" lb="/app3/"
tn="space Logged In Users 1-26" dt="text"
by="1446"/>
</testResults>
желаемый правильный результат (включая выходные данные отладки):
Min time: 758
Min time: 113
Min time: 153