From 13c378fc26facd320d797d9cd4b7340a8b32ddd9 Mon Sep 17 00:00:00 2001
From: Michael Kay If there are duplicate keys, that is, if two or more maps contain entries having the
$options
) argument.$options
) argument.
In the event that two or more entries in the input maps have the
+
A single entry is created by combining the duplicates.
The value of the resulting entry is formed by combining
+ the entries in the input maps according to the value of the
+ duplicates
option.
The key of the resulting entry is one of the keys from
+ the duplicate entries: which one is chosen is xs:dateTime
+ values with different timezones.)
The position of the combined entry in the
The entries that may appear in the $options
map are as follows:
$maps
argument.
- The key value in the result map that corresponds to such a set of duplicates must
- be the xs:byte(1)
- and xs:short(1)
, the key in the result could legitimately be xs:long(1)
.
+ of all the values associated with the key.
@@ -23104,6 +23115,8 @@ xs:QName('xs:double')
By way of explanation, $combine
is a function that combines
- two maps by iterating over the keys of the second map, adding each key and its corresponding
- value to the first map as it proceeds. The second call of return
clause then iterates over the maps supplied in the call
- to $combine
.
By way of explanation, the function first reduces the sequence of input maps
+ to a sequence of key-value pairs, retaining order of both the maps and of the
+ entries within each map. It then combines key-value pairs having the
+ $combine
function
+ successively to pairs of duplicates. The position in the use-last
is used: the value of the resulting
+ entry corresponds to the last entry with a given key, but the position of the entry
+ in the result map corresponds to the position of the first entry with that key.
+
This algorithm processes the supplied maps in a defined order, but processes the keys within - each map in implementation-dependent order.
The use of "duplicates": "use-any"
, but it is not the only conformant
- implementation and is not intended to be a realistic implementation. The purpose of this
- option is to allow the implementation to use whatever strategy is most efficient; for example,
- if the input maps are processed in parallel, then specifying "duplicates": "use-any"
- means that the implementation does not need to keep track of the original order of the sequence of input
- maps.
The optional $combine
argument can be used to define how
duplicate keys should be handled. The default is to form the sequence concatenation
- of the corresponding values, retaining their order in the input sequence.
$input
.
+ Given that two keys deemed to be duplicates might differ (for example, they
+ might have different type annotations, or they might be xs:dateTime
+ values with different timezones), it is If the key is not already present in the target map, the processor adds a - new key-value pair to the map, with that key and that value.
If the key is already present, the processor calls the $combine
function to combine the existing value for the key with the new value,
- and replaces the entry with this combined value.
$input
sequence.
+
+ Given that two keys deemed to be duplicates might differ (for example, they
+ might have different type annotations, or they might be xs:dateTime
+ values with different timezones), it is
The order of the arguments passed to the function reflects the order of the maps in which +
More specifically, if the on-duplicates
expression is present and returns
+ a function $F
, and if the input sequence is $S
, then the result of the
+ map:of-pairs($S =!> map:pairs(), { 'combine': $F })
.
Thus, if the values are all singleton items (which is not necessarily the case), and if the sequence
of values is S, then the final result is fold-left(tail(S), head(S), F)
.
For example, the following table shows some useful callback functions that might be supplied, and explains their effect:
@@ -35870,6 +35875,19 @@ the same group, and the--> +The position in the result map of the combined entry + corresponding to a set of duplicate + entries in the input corresponds to the position of the first of the duplicates + in the input.
+The key of the combined entry corresponding to a set of duplicate
+ entries in the input is one of the duplicate keys, but it is
+ xs:dateTime
values might have different
+ timezones.)
This example takes as input an XML document such as: