Re: [xsl] Map duplicate handling differences

Subject: Re: [xsl] Map duplicate handling differences
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 9 Dec 2022 17:02:27 -0000
On Fri, Dec 09, 2022 at 04:34:53PM -0000, Michael Kay mike@xxxxxxxxxxxx scripsit:
> This shortcoming of xsl:map has been noted:
> 
> https://github.com/qt4cg/qtspecs/issues/169
> 
> Saxon 11 with XSLT 4.0 enabled already supports the proposed on-duplicates
> attribute, for example
> 
> <xsl:map on-duplicates="function($x, $y){$x}">
> 
> which achieves the effect of use-first in map:merge.

https://www.saxonica.com/papers/xmlprague-2020mhk.pdf says "the required
type is a function with arity 2" and seems to presume that there will be
only two duplicates, rather than potentially arbitrarily many
duplicates.

Would

<xsl:map on-duplicates="function($x as item()+, $y){head($x)}">

work?

<xsl:map on-duplicates="function($x as item()+, $y){$x[$y]}"> ?

(I have no idea why I'd want to do the second one, but it leaps to mind
with a required arity of 2.)

I have fairly often wanted to group all the examples of something under
a key; everything with a date in June, everything with a level depth of
three, stuff like that.  It'd be extremely convenient if
xsl:map/@on-duplicates allowed for this kind of "everything with this
key maps under this key" use case.

(I've put this in as a comment on github.)

Thanks!

-- 
Graydon Saunders  | graydonish@xxxxxxxxx
^fs oferiode, pisses swa mfg.
-- Deor  ("That passed, so may this.")

Current Thread