RE: [xsl] Caching source documents and key()s

Subject: RE: [xsl] Caching source documents and key()s
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Thu, 9 Aug 2001 10:57:33 +0100
> I have a JAVA web application which has to present content from
> the same XML document several times for an user task, sort of
> a poor, short-lived in-memory database.
> Can anybody share experiences on caching source documents,
> using TrAX/JAXP1.1? Should i cache the File representation,
> or is it better to cache a DOM tree or SAX events, provided
> that ca. 60% of the file content is markup or ignorable whitespace?
>
> Furthermore, i use key() heavily to pull stuff from cross referenced
> elements. It would be nice to keep already built indexes across
> invocations of the processor, preferably along with the processor
> dependent representation of the input source. Something like what
> Templates is for the style sheet.
> Any comments from our processor implementors about this?

I think the answers are going to be processor dependent.

With Saxon, you should cache Saxon's own native tree structure, which you
can create using JAXP interfaces if you nominate Saxon as your
DocumentBuilder. You should avoid using <xsl:strip-space> in your stylesheet
(if you need to strip spaces, do it once in a separate transformation, and
save the result document), and if you want key indexes to be reused, you
should use the same stylesheet (Templates object) each time, because Saxon
won't recognize equivalence between two keys defined in different
stylesheets.

Saxon's standard tree model takes slightly longer to build and uses more
memory than its tiny tree model, but it's faster to navigate, so if you are
using the tree repeatedly then it's probably worth using the standard tree
model: if you only use it once the tinytree is usually better.

Mike Kay
Software AG


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread