From 39fa65ba5377cc9947b04988151c4e882375e74d Mon Sep 17 00:00:00 2001
From: Michael Kay The position of that entry in the The key of that entry will be the key used
- in the The key of the combined entry
+ will correspond to the key of one of the duplicates: it is
+ The function The key of the entry containing the combined value is the The key of the combined entry
+ will correspond to the key of one of the duplicates: it is
+ The function If The Otherwise, when xs:dateTime
values in different timezones.)$input
argument.xs:dateTime
values in different timezones.)$map
,
- with the exception of any entry whose key is the $key
, together with a new
- entry whose key is $key
and whose associated value is $value
.$map
contains an entry whose key is the $key
, the function returns
+ a map in which that entry is replaced (at the same relative position)
+ with a new entry whose value is $value
. It is
+ $key
.
+ All other entries in the map are unchanged, and retain their relative order.$map
contains an entry whose key is $key
,
- then the new value replaces the old value and the position of the entry is not changed;
- otherwise, the new entry is added after all existing entries.$map
contains no such entry, the function
+ returns a map containing all entries from the supplied $map
+ (retaining their relative position) followed by a new entry whose key
+ is $key
and whose associated value is $value
.$map
, but nevertheless
differs from the existing key in some way:
for example, it might have a different type annotation, or it might be an xs:dateTime
- value in a different timezone. In this situation the key that appears in the result map
- is always the supplied $key
, not the existing key.
$key
or the existing key.
@@ -24191,7 +24193,12 @@ declare function map:find($input as item()*,
Enhanced to allow for ordered maps.
Enhanced to allow for ordered maps.
+It is no longer guaranteed that the new key replaces the existing key.
+The position of the combined entry in the
The key of the combined entry in the
- The key of the combined entry
+ will correspond to the key of one of the duplicates: it is
+ xs:dateTime
values in different timezones.) xs:anyURI
or (when XPath 1.0 compatibility
mode is in force) an instance of xs:boolean
or xs:duration
.
When
For compatibility issues regarding earlier versions, see the 3.1 version of this specification.
diff --git a/specifications/xslt-40/src/element-catalog.xml b/specifications/xslt-40/src/element-catalog.xml index 96973de4a..6b87e08a6 100644 --- a/specifications/xslt-40/src/element-catalog.xml +++ b/specifications/xslt-40/src/element-catalog.xml @@ -1702,7 +1702,7 @@xsl:map/@on-duplicates
is available,
+ A new attribute xsl:map/@duplicates
is available,
allowing control over how duplicate keys are handled by the fn:atomic-equal(K, L)
returns true
.
In the absence of the In the absence of the on-duplicates
attribute,
+ duplicates
attribute,
a
The result of evaluating the on-duplicates
attribute, if present,
More formally, the result of the $maps
- is the input sequence to $combine
- is the on-duplicates
+
The result of evaluating the duplicates
attribute, if present, "use-first"
, "use-last"
,
+ "use-any"
, "combine"
, or "reject"
,
+ or a function with arity 2. These values correspond to the permitted
+ values of the duplicates
option of the
+
The result of the $maps
+ is the input sequence to $duplicates
+ is the duplicates
attribute, then the result of the instruction is the result of the function
- call map:merge($maps, { "combine": $combine })
.
map:of-pairs(map:pairs($maps), { "duplicates": $duplicates })
.
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
- as the value of the on-duplicates
attribute, and explains their effect:
The following table shows some possible values
+ of the duplicates
attribute, and explains their effect:
fn($a, $b) { $a } |
+ duplicates="use-first" |
The first of the duplicate values is used. | |
fn($a, $b) { $b } |
+ duplicates="use-last" |
The last of the duplicate values is used. | |
fn($a, $b) { $a, $b } |
+ duplicates="combine" |
The on-duplicates="op(',')" . |
|
fn($a, $b) { max(($a, $b)) } |
+ duplicates="fn($a, $b) { max(($a, $b)) }" |
The highest of the duplicate values is used. | |
fn($a, $b) { min(($a, $b)) } |
+ duplicates="fn($a, $b) { min(($a, $b)) }" |
The lowest of the duplicate values is used. | |
concat(?, ', ', ?) } |
+ duplicates="concat(?, ', ', ?) }" |
The comma-separated string concatenation of the duplicate values is used. | |
fn($a, $b) { $a + $b } |
- The sum of the duplicate values is used.
- This could also be expressed as on-duplicates="op('+')"
+ | ||
duplicates="op('+')" |
+ The sum of the duplicate values is used. | +||
duplicates="fn($a, $b) { subsequence(($a, $b), 1, 4) }" |
+ The first four of the duplicates are retained; any further duplicates + are discarded. | ||
fn($a, $b) { error() } |
- Duplicates are rejected as an error (this is the default in the absence of the
- on-duplicates attribute). |
+ duplicates="fn($a, $b) { distinct-values(($a, $b)) }" |
+ When multiple entries have the same key, the corresponding values + are retained only if they are distinct from other values having the + same key. + |
The logic is:
Specifying the effect by reference to
Specifying the effect by reference to
The position of the merged entry in the result corresponds to the position of the first of the duplicate keys in the input.
The key used for the merged entry in the result corresponds
- to the last of the duplicate keys in the input. This is relevant when
+ to one of the duplicate keys in the input: it is
+ xs:dateTime
values in different timezones.