Re: [xsl] I love programs that output programs

Subject: Re: [xsl] I love programs that output programs
From: "Liam R. E. Quin liam@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 18 Jan 2025 05:46:11 -0000
On Fri, 2025-01-17 at 20:22 +0000, Roger L Costello costello@xxxxxxxxx
wrote:
> Hi Folks,
>
> Recently I was reading Brian Kernighan's new book on AWK,

Awksome! I hadn't known there was one.

One of the first complex text processing programs i wrote was to read a
bunch of text files, identify all of the references, and produce a sed
script that would replace them with calls to a "refer" database (refer,
written by Mike Lesk at Bell labs in the Unix group, was the
inspiration for bibtex).

Coincidentally the source code for refer was pretty weird, and i
remember
	main(argc, argv)
         int argc; char **argv;
        {
          . . .
          if (argv[0] < 16000) {
              ...
          }
        }
which to anyone who knows C was a little startling.

Programs that produce programs can be super useful.

Ibve done a bit with generating XSLT on the fly with XSLT, and then
running it with fn:transform(), which can be super powerful.

Although much of the need to do that is reduced by XSLT shadow
attributes, there are still cases where itbs helpful. An example might
be reading a namespace name from an input document, and writing XSLT on
the fly to remove it without affecting others. Therebs other ways to do
that, but hey, itbs fun :)

As Dmitre notes, itbs easy to write things that are hard to read, so
you do have to be careful not to overdo it.

liam


--
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