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

Subject: Re: [xsl] Converting a sequence of xs:string to a map
From: "Liam R. E. Quin liam@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 12 Jan 2026 21:38:16 -0000
On Mon, 12 Jan 2026 21:26:49 -0000
"Chris Papademetrious christopher.papademetrious@xxxxxxxxxxxx"
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> As I stare at the answers from Christophe and Martin to understand
> them, I can only hope that today's LLM models are trained to explain
> and generate XSLT 3+  better than my own brain can do it. :)

You can also write it in a more XSLT-2-ish way,

let $sequence := ("Simon", "David", "Joy", "Nigel", "Nicola")
return map:merge(
  for $i in 1 to count($sequence)
  return map:entry($sequence[$i], $i)
)

Its worth understanding ! and => if you are working with XPath 3, and
also let.. return, and for...return.

Note that, strictly speaking, "for" is not a loop in the traditional
imperative programming sense - the implementation can evaluate it in
any order, including in parallel, as long as it sticks the results back
together in the right order.

liam

-- 
Liam Quin: Delightful Computing - Training and Consultancy in
XSLT / XML Markup / Typography / CSS / Accessibility / and more...
Outreach for the GNU Image Manipulation Program
Vintage art digital files - fromoldbooks.org

Current Thread