Re: Processiing arrays in XSLT 4

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

> >
> > 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.
> >
>
> This feels very counter-intuitive to me. Perhaps you could flesh out the
> use case I supplied to see what the full solution looks like.
>

This addresses the issue you raised for providing the members of an array
that is to be constructed.

As for the other use case, I already +1ed one of the alternatives that you
proposed:

<xsl:for-each-member select="array" bind-to="member" position="pos">
   <xsl:if test="$pos ne 1">,</xsl:if>
   <xsl:for-each select="$member">
      ...


+1 again, if it was not seen at:
https://lists.w3.org/Archives/Public/public-xslt-40/2021Jan/0001.html

As for something being counter-intuitive, this is rather personal and not
objective.

A better metric is the amount of code that needs to be written and to what
extent a proposed solution is (cumbersome and) error-prone.

With a member-generator function, one is not being syntax- or location-
bound, which, among other things, leads to greater reusability.
Also no need for the developer to have to memorize imposed, complicated and
unnecessary syntax, as this syntax will not exist.

Thanks,
Dimitre



>
> Michael Kay
> Saxonica

Received on Saturday, 9 January 2021 23:35:21 UTC