Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 426083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:26:39+00:00 2026-05-12T19:26:39+00:00

Here is a template I call to generate a menu, and it kinda breaks.

  • 0

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.

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.
>

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…

Help?

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.

The site is organized like this:

<?xml version="1.0"?>
<site xsi:noNamespaceSchemaLocation="onepagev2.xsd"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <page pagename="Alpha">
    <language langname="en" path="./en/Alpha" dephtCount="3">
      <title>Alpha Anglo</title>
      <content>Oh noes.</content>
    </language>
    <language langname="fr" path="./fr/Alpha" dephtCount="3">
      <title>Alpha Franco</title>
      <content>Oh non.</content>
    </language>
  </page>
  <page pagename="Beta">
    <language langname="en" path="./en/Beta" dephtCount="3">
      <title>Beta Anglo</title>
      <content>Content B is content B is content B!</content>
    </language>
    <language langname="fr" path="./fr/Beta" dephtCount="3">
      <title>Beta Franco</title>
      <content>Contenu B est contenu B est contenu B!</content>
    </language>
  </page>
  <page pagename="Beta2">
    <language langname="en" path="./en/Beta/Beta2" dephtCount="4">
      <title>Beta Anglo</title>
      <content>Content B is content B is content B!</content>
    </language>
    <language langname="fr" path="./fr/Beta/Beta2" dephtCount="4">
      <title>Beta Franco</title>
      <content>Contenu B est contenu B est contenu B!</content>
    </language>
  </page>
</site>

The template:

<xsl:template name="menubuildr">
  <xsl:param name="p-path"/>
  <xsl:param name="p-lang"/>
  <xsl:param name="p-i" select="2"/>
  <xsl:param name="p-filter"/>
  <xsl:param name="p-max"/>
  <xsl:if test="$p-i &lt; $p-max">
    <ul>
      <xsl:variable name="nextLevel">
        <xsl:for-each select="str:split(string($p-path),'/')">
          <xsl:if test="position()&lt;$p-i + 1">
            <xsl:value-of select="."/>
            <xsl:if test="position()&lt;($p-i)">
              <xsl:text>/</xsl:text>
            </xsl:if>
          </xsl:if>
        </xsl:for-each>
      </xsl:variable>
      <xsl:for-each 
        select="/site/page/language[
                           starts-with(@path,$p-filter) 
                       and @dephtCount = ($p-i)
                       and $p-lang = @langname]">
        <li>
          <xsl:value-of select="@path"/>
          <xsl:text>:</xsl:text>
          <xsl:value-of select="@dephtCount"/>
          <xsl:call-template name="menubuildr">
            <xsl:with-param name="p-lang" select="$p-lang" />
            <xsl:with-param name="p-filter" select="$nextLevel"/>
            <xsl:with-param name="p-i" select="$p-i + 1"/>
            <xsl:with-param name="p-path" select="$p-path"/>
            <xsl:with-param name="p-max" select="$p-max"/>
          </xsl:call-template>
        </li>
      </xsl:for-each>
    </ul>
  </xsl:if>
</xsl:template>

Sample call:

    <div class="menu">Menu  
        <xsl:call-template name="menubuildr">  
          <xsl:with-param name="p-lang" select="@langname" />  
          <xsl:with-param name="p-filter">  
            <xsl:text>./</xsl:text>  
            <xsl:value-of select="@langname"/>  
          </xsl:with-param>   
          <xsl:with-param name="p-i" select="2"/>  
          <xsl:with-param name="p-path" select="@chemin"/>  
          <xsl:with-param name="p-max" select="count(str:split(string(@chemin),'/'))"/>  
        </xsl:call-template>  
        <hr/>  
    </div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T19:26:39+00:00Added an answer on May 12, 2026 at 7:26 pm

    I think there is an error in this test <xsl:if test="position()&lt;$p-i + 1">.

    Believe me, it’s always be true. 🙂

    I guess you want this <xsl:if test="position()&lt;($p-i + 1)">

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've written a simple T4 template (call it web.tt) to generate a web.config file.
Here is one of my header file which consists of a union template with
I'm building an excel template (*.xlt) for a user here, and one of the
My goal here is to create a very simple template language. At the moment,
C++ 0x has template aliases (sometimes referred to as template typedefs). See here .
I'm trying to use a class within a T4 template in VS2008. Here is
I am using the jquery-tmpl template library to build a dynamic <select> list. In
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.