Re: [xsl] max value

Subject: Re: [xsl] max value
From: "Charly" <cohana@xxxxxxxxxxxxxxx>
Date: Tue, 11 Dec 2001 16:36:48 -0800
Thanks Mark,
I still have a problem with the last(), after I do the sort the last doesn't
give the last position anymore .
In my case the last() return 2.
below is my example

<books>
  <book>    <name> Brian   </name>   <listprice> 14 </listprice>  </book>
  <book>    <name> Charles </name>   <listprice> 10 </listprice>  </book>
  <book>    <name> Alan  </name>   <listprice> 12 </listprice>  </book>
  <book>    <name> Jeff    </name>   <listprice> 97 </listprice>  </book>
  <book>    <name> Scott   </name>   <listprice> 22 </listprice>  </book>
</books>


<xsl:template match="/books">
<body>
<table border="1">
  <xsl:for-each select="book">
    <xsl:sort select="listprice" data-type="number" />
    <tr>
    <td> <xsl:value-of select="position()" /> </td>
    <td> <xsl:value-of select="last()" />     </td>
    </tr>
  </xsl:for-each>
</table>
</body>
</xsl:template>
</xsl:stylesheet>


----- Original Message -----
From: "Mark Miller" <storefront2000@xxxxxxxxx>
To: "XSLT List" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Tuesday, December 11, 2001 8:20 AM
Subject: RE: [xsl] max value


> Sort and take the last value from the sort.
>
> <xsl:template match="/values">
>   <xsl:for-each select="value">
>     <xsl:sort select="." data-type="number"/>
>     <xsl:if test="position() = last()">
>       <xsl:value-of select="."/>
>     </xsl:if>
>   </xsl:for-each>
> </xsl:template>
>
> Mark
>
> > Is there a way to get the max value .
> >
> > something that would look like and returns "11"
> >
> > <xsl:template match="values">
> >       <xsl:value-of select="max(value)" />
> > </xsl:template>
> >
> > <values>
> >    <value>7</value>
> >    <value>11</value>
> >    <value>8</value>
> >    <value>4</value>
> > </values>
>
>
> __________________________________________________
> Do You Yahoo!?
> Check out Yahoo! Shopping and Yahoo! Auctions for all of
> your unique holiday gifts! Buy at http://shopping.yahoo.com
> or bid at http://auctions.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