[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: tough problem: infinit loop caused by XSL recusive
On Fri, 18 May 2001 12:03:04 -0400, you wrote: >Hi, > >1. I try to transform a XML file to a text file by using transform class of >xalan 2.0. >2. I call the following template with countLoop select="14" that cause the >infinite loop and stack overflow, >however if I set select="8" it works fine. Why do you sy 'infinite'? Does it take a long time in comparison to the 8-iteration version? I am guessing not. > >3. Does anyone know how to the reason? Your template calls itself, so Xalan may be using recursion at the java level too, hence using a stack frame for every call. >How to fix it? Most XSL processors try to do what is called tail recursion elimination. Basically this means implementing the recursive call as a loop instead. The catch is, this is only possible for certain forms of code, usually where the recursive call is at the end of the template body. Though this is the case with your example, you may have "hidden" it from Xalan: you might try restructuring the code so that instead of <template> <stuff> <if x<= limit> <more stuff> <call (x+1)> </if> </template> you do <template> <stuff> <more stuff> <if x< limit> <call (x+1)> </if> </template> The idea is that you make it more obvious to Xalan that the recursive call can be replaced by a jump to the beginning of the template. I must say I am guessing here as I do not know the optimisation algorithms which Xalan uses. Or you could try a different XSLT processor which may optimise your code better, e.g. Saxon (no offence intended to the Xalan folk or any other processor writers - Saxon happens to be the one that I know can handle things like this). Mike Kay might tell us if you still have to do the restructuring. > Is there any >properties file which define the default stack size for xalan 2.0? > It should not need anything specific to Xalan - look at your JVM docs to see how to increase stack/heap size. Hope this helps. Trevor Nash XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|