Re: Node with maximum attribute value

Subject: Re: Node with maximum attribute value
From: John Aldridge <john.aldridge@xxxxxxxxxxxxxxxx>
Date: Mon, 21 Feb 2000 19:09:09 +0000
At 17:50 21/02/00 -0000, "Richard Birkby" <rbirkby@xxxxxxxxxxxxxxx> 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


Current Thread