xsl-list
[Top] [All Lists]

Re: Top n values

2002-10-17 12:59:59
--- Dan Diebolt wrote:
 
I need to process the top n values in a list where n
is dynamic. So if n=3 and I had the following XML:

<root>
 <item>1</item>
 <item>5</item>
 <item>3</item>
 <item>2</item>
 <item>6</item>
 <item>4</item>
</root>

I need to process <item>'s with values 6,5,4. If I had
captured n in a variable/parameter, what is the most 
efficient way to do this? What I want to avoid is walking 
the <item> nodset multiple times as there are a lot of
<item>s (thousands). Thanks.


You can sort the node-set and produce the first three nodes.

Or you could use:

http://www.topxml.com/code/default.asp?p=3&id=v20010310050532

but it is not so efficient.





=====
Cheers,

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

__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com

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



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