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

RE: Re: Selecting Maximum Values

Subject: RE: Re: Selecting Maximum Values
From: Jeroen Hellingman <JeroenH@xxxxxxxxxxxxx>
Date: Tue, 19 Mar 2002 08:54:10 +0100
maximum value list xsl
Without extensions and resort to sorting, something like this should work:
(considering that the maximum of a list is either the head or the maximum of
the tail of the list)


	<xsl:template name="find-max">
		<xsl:param name="list"/>
		<xsl:choose>
			<xsl:when test="$list">
				<xsl:variable name="head">
					<xsl:value-of select="$list[1]"/>
				</xsl:variable>
				<xsl:variable name="maxTail">
					<xsl:call-template name="find-max">
						<xsl:with-param name="list"
select="$list[position()!=1]"/>
					</xsl:call-template>
				</xsl:variable>
				<xsl:choose>
					<xsl:when test="$head &lt;
$maxTail">
						<xsl:value-of
select="$maxTail"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of
select="$head"/>
					</xsl:otherwise>
				</xsl:choose>	
			</xsl:when>
			<xsl:otherwise>0</xsl:otherwise>
		</xsl:choose>
	</xsl:template>


-----Original Message-----
From: Dimitre Novatchev [mailto:dnovatchev@xxxxxxxxx]
Sent: Tuesday, 19 March, 2002 08:31
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Re: Selecting Maximum Values


> I was wondering if there was a simplier way, or is this the way to do
> it.  I'm never sure if I'm doing it the "right"
> way. :)

Use the maximum function from FXSL. You can customise it to accept a
comparison function as a parameter -- than you'll have a very flexible
maximum, which is not offered by XSLT 2.0 or any other library.

Cheers,
Dimitre Novatchev




__________________________________________________
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

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

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


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.