Subject: RE: Finding min and max
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Wed, 8 Sep 2004 22:05:20 +0100
|
> I need help with finding min & max value in a nodeset based
> on the account
> type (I and R) AND minimum and maximum value in a nodeset (no
> matter what
> the account type is).
Well, you presumably know how to select the nodes that satisfy the relevant
condition, e.g. record[Account='I']/High. Given a node-set, there are
several ways you can find the min and max value:
* In XPath 2.0, use the min() and max() functions.
* Sort the nodes, and choose the first and last in sorted order
* Do a scan of the nodes using a recursive template, keeping track of the
highest and lowest so far.
The third approach is probably the most efficient because you can get the
min and max in a single scan, but it's also the hardest one to code,
especially for a beginner.
Michael Kay
> Anybody can help ?
>
> The xml structure is like this:
>
> <Trade>
> <Record>
> <Account>R</Account>
> <High>1000</High>
> </Record>
> <Record>
> <Account>R</Account>
> <High>2000</High>
> </Record>
> <Record>
> <Account>I</Account>
> <High>5000</High>
> </Record>
> <Record>
> <Account>I</Account>
> <High>2000</High>
> </Record>
> </Trade>
>
> Any help will be appreciated
>
> _________________________________________________________________
> Help STOP SPAM with the new MSN 8 and get 2 months FREE*
> http://join.msn.com/?page=features/junkmail
|