|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Re: Selecting Maximum Values
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 < $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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








