Numeric Functions
abs
abs($arg as numeric) as numeric
Returns the absolute value of $arg.
abs(-5) → 5avg
avg($arg as xs:anyAtomicType*) as xs:anyAtomicType?
Returns the average of the values in $arg.
avg((1, 2, 3, 4)) → 2.5ceiling
ceiling($arg as numeric) as numeric
Returns the smallest integer greater than or equal to $arg.
ceiling(3.2) → 4floor
floor($arg as numeric) as numeric
Returns the largest integer less than or equal to $arg.
floor(3.8) → 3max
max($arg as xs:anyAtomicType*) as xs:anyAtomicType?
Returns the maximum value from a sequence.
max((1, 5, 3)) → 5min
min($arg as xs:anyAtomicType*) as xs:anyAtomicType?
Returns the minimum value from a sequence.
min((1, 5, 3)) → 1number
number($arg as xs:anyAtomicType?) as xs:double
Converts the argument to a double.
round
round($arg as numeric?) as numeric?
Rounds to the nearest integer (0.5 rounds up).
round(2.5) → 3round-half-to-even
round-half-to-even($arg as numeric?) as numeric?
round-half-to-even($arg as numeric?, $precision as xs:integer) as numeric?
Rounds to the given precision using banker’s rounding (half-to-even).
round-half-to-even(2.5) → 2
round-half-to-even(3.5) → 4sum
sum($arg as xs:anyAtomicType*) as xs:anyAtomicType
Returns the sum of the values in $arg.
sum((1, 2, 3)) → 6format-number
format-number($value as numeric, $picture as xs:string) as xs:string
format-number($value as numeric, $picture as xs:string, $name as xs:string) as xs:string
Formats a number as a string according to the picture string. Supports named decimal formats (via DecimalFormat) with configurable decimal separator, grouping separator, percent, per-mille, zero digit, exponent separator, infinity, and NaN strings. The optional third argument names a decimal format defined in the stylesheet. Digit families (e.g. using non-ASCII zero digits) and exponent patterns (e.g. 0.00e0) are supported.
format-number(1234.5, '#,##0.00') → "1,234.50"
format-number(0.5, '00%') → "50%"format-integer
format-integer($value as xs:integer, $picture as xs:string) as xs:string
format-integer($value as xs:integer, $picture as xs:string, $lang as xs:string) as xs:string
Formats an integer according to the picture string. Supports word formatting (w for lower case, W for upper case, Ww for title case), Roman numerals (i / I), alphabetic numbering (a / A), and ordinal modifiers (;o suffix). Digit families from other scripts are detected automatically.
format-integer(42, 'w') → "forty-two"
format-integer(42, 'W') → "FORTY-TWO"
format-integer(42, 'Ww') → "Forty-Two"
format-integer(3, 'i') → "iii"
format-integer(3, 'I') → "III"
format-integer(1, '1;o') → "1st"
format-integer(2, '1;o') → "2nd"