If you just want to load the _files_ into memory, you could implement and
plug in an EntityResolver which includes caching logic.  But more
typically, what you'd do is pre-build the stylesheets and cache those as
objects in ready-to-run form. This is (slightly misleadingly) described as
"compiled stylesheets" in the Xalan documentation. If you take a look at
http://xml.apache.org/xalan-j/usagepatterns.html, that shows that you can
use a TransformerFactory to produce a Transformer; this Transformer object
could then be cached by your code and invoked whenever that transformation
was to be performed. I don't know whether anyone has a simple off-the-shelf
example of that approach...?

A recent addition to the Xalan package, thanks to our friends at Sun, is
the XSLTC "translet" code. This takes the concept one step further, and
attempts to compile the stylesheet all the way down to custom Java code.
XSLTC doesn't yet support the complete XSLT language (or didn't last time I
checked), and we're still working to integrate it with interpretive Xalan
so the two can share as much code as possible. A TRaX API for the XSLTC
code has been made available, which makes using XSLTC look very much like
using interpretive mode: you'd just select a different TransformerFactory
to switch into XSLTC mode. See
http://xml.apache.org/xalan-j/xsltc_usage.html

Reply via email to