2006-10-03

Finding Extreme Values in XSLT

Here's a neat trick to find the maximum value for an element using XSLT:

<xsl:variable name="max-date">
  <xsl:for-each select="/jira-work-activity/entry/date">
    <xsl:sort order="descending"/>
    <xsl:if test="position()=1"><xsl:value-of select="."/></xsl:if>
  </xsl:for-each>
</xsl:variable>