xsl-list
[Top] [All Lists]

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

2022-06-02 09:31:39
On 02/06/2022 12:45, Roger L Costello costello(_at_)mitre(_dot_)org wrote:
Question: what techniques do you use to control the complexity of a large XSLT 
program?

I've been shot down in flames for this on previous occasion, but sometimes there has developed a notion that you should ALWAYS use application of template rules to declare choice and alternatives, mostly on the grounds of future extensibility.

But often your problem locally is defined by a very clear and finite set of ordered (and possibly mutually exclusive alteratives). In such cases I've seen code which goes to inordinate lengths to describe these exclusive choices through separate templates by repeating predicates and their negations or working hard to control or define template priorities. In such cases 'unintended overlap' with templates off in the far reaches of your code universe becomes a distinct risk, certainly if you don't use modes or have include/importation arms and debugging such can be a nightmare.

In some of these cases a much simpler, more controllable. and much more clearly readable, local solution might be to use an xsl:choose which gives you a clearly defined order of conditions, with complete local previous context and which will NOT be interfered with from externally defined sections of code.

--
*John Lumley* MA PhD CEng FIEE
john(_at_)saxonica(_dot_)com
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>