math.max.template.xsl 722 B

12345678910111213141516171819202122
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet version="1.0"
  3. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  4. xmlns:math="http://www.exslt.org/math"
  5. exclude-result-prefixes="math">
  6. <xsl:template name="math:max">
  7. <xsl:param name="nodes" select="/.." />
  8. <xsl:choose>
  9. <xsl:when test="not($nodes)">NaN</xsl:when>
  10. <xsl:otherwise>
  11. <xsl:for-each select="$nodes">
  12. <xsl:sort data-type="number" order="descending" />
  13. <xsl:if test="position() = 1">
  14. <xsl:value-of select="number(.)" />
  15. </xsl:if>
  16. </xsl:for-each>
  17. </xsl:otherwise>
  18. </xsl:choose>
  19. </xsl:template>
  20. </xsl:stylesheet>