Re: [xsl] sanely ordering template imports?

Subject: Re: [xsl] sanely ordering template imports?
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Tue, 06 Dec 2011 20:01:41 +0000
>I can't be the first person who has encountered this, so I'm wondering what you all do in situations like that. Do you simply take the hit of redundant import statements, or do you restructure your stylesheets?

A little war story: I was once presented with a stylesheet in which one module, called something like common.xsl, was imported by about 40 other modules, each itself part of the stylesheet. The result: every definition in common.xsl was compiled 40 times, and generated 40 copies of each of its compiled templates and global variables, each one at different import precedence. For templates at least, you can't just forget 39 of the instances, because a template that does xsl:next-match will invoke itself 39 times before finally calling the built-in template.

These days Saxon only compiles each template once, and has 40 small entries pointing to it, each representing the same rule but with different precedence. But it's still mighty inefficient. Try to avoid this kind of module structure.

Michael Kay
Saxonica

Current Thread