[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Perfomance: 'conditional instruction' vs. 'multi
At 2012-11-03 16:24 +0100, Norbert Heidbrink wrote:
if a node is to be processed differently, depending on a certain condition, there are two approaches. I am not an implementer, just a user, but this is how I see it and teach it. Approach 1 allows the processor to optimize the method by which it decides between the two template rules each with a template to build the result tree. Approach 2 burdens the processor to execute your own determination of how to choose between the two templates to build the result tree. Approach 1 is declarative, approach 2 is imperative. Approach 2 may be more intuitive to classical programmers, approach 1 may be a bit harder for classical programmers to wrap their heads around. Approach 1 can be exploited by an importing stylesheet in order to effect nuanced differences in the stylesheet for one of the two template rules, even when the imported stylesheet is read-only. Approach 2 prevents nuanced overriding of only one of the two templates and imposes the burden on the importing stylesheet to replicate the behaviours of the other template already in the imported stylesheet that don't need to change. For these reasons, especially the last one, I tell my students approach 1 is "better" and approach 2 has drawbacks. I always try to write my stylesheets so that in the future I can better exploit the stylesheet without changing it, even if I don't yet know what those future requirements might be. That allows me to continue using the unchanged stylesheet wherever I am using it, and yet leverage it for other reasons in other contexts by the importing stylesheet selectively changing behaviours. Top-level constructs can be overridden in their entirety, while their contents cannot be selectively overridden. The more template rules I have, the more nuanced I can change the behaviours. The fewer template rules I have, the less flexibility I have to override smaller portions of the imported stylesheet. I hope this helps. . . . . . . . . . . Ken
|
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
|