Archive for August, 2009

Giving saxon-xslt large amounts of memory

August 4, 2009

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.