Re: [xslt] math:max and node-sets
- From: Markus Bayerlein <bayerlein genomatix de>
- To: xslt gnome org
- Subject: Re: [xslt] math:max and node-sets
- Date: Tue, 13 Jan 2004 12:27:10 +0100
> Now, finally, to the result. Permit me to abbreviate your element
> name "dummynode" to just "d". The Result Tree Fragment in resNodes,
> with your test file, looks like this:
> <d>300</d><d>100</d><d>200></d><d>300</d><d>nothing</d>
>
> If taken as a Result Tree Fragment, under the rules of XSL, that
> will be converted to the *string value of the node that is first*,
> i.e. '300', and when this string is converted to a number, under the
> rules of XPath, it has the value 300. When this is given as the
> argument to math:max, it is taken as a node-set with a single node,
> value 300, so math:max returns 300.
>
> If the argument of math:max is converted to a nodeset, however (i.e.
> foo:maxVal2), the function examines each of the nodes. This includes
> the node with the string value 'nothing' which, by XPath definition,
> is NaN. Again *by definition* of the math:max function, if any of
> the nodes are NaN the function returns NaN.
>
Nodes with a non-number value are explicitly excluded from the tree
fragment:
<xsl:variable name="resNodes">
<xsl:for-each select="$nodes">
<xsl:if test="@val and string(number(@val)) != 'NaN'">
<dummynode>
<xsl:value-of select="@val"/>
</dummynode>
</xsl:if>
</xsl:for-each>
</xsl:variable>
So $resNodes is rather
<dummynode>300</dummynode>
<dummynode>100</dummynode>
<dummynode>200</dummynode>
<dummynode>300</dummynode>
and despite your lucid explanation I would expect a math:max value of
300.
Markus
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]