Re: [xsl] slow xsltproc XInclude processing w/complex document?

Subject: Re: [xsl] slow xsltproc XInclude processing w/complex document?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 6 Jul 2004 22:37:59 +0100
Hi Paul,

> I've been running some tests on a document that includes nested
> Xinclude directives. The document is complex: upwards of 1500 files,
> nested to a depth of up to 4 levels. Total size of content is about
> 4.8MB.

As you probably know, XSLT holds the files that it loads in memory.
You haven't said how much memory your machines have, but it might
simply be that holding all those files (and the flattened result
document) in memory is causing problems.

Another thing is that you're traversing every single node in those
documents. Every node visit takes time, because the processor has to
work out what to do with the node, so cutting down the node visits
would be good. You could try, for example, changing the identity
template that you're using at the moment for:

<xsl:template match="node()">
  <xsl:copy-of select="." />

<xsl:template match="*[.//xi:include]">
    <xsl:copy-of select="@*" />
    <xsl:apply-templates />

Overall, though, if speed is an issue, you would be much better off
using a SAX Filter to do the transformation: that way you wouldn't be
storing the documents in memory, each node would have to be visited
only once, and the output can stream out (if that helps). Mind you,
you say that the XInclude resolution is only a test, so perhaps you
can't do your real transformation using SAX...



Jeni Tennison

Current Thread