[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Finding min and max

Subject: RE: Finding min and max
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Wed, 8 Sep 2004 22:05:20 +0100
xsl max
> 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.