min
The minimum of a sequence of values
Description
The fn:min function finds the minimum of a sequence of values. The $arg sequence can only obtain values of one type, or a type derived from it. The one exception is that they can be all numeric, in which case numeric promotion rules apply. That type must be ordered; it must be possible to compare the values using the < and > operators.
The fn:min functions assumes untyped values are numeric unless they are explicitly cast to xs:string. To treat untyped data as strings, use the fn:string function as shown in the last example below.
Parameters |
Description |
---|---|
arg:integer() |
the sequence of values |
collation:string() |
the collation to use for comparing strings |
Examples
XPath |
Results |
---|---|
min( (2.0, 1, 3.5, 4) ) |
1 |
min( (‘a’, ‘b’, ‘c’) ) |
a |
min($ordDoc//item/@color) |
Error FORG0006, if color is untyped |
min($ordDoc//item//string(@color)) |
zero-length string |
min($ordDoc//item/@color/string(.)) |
beige |