[xslt] [xslt]: Who has a real world use for a high --maxdepth?



I'm new to xslt but notice that, so far, only error conditions seem to 
hit the default xsltMaxDepth of 5000.

One example is from the "Sams Teach Yourself XSLT in 21 Days" book. The 
section on recursion ("Day 17") has a stylesheet that computes the 
factorial of a number, for example:

     $ xsltproc -param factorial 7 17list02a.xsl 17list03.xml
     5040

If you give it a string parameter, it churns until it runs into the 
xsltMaxDepth limit:

     $ xsltproc -param factorial "junk" 17list02a.xsl 17list03.xml
     runtime error: file 17list02a.xsl line 22 element variable  
     xsltApplyOneTemplate: loop found ???
     try increasing xsltMaxDepth (--maxdepth)
     Templates:
     #0 name calculate
     ... more debug output removed, including NaN info ...


The problem I have run into is with a little processor I've implemented 
that uses libxslt. An xsltMaxDepth of 5000 is too high for the context 
it is running in; by the time it reaches 5000 it overflows the stack and 
that first "runtime error" is lost. So I reset xsltMaxDepth to a much 
lower value that guarantees that the error won't overflow the stack. 
(OK, another fix was to put a check into the stylesheet that does a 
<xsl:message terminate="yes"> if the parameter is not a number, but 
that's kind of beside the point. I really want the processor to recover 
gracefully from stylesheet foibles.)

So, I'm try to balance stack usage with maxdepth requirements, and am 
looking for a stylesheet that legitimately requires a high maxdepth. So 
far the largest I have found is in the libxslt tests: 
tests/XSLTmark/bottles.xsl .

This succeeds:
 xsltproc --maxdepth 102 bottles.xsl bottles.xml

This exceeds the maxdepth:
 xsltproc --maxdepth 101 bottles.xsl bottles.xml

I thought maybe the fractal example at 
http://incrementaldevelopment.com/xsltrick/aufgang/#fractal might stress 
maxdepth, but it appears not to.
     
So ... what are the opinions? who has a use for a high maxdepth and how 
high is "high"?

thanks,

 -jean






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]