- From: Reece Dunn <msclrhd@googlemail.com>
- Date: Tue, 12 Jan 2021 18:20:53 +0000
- To: Michael Kay <mike@saxonica.com>
- Cc: Martin Honnen <martin.honnen@gmx.de>, public-xslt-40@w3.org
- Message-ID: <CAGdtn2432ECRNNH5ACF+TQFPv3u4uZ7n1NyWoXgcW729DQFYEA@mail.gmail.com>
On Tue, 12 Jan 2021 at 13:04, Michael Kay <mike@saxonica.com> wrote: > Yes, that's right (I had already spotted it but didn't want to trouble > anyone...) > > I think we can also allow <xsl:for-each map="$map"> creating items > accessible as .?key and .?value. I've tried a few JSON-to-XML examples and > it works quite nicely, including (probably) for grouping. > I like this approach for both arrays and maps. > I think the keywords array="X" and map="Y" work OK, rather that say > element-in-array or entry-in-map. After all, X is an array and Y is a map. > It would ideally be > > <xsl:for-each-in array="X"> > > but we don't want to change the instruction name. > > Or we could do > > <xsl:for-each in-array="X"> > > but it feels like unnecessary noise. > If we are going for consistency with the XPath/XQuery proposal then this could be member="..." that accepts an array or map. I'm happy either way (@array/@map or @member). Kind regards, Reece > Michael Kay > Saxonica > > > On 12 Jan 2021, at 12:38, Martin Honnen <martin.honnen@gmx.de> wrote: > > > > > > On 12.01.2021 12:27, Martin Honnen wrote: > >> > >> On 12.01.2021 11:25, Michael Kay wrote: > >>> Mindful of DImitre's exhortation to avoid growing the language any > >>> more than is necessary, I propose the following: > >>> > >>> * xsl:for-each, xsl:iterate, and xsl:for-each-group acquire an > >>> attribute array=expression which can be used instead of > >>> select=expression > >>> > >>> * specifying array="EXPR" is equivalent to specifying > >>> select="array:for-each(EXPR, function($x){map{'value': $x})"/> > > > > > > Is that meant as > > > > select="array:for-each(EXPR, function($x){map{'value': $x}})?*" > > > > ? > > > >>> > >>> The effect is that you iterate over the members of the array, and > >>> that you can refer to the current member of the array as .?value. The > >>> position of the member within the array is available as position(). > >>> > >>> > >> > >> Does that work with for-each-group where inside of the instruction > >> position() is supposed to give you the position of the current group and > >> not the position of the item in the grouping population? > >> > >> Or how does grouping work if the population is a (single?) array created > >> by array:for-each? > >> > >> > > > > >
Received on Tuesday, 12 January 2021 18:21:20 UTC