Re: the "~" operator (was Re: [xsl] Add id to next element)

Subject: Re: the "~" operator (was Re: [xsl] Add id to next element)
From: "Liam R. E. Quin liam@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 20 May 2022 03:03:27 -0000
On Fri, 2022-05-20 at 02:05 +0000, Graydon graydon@xxxxxxxxx wrote:
>
> I'm not sure I want that ~ operator MORE than I want to be able to
> stuff
> XPath expressions into macros,

In XSLT you can already write,

<!DOCTYPE xsl:stylesheet [
  <!ENTITY pattern " '\d{2,5}' ">
  <!ENTITY firstToken "(tokenize(., &pattern;) [1])">
]>
<xsl:stylesheet>
  <xsl:sequence select="//extension ! &firstToken;" />
</xsl:stylesheet>

but syntactic sugar for lambda expressions with arguments and closures,
and the chaining of xsl instructions in the blog post, would be very
interesting.

  tokenize(., &pattern;) ! N;x { if ($x castable as xs:number) then
number($x) else 17 }



--
Liam Quin,B https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations: B http://www.fromoldbooks.org

Current Thread