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

Subject: Re: [xsl] Converting a sequence of xs:string to a map
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 12 Jan 2026 21:07:11 -0000
On 12/01/2026 21:53, Martin Honnen martin.honnen@xxxxxx 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()


In XPath/XQuery 4 you can use


B map:build(('amount', 'vat-rate', 'total'), fn { . }, fn ($i, $n) { $n })

Current Thread