This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: does xslt support max(), min() and avg() functions ??
- To: anand awasthi <anand-awasthi at usa dot net>
- Subject: Re: [xsl] does xslt support max(), min() and avg() functions ??
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Wed, 14 Feb 2001 12:55:53 +0000
- CC: xsl-list at lists dot mulberrytech dot com, xslt at p2p dot wrox dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <20010213191436.17190.qmail@nwcst319.netaddress.usa.net>
- Reply-To: xsl-list at lists dot mulberrytech dot com
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
other
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.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list