Re: [xsl] Is it possible to write an XSLT program that outputs an XSLT program that outputs an XSLT program?

Subject: Re: [xsl] Is it possible to write an XSLT program that outputs an XSLT program that outputs an XSLT program?
From: "David Carlisle d.p.carlisle@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 2 Jul 2023 16:58:43 -0000
On Sun, 2 Jul 2023 at 11:58, Roger L Costello costello@xxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> Hi Folks,
>
> Years ago I read the source code for the XSLT implementation of
> Schematron. From it I learned how to write an XSLT program that outputs an
> XSLT program. Since that time I have written a number of XSLT programs that
> output XSLT programs. I enjoy writing these kinds of programs. They seem
> almost magical. A program that produces a program - wow!
>
> This week I got to wondering: is it possible to write an XSLT program that
> outputs an XSLT program and when the latter is run it outputs another XSLT
> program? That is,
>
> XSLT program #1 --> run --> outputs XSLT program #2 --> run --> outputs
> XSLT program #3 --> run --> solves some problem
>
> Is this even possible in XSLT? Have you ever done this? What types of
> problems are suitable for this approach?
>
> /Roger
>



<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"; version="3.0">
<xsl:template match="/">
 <xsl:copy-of select="doc('')"/>
</xsl:template>
</xsl:stylesheet>


has the useful feature of taking any xml on input and returning an equally
useful stylesheet as result.

Current Thread