Please check the errata for any errors or issues reported since publication.
See also translations.
This document is also available in these non-normative formats: Specification in XML format and XML function catalog.
Copyright © 2000 W3C® (MIT, ERCIM, Keio, Beihang). W3C liability, trademark and document use rules apply.
This document defines constructor functions, operators, and functions on the datatypes defined in [XML Schema Part 2: Datatypes Second Edition] and the datatypes defined in [XQuery and XPath Data Model (XDM) 3.1]. It also defines functions and operators on nodes and node sequences as defined in the [XQuery and XPath Data Model (XDM) 3.1]. These functions and operators are defined for use in [XML Path Language (XPath) 4.0] and [XQuery 4.0: An XML Query Language] and [XSL Transformations (XSLT) Version 4.0] and other related XML standards. The signatures and summaries of functions defined in this document are available at: http://www.w3.org/2005/xpath-functions/.
A summary of changes since version 3.1 is provided at G Changes since version 3.1.
This version of the specification is work in progress. It is produced by the QT4 Working Group, officially the W3C XSLT 4.0 Extensions Community Group. Individual functions specified in the document may be at different stages of review, reflected in their History notes. Comments are invited, in the form of GitHub issues at https://github.com/qt4cg/qtspecs.
The publications of this community group are dedicated to our co-chair, Michael Sperberg-McQueen (1954–2024).
Maps were introduced as a new datatype in XDM 3.1. This section describes functions that operate on maps.
A map is a kind of item.
[Definition] A map consists of a sequence of entries, also known as key-value pairs. Each entry comprises a key which is an arbitrary atomic item, and an arbitrary sequence called the associated value.
[Definition] Within a map, no two entries have the same key. Two atomic items K1 and K2 are the same key for this purpose if the function call fn:atomic-equal($K1, $K2) returns true.
It is not necessary that all the keys in a map should be of the same type (for example, they can include a mixture of integers and strings).
Maps are immutable, and have no identity separate from their content. For example, the map:remove function returns a map that differs from the supplied map by the omission (typically) of one entry, but the supplied map is not changed by the operation. Two calls on map:remove with the same arguments return maps that are indistinguishable from each other; there is no way of asking whether these are “the same map”.
A map can also be viewed as a function from keys to associated values. To achieve this, a map is also a function item. The function corresponding to the map has the signature function($key as xs:anyAtomicValue) as item()*. Calling the function has the same effect as calling the map:get function: the expression $map($key) returns the same result as get($map, $key). For example, if $books-by-isbn is a map whose keys are ISBNs and whose assocated values are book elements, then the expression $books-by-isbn("0470192747") returns the book element with the given ISBN. The fact that a map is a function item allows it to be passed as an argument to higher-order functions that expect a function item as one of their arguments.
The functions defined in this section use a conventional namespace prefix map, which is assumed to be bound to the namespace URI http://www.w3.org/2005/xpath-functions/map.
The function call map:get($map, $key) can be used to retrieve the value associated with a given key.
There is no operation to atomize a map or convert it to a string. The function fn:serialize can in some cases be used to produce a JSON representation of a map.
| Function | Meaning |
|---|---|
map:build | Returns a map that typically contains one entry for each item in a supplied input sequence. |
map:contains | Tests whether a supplied map contains an entry for a given key. |
map:empty | Returns true if the supplied map contains no entries. |
map:entries | Returns a sequence containing all the key-value pairs present in a map, each represented as a single-entry map. |
map:entry | Returns a single-entry map that represents a single key-value pair. |
map:filter | Selects entries from a map, returning a new map. |
map:find | Searches the supplied input sequence and any contained maps and arrays for a map entry with the supplied key, and returns the corresponding values. |
map:for-each | Applies a supplied function to every entry in a map, returning the sequence concatenationXP of the results. |
map:get | Returns the value associated with a supplied key in a given map. |
map:items | Returns a sequence containing all the values present in a map, in order. |
map:keys | Returns a sequence containing all the keys present in a map. |
map:keys-where | Returns a sequence containing selected keys present in a map. |
map:merge | Returns a map that combines the entries from a number of existing maps. |
map:of-pairs | Returns a map that combines data from a sequence of key-value pair maps. |
map:pair | Returns a key-value pair map that represents a single key-value pair. |
map:pairs | Returns a sequence containing all the key-value pairs present in a map, each represented as a key-value pair map. |
map:put | Returns a map containing all the contents of the supplied map, but with an additional entry, which replaces any existing entry for the same key. |
map:remove | Returns a map containing all the entries from a supplied map, except those having a specified key. |
map:replace | Returns a map based on the contents of an existing map, computing a new value to be associated with a supplied key. |
map:size | Returns the number of entries in the supplied map. |
Returns a map based on the contents of an existing map, computing a new value to be associated with a supplied key.
map:replace( | ||
$map | as , | |
$key | as , | |
$action | as | |
) as | ||
This function is context-independent, and focus-independent.
If the supplied $map contains an existing entry for the supplied $key, then the returned map contains an entry for that $key whose value is obtained by applying the supplied $action to the existing value associated with that key.
Otherwise, the returned map contains an entry for the supplied $key whose value is obtained by applying the supplied $action to an empty sequence.
If there is an existing entry then the new entry replaces the old in its existing position; otherwise it goes at the end. The relative order of other entries in the map is retained.
The effect of the function is equivalent to the result of the following XPath expression.
if (map:contains($map, $key))
then map:put($map, $key, $action(map:get($map, $key)))
else map:put($map, $key, $action(()))| Expression: |
|
|---|---|
| Result: | { 1: "ALPHA", 2: "beta" } |
| Expression: |
|
| Result: | { 1: "alpha", 2: "beta", 3: "" } |
| Expression: | fold-left(
("a", "b", "c", "a"),
{},
fn($map, $key) {
map:replace($map, $key, fn($val) { ($val otherwise 0) + 1 })
}
) |
| Result: | { "a": 2, "b": 1, "c": 1 } |
Returns the number of entries in the supplied map.
map:size( | ||
$map | as | |
) as | ||
This function is deterministic, context-independent, and focus-independent.
The function map:size takes any map as its $map argument and returns the number of entries that are present in the map.
The effect of the function is equivalent to the result of the following XPath expression.
count(map:entries($map))
| Expression | Result |
|---|---|
| 0 |
| 2 |
Arrays were introduced as a new datatype in XDM 3.1. This section describes functions that operate on arrays.
An array is an additional kind of item. An array of size N is a mapping from the integers (1 to N) to a set of values, called the members of the array, each of which is an arbitrary sequence. Because an array is an item, and therefore a sequence, arrays can be nested.
An array acts as a function from integer positions to associated values, so the function call $array($index) can be used to retrieve the array member at a given position. The function corresponding to the array has the signature function($index as xs:integer) as item()*. The fact that an array is a function item allows it to be passed as an argument to higher-order functions that expect a function item as one of their arguments.
The functions defined in this section use a conventional namespace prefix array, which is assumed to be bound to the namespace URI http://www.w3.org/2005/xpath-functions/array.
As with all other values, arrays are treated as immutable. For example, the array:reverse function returns an array that differs from the supplied array in the order of its members, but the supplied array is not changed by the operation. Two calls on array:reverse with the same argument will return arrays that are indistinguishable from each other; there is no way of asking whether these are “the same array”. Like sequences, arrays have no identity.
All functionality on arrays is defined in terms of two primitives:
The function array:members decomposes an array to a sequence of value records.
The function array:of-members composes an array from a sequence of value records.
A value record here is an item that encapsulates an arbitrary value; the representation chosen for a value record is record(value as item()*), that is, a map containing a single entry whose key is the string "value" and whose value is the encapsulated sequence.
| Function | Meaning |
|---|---|
array:append | Returns an array containing all the members of a supplied array, plus one additional member at the end. |
array:build | Returns an array obtained by evaluating the supplied function once for each item in the input sequence. |
array:empty | Returns true if the supplied array contains no members. |
array:filter | Returns an array containing those members of the $array for which $predicate returns true. A return value of () is treated as false. |
array:flatten | Replaces any array appearing in a supplied sequence with the members of the array, recursively. |
array:fold-left | Evaluates the supplied function cumulatively on successive members of the supplied array. |
array:fold-right | Evaluates the supplied function cumulatively on successive values of the supplied array. |
array:foot | Returns the last member of an array. |
array:for-each | Returns an array whose size is the same as array:size($array), in which each member is computed by applying $action to the corresponding member of $array. |
array:for-each-pair | Returns an array obtained by evaluating the supplied function once for each pair of members at the same position in the two supplied arrays. |
array:get | Returns the value at the specified position in the supplied array (counting from 1). |
array:head | Returns the first member of an array, that is $array(1). |
array:index-of | Returns a sequence of positive integers giving the positions within the array $array of members that are equal to $target. |
array:index-where | Returns the positions in an input array of members that match a supplied predicate. |
array:insert-before | Returns an array containing all the members of the supplied array, with one additional member at a specified position. |
array:items | Returns the sequence concatenation of the members of an array. |
array:join | Concatenates the contents of several arrays into a single array, with an optional separator between adjacent members. |
array:members | Delivers the contents of an array as a sequence of value records. |
array:of-members | Constructs an array from the contents of a sequence of value records. |
array:put | Returns an array containing all the members of a supplied array, except for one member which is replaced with a new value. |
array:remove | Returns an array containing all the members of the supplied array, except for the members at specified positions. |
array:replace | Returns an array containing all the members of a supplied array, except for one member which is replaced with a new value, the new value being computed from the previous value. |
array:reverse | Returns an array containing all the members of a supplied array, but in reverse order. |
array:size | Returns the number of members in the supplied array. |
array:slice | Returns an array containing selected members of a supplied input array based on their position. |
array:sort | Sorts a supplied array, based on the value of a number of sort keys supplied as functions. |
array:split | Delivers the contents of an array as a sequence of single-member arrays. |
array:subarray | Returns an array containing all members from a supplied array starting at a supplied position, up to a specified length. |
array:tail | Returns an array containing all members except the first from a supplied array. |
array:trunk | Returns an array containing all members except the last from a supplied array. |
Returns an array containing all the members of a supplied array, except for one member which is replaced with a new value, the new value being computed from the previous value.
array:replace( | ||
$array | as , | |
$position | as , | |
$action | as | |
) as | ||
This function is deterministic, context-independent, and focus-independent.
Informally, the result is an array whose size is array:size($array), in which all members in positions other than $position are the same as the members in the corresponding position of $array, and the member in position $position is the result of applying the $action function to the original value in that position.
The effect of the function is equivalent to the result of the following XPath expression.
$array
=> array:remove($position)
=> array:insert-before($position, $action(array:get($array, $position)))A dynamic error occurs [err:FOAY0001] if $position is not in the range 1 to array:size($array) inclusive.
This error will always occur if $array is empty.
| Expression | Result |
|---|---|
array:replace(
[ 10, 11, 12 ],
2,
fn { . + 10 }
) | [ 10, 21, 12 ] |
array:replace(
[ "a", "b", "c" ],
2,
concat(?, "x")
) | [ "a", "bx", "c" ] |
array:replace(
[ ("a", "b"), ("c", "d") ],
2,
reverse#1
) | [ ("a", "b"), ("d", "c") ] |
Returns an array containing all the members of a supplied array, but in reverse order.
array:reverse( | ||
$array | as | |
) as | ||
This function is deterministic, context-independent, and focus-independent.
The function returns an array with the same number of members as $array, but in reverse order.
The effect of the function is equivalent to the result of the following XPath expression.
$array => array:members() => reverse() => array:of-members()
| Expression | Result |
|---|---|
| [ "d", "c", "b", "a" ] |
| [ ("c", "d"), ("a", "b") ] |
| [ (1, 2, 3, 4, 5) ] |
| [] |
Returns the number of members in the supplied array.
array:size( | ||
$array | as | |
) as | ||
This function is deterministic, context-independent, and focus-independent.
The function returns the number of members in the array.
The effect of the function is equivalent to the result of the following XPath expression.
count(array:members($array))
Note that because an array is an item, the fn:count function when applied to an array always returns 1.
| Expression | Result |
|---|---|
| 3 |
| 2 |
| 0 |
| 1 |
Returns an array containing selected members of a supplied input array based on their position.
array:slice( | ||
$array | as , | |
$start | as | := (), |
$end | as | := (), |
$step | as | := () |
) as | ||
This function is deterministic, context-independent, and focus-independent.
Informally, the array is converted to a sequence, the function fn:slice is applied to this sequence, and the resulting sequence is converted back to an array.
The effect of the function is equivalent to the result of the following XPath expression.
$array => array:members() => slice($start, $end, $step) => array:of-members()
Note that unlike other operations on arrays, there are no out-of-bounds errors for inappropriate values of $start, $end, or $step.
| Variables | |
|---|---|
let $in := [ 'a', 'b', 'c', 'd', 'e' ] | |
| Expression | Result |
|---|---|
| [ "b", "c", "d" ] |
| [ "b", "c", "d", "e" ] |
| [ "a", "b" ] |
| [ "c" ] |
| [ "d", "c" ] |
| [ "b", "d" ] |
| [ "e", "c" ] |
| [] |
| [] |
| [ "a", "b", "c", "d", "e" ] |
| [ "e" ] |
| [ "c", "d", "e" ] |
| [ "a", "b", "c", "d" ] |
| [ "b", "c", "d" ] |
| [ "d", "c", "b" ] |
| [ "b", "c", "d" ] |
| [ "d", "c", "b" ] |
| [ "b", "d" ] |
| [ "d", "b" ] |
| [ "a", "b", "c", "d" ] |
Sorts a supplied array, based on the value of a number of sort keys supplied as functions.
array:sort( | ||
$array | as , | |
$collations | as | := fn:default-collation(), |
$keys | as | := fn:data#1, |
$orders | as | := 'ascending' |
) as | ||
This function is deterministic, context-dependent, and focus-independent. It depends on collations.
The result of the function is an array that contains all the members from $input, typically in a different order, the order being defined by the supplied sort key definitions.
A sort key definition has three parts:
A sort key function, which is applied to each member in the input array to determine a sort key value.
A collation, which is used when comparing sort key values that are of type xs:string or xs:untypedAtomic.
An order direction, which is ascending or descending.
The number of sort key definitions is determined by the number of function items supplied in the $keys argument. If the argument is absent or empty, the default is a single sort key definition using the function data#1.
The $nth sort key definition (where $n counts from one (1)) is established as follows:
The sort key function is $keys[$n] otherwise data#1.
The collation is $collations[$n] otherwise $collations[last()] otherwise default-collation(). That is, it is the collation supplied in the corresponding item of the supplied $collations argument; or in its absence, the last entry in $collations; or if $collations is absent or empty, the default collation from the static context of the caller.
The order direction is $orders[$n] otherwise $orders[last()] otherwise "ascending". That is, it is "ascending" or "descending" according to the value of the corresponding item in the supplied $orders argument; or in its absence, the last entry in $orders; or if $orders is absent or empty, then "ascending".
When comparing values of types other than xs:string or xs:untypedAtomic, the corresponding collation is ignored, and no error is reported if the supplied value is not a known or valid collation name. If it is necessary to supply such an ignored value (for example, in the case where a non-string sort key is followed by another sort key that requires a collation) the empty string can be supplied.
The result of the function is defined by reference to the fn:sort function.
The effect of the function is equivalent to the result of the following XPath expression.
$array
=> array:members()
=> sort(
$collations,
for $key in ($keys otherwise data#1)
return fn($member as record(value)) as xs:anyAtomicType* {
$key($member?value)
},
$orders
)
=> array:of-members()If the set of computed sort keys contains values that are not comparable using the lt operator then the sort operation will fail with a type error ([err:XPTY0004]XP).
| Expression: |
|
|---|---|
| Result: | [ 1, 3, 4, 5, 6 ] |
| Expression: |
|
| Result: | [ 6, 5, 4, 4e0, 3, 1 ] |
| Expression: |
|
| Result: | [ 1, -2, 5, 8, 10, -10, 10 ] |
| Expression: |
|
| Result: | [ [ 1, "e" ], [ 1, "f" ], [ 2, "g" ], [ 2, "i" ] ] |
| Expression: | array:sort(
[ [ 2, "i" ], [ 1, "e" ], [ 2, "g" ], [ 1, "f" ] ],
(),
(array:get(?, 1), array:get(?, 2)),
("ascending", "descending")
) |
| Result: | [ [ 1, "f" ], [ 1, "e" ], [ 2, "i" ], [ 2, "g" ]] |
To sort an array of strings | |
let $SWEDISH := collation({ 'lang': 'se' })
return array:sort($in, $SWEDISH) | |
To sort an array of maps representing employees, using last name as the major sort key and first name as the minor sort key, with the default collation: | |
array:sort($employees, (), fn($emp) { $emp?name?last, $emp?name?first }) | |
Delivers the contents of an array as a sequence of single-member arrays.
array:split( | ||
$array | as | |
) as | ||
This function is deterministic, context-independent, and focus-independent.
The members of the array are delivered as a sequence of single-member arraysDM. Each returned array encapsulates the value of one member of $array.
The effect of the function is equivalent to the result of the following XPath expression.
array:for-each($array, fn($member) { [] => array:append($member) })
=> array:items()The function call array:split($array) produces the same result as the expression for member $m in $array return [ $m ].
This function is the inverse of array:join.
| Expression: |
|
|---|---|
| Result: | () |
| Expression: |
|
| Result: | [ () ] |
| Expression: |
|
| Result: | [ (1, 2, 3, 4, 5) ] |
| Expression: | array:split(
array { 1 to 5 }
) |
| Result: | [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ] |
| Expression: | array:split( [ (1, 1), (2, 4), (3, 9), (4, 16), (5, 25) ] ) ! sum(.) |
| Result: | 2, 6, 12, 20, 30 |
| Expression: | let $array := [ "any array" ] return deep-equal( $array, array:join(array:split($array)) ) |
| Result: | true() |
Supplying an empty sequence as the value of an optional argument is equivalent to omitting the argument.
Returns an array containing all members from a supplied array starting at a supplied position, up to a specified length.
array:subarray( | ||
$array | as , | |
$start | as , | |
$length | as | := () |
) as | ||
This function is deterministic, context-independent, and focus-independent.
Except in error cases, the two-argument version of the function returns the same result as the three-argument version when called with $length equal to the value of array:size($array) - $start + 1.
Setting the third argument to the empty sequence has the same effect as omitting the argument.
The effect of the function is equivalent to the result of the following XPath expression, except in error cases.
$array => array:members() => subsequence($start, $length) => array:of-members()
A dynamic error is raised [err:FOAY0001] if $start is less than one or greater than array:size($array) + 1.
For the three-argument version of the function:
A dynamic error is raised [err:FOAY0002] if $length is less than zero.
A dynamic error is raised [err:FOAY0001] if $start + $length is greater than array:size($array) + 1.
The value of $start can be equal to array:size($array) + 1 provided that $length is either equal to zero or omitted. In this case the result will be an empty array.
| Expression | Result |
|---|---|
| [ "b", "c", "d" ] |
| [] |
| [] |
| [ "b" ] |
| [ "b", "c" ] |
| [] |
| [] |
Returns an array containing all members except the first from a supplied array.
array:tail( | ||
$array | as | |
) as | ||
This function is deterministic, context-independent, and focus-independent.
The function returns an array containing all members of the supplied array except the first.
The effect of the function is equivalent to the result of the following XPath expression.
array:remove($array, 1)
A dynamic error occurs [err:FOAY0001] if $array is empty.
If the supplied array contains exactly one member, the result will be an empty array.
| Expression | Result |
|---|---|
| [ 6, 7, 8 ] |
| [] |
Returns an array containing all members except the last from a supplied array.
array:trunk( | ||
$array | as | |
) as | ||
This function is deterministic, context-independent, and focus-independent.
The function returns an array containing all members of the supplied array except the last.
The effect of the function is equivalent to the result of the following XPath expression.
array:remove($array, array:size($array))
A dynamic error occurs [err:FOAY0001] if $array is empty.
If the supplied array contains exactly one member, the result will be an empty array.
| Expression | Result |
|---|---|
| [ 5, 6, 7 ] |
| [] |
Use the arrows to browse significant changes since the 3.1 version of this specification.
See 1 Introduction
Sections with significant changes are marked Δ in the table of contents. New functions introduced in this version are marked ➕ in the table of contents.
See 1 Introduction
PR 1547 1551
New in 4.0
PR 629 803
New in 4.0
See 3.2.2 fn:message
PR 1260 1275
A third argument has been added, providing control over the rounding mode.
See 4.4.4 fn:round
New in 4.0
See 4.4.7 fn:is-NaN
PR 1049 1151
Decimal format parameters can now be supplied directly as a map in the third argument, rather than referencing a format defined in the static context.
PR 1205 1230
New in 4.0
See 4.8.2 math:e
See 4.8.16 math:sinh
See 4.8.17 math:cosh
See 4.8.18 math:tanh
The 3.1 specification suggested that every value in the result range should have the same chance of being chosen. This has been corrected to say that the distribution should be arithmetically uniform (because there are as many xs:double values between 0.01 and 0.1 as there are between 0.1 and 1.0).
PR 261 306 993
New in 4.0
See 5.4.1 fn:char
New in 4.0
PR 937 995 1190
New in 4.0
See 5.4.13 fn:hash
The $action argument is new in 4.0.
See 5.6.4 fn:replace
New in 4.0
PR 1423 1413
New in 4.0
New in 4.0
Reformulated in 4.0 in terms of the new fn:in-scope-namespaces function; the semantics are unchanged.
Reformulated in 4.0 in terms of the new fn:in-scope-namespaces function; the semantics are unchanged.
New in 4.0
New in 4.0
See 13.1.12 fn:slice
New in 4.0. The function is identical to the internal op:same-key function in 3.1
PR 1120 1150
A callback function can be supplied for comparing individual items.
Changed in 4.0 to use transitive equality comparisons for numeric values.
New in 4.0. Originally proposed under the name fn:uniform
New in 4.0. Originally proposed under the name fn:unique
PR 1117 1279
The $options parameter has been added.
A new function is available for processing input data in HTML format.
PR 259 956
New in 4.0
An option is provided to control how JSON numbers should be formatted.
Additional options are available, as defined by fn:parse-json.
New in 4.0
New in 4.0
New in 4.0
New in 4.0
See 16.2.4 fn:every
New in 4.0
New in 4.0
New in 4.0
New in 4.0
New in 4.0
See 16.2.16 fn:some
PR 521 761
New in 4.0
New in 4.0
A third argument is added, allowing user control of how absent keys should be handled.
See 17.4.9 map:get
New in 4.0
PR 478 515
New in 4.0
New in 4.0
New in 4.0
See 17.4.15 map:pair
New in 4.0
New in 4.0
New in 4.0.
New in 4.0
A third argument is added, allowing user control of how index-out-of-bounds conditions should be handled.
PR 968 1295
New in 4.0
PR 476 1087
New in 4.0
PR 360 476
New in 4.0
New in 4.0
New in 4.0
New in 4.0
New in 4.0
Supplying an empty sequence as the value of an optional argument is equivalent to omitting the argument.
New functions are provided to obtain information about built-in types and types defined in an imported schema.
Options are added to customize the form of the output.
See 2.2.6 fn:path
PR 533 719 834
New functions are available for processing input data in CSV (comma separated values) format.
PR 734 1233
New in 4.0
See 16.2.2 fn:chain
A new function fn:elements-to-maps is provided for converting XDM trees to maps suitable for serialization as JSON. Unlike the fn:xml-to-json function retained from 3.1, this can handle arbitrary XML as input.
New in 4.0
New in 4.0.
The default for the escape option has been changed to false. The 3.1 specification gave the default value as true, but this appears to have been an error, since it was inconsistent with examples given in the specification and with tests in the test suite.
The spec has been corrected to note that the function depends on the implicit timezone.
In 3.1, given a mixed input sequence such as (1, 3, 4.2e0), the specification was unclear whether it was permitted to add the first two integer items using integer arithmetic, rather than converting all items to doubles before performing any arithmetic. The 4.0 specification is clear that this is permitted; but since the items can be reordered before being added, this is not required.
See 13.4.2 fn:avg
See 13.4.5 fn:sum
It is explicitly stated that the limits for $precision are implementation-defined.
See 4.4.4 fn:round
For consistency with the new functions map:build and map:of-pairs, the handling of duplicates may now be controlled by the combine option as an alternative to the existing duplicates option.
PR 173
New in 4.0
See 16.3.4 fn:op
PR 203
New in 4.0
See 17.4.1 map:build
PR 207
New in 4.0
PR 222
New in 4.0
See 13.2.7 fn:starts-with-subsequence
PR 250
New in 4.0
See 13.1.3 fn:foot
See 13.1.15 fn:trunk
PR 258
New in 4.0
PR 313
The second argument can now be a sequence of integers.
See 13.1.8 fn:remove
PR 314
New in 4.0
PR 326
Higher-order functions are no longer an optional feature.
See 1.2 Conformance
PR 419
New in 4.0
PR 434
New in 4.0
The function has been extended to allow output in a radix other than 10, for example in hexadecimal.
PR 482
Deleted an inaccurate statement concerning the behavior of NaN.
PR 507
New in 4.0
PR 546
The rules regarding use of non-XML characters in JSON texts have been relaxed.
PR 614
New in 4.0
PR 623
Substantially revised to allow multiple sort key definitions.
See 16.2.17 fn:sort
PR 631
New in 4.0
PR 662
Constructor functions now have a zero-arity form; the first argument defaults to the context item.
PR 680
The case-insensitive collation is now defined normatively within this specification, rather than by reference to the HTML "living specification", which is subject to change. The collation can now be used for ordering comparisons as well as equality comparisons.
PR 702
The function can now take any number of arguments (previously it had to be two or more), and the arguments can be sequences of strings rather than single strings.
See 5.4.4 fn:concat
PR 710
Changes the function to return a sequence of key-value pairs rather than a map.
PR 727
It has been clarified that loading a module has no effect on the static or dynamic context of the caller.
PR 795
New in 4.0
PR 828
The $predicate callback function accepts an optional position argument.
See 16.2.5 fn:filter
The $action callback function accepts an optional position argument.
The $predicate callback function now accepts an optional position argument.
The $action callback function now accepts an optional position argument.
PR 881
The way that fn:min and fn:max compare numeric values of different types has changed. The most noticeable effect is that when these functions are applied to a sequence of xs:integer or xs:decimal values, the result is an xs:integer or xs:decimal, rather than the result of converting this to an xs:double
See 13.4.3 fn:max
See 13.4.4 fn:min
PR 901
All three arguments are now optional, and each argument can be set to an empty sequence. Previously if $description was supplied, it could not be empty.
See 3.1.1 fn:error
The $label argument can now be set to an empty sequence. Previously if $label was supplied, it could not be empty.
See 3.2.1 fn:trace
The third argument can now be supplied as an empty sequence.
The second argument can now be an empty sequence.
The optional second argument can now be supplied as an empty sequence.
The 3rd, 4th, and 5th arguments are now optional; previously the function required either 2 or 5 arguments.
The optional third argument can now be supplied as an empty sequence.
PR 905
The rule that multiple calls on fn:doc supplying the same absolute URI must return the same document node has been clarified; in particular the rule does not apply if the dynamic context for the two calls requires different processing of the documents (such as schema validation or whitespace stripping).
See 13.6.1 fn:doc
PR 909
The function has been expanded in scope to handle comparison of values other than strings.
PR 924
Rules have been added clarifying that users should not be allowed to change the schema for the fn namespace.
See C Schemas
PR 925
The decimal format name can now be supplied as a value of type xs:QName, as an alternative to supplying a lexical QName as an instance of xs:string.
PR 932
The specification now prescribes a minimum precision and range for durations.
PR 933
When comments and processing instructions are ignored, any text nodes either side of the comment or processing instruction are now merged prior to comparison.
PR 940
New in 4.0
PR 953
Constructor functions for named record types have been introduced.
PR 962
New in 4.0
PR 969
New in 4.0
See 17.4.3 map:empty
PR 984
New in 4.0
See 8.4.1 fn:seconds
PR 987
The order of results is now prescribed; it was previously implementation-dependent.
PR 988
New in 4.0
See 14.3.8 fn:pin
See 14.3.9 fn:label
PR 1022
Regular expressions can include comments (starting and ending with #) if the c flag is set.
See 5.6.1 Regular expression syntax
See 5.6.2 Flags
PR 1028
An option is provided to control how the JSON null value should be handled.
PR 1032
New in 4.0
See 13.1.17 fn:void
PR 1046
New in 4.0
PR 1059
Use of an option keyword that is not defined in the specification and is not known to the implementation now results in a dynamic error; previously it was ignored.
See 1.7 Options
PR 1068
New in 4.0
PR 1072
The return type is now specified more precisely.
PR 1090
When casting from a string to a duration or time or dateTime, it is now specified that when there are more digits in the fractional seconds than the implementation is able to retain, excess digits are truncated. Rounding upwards (which could affect the number of minutes or hours in the value) is not permitted.
PR 1093
New in 4.0
PR 1117
The $options parameter has been added.
PR 1182
The $predicate callback function may return an empty sequence (meaning false).
See 16.2.4 fn:every
See 16.2.5 fn:filter
See 16.2.16 fn:some
PR 1191
New in 4.0
See 2.3.1 fn:distinct-ordered-nodes
The $options parameter has been added, absorbing the $collation parameter.
PR 1250
For selected properties including percent and exponent-separator, it is now possible to specify a single-character marker to be used in the picture string, together with a multi-character rendition to be used in the formatted output.
PR 1257
The $options parameter has been added.
PR 1262
New in 4.0
PR 1265
The constraints on the result of the function have been relaxed.
PR 1280
As a result of changes to the coercion rules, the number of supplied arguments can be greater than the number required: extra arguments are ignored.
See 16.2.1 fn:apply
PR 1288
Additional error conditions have been defined.
PR 1296
New in 4.0
PR 1333
A new option is provided to allow the content of the loaded module to be supplied as a string.
PR 1353
An option has been added to suppress the escaping of the solidus (forwards slash) character.
PR 1358
New in 4.0
PR 1361
The term atomic value has been replaced by atomic item.
See 1.9 Terminology
PR 1393
Changes the function to return a sequence of key-value pairs rather than a map.
PR 1409
This section now uses the term primitive type strictly to refer to the 20 atomic types that are not derived by restriction from another atomic type: that is, the 19 primitive atomic types defined in XSD, plus xs:untypedAtomic. The three types xs:integer, xs:dayTimeDuration, and xs:yearMonthDuration, which have custom casting rules but are not strictly-speaking primitive, are now handled in other subsections.
See 21.1 Casting from primitive types to primitive types
The rules for conversion of dates and times to strings are now defined entirely in terms of XSD 1.1 canonical mappings, since these deliver exactly the same result as the XPath 3.1 rules.
See 21.1.2.2 Casting date/time values to xs:string
The rules for conversion of durations to strings are now defined entirely in terms of XSD 1.1 canonical mappings, since the XSD 1.1 rules deliver exactly the same result as the XPath 3.1 rules.
PR 1455
Numbers now retain their original lexical form, except for any changes needed to satisfy JSON syntax rules (for example, stripping leading zero digits).
PR 1481
The function has been extended to handle other Gregorian types such as xs:gYearMonth.
See 9.5.1 fn:year-from-dateTime
See 9.5.2 fn:month-from-dateTime
The function has been extended to handle other Gregorian types such as xs:gMonthDay.
See 9.5.3 fn:day-from-dateTime
The function has been extended to handle other types including xs:time.
See 9.5.4 fn:hours-from-dateTime
See 9.5.5 fn:minutes-from-dateTime
The function has been extended to handle other types such as xs:gYearMonth.
PR 1504
New in 4.0
Optional $separator added.
PR 1523
New in 4.0
PR 1545
New in 4.0
PR 1570
New in 4.0
PR 1703
The order of entries in maps is retained.
Ordered maps are introduced.
Enhanced to allow for ordered maps.
See 17.4.7 map:find
See 17.4.17 map:put