This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: max value
- From: Mike Brown <mike at skew dot org>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Mon, 10 Dec 2001 16:52:06 -0700 (MST)
- Subject: Re: [xsl] max value
- Reply-to: xsl-list at lists dot mulberrytech dot com
Charly wrote:
> Hello,
> 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>
Check out exslt.org.
<xsl:template match="values">
<xsl:choose xmlns:math="http://exslt.org/math">
<xsl:when test="function-available('math:max')">
<xsl:value-of select="math:max(value)"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="not(value)">NaN</xsl:when>
<xsl:otherwise>
<xsl:for-each select="value">
<xsl:sort data-type="number" order="descending" />
<xsl:if test="position() = 1">
<xsl:value-of select="number(.)" />
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
- Mike
____________________________________________________________________________
mike j. brown, fourthought.com | xml/xslt: http://skew.org/xml/
denver/boulder, colorado, usa | personal: http://hyperreal.org/~mike/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list