[xsl] Map duplicate handling differences

Subject: [xsl] Map duplicate handling differences
From: "Michael Mueller-Hillebrand michael.mueller-hillebrand@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 9 Dec 2022 15:51:37 -0000
Hello Friday folks,

I have noticed that the duplicate handling when constructing maps is different
and I would like to understand the reason.

When using <xsl:map> with <xsl:map:entry> the transformer rejects duplicate
keys with a runtime error.

<xsl:variable name="pairsMap" as="map(xs:string, xs:string)">
    <xsl:map>
       <xsl:for-each select="tokenize($pairsString, ';')">
            <xsl:map-entry key="substring-before(., '=')"
select="substring-after(., '=')"/>
        </xsl:for-each>
    </xsl:map>
</xsl:variable>

When using map:merge() without any extra options it uses duplicates:use-first
(I learned I can turn on brejectb or buse-lastb or bcombineb):

<xsl:variable name="pairsMap" as="map(xs:string, xs:string)"
        select="map:merge(
            for $t in tokenize($pairsString, ';')
                return map:entry(substring-before($t, '='),
substring-after($t, '=')))"/>

Have I overlooked a way to define options in the xsl:map case?
Or is this a subtle way to get us to move to inline XPath?

Have a nice weekend,

- Michael

Michael MC<ller-Hillebrand
Senior Consultant
Phone +49 951-20859-752
Mobil +49 172-819 34 13
michael.mueller-hillebrand@xxxxxxxxx<mailto:michael.mueller-hillebrand@docufy
.de>
www.docufy.de<https://www.docufy.de/> |
DOCUFY@LinkedIN<https://www.linkedin.com/company/3845358/>
Datenschutz<https://www.docufy.de/datenschutz/>
DOCUFY GmbH | KirschC$ckerstr. 27 | 96052 Bamberg | Deutschland
CEO: Nadine Prill | Amtsgericht Bamberg HRB5423

Current Thread