Controlling duplicates on xsl:map

The on-duplicates attribute can be specified on xsl:map to control what happens when two entries in the map would have the same key (in XSLT 3.0 this is always an error). The value of the attribute is an expression, which must evaluate to a function. The function is called when an entry in the map would conflict with an existing entry. It is supplied with two arguments, the value of the existing entry and the value of the new entry, and it returns a new value to be associated with the duplicate key (or it can throw an error, to replicate the default behavior). For example on-duplicates="->($old, $new){$old, $new} causes the new value to be the sequence-concatenation of the supplied values, while on-duplicates="->($old, $new){$old || ',' || $new} concatenates the values with comma as a separator. Specifying on-duplicates="->($old, $new){$old} takes the first of the duplicates, while on-duplicates="->($old, $new){$new} takes the last.