On 02/06/2022 12:45, Roger L Costello costello@xxxxxxxxx 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@xxxxxxxxxxxx