Re: [xsl] I wrote an XSLT program that converts a mapping XML file into a large, powerful XSLT program

Subject: Re: [xsl] I wrote an XSLT program that converts a mapping XML file into a large, powerful XSLT program
From: "Dimitre Novatchev dnovatchev@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 30 Oct 2024 17:03:49 -0000
There are different possible variations of the "multi-step transformation"
pattern.

Besides generating an XSLT stylesheet in the last step - which is similar
to "compiling", one could alternatively have an XSLT transformation that
interprets the final produced rules-result - in transforming one or more
data-documents.

Both approaches have pluses and minuses. Using an interpreter may
significantly decrease the current large size of the final transformation -
from 204MB to probably 1% (0.01) of that size.

When using a multistep interpreter, saving the last rules-result to be
re-used in later executions will also eliminate the need to perform the
same multiple steps again and again on each execution. This is equivalent
to a "compiler", where the result of the "compilation" is a simple
rules-document that will be interpreted on each "execution".

Thanks,
Dimitre.


On Wed, Oct 30, 2024 at 4:45b/AM Roger L Costello costello@xxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> Hi Folks,
>
> I created an XML file (a "mapping file") that describes how to convert a
> legacy XML format into a new XML format.
>
> To implement the conversion, I used a pipeline approach. The first step is
> an XSLT program that converts the mappings (in the mapping file) into a
> bunch of template rules, one template rule per mapping. In other words, the
> output of the first XSLT program is another XSLT program. (Cool!
> Dynamically generated XSLT program) The second step ran the generated XSLT
> program on a legacy XML file to produce XML in the new format.
>
> Here are some statistics on file sizes:
>
> Size of the mapping file: 383 KB
> Size of the XSLT program that converts the mappings (in the mapping file)
> to template rules: 154 KB
> Size of the XSLT program that was generated: 204622 KB  <-- Huge!
>
> Lesson Learned: With a good description document (e.g., a good mappings
> document) and a few lines of XSLT code, you can dynamically generate a huge
> XSLT program that can do an enormous amount of work.
>
> I love this approach to programming. It harkens back to my time writing
> parsers and compilers.
>
> /Roger

Current Thread