Re: [xsl] Converting a sequence of xs:string to a map

Subject: Re: [xsl] Converting a sequence of xs:string to a map
From: "Michael Kay michaelkay90@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 13 Jan 2026 12:59:19 -0000
And for completeness, XPath 4.0 now allows

{ $strings ! {., posiiton()} }

Michael Kay
Saxonica

> On 12 Jan 2026, at 22:50, Michael Kay <michaelkay90@xxxxxxxxx> wrote:
>
> If you want an XSLT 3.0 solution rather than an XPath solution then you
could do
>
> <xsl:map>
>   <xsl:for-each select="$strings">
>      <xsl:map-entry key="." select="position()"/>
>   </xsl:for-each>
> </xsl:map>
>
> Michael Kay
> Saxonica
>
>> On 12 Jan 2026, at 20:53, Martin Honnen martin.honnen@xxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>>
>>
>> On 12/01/2026 21:48, Christophe Marchand christophe@xxxxxxxxxxxx wrote:
>>> I have a sequence of xs:string : ('amount', 'vat-rate', 'total')
>>> And I want a map where keys are the labels from the sequence, and values
are the position of label in sequence : { 'amount': 1, 'vat-rate': 2, 'total':
3}
>>
>>
>> One way would be
>>
>> (('amount', 'vat-rate', 'total') ! map:entry(., position())) =>
map:merge()

Current Thread