467,077 Members | 1,022 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,077 developers. It's quick & easy.

XSL /XML replication of tree folder structure

Dear friends

I am emulating thr tree structure mentioned in the article
http://www.15seconds.com/issue/010921.htm

I have succesfully created the folder structure for level 2 I need
this structure till 5 level is there any easier way to generate this
using xsl

My xml tree node is

<tree>
<entity>
<description>Level 0</description>
<contents>
<entity>
<description>Level 1</description>
<contents>
<entity>Level 2</entity>
<contents>
<entity>Level 3</entity>

</contents>
</contents>
</entity>
..........

</contents>
</entity>
</tree>

xsl code which used to generate
<!-- First xsl for each start -->

<xsl:for-each select="tree/entity">
<table border="0" cellpadding="1" cellspacing="1">
<tr>
<td width="16">
<a id="x{./description}"
href="javascript:Toggle('{./description}');">
<img src="../images/closedfolder.gif" width="16" height="16"
hspace="0" vspace="0" border="0"/>
</a>
</td>
<td>
<a id="x{./description}"
href="javascript:Toggle('{./description}');">
<b><xsl:value-of select="./description"/></b>
</a>
</td>
</tr>
</table>
<DIV id="{./description}" style="display: none; margin-left: 2em;">
<!-- Second xsl for each start-->
<xsl:for-each select="./contents/entity">
<table border="0" cellpadding="1" cellspacing="1">
<tr>
<td width="16">
<a id="x{./description}"
href="javascript:Toggle('{./description}');">
<img src="../images/openfolder.gif" width="16" height="16"
hspace="0" vspace="0" border="0"/>
</a>
</td>
<td>
<a id="x{./description}"
href="javascript:Toggle('{./description}');">
<b>
<xsl:value-of select="./description"/>
</b>
</a>
</td>
</tr>
</table>
<DIV id="{./description}" style="display: none; margin-left: 2em;">
<!-- Third xsl for each start -->
<xsl:for-each select="./contents/entity">
<table border="0" cellpadding="1" cellspacing="1">
<xsl:choose>
<xsl:when test="string-length(./contents/entity)&lt;5">
<tr>
<td width="16">

<DIV id="x{./Programmeid}" style="display:hidden;">
<img src="../images/doc.gif" width="16" height="16" hspace="0"
vspace="0" border="0"/>
</DIV>

</td>
<td>

<b>
<xsl:value-of select="./description"/>
</b>

</td>
</tr>
</xsl:when>
<xsl:otherwise>
<tr>
<td width="16">
<a id="x{./description}"
href="javascript:Toggle('{./description}');">
<img src="../images/openfolder.gif" width="16" height="16"
hspace="0" vspace="0" border="0"/>
</a>
</td>
<td>
<a id="x{./description}"
href="javascript:Toggle('{./description}');">
<b>
<xsl:value-of select="./description"/>
</b>
</a>
</td>
</tr>
</xsl:otherwise>
</xsl:choose>
</table>

<xsl:if test="string-length(./contents/entity)&gt;5">
<DIV id="{./description}" style="display: none; margin-left: 2em;">
<xsl:for-each select="./contents/entity">
<table border="0" cellpadding="1" cellspacing="1">
<tr>
<td width="16">

<DIV id="x{./Programmeid}" style="display:hidden;">
<img src="../images/doc.gif" width="16" height="16" hspace="0"
vspace="0" border="0"/>
</DIV>

</td>
<td>
<b>
<xsl:value-of select="./description"/>
</b>

</td>
</tr>
</table>
</xsl:for-each>
</DIV>
</xsl:if>
</xsl:for-each>
</DIV>
</xsl:for-each>
</DIV>
</xsl:for-each>

If any one has easier approach to generate the tree structure kindly
suggest.

Regards
Raghavendra K
Jul 20 '05 #1
  • viewed: 5566
Share:
2 Replies

"ragha" <pa********@yahoo.com> wrote in message
news:f5**************************@posting.google.c om...
Dear friends

I am emulating thr tree structure mentioned in the article
http://www.15seconds.com/issue/010921.htm

I have succesfully created the folder structure for level 2 I need
this structure till 5 level is there any easier way to generate this
using xsl

My xml tree node is [snipped]
xsl code which used to generate
[snipped]

If any one has easier approach to generate the tree structure kindly
suggest.


Yes.

Read about xsl:template and xsl:apply-templates.

In your code you need to have a single xsl:template matching "entity". No
need of using xsl:for-each or repeating the same code fixed number of times.
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
Jul 20 '05 #2
Dear Novatchev,

Thank you for your response.

Regards
Ragha

"Dimitre Novatchev" <dn********@yahoo.com> wrote in message news:<bp*************@ID-152440.news.uni-berlin.de>...
"ragha" <pa********@yahoo.com> wrote in message
news:f5**************************@posting.google.c om...
Dear friends

I am emulating thr tree structure mentioned in the article
http://www.15seconds.com/issue/010921.htm

I have succesfully created the folder structure for level 2 I need
this structure till 5 level is there any easier way to generate this
using xsl

My xml tree node is

[snipped]

xsl code which used to generate


[snipped]

If any one has easier approach to generate the tree structure kindly
suggest.


Yes.

Read about xsl:template and xsl:apply-templates.

In your code you need to have a single xsl:template matching "entity". No
need of using xsl:for-each or repeating the same code fixed number of times.
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Andi Plotsky | last post: by
reply views Thread by John H. | last post: by
4 posts views Thread by shuisheng | last post: by
5 posts views Thread by ken | last post: by
8 posts views Thread by Sharktbbtfy | last post: by
2 posts views Thread by graphicsxp | last post: by
3 posts views Thread by prasath03 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.