Technical Saxon API question: is it possible to resolve and therefore cache included or imported stylesheets at transformation-time?
The background is this: we have many, many xslt files in our application. 1600+ of those are "root" stylesheets, tied to specific pages. Several hundred others are "include" stylesheets...containing shared templates that all of the root stylesheets use.
Our problem is that we have to cache the compiled stylesheets...no question there. But to do so each root stylesheet is caching all of the hundreds of include stylesheets. Before you say that we just need to live with it because that is the price of performance, understand that we are talking about a huge amount of memory burnt on this. E.g. out of a 900MB total heap, the stylesheet cache accounts for about 1/3 of that...300MB. And, I estimate that the redundantly cached includes account for 90% of this (the includes have includes that have includes...it goes deep).
The API I need is something that resolves a cached, compiled Templates (or saxon equivalent) object. Not just a Source object that is streamed in. I want to compile and cache each .xsl file...then resolve them with a custom resovler during transform().
Possible? Alternatives? I don't care whether we use JAXP or Saxon-specific APIs. Any help is greatly appreciated.
I appreciate the reason you want this: however, XSLT isn't really designed to make separate compilation of stylesheet modules a realistic option. In fact, it's not even necessary for an included module to be a valid stylesheet in its own right: it can contain references to variables and named templates that aren't resolved until the main module is available. If an included module is included by 5 different main modules, then a variable reference can resolve differently in each case; and the variables could all be of different types, meaning that all the type-checking code is generated differently in each case. I hope this gives a feel for the problem.
I wonder if you really need 1600 separate "root" stylesheets? You'd be better off including these all into one big stylesheet and then somehow selecting the right entry point when you start the transformation - there are a number of ways of doing this, such as starting at a named template.
At some time in the future I'm hoping to allow separately-compiled function libraries, which could be either XSLT or XQuery. Functions have fewer context dependencies than templates. In XSLT they are still allowed to contain references to global variables, which might be supplied by an including stylesheet; but I could impose restrictions on the kind of function libraries that you are allowed to compile. However, this is just a conjectural enhancement (and quite a substantial one) and doesn't help you today, I'm afraid.
|Free forum by Nabble||Edit this page|