Page 1 of 1

need help with this statement

Posted: Thu Oct 12, 2006 10:27 am
by tournevice
Hi everyone,

I'm new to xslt and I need some help.

Here is the thing : I got this :

Code: Select all


 <xsl:variable name="allMinTime">
<xsl:call-template name="min">
<xsl:with-param name="nodes" select="/testResults/sample/@t" />
</xsl:call-template>
</xsl:variable>
and this :

Code: Select all


<xsl:template name="min">
<xsl:param name="nodes" select="/.." />

<xsl:choose>
<xsl:when test="not($nodes)">something</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>
When I want to display $allMinTime, I got "NaN" as an answer, instead of a value. The thing I'm sure is that "/testResults/sample/@t" works because I use it here : <xsl:variable name="allTotalTime" select="sum(/testResults/sample/@t)" /> and when I display $allTotalTime, it works.

<xsl:sort data-type="number" /> seems to be the problem, but I'm not sure...

Any idea?

Thx for your help !

Posted: Thu Oct 12, 2006 12:33 pm
by sorin_ristache
Hello,

If the values of all the /testResults/sample/@t attributes can be converted to numbers (they are numbers, booleans or nodesets which can be converted to numbers) you should not get NaN as a result. If not the non number value is converted to NaN. Can you post a sample of the input XML ?


Regards,
Sorin