[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XSLT 4 xsl:with
I finished reading through the xslt4 doc. Great stuff, and I do the for-each-context-switch as well. I had some preprocessors converting a <gen:context select=""> (gen prefix pointing to a different ns) to that context-setting-only xsl:for-each as well (with xsl prefix pointing to the xslt namespace). Good to see the specs including some of these common adjustments... I should look back through them. :) On Tue, May 19, 2020 at 10:55 AM Imsieke, Gerrit, le-tex gerrit.imsieke@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > Of course such an xsl:with instruction won't be penalized by HOAXCoQS > [1], unlike xsl:for-each, which reeks of XSLT 1 habits most of the time. > xsl:with won't get brownie points though; I'd consider it "neutral". > > But read my previous messages in this thread. Instead of xsl:with I > propose to use a @context-item attribute (an @xsl:context-item attribute > on non-xsl elements). If you really need the kind of wrapper that > xsl:with provides, you can still write > > <xsl:sequence context-item="$context"> > <xsl:variable .../><!-- @select evaluated in the context of $context --> > <foo>...</foo><!-- any expression within is also evaluated in the > context of $context --> > <bar>...</bar> > </xsl:sequence> > > but most of the time the XSLT code will become more compact because the > context can be set by an attribute on almost any element, not with an > instruction. > > -- Gerrit > > [1] https://github.com/sydb/HOAXCoQS > > On 19.05.2020 19:14, Pieter Lamers pieter.lamers@xxxxxxxxxxxx wrote: > > I think <xsl:with select="..."> is an elegant rewrite of for-each. It > > does make me wonder whether it would earn brownie points or penalties in > > Gerrit's highly opiniated book. > > > > > > On 19/05/2020 18:52, Liam R. E. Quin liam@xxxxxxxxxxxxxxxx wrote: > >> On Tue, 2020-05-19 at 08:54 +0000, Pieter Masereeuw pieter@xxxxxxxxxxxx > >>> Because such a for-each does not repeat, I always add a comment like > >>> <!-- Merely sets the context, does not repeat -->. > >> I tend to comment these too, although not with the repeat part - be > >> careful, too, as in English a less-informed reader might get an > >> incorrect impression reinforced that for-each is a loop, rather than a > >> mapping operator. > >> > >> Yes, an xsl:with-context-item select=.... would be clearer. Wkether > >> it's worth increasing the size of the language for it is a judgment > >> call that's a little harder, i think. > >> > >> Best, > >> > >> Liam
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|