[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Running out of Memory

Subject: Re: [xsl] Running out of Memory
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Wed, 15 Aug 2012 23:52:23 +0100

Many implementations will keep a document loaded doc() in memory in case you read the same URI again, so they can satisfy the rule that you get the identical document instance both times.

Saxon provides a way of avoiding this using the saxon:discard-document() extension function.

Michael Kay

On 15/08/2012 21:02, Terry Badger wrote:
I use the attached template to collect all of the files in a given archieve into a variable $all-chapters and each time the loop ran it would destory the variable and I would use little memory. After processing a few 100 archieves I run out of memory. Am I thinging about this correctly? Is there a more correct way to do this?
Here is the template:
<xsl:result-documenthref="{concat($protocol , $base-out , '/' , $date , '_all-chapters_' , $book , '.txt')}"format="badger-1">
<!-- ==================================================================== -->
<!-- use Java to get the list of files - not all version of Saxon will work -->
<xsl:variablename="dir"select="file:new(resolve-uri(concat('file:/' , $base-in)))"/>
<xsl:variablename="file-name"select="subsequence(reverse(tokenize($uri-to-string, '\\')), 1, 1)"/>
<!-- process the selected book or All -->
<xsl:variablename="document"select="doc(concat($jar-protocol , $base-in , $file-name , '!' , '/designmap.xml'))"/>
<xsl:copy-ofselect="doc(concat($jar-protocol , $base-in , $file-name , '!/' , .))"/>
<xsl:copy-ofselect="doc(concat($jar-protocol , $base-in , $file-name , '!/' , .))"/>
<xsl:copy-ofselect="doc(concat($jar-protocol , $base-in , $file-name , '!/' , .))"/>
<!-- the work is done here -->
<!-- <xsl:apply-templates select="$all-chapters"/>-->

Current Thread