Loading TOC...


   $arg as Sequence | Array,
   [$collation as String]
) as xs.anyAtomicType?


Selects an item from the input sequence $arg whose value is less than or equal to the value of every other item in the input sequence. If there are two or more such items, then the specific item whose value is returned is implementation dependent.

The following rules are applied to the input sequence:

The items in the resulting sequence may be reordered in an arbitrary order. The resulting sequence is referred to below as the converted sequence.This function returns an item from the converted sequence rather than the input sequence.

If the converted sequence is empty, the empty sequence is returned.

All items in $arg must be numeric or derived from a single base type for which the le operator is defined. In addition, the values in the sequence must have a total order. If date/time values do not have a timezone, they are considered to have the implicit timezone provided by the dynamic context for purposes of comparison. Duration values must either all be xs:yearMonthDuration values or must all be xs:dayTimeDuration values.

If any of these conditions is not met, then a type error is raised [err:FORG0006].

If the converted sequence contains the value NaN, the value NaN is returned.

If the items in the value of $arg are of type xs:string or types derived by restriction from xs:string, then the determination of the item with the largest value is made according to the collation that is used. If the type of the items in $arg is not xs:string and $collation is specified, the collation is ignored.

The collation used by the invocation of this function is determined according to the rules in 7.3.1 Collations.

Otherwise, the result of the function is the result of the expression:

   if (every $v in $c satisfies $c[1] le $v)
   then $c[1]
   else fn:min(fn:subsequence($c, 2))

evaluated with $collation as the default collation if specified, and with $c as the converted sequence.

For detailed type semantics, see Section 7.2.10 The fn:min, fn:max, fn:avg, and fn:sum functions[FS].


If the converted sequence contains exactly one value then that value is returned.

The default type when the fn:min function is applied to xs:untypedAtomic values is xs:double. This differs from the default type for operators such as gt, and for sorting in XQuery and XSLT, which is xs:string.

$arg The sequence of values whose minimum will be returned.
$collation The optional name of a valid collation URI. For information on the collation URI syntax, see the Search Developer's Guide.


fn.min([2, 7]);
=> 2

fn.min([fn.currentDate(), xs.date("2001-01-01")]);

fn.min(["a", "b", "c"]);


    Powered by MarkLogic Server 7.0-4.1 and rundmc | Terms of Use | Privacy Policy