:)
That code is neat.
Thank you very much for the solution, I appreciate your help.
-Regards
Rashmi
----- Original Message ----
From: Gabriel Osorio <gosorio(_at_)tournet(_dot_)com>
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Sent: Friday, February 16, 2007 9:07:19 PM
Subject: RE: [xsl] Recursively Generating Menu and Sub-Menu items
Good exercise!!
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:template match="item">
<ul>
<li>
<xsl:value-of select="name" />
</li>
<xsl:apply-templates select="item" />
</ul>
</xsl:template>
</xsl:stylesheet>
-----Original Message-----
From: Rashmi Rubdi [mailto:dev_subscriptions(_at_)yahoo(_dot_)com]
Sent: Friday, February 16, 2007 7:50 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Recursively Generating Menu and Sub-Menu items
Hello Everyone,
I'm still learning XSLT while also learning other languages so it has been a
little slow for me to pick things up with each language.
I did some searching on my problem, and came accross a few similar threads
but the code they demostrated was rather large and contained unrelated code
with it, so it was a little difficult to understand the desired solution.
I want to recursively generate nested menus with XSLT with the menu
structured inside an XML.
I have a sample XML structure which is supposed to represent a Menu
hierarchy as follows:
(Please note that I'm flexible with any other XML structure that represents
a nested menu, if it helps to improves the XSLT solution)
<?xml version="1.0" encoding="UTF-8"?>
<item>
<name>Main Menu</name>
<item>
<name>First Level Item</name>
<item>
<name>Second Level Item</name>
<item>
<name>Third Level Item</name>
</item>
</item>
</item>
<item>
<name>ABC</name>
<item>
<name>XYZ</name>
<name>PQR</name>
</item>
<item>
<name>LMN</name>
</item>
</item>
</item>
The desired output is in the form of an HTML nested list as follows:
<ul>
<li>Main Menu
<ul>
<li>First Level Item
<ul>
<li>Second Level Item
<ul>
<li>Third Level Item</li>
</ul>
</li>
</ul>
</li>
<li>ABC
<ul>
<li>XYZ</li>
<li>PQR</li>
<li>LMN</li>
</ul>
</li>
</ul>
</li>
</ul>
I have tried to generate the above output with the following XSLT 1.0 :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="item"/>
</xsl:template>
<xsl:template match="item">
<ul>
<xsl:apply-templates select="name"/>
</ul>
</xsl:template>
<xsl:template match="name">
<li>
<xsl:value-of select="name"/>
</li>
</xsl:template>
</xsl:stylesheet>
but the above xslt generates this ouput: <ul><li/></ul>
Any help is appreciated.
-Regards
Rashmi
____________________________________________________________________________
________
Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
http://answers.yahoo.com/dir/?link=list&sid=396546091
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http:
mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
____________________________________________________________________________________
TV dinner still cooling?
Check out "Tonight's Picks" on Yahoo! TV.
http://tv.yahoo.com/
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--