xsl-list
[Top] [All Lists]

RE: Calculation of Minimum or Maximum value of an element

2002-11-12 02:33:09
Here are four techniques you can use:

1. Use the XPath expression

       A[not(../A < .)]
   which finds all A elements that have no other A whose value is
smaller. This expression has quadratic performance.

2. Sort the list and (using the xx:node-set() extension) select the
first or last in sorted order. This has (n log n) performance.

3. Use a recursive template. This has linear performance.

4. Use a library routine, such as the EXSLT min() function: see
www.exslt.org.

Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com 

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of 
Chitra Lalita Madhwacharyula
Sent: 12 November 2002 01:46
To: XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Calculation of Minimum or Maximum value of an element



      Hello,

      Can anyone please tell me how to calculate the minimum or
maximum values of a set of nodes and display them using       XSLT ?
      For e.g if I have
      <A>300</A>
      <A>250</A>
      <A>900</A>
      How can I write a template or a function which 
calculates the least A element value and displays it ???

      Thanx,
      Chitra

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




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



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