saxon:lowest($input as item()*) => item()*
saxon:lowest($input as item()*, $key as function()) => item()?
This function returns the item or items from the input sequence that have the lowest value for the function $key
.
If the second argument is omitted, it defaults to the function fn:data#1
, that is, it atomizes the item from the
input sequence.
In XQuery 1.1, the function may be obtained in a variety of ways. In other environments, it may be obtained by calling the saxon:function() extension function.
The $key
function is evaluated for each item in $input
in turn, with that item supplied
as the parameter to the function. Any NaN values are ignored. If the input sequence is empty, the result
is an empty sequence. If several items have the lowest value, the result sequence contains them all.
Example: saxon:lowest(sale, function($x){$x/@price * $x/@qty'}) will evaluate price times
quantity for each child <sale>
element, and return the element or elements for which this has the lowest
value.