Re: [xsl] XSLT programs that blur the distinction between program and data?

Subject: Re: [xsl] XSLT programs that blur the distinction between program and data?
From: "Norm Tovey-Walsh ndw@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 9 Apr 2022 16:14:17 -0000
> (1) An XSLT program may have some embedded XML that the program uses.
> That embedded XML is both part of the program and it is data for the
> program; so it is both program and data. That is definitely blurring
> the distinction between program and data!

That doesnbt seem especially blurry to me. Most programs have some
statically initialized data. Ibm not sure my Java program with a map of
arrays of maps is that different from an XSLT stylesheet with some
embedded XML.

> (2) An XSLT program can modify itself at runtime. [Is this possible?
> Can one part of XSLT program treat another part of the program as
> data, modify it, and then continue running but with the modified
> program?]

Thatbs sort of going to depend on how you define your terms. An XSLT
stylesheet doesnbt necessarily have access to its original XML form. It
may have been compiled, for example. Excluding any magic that might be
provided by extension functions, it has no facilities to modify its
execution environment directly the way, for example, lisp systems often
allow.

But if the processor implements fn:transform, then it can generate
stylesheets on the fly to run. If it does have access to itbs original
XML form, then it can use transformations of that form to generate the
new transforms.

I havenbt yet encountered a problem where that felt like the easiest way
to solve it, but it could be done.

> Is there a classic use case for (1)? That is, is there a classic use
> case for an XSLT program that uses embedded XML data?

Absolutely. The DocBook XSLT stylesheets, for example, embed the XML
data for doing localization. (In fact, that data eventually got large
enough and diverse enough that I pushed it back out into separate files,
but it started off embedded. The stylesheet containing the embedding
was, naturally, generated by processing a different stylesheet and the
data. But that was a bpreprocessorb step, not part of the userbs
runtime.)

> Is there a classic use case for (2)?

Almost certainly, but none spring immediately to my mind.

                                        Be seeing you,
                                          norm

--
Norman Tovey-Walsh <ndw@xxxxxxxxxx>
https://nwalsh.com/

> Anger ventilated often hurries towards forgiveness; anger concealed
> often hardens into revenge.--Edward G. Bulwer-Lytton

[demime 1.01d removed an attachment of type application/pgp-signature which had a name of signature.asc]

Current Thread