Re: Processiing arrays in XSLT 4

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

> That seems to be no better than
>
> <xsl:for-each select="1 to array:size($array)">
>    <xsl:variable name="member" select="$array(.)"/>
>
> which you can do today, and which seems a rather clumsy solution to me.

Surely iteratiing over the members of an array can be expressed more
> declaratively than this?
>

Surely, there is even no need to iterate at all, if we have the syntax
below:

<xsl:array member-source="*"  member-generator="my:mapHistory"/>

Here, the XSLT processor is calling my:mapHistory() once for every item in
member-source, and the result of the call is the corresponding, Nth member
of the array.

Thanks,
Dimitre


>
> Michael Kay
> Saxonica
>
> > On 9 Jan 2021, at 21:15, Liam R. E. Quin <liam@fromoldbooks.org> wrote:
> >
> > On Sat, 2021-01-09 at 16:38 +0000, Michael Kay 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?
> >
> > How about,
> > <xsl:at-each-member at="pos" select="array" as="xs:integer*">
> >  <!--* now $pos is avaiable as type xs:integer* *-->
> > and do the same for for-each
> > ?
> >
> > Liam
> >
> > --
> > Liam Quin, https://www.delightfulcomputing.com/
> > Available for XML/Document/Information Architecture/XSLT/
> > XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
> > Barefoot Web-slave, antique illustrations:  http://www.fromoldbooks.org
> >
> >
>
>
>

Received on Saturday, 9 January 2021 22:53:57 UTC