xsl-list
[Top] [All Lists]

Re: [xsl] best practices for using XSLT modes

2019-12-05 10:48:40
On Wed, Dec 4, 2019 at 2:43 AM Michael Kay mike(_at_)saxonica(_dot_)com
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

...
Secondly, I found it useful recently to split the mode for evaluating 
assertions into two: one mode handles the case where the test produces a 
normal result, the other handles the case where it produces a dynamic error, 
and we issue a different apply-templates instruction for the two cases. The 
reason for this is that the two modes have different default behaviour (the 
mode that handles error outcomes returns "false" for all assertions except 
the one with match="error"): this change eliminated a lot of logic. Perhaps 
the same effect could have been achieved using a generic template rule 
delegating to specific template rules using next-match; but in this scenario 
where we're basically handling a two-dimensional decision tree (X - what is 
the outcome of a test?, Y - what is the assertion being tested?) then using 
modes for one of the dimensions and match patterns for the other can be 
useful.


Thank you for identifying the conceptual framework I've been using for
a long time in XSLT.  This concept of segmenting the dimensionality of
the problem with modes taking the dimension which appears more
'enumerated' and the match taking the more 'continuous-like'.  That's
what I've been doing, but didn't really recognize it until mentioned.

- Brian

I would find it quite difficult to capture this experience and produce 
general guidance on XSLT coding/design patterns; but if you're writing 
complex stylesheets, modes are a powerful tool at your disposal and can be 
used with care to great effect.

Michael Kay

XSL-List info and archive
EasyUnsubscribe (by email)
--~----------------------------------------------------------------
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>