Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training,
learning paths, books, tutorials, and more.

Finding Minimums and Maximums

Problem

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

Solution

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

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