I needed to find the maximum attribute value using XPATH.  I found the solution here http://www.dpawson.co.uk/xsl/sect2/N5121.html but below is my sample.

Here is my test xml

<node value='1'/>
<node value='2'/>
<node value='3'/>
<node value='4'/>
<node value='2'/>
<node value='1'/>

Here is my xsl

<xsl:variable name="maxValue3">
 <xsl:for-each select="//node">
  <xsl:sort data-type="number" select="@value" order="descending"/>
  <xsl:if test="position()=1">
   <xsl:value-of select="@value"/>
maxValue3:<xsl:value-of select="$maxValue3"/>

Probably not the most efficient solution, but it works.


Print | posted on Thursday, April 9, 2009 12:00 PM