title: XSLT menu generation problem
body: <p>Here is a template I call to generate a menu, and it kinda breaks. Using Xalan, I get heap size error, so my guess would be that something in it is horribly broken and unholy.</p>
  
  <p>I preset the template for the current portion of the website tree, feeding it the path from the root of the site, the language, the current depht (p-i), and a filter.
  ></p>
  
  <p>What this is supposed to do is to select everything on the current level, and then carry on with the next iteration which should be as simple as updating the "nextLevel" when called again, for the next level of menu...</p>
  
  <p>Help?</p>
  
  <p>Edit: As far as I know, it works as long as I don't go into recursion. I get the first level specified by my depht parameter, and nothing more.</p>
  
  <p>The site is organized like this:   </p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;site xsi:noNamespaceSchemaLocation="onepagev2.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
    &lt;page pagename="Alpha"&gt;
      &lt;language langname="en" path="./en/Alpha" dephtCount="3"&gt;
        &lt;title&gt;Alpha Anglo&lt;/title&gt;
        &lt;content&gt;Oh noes.&lt;/content&gt;
      &lt;/language&gt;
      &lt;language langname="fr" path="./fr/Alpha" dephtCount="3"&gt;
        &lt;title&gt;Alpha Franco&lt;/title&gt;
        &lt;content&gt;Oh non.&lt;/content&gt;
      &lt;/language&gt;
    &lt;/page&gt;
    &lt;page pagename="Beta"&gt;
      &lt;language langname="en" path="./en/Beta" dephtCount="3"&gt;
        &lt;title&gt;Beta Anglo&lt;/title&gt;
        &lt;content&gt;Content B is content B is content B!&lt;/content&gt;
      &lt;/language&gt;
      &lt;language langname="fr" path="./fr/Beta" dephtCount="3"&gt;
        &lt;title&gt;Beta Franco&lt;/title&gt;
        &lt;content&gt;Contenu B est contenu B est contenu B!&lt;/content&gt;
      &lt;/language&gt;
    &lt;/page&gt;
    &lt;page pagename="Beta2"&gt;
      &lt;language langname="en" path="./en/Beta/Beta2" dephtCount="4"&gt;
        &lt;title&gt;Beta Anglo&lt;/title&gt;
        &lt;content&gt;Content B is content B is content B!&lt;/content&gt;
      &lt;/language&gt;
      &lt;language langname="fr" path="./fr/Beta/Beta2" dephtCount="4"&gt;
        &lt;title&gt;Beta Franco&lt;/title&gt;
        &lt;content&gt;Contenu B est contenu B est contenu B!&lt;/content&gt;
      &lt;/language&gt;
    &lt;/page&gt;
  &lt;/site&gt;
  </code></pre>
  
  <p>The template:</p>
  
  <pre><code>&lt;xsl:template name="menubuildr"&gt;
    &lt;xsl:param name="p-path"/&gt;
    &lt;xsl:param name="p-lang"/&gt;
    &lt;xsl:param name="p-i" select="2"/&gt;
    &lt;xsl:param name="p-filter"/&gt;
    &lt;xsl:param name="p-max"/&gt;
    &lt;xsl:if test="$p-i &amp;lt; $p-max"&gt;
      &lt;ul&gt;
        &lt;xsl:variable name="nextLevel"&gt;
          &lt;xsl:for-each select="str:split(string($p-path),'/')"&gt;
            &lt;xsl:if test="position()&amp;lt;$p-i + 1"&gt;
              &lt;xsl:value-of select="."/&gt;
              &lt;xsl:if test="position()&amp;lt;($p-i)"&gt;
                &lt;xsl:text&gt;/&lt;/xsl:text&gt;
              &lt;/xsl:if&gt;
            &lt;/xsl:if&gt;
          &lt;/xsl:for-each&gt;
        &lt;/xsl:variable&gt;
        &lt;xsl:for-each 
          select="/site/page/language[
                             starts-with(@path,$p-filter) 
                         and @dephtCount = ($p-i)
                         and $p-lang = @langname]"&gt;
          &lt;li&gt;
            &lt;xsl:value-of select="@path"/&gt;
            &lt;xsl:text&gt;:&lt;/xsl:text&gt;
            &lt;xsl:value-of select="@dephtCount"/&gt;
            &lt;xsl:call-template name="menubuildr"&gt;
              &lt;xsl:with-param name="p-lang" select="$p-lang" /&gt;
              &lt;xsl:with-param name="p-filter" select="$nextLevel"/&gt;
              &lt;xsl:with-param name="p-i" select="$p-i + 1"/&gt;
              &lt;xsl:with-param name="p-path" select="$p-path"/&gt;
              &lt;xsl:with-param name="p-max" select="$p-max"/&gt;
            &lt;/xsl:call-template&gt;
          &lt;/li&gt;
        &lt;/xsl:for-each&gt;
      &lt;/ul&gt;
    &lt;/xsl:if&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>Sample call:  </p>
  
  <pre><code>    &lt;div class="menu"&gt;Menu  
          &lt;xsl:call-template name="menubuildr"&gt;  
            &lt;xsl:with-param name="p-lang" select="@langname" /&gt;  
            &lt;xsl:with-param name="p-filter"&gt;  
              &lt;xsl:text&gt;./&lt;/xsl:text&gt;  
              &lt;xsl:value-of select="@langname"/&gt;  
            &lt;/xsl:with-param&gt;   
            &lt;xsl:with-param name="p-i" select="2"/&gt;  
            &lt;xsl:with-param name="p-path" select="@chemin"/&gt;  
            &lt;xsl:with-param name="p-max" select="count(str:split(string(@chemin),'/'))"/&gt;  
          &lt;/xsl:call-template&gt;  
          &lt;hr/&gt;  
      &lt;/div&gt;
  </code></pre>