math.lowest.function.xsl 1023 B

1234567891011121314151617181920212223242526272829
  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://exslt.org/math"
  5. xmlns:exsl="http://exslt.org/functions"
  6. extension-element-prefixes="exsl"
  7. exclude-result-prefixes="math">
  8. <exsl:function name="math:lowest">
  9. <xsl:param name="nodes" select="/.." />
  10. <xsl:choose>
  11. <xsl:when test="$nodes and not($nodes[number(.) != number(.)])">
  12. <xsl:variable name="min">
  13. <xsl:for-each select="$nodes">
  14. <xsl:sort data-type="number" />
  15. <xsl:if test="position() = 1">
  16. <xsl:value-of select="number(.)" />
  17. </xsl:if>
  18. </xsl:for-each>
  19. </xsl:variable>
  20. <exsl:return select="$nodes[. = $min]" />
  21. </xsl:when>
  22. <xsl:otherwise>
  23. <exsl:return select="/.." />
  24. </xsl:otherwise>
  25. </xsl:choose>
  26. </exsl:function>
  27. </xsl:stylesheet>