Subject: Re: [xsl] Map duplicate handling differences From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 9 Dec 2022 16:08:36 -0000 |
Am 12/9/2022 um 4:51 PM schrieb Michael Mueller-Hillebrand michael.mueller-hillebrand@xxxxxxxxx: > > 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)"> > > B B B <xsl:map> > > B B B B B B <xsl:for-each select="tokenize($pairsString, ';')"> > > <xsl:map-entry key="substring-before(., '=')" > select="substring-after(., '=')"/> > > </xsl:for-each> > > B B B </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( > > B B B B B B B B B B B for $t in tokenize($pairsString, ';') > > B B B B B B B B B B B B B B B B 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? > XSLT 4 is going to remedy that shortcoming, see https://qt4cg.org/specifications/xslt-40/Overview-diff.html#duplicate-keys and <!-- Category: instruction --> <xsl:map B B on-duplicates? =expressionB > B B <!-- Content:sequence-constructor--> </xsl:map>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Map duplicate handling differ, Michael Mueller-Hill | Thread | Re: [xsl] Map duplicate handling di, Michael Kay mike@xxx |
[xsl] Map duplicate handling differ, Michael Mueller-Hill | Date | Re: [xsl] Map duplicate handling di, Michael Kay mike@xxx |
Month |