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]
Other format: [Raw text]

RE: 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@investacorp.com]
Sent: Monday, December 10, 2001 7:41 PM
To: xsl-list@lists.mulberrytech.com
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


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