xsl-list
[Top] [All Lists]

RE: Finding min and max

2004-09-08 14:05:20

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


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--





<Prev in Thread] Current Thread [Next in Thread>