need help with this statement

Here should go questions about transforming XML with XSLT and FOP.
tournevice
Posts: 1
Joined: Thu Oct 12, 2006 10:16 am

need help with this statement

Post 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 !
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post 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
Post Reply