RE: [xsl] Best Practice - collection() function

Subject: RE: [xsl] Best Practice - collection() function
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 7 Jul 2008 00:13:35 +0100
> I use the collection function to generate a single FO file 
> for PDF output.
> There are several times I use the collection function to 
> output different information for the FO (table of contents, 
> index). Everything works as expected, but it becomes highly 
> inefficient when I use the collection function on the same 
> folder 3 times. 
> 
> For example, I would use the collection(file:///c:/folder) 3 
> times in my
> xslt:
> 
> * to build a TOC
> * to build a Index
> * Build chapters in a book.
> 
> Because I have to build my FO with page sequences, I end up 
> calling the same 800 xml files 3 times. Is there a way to do 
> this more efficiently?

The implementation of the collection() function is likely to vary from one
product to another - one can't generalize about it's caching behaviour
without knowing which product you are talking about.

If you want to maximize the chances that the result of the collection()
function is held in memory, so that multiple calls with the same URI don't
re-read the individual files, then it would be best to put the result in a
variable.

I think that Saxon will re-read the directory contents on each call, but
will cache the individual documents.

Michael Kay
http://www.saxonica.com/

Current Thread