RE: [xsl] The best way of getting the largest value

Subject: RE: [xsl] The best way of getting the largest value
From: "Kaine Varley" <kaine.varley@xxxxxxxxxxxxxxxxxx>
Date: Fri, 2 May 2003 15:51:50 +0100
Craig, thanks for the reference
(http://www.exslt.org/math/functions/max/index.html), although I was
disappointed to see that MSXML parser does support the math:max
function, but the following template I found there does the trick:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                xmlns:math="http://www.exslt.org/math";
                exclude-result-prefixes="math">

<xsl:template name="math:max">
   <xsl:param name="nodes" select="/.." />
   <xsl:choose>
      <xsl:when test="not($nodes)">NaN</xsl:when>
      <xsl:otherwise>
         <xsl:for-each select="$nodes">
            <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:template>

</xsl:stylesheet> 


Kaine



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread