Re: Processiing arrays in XSLT 4

On Sat, Jan 9, 2021 at 10:08 PM Michael Kay <mike@saxonica.com> wrote:

> It seems a no-brainer to provide an XSLT instruction along the lines
>
> <xsl:for-each-member select="array">
>   ....
> </xsl:for-each>
>
> to process the members of a supplied array.
>
> The question is: within the body of this instruction, how should one refer
> to the current member of the array?
>

To do this, I'd like to propose enhancements to syntax of xsl:iterate.
Something, along the following lines,

1) Let the XSLT 4.0 variable 'A' represents an array.

for e.g,
<xsl:variable name="A" select="array { 1, 2, 5, 7 }"/>

2) Then do following,

<xsl:iterate idx="1 to array:size($A)">
   <!-- do something with $A($idx) -->
</xsl:iterate>

Notes:
Currently XSLT 4.0 xsl:iterate instruction is defined as follows (quoted
from XSLT 4.0 spec, which I propose to be retained in XSLT 4.0),

*<xsl:iterate*
*   select = expression>*
*   <!-- Content: (xsl:param*, xsl:on-completion?, sequence-constructor)
-->*
*</xsl:iterate>*

*Where, xsl:iterate/@select contains an expression which is evaluated to
produce a sequence, called the input sequence.*



-- 
Regards,
Mukul Gandhi

Received on Tuesday, 12 January 2021 07:37:38 UTC