You need to find the minimum (or maximum) numerical node (or nodes) in a node set.

The EXSLT functions that perform these operations are
`math:min`

, `math:max`

,
`math:lowest`

, and `math:highest`

.
`min`

and
`max`

find the value of the node with minimum and
maximum numerical value, respectively. EXSLT defines
`math:min`

as follows:

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:sortwith 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 thenumberfunction.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.

`math:max`

is defined similarly. EXSLT provides pure
XSLT implementations that are literal implementations of this
definition, as shown in Example 2-9.

Example 2-9. EXSLT min and max implement directly from the definition

<xsl:template name="math:min"> <xsl:param name="nodes" select="/.." /> <xsl:choose> <xsl:when test="not($nodes)">NaN</xsl:when> <xsl:otherwise> <xsl:for-each select="$nodes"> <xsl:sort data-type="number" /> <xsl:if test="position( ) = 1"> <xsl:value-of select="number(.)" /> </xsl:if> </xsl:for-each> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="math:max"> <xsl:param name="nodes" select="/.." /> <xsl:choose> <xsl:when test="not($nodes)">NaN</xsl:when> <xsl:otherwise> ...

Start Free Trial

No credit card required