[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] max value


Subject: RE: [xsl] max value
From: Jeff Beadle <Jbeadle@xxxxxxxx>
Date: Tue, 11 Dec 2001 11:27:29 -0500

Charly,

for the select attribute use the following:
...
<xsl:sort select="text()" data-type="number" order="descending"/>
...

sorry 'bout that, forgot that the select attribute was required (msxsml
doesn't require it, if it isn't defined, then the text node of the given
context node is assumed).


The purpose of the example-by-pattern xsl:param, was just to illustrate two
mechanisms of accomplishing the same goal.  I would think the most common
usage, would be of the named template.  Whether to implement a template by
pattern or by name is a design choice.


-Jeff


-----Original Message-----
From: Charly [mailto:cohana@xxxxxxxxxxxxxxx]
Sent: Tuesday, December 11, 2001 2:02 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] max value


Thanks Jeff,
but I have the following error now
500 Servlet Exception
tmp.xsl:18: xsl:sort expects attribute `select'
also why do I need to call <xsl:param name="example-by-pattern" select="0"/>
without a template .



----- Original Message -----
From: "Jeff Beadle" <Jbeadle@xxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Tuesday, December 11, 2001 6:21 AM
Subject: RE: [xsl] max value


> Here's two examples:  one is template by match, the other by template by
> name.
>
>
> <xsl:param name="example-by-pattern" select="0"/>
>
> <xsl:template match="/">
> <xsl:choose>
> <xsl:when test="1=$example-by-pattern">
> <xsl:apply-templates />
> </xsl:when>
> <xsl:otherwise>
> <xsl:call-template name="GetMax">
> <xsl:with-param name="values"
> select="//values//value"/>
> </xsl:call-template>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
>
>
> <xsl:template match="values">
> <xsl:variable name="max">
> <xsl:for-each select="value">
> <xsl:sort data-type="number"
> order="descending"/>
> <xsl:if test="position()=1">
> <xsl:copy-of select="."/>
> </xsl:if>
> </xsl:for-each>
> </xsl:variable>
> <xsl:value-of select="$max"/>
> </xsl:template>
>
>
> <xsl:template name="GetMax">
> <xsl:param name="values"/>
> <xsl:variable name="max">
> <xsl:for-each select="$values">
> <xsl:sort data-type="number"
> order="descending"/>
> <xsl:if test="position()=1">
> <xsl:copy-of select="."/>
> </xsl:if>
> </xsl:for-each>
> </xsl:variable>
> <xsl:value-of select="$max"/>
> </xsl:template>
>
>
> -Jeff
>
>
> -----Original Message-----
> From: Charly [mailto:cohana@xxxxxxxxxxxxxxx]
> Sent: Monday, December 10, 2001 7:41 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] max value
>
>
> 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>
>
>
> Please help
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>


 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
  • RE: [xsl] max value, (continued)
    • Mark Miller - Tue, 11 Dec 2001 08:20:08 -0800 (PST)
      • Charly - Tue, 11 Dec 2001 16:36:48 -0800
        • Mike Brown - Tue, 11 Dec 2001 19:04:43 -0700 (MST)
        • Charly - Wed, 12 Dec 2001 09:43:21 -0800
    • Jeff Beadle - Tue, 11 Dec 2001 11:27:29 -0500 <=