Creates a new map that combines entries from a number of existing maps. There is one
entry in the new map for each distinct key present in the union of the input maps;
the way duplicate keys are handled is determined by the supplied
WARNING: Since 220.127.116.11, the changes in the W3C Specification introduce a significant change to the default behaviour of the function when there are duplicate keys. Previously (up to and including 18.104.22.168), the associated value for each key in the new map was taken from the last map in the input sequence containing that key. From 22.214.171.124, the default behaviour is to take the value from the first map containing that key.
merge($maps as map(*)*) ➔ map(*)
The input maps
merge($maps as map(*)*, $options as map(*)) ➔ map(*)
The input maps
Used to control the way in which merging takes place
Links to W3C specifications
Notes on the Saxon implementation
From 9.9.1, two new vendor-defined options are recognized, and together can be used to explicitly
indicate that the new optimized implementation of maps (
be used for the resulting merged map. The option
'key-type':'string' constrains the entries
in the map to be strings (a dynamic error occurs if not), and
that the map should be constructed assuming no
calls will take place (if they do, they will work, but will result in the whole map being copied).
XPath 3.1 version implemented since Saxon 9.7.
Signature changed to add
$options argument from 126.96.36.199, with one recognized option
'duplicates':'reject'|'use-first'|'use-last'|'combine'|'unspecified'. For full
details see the specification.
From 188.8.131.52, there is a change to the default behaviour of the function when there are duplicate keys. Previously, the associated value for each key in the new map was taken from the last map in the input sequence containing that key. From 184.108.40.206, the default behaviour is to take the value from the first map containing that key. See the warning above.
From 220.127.116.11, the option
'duplicates':'unspecified' is renamed
'unspecified' is retained
as a synonym).
Available as defined in XSLT 3.0 since Saxon 9.6; in XSLT, XPath, and XQuery, whether or not 3.0 is available.
This function replaces the function
map:new() defined in previous working
drafts of XSLT 3.0, which was available in Saxon 9.4 to 9.6.