[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
> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|