This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Node with maximum attribute value


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]