math.highest.template.xsl 779 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:highest">
  7. <xsl:param name="nodes" select="/.." />
  8. <xsl:if test="$nodes and not($nodes[number(.) != number(.)])">
  9. <xsl:variable name="max">
  10. <xsl:for-each select="$nodes">
  11. <xsl:sort data-type="number" order="descending" />
  12. <xsl:if test="position() = 1">
  13. <xsl:value-of select="number(.)" />
  14. </xsl:if>
  15. </xsl:for-each>
  16. </xsl:variable>
  17. <xsl:copy-of select="$nodes[. = $max]" />
  18. </xsl:if>
  19. </xsl:template>
  20. </xsl:stylesheet>