Re: [xsl] XSLT 4 xsl:with

Subject: Re: [xsl] XSLT 4 xsl:with
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 21 May 2020 04:17:40 -0000
On Tue, May 19, 2020 at 06:10:56PM -0000, Wendell Piez wapiez@xxxxxxxxxxxxxxx scripsit:
> Does anyone else find themselves doing
> 
> <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?
> 
> Or ... would <xsl:with>...</xsl:with> or <xsl:for>...</xsl:for> or
> <xsl:at>...</xsl:at> be a serviceable and better way to do this as
> well?

Wouldn't the equivalent be

<xsl:with-context select="some-node">
    ... stuff happens...
</xsl:with-context>

Using for-each-group gives you a sequence in current-group(); I would think that if you expect a sequence, you might-maybe be better to use xsl:for-each rather than xsl:with-context.  If I understood the original idea, it was a way to be less confusing by not using xsl:for-each in the singleton case.

If we were to allow modes on xsl:with-context, it'd be a way to do mode-based selection.

-- 
Graydon Saunders  | graydonish@xxxxxxxxx
^fs oferiode, pisses swa mfg.
-- Deor  ("That passed, so may this.")

Current Thread