xsl-list
[Top] [All Lists]

Re: [xsl] XSLT 4 xsl:with

2020-05-19 16:09:12
Hi Gerrit,

Thanks for your response, the <xsl:sequence> afterthought you brougtht up is finally dawning upon me. I did initially read through the thread, and I also think it is better to use existing vocabulary and to fill the gaps in the paradigm, rather than to cook up new verbs. It's just that I /also/ like <xsl:with>, which feels completely familiar to me, even though it does not exist yet.

@Michael Kay, I am happy to see that the discussion you intended to provoke with your article and presentation at XML Prague is actually happening! I was a bit worried that there would not be a single place where this would going to be, and now there could be two. (for the unfamiliar: https://www.xml.com/news/2020-04-slack-workspace-for-the-xml-community/)

Best
Pieter

On 19/05/2020 19:55, Imsieke, Gerrit, le-tex 
gerrit(_dot_)imsieke(_at_)le-tex(_dot_)de 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(_dot_)lamers(_at_)benjamins(_dot_)nl 
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(_at_)fromoldbooks(_dot_)org wrote:
On Tue, 2020-05-19 at 08:54 +0000, Pieter Masereeuw 
pieter(_at_)masereeuw(_dot_)nl
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



--
Pieter Lamers
John Benjamins Publishing Company
Postal Address: P.O. Box 36224, 1020 ME AMSTERDAM, The Netherlands
Visiting Address: Klaprozenweg 75G, 1033 NN AMSTERDAM, The Netherlands
Warehouse: Kelvinstraat 11-13, 1446 TK PURMEREND, The Netherlands
tel: +31 20 630 4747
web: www.benjamins.com
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>