Re: [xsl] does xslt support max(), min() and avg() functions ??

Subject: Re: [xsl] does xslt support max(), min() and avg() functions ??
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 14 Feb 2001 12:55:53 +0000
Hi Anand,

> i want to get the maximum, minimum and average values of xml
> elements....i want to use XSLTs for this purpose...does XSLT support
> mathematical functions ornot ?? how can i implement mathematical
> functions using XSLTs ??

XSLT supports a fairly limited list of mathematical functions, which
doesn't include maximums, minimums or averages.

How to calculate maximums and minimums depends on the source XML, but
there are generally three possibilities:

  1. an XPath that picks the node whose value isn't lower than any
  2. sorting a node set and choosing the first in the sorted order
  3. using recursion

Calculating averages involves counting the nodes whose values you want
to average using the count() function, and summing their values either
through the sum() function or through recursion if necessary.

If you give more details about what you're trying to achieve, what
your source XML looks like and what XSLT you've managed to put
together so far, I'm sure someone will be able to help you more.



Jeni Tennison

 XSL-List info and archive:

Current Thread