[xsl] recursive call-template problem

Subject: [xsl] recursive call-template problem
From: omprakash.v@xxxxxxxxxxxxx
Date: Mon, 14 Mar 2005 17:36:32 +0530
Hi,
    I have a recursive call to call-template as follows:

What I would like to control is the number of empty td's i create based on
the level the child node is in. For eg. for a level 1 node, I will put 1
empty <td>, for a level 2 node, 2 empty <td>s and so on.

The problem is how do I know when the treeview template is getting called
with a different depth so I can base my no of <td> on that value.

One solution that came to me was make it a function of depth itself. But
what if it is not 1 to 1. For eg. I need 2 <td>s  for a level 1 node and 4
<td> for a level 2 node. Is there another way that the caller might tell
how many <td>s to add.

Also, How do I express the following in xsl:

Procedural code begin:

while (count > 0) {
   put <td>
  count--;
}



<xsl:template name="treeview">
    <xsl:param name="depth"/>
    <xsl:param name="content"/>



                <tr>
           <td>&nbsp;</td>
           <td>
           <xsl:value-of select="name(.)"/>
          </td>
          </tr>


         <xsl:for-each select="$content/*">
     <xsl:call-template name="treeview">
                <xsl:with-param name="content" select="."/>
                <xsl:with-param name="depth" select="number($depth)+1"/>
              </xsl:call-template>
       </xsl:for-each>

</xsl:template>


Cheers,
Omprakash.V



This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. 
If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately.
You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification,
distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited.

Visit Us at http://www.polaris.co.in

Current Thread