xsl-list
[Top] [All Lists]

Re: [xsl] Running out of Memory

2012-08-16 14:22:08
Michael Kay,
Thank you. Works well.
Terry Badger

From: Michael Kay <mike(_at_)saxonica(_dot_)com>
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
Sent: Wednesday, August 15, 2012 6:52 PM
Subject: Re: [xsl] Running out of Memory

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
Saxonica

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?
Terry
Here is the template:
<xsl:templatename="main">
<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="files"select="file:listFiles($dir)"/>
<xsl:for-eachselect="$files">
<xsl:variablename="uri-to-string">
<xsl:value-ofselect="."/>
</xsl:variable>
<xsl:variablename="file-name"select="subsequence(reverse(tokenize($uri-to-string,
 '\\')), 1, 1)"/>
<!-- process the selected book or All -->
<xsl:variablename="all-chapters">
<xsl:variablename="chapter"select="$file-name"/>
<xsl:variablename="document"select="doc(concat($jar-protocol , $base-in , 
$file-name , '!' , '/designmap.xml'))"/>
<xsl:elementname="chapter">
<xsl:attributename="name"select="$chapter"/>
<xsl:copy-ofselect="$document"/>
<xsl:elementname="MasterSpreads-all">
<xsl:for-eachselect="$document/Document/idPkg:MasterSpread/@src">
<xsl:copy-ofselect="doc(concat($jar-protocol , $base-in , $file-name , '!/' , 
.))"/>
</xsl:for-each>
</xsl:element>
<xsl:elementname="Spreads-all">
<xsl:for-eachselect="$document/Document/idPkg:Spread/@src">
<xsl:copy-ofselect="doc(concat($jar-protocol , $base-in , $file-name , '!/' , 
.))"/>
</xsl:for-each>
</xsl:element>
<xsl:elementname="Stories-all">
<xsl:for-eachselect="$document/Document/idPkg:Story/@src">
<xsl:copy-ofselect="doc(concat($jar-protocol , $base-in , $file-name , '!/' , 
.))"/>
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:variable>
<!-- the work is done here -->
<!-- <xsl:apply-templates select="$all-chapters"/>-->
</xsl:for-each>
</xsl:result-document>
</xsl:template>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


<Prev in Thread] Current Thread [Next in Thread>