I came across this problem when I needed to output a large number of literal elements in a result document. When the stylesheet is executed from the Joost API (e.g. from net.sf.joost.Main) then the stylesheet works as expected. However, if the stylesheet is executed from TrAX then I get a stack overflow of the form:
java.lang.StackOverflowError
at java.util.HashMap$Entry.<init>(HashMap.java:683)
at java.util.HashMap.addEntry(HashMap.java:753)
at java.util.HashMap.put(HashMap.java:385)
at net.sf.joost.instruction.AbstractInstruction.deepCopy(Unknown Source)
at net.sf.joost.instruction.AbstractInstruction.onDeepCopy(Unknown Source)
at net.sf.joost.instruction.NodeBase.onDeepCopy(Unknown Source)
at net.sf.joost.instruction.LitElementFactory$Instance.onDeepCopy(Unknown Source)
at net.sf.joost.instruction.AbstractInstruction.deepCopy(Unknown Source)
at net.sf.joost.instruction.AbstractInstruction.onDeepCopy(Unknown Source)
at net.sf.joost.instruction.NodeBase$End.onDeepCopy(Unknown Source)
at net.sf.joost.instruction.AbstractInstruction.deepCopy(Unknown Source)
at net.sf.joost.instruction.AbstractInstruction.onDeepCopy(Unknown Source)
... etc.
The attached ZIP contains a simple Java program and STX transform which illustrate the issue. For this simple example the stack overflow will occur on 32-bit JVMs on Linux and Windows. 64-bit JVMs on Linux appear to have a higher threshold.
--
Doug
Simple program and transform illustrating issue
This turns out to be more complicated than I thought. Obviously this is a recursion problem, so have to rewrite some recursion code into an iteration. Unfortunately I'm running out of ideas how to do it for this evening.
Anyway, as workaround hint (in case you didn't know - I actually didn't): you can increase the stack size by using the VM parameter -Xss<size>