This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Node with maximum attribute value
- To: xsl-list at mulberrytech dot com
- Subject: Re: Node with maximum attribute value
- From: John Aldridge <john dot aldridge at informatix dot co dot uk>
- Date: Mon, 21 Feb 2000 19:09:09 +0000
- Reply-To: xsl-list at mulberrytech dot com
At 17:50 21/02/00 -0000, "Richard Birkby" <rbirkby@thundermain.com> wrote:
>I want to find the maximum mid attribute from the node-set. My
>first idea was to use a sorted for-each, and assign a variable to the
>maximum value, however variables cannot be reassigned. Is there another
>way? Thanks, Richard
This is the best I came up with when I encountered a similar problem. It
seems pretty gross to have to sort the whole list just to find a maximum,
though. If anyone knows a better way...
<xsl:variable name="maxmid">
<xsl:for-each select="closing-price">
<xsl:sort select="number(@mid)" data-type="number" order="descending"/>
<xsl:if test="position()=1">
<xsl:value-of select="number(@mid)"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
--
Cheers,
John
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list