EXSLT - math:min

Implementer Page: math.min.html
Function Package: math.min.zip

Function Syntax

number math:min(node-set)

Template Syntax

<xsl:call-template name="math:min">
   <xsl:with-param name="nodes" select="node-set" />
</xsl:call-template>

The math:min function returns the minimum value of the nodes passed as the argument. The minimum value is defined as follows. The node set passed as an argument is sorted in ascending order as it would be by xsl:sort with a data type of number. The minimum is the result of converting the string value of the first node in this sorted list to a number using the number function.

If the node set is empty, or if the result of converting the string values of any of the nodes to a number is NaN, then NaN is returned.

The math:min template returns a result tree fragment whose string value is the result of turning the number returned by the function into a string.

Implementations

The following XSLT processors support math:min:

Implementations of math:min are available in the following languages:

Examples

Function

The following example shows how to use the math:min function:

Source

<values>
   <value>7</value>
   <value>11</value>
   <value>8</value>
   <value>4</value>
</values>

Stylesheet

<xsl:template match="values">
   <result>
      <xsl:text>Minimum: </xsl:text>
      <xsl:value-of select="math:min(value)" />
   </result>
</xsl:template>

Result

<result>Minimum: 4</result>

Template

The following example shows how to use the math:min template:

Source

<values>
   <value>7</value>
   <value>11</value>
   <value>8</value>
   <value>4</value>
</values>

Stylesheet

<xsl:template match="values">
   <result>
      <xsl:text>Minimum: </xsl:text>
      <xsl:call-template name="math:min">
         <xsl:with-param name="nodes"
                         select="value" />
      </xsl:call-template>
   </result>
</xsl:template>

Result

<result>Minimum: 4</result>

http://www.exslt.org/math/functions/min/index.html last modified 2002-11-12