Re: [xsl] How to cope with the complexity of an XSLT program with thousands of template rules?

Subject: Re: [xsl] How to cope with the complexity of an XSLT program with thousands of template rules?
From: "G. Ken Holman g.ken.holman@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 2 Jun 2022 13:11:24 -0000
To manage large projects I use my own embedded stylesheet documentation methodology:

https://cranesoftwrights.github.io/resources/#xslstyle

... and I don't check in fragments until there are no violations of my stylesheet writing rules (every template documented, every parameter documented, every parameter and global variable declaration includes as= attribute, etc.).

The documentation can be written in either DocBook, DITA, or XHTML.

The HTML result includes a summary of the import/include tree, all of the embedded documentation, and an alphabetized index of every global variable/parameter. You can download a sample of the documentation from this repository (no online viewing, apparently):

https://sourceforge.net/p/sportsmlt/code/HEAD/tree/2.0/sportsmlt2.html

I have a number of very large projects with customers with dozens of stylesheet fragments. I have more confidence in my work when I am shown by XSLStyle that I've followed all of my writing rules in all of my entire library.

I use the methodology from the very start of development to ensure complete documentation and integrity.

Probably it is too late for you to be able to use XSLStyle since it wasn't used from the start and there is too much to retrofit.

But you did ask what others use, and for 18 years this has been one important component of the success of my stylesheet writing projects.

. . . . . . Ken

At 2022-06-02 11:46 +0000, Roger L Costello costello@xxxxxxxxx wrote:
Hi Folks,

I have an XSLT program with thousands of template rules.

Ugh!

It's too much complexity for my tiny brain.

To help deal with the complexity I have implemented the following:

1. I split up the template rules across a number of files. Less template rules in a file seems to reduce the stress on my brain.

2. I make extensive use of ENTITIES. I have come to love ENTITIES! They are super helpful -- way less errors -- to define a value in one place and then use the value (via an ENTITY reference) in many places.

3. Hundreds of my template rules are empty, e.g.,

    <xsl:template match="(sid|star)/supplementalData">
        <xsl:param name="TRM_PAR_row" as="element(row)"/>
    </xsl:template>

To shrink things, I changed those empty rules using the XML empty tag abbreviation, e.g.,

<xsl:template match="(sid|star)/supplementalData"/>

That helps make the files a bit shorter. Shorter is better for my brain.

Question: what techniques do you use to control the complexity of a large XSLT program?

/Roger



--
Contact info, blog, articles, etc. http://www.CraneSoftwrights.com/s/ |
Check our site for free XML, XSLT, XSL-FO and UBL developer resources |
Streaming hands-on XSLT/XPath 2 training class @US$125 (5 hours free) |
Essays (UBL, XML, etc.) http://www.linkedin.com/today/author/gkholman |

Current Thread