Re: [xsl] I love programs that output programs

Subject: Re: [xsl] I love programs that output programs
From: "BR Chrisman brchrisman@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 19 Jan 2025 07:55:47 -0000
On Sat, Jan 18, 2025 at 9:22b/PM Dimitre Novatchev dnovatchev@xxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> > As Dmitre notes, itbs easy to write things that are hard to read, so
> >   you do have to be careful not to overdo it.
>
> In my practice I have done something more practical and convenient than
> writing an XSLT transformation ( a set of stylesheets)  that generates
> another XSLT transformation (another set of stylesheets) that generates yet
> another XSLT transformation (yet another set of stylesheets), ..., and so
> on, ... , ad finitum  ...
>
> What is significantly more pragmatic, convenient, readable and doable is
> to write:
>
>    - Just one set of stylesheets/templates.
>    - Generate as the result of each pass new data (XML).
>    - Have all templates that must transform DataN.xml into
>    DataNPlusOne.xml, be in the same mode, let us call it "passN".
>
> This really works well, much better than generating XSLT code again and
> again, though even this better approach has its limits: when I wrote such a
> 5-6 pass transformation, there was no one that could understand what this
> was doing, but me ...
>

... such that each pass is the same stylesheet(s) operating the transform,
but with each invocation, the input is different and getting diverted to a
different mode?
My practice has been to have separate transform files and a build procedure
that always clearly segments the transforms and their, input, and output
for each step in the pipeline for debugging purposes (my data sets aren't
huge).
I use modes, but typically in a more ad-hoc fashion.


>
>
>
>
> On Fri, Jan 17, 2025 at 9:46b/PM Liam R. E. Quin liam@xxxxxxxxxxxxxxxx <
> xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
>> 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, 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:  http://www.fromoldbooks.org
>>
>>
>>
>
> --
> Cheers,
> Dimitre Novatchev
> ---------------------------------------
> Truly great madness cannot be achieved without significant intelligence.
> ---------------------------------------
> To invent, you need a good imagination and a pile of junk
> -------------------------------------
> Never fight an inanimate object
> -------------------------------------
> To avoid situations in which you might make mistakes may be the
> biggest mistake of all
> ------------------------------------
> Quality means doing it right when no one is looking.
> -------------------------------------
> You've achieved success in your field when you don't know whether what
> you're doing is work or play
> -------------------------------------
> To achieve the impossible dream, try going to sleep.
> -------------------------------------
> Facts do not cease to exist because they are ignored.
> -------------------------------------
> Typing monkeys will write all Shakespeare's works in 200yrs.Will they
> write all patents, too? :)
> -------------------------------------
> Sanity is madness put to good use.
> -------------------------------------
> I finally figured out the only reason to be alive is to enjoy it.
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/965995> (by
> email <>)

Current Thread