[xsl] Re: getting the text nodes from a set of attribute nodes

Subject: [xsl] Re: getting the text nodes from a set of attribute nodes
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Thu, 4 Sep 2003 21:53:51 +0200
> since i probably explained myself badly (still getting used to the
> terminology), i did clarify the semantics of comparing two nodes,
> involving the arithmetic operators and number(), so i guess the point i
> was making was that the actual nodes in question could have been simply
> text nodes whose string values represented the numeric values of interest,
> that's all.

Or, generally, nodes, whose string value can be interpreted as a number,
that is, for every node nd in the node-set

number(string(nd)) = number(string(nd))

The string() function above can be omitted, so the necessary pre-condition
for the meaningfulness of finding minimum with the XPath expression:

   $nodes[not($nodes &lt; .)]


   not($nodes[not( number(.) = number(.) )])

BTW, the expression

   $nodes[not($nodes &lt; .)]

looks elegant, but it is evaluated in O(N^2) in the average and in the worst

There is a linear ( O(N) ) algorithm with primitive or DVC recursion and an
O(N*log(N)) algoritm using xsl:sort.

For anyone, who'd prefer to save their time by not having to re-implement
max() and min() again and again due to small differences in the way the ">"
operator is defined, I would recommend using the "minimum" and "maximum"
templates from FXSL, which accept a "greater-than" function as parameter.


Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread