Re: [xslt] math:max and node-sets

> 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

  <xsl:variable name="resNodes">
    <xsl:for-each select="$nodes">
      <xsl:if test="@val and string(number(@val)) != 'NaN'">
          <xsl:value-of select="@val"/>

So $resNodes is rather

and despite your lucid explanation I would expect a math:max value of


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]