Subject: Re: [xsl] XSLT 4 xsl:with From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 21 May 2020 05:58:09 -0000 |
>> <xsl:for-each-group select="some-node" group-by="true()"> >> .... inside I have current-group() ... >> </xsl:for-each-group> >> >> -- which has sometimes made me wonder if group-by="true()" might be a >> default on for-each-group? >> This reminds me that I've been trying to find a good syntax for doing <xsl:for-each-member-in-array select="[(1 to 3), (5 to 9), (10 to 20)]"> <x>{count(current-member())}</x> </xsl:for-each-member-in-array> where the result is <x>3<x><x>5</x><x>11</x> I have a general distaste for adding more bits and pieces to the dynamic context (current-this() and current-that()). They all clutter the space, they have messy static and dynamic scoping rules, and you often end up binding them to variables anyway. I would prefer to bind explicit variables: in some drafts of XSLT 3.0 we used binding variables on xsl:for-each-group, and that's what saxon:for-each-member currently does: https://saxonica.com/documentation/index.html#!extensions/instructions/for-ea ch-member <saxon:for-each-member select="[(1 to 3), (5 to 9), (10 to 20)]" bind-to="m"> <x>{count($m)}</x> </saxon:for-each-member> What do other people feel? Should we have @bind-to on other things like xsl:for-each and xsl:for-each-group? The other approach to the above construct is to do it all in XPath. You can also do this in Saxon 10: <xsl:sequence select="[(1 to 3), (5 to 9), (10 to 20)] => array:for-each(_{saxon:new-element("x", string(count($1))})"/> Michael Kay Saxonica
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSLT 4 xsl:with, Graydon graydon@xxxx | Thread | Re: [xsl] XSLT 4 xsl:with, Graydon graydon@xxxx |
Re: [xsl] XSLT 4 xsl:with, Graydon graydon@xxxx | Date | [xsl] Intersection of two sets base, Roger L Costello cos |
Month |