Giving saxon-xslt large amounts of memory

I was running the following XSLT 2.0 script:

<?xml version="1.0" encoding="UTF-8"?>  
<xsl:stylesheet version="2.0" 
 <xsl:variable name="files" select="collection('./tei/?select=*.xml')"/>  

    <xsl:template match="/">  
          <xsl:for-each select="for $x in $files return saxon:discard-document($x)">  
             <xsl:for-each select=".//tei:name">
                   <xsl:value-of select=".//text()"/>  
<span style="font-size: x-small;"> 

It just iterates over all files and all names within the file and outputs a list of the text with the names with lots of whitespace (I detest XML all scrunched up without whitespace).

Alas it was giving me the error “Exception in thread “main” java.lang.OutOfMemoryError: Java heap space” errors, so I knew I had to give it more. The trick turned out to be changing the command line from:

saxonb-xslt -ext:on get-all-names.xsl get-all-names.xsl


java -Xmx8000M -jar /usr/share/java/openoffice/saxon9.jar  -ext:on get-all-names.xsl get-all-names.xsl

This, of course, is on a 64bit machine with 8G of RAM, so Java can stretch out it’s legs into that space. Worked a treat.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: