Re: [xsl] Theory question about keys (no code)

Subject: Re: [xsl] Theory question about keys (no code)
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Sun, 02 Sep 2012 19:26:59 +0100
It's up to the implementation when it builds the index.

However, it's worth noting that a transformation might have several source documents, and the key() function can be used to search any of them. In general the processor doesn't know that a particular input document needs to be indexed until the key() function is used to search that document. Therefore, a sensible strategy is to build the index for a particular input document the first time key() is used to search that document.

A complication is that XSLT 2.0 allows you to search part of a document (by specifying a third argument that is an element node). One can imagine a number of strategies for handling this, based on different assumptions about whether the application is likely to go on to search other parts of the document as well. Saxon builds an index for the whole document even if the request is to only search part of it.

Michael Kay

On 06/08/2012 18:16, FAIR, ED wrote:

I am not totally new to xslt but have a very basic question about keys.

My stylesheets are working but performance is starting to suffer as document sizes have grown. I'm trying to improve performance by adding and using keys.

I understand that an xsl:key creates something like an associative array that can be used to cross-reference elements in my document using the key() function. I have no problem understanding these concepts.

My question is: when is the associative array built? Is it built entirely in the beginning, as the source document is first read into memory? Or is it built incrementally, as each template is matched during transformation?

FWIW, I am using xslt 1.0, xsltproc in Solaris 10:

       $ xsltproc -V
       Using libxml 20623, libxslt 10115 and libexslt 812
       xsltproc was compiled against libxml 20623, libxslt 10115 and libexslt 812
       libxslt 10115 was compiled against libxml 20623
       libexslt 812 was compiled against libxml 20623
       [vsadm@alnvitalpol2: /usr/home/vsadm/csv-pcrf-1 ]


Current Thread