Subject: RE: [xsl] Re: Selecting Maximum Values From: Jeroen Hellingman <JeroenH@xxxxxxxxxxxxx> Date: Tue, 19 Mar 2002 08:54:10 +0100 |
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: [xsl] 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: Selecting Maximum Values, Dimitre Novatchev | Thread | [xsl] How can I merge two DTD by us, Stephane . Le-Deaut |
[xsl] Re: Selecting Maximum Values, Dimitre Novatchev | Date | RE: [xsl] Normalize-space does not , Michael Kay |
Month |