[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to cope with the complexity of an XSLT program

Subject: Re: How to cope with the complexity of an XSLT program with thousands of template rules?
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 2 Jun 2022 12:09:50 -0000
Re:  How to cope with the complexity of an XSLT program
> Question: what techniques do you use to control the complexity of a large
XSLT program?
>

Modes, primarily. Aligned with modules, so one module holds all the rules for
one mode.

A technique I used in the Java-to-C# transpiler, which worked very nicely, was
to have two levels of despatch:

<xsl:template match="some-element" mode="mode-A">
  <xsl:apply-templates select="." mode="mode-B"/>
</xsl:template>


<xsl:template match="*[@class='one']" mode="mode-B">...</xsl:template>

<xsl:template match="*[@class='two']" mode="mode-B">...</xsl:template>


It makes it much easier for the human reader to work out which rules are going
to fire for which elements, and it makes it easier for the processor too.

In mode-A, if you know the element name, you know which rule will fire.

In mode-B, if you know the value of the @class attribute, you know which rule
will fire.

It's basically a two-level decision tree instead of a flat single-level
ruleset.

Michael Kay
Saxonica

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.