Go Back   CodingForums.com > :: Client side development > XML

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-22-2002, 09:36 PM   PM User | #1
Evlich
New Coder

 
Join Date: Jun 2002
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Evlich is an unknown quantity at this point
Parsing help please...

Ok, I am having problems trying to figure this whole XSL thing out. Here is what my XML doc looks like:
Code:
<leftmenu>
 <menu title="Site">
  <item>Home</item>
  <item>Site Map</item>
  <item>News Archive</item>
  <item>About xElements</item>
  <item>Forums</item>
  <item>Contact</item>
 </menu>
 <menu title="Programming">
  <menu title="C &amp; C++">
   <item>Tutorials</item>
   <item>References</item>
   <item>Forms &amp; Discussions</item>
   <item>Samples &amp; Program</item>
  </menu>
  <menu title="Java">
   <item>Tutorials</item>
   <item>References</item>
   <item>Forms &amp; Discussions</item>
   <item>Samples &amp; Program</item>
  </menu>
 </menu>
 <menu title="Alogithm Archive">
  <item>The Archive</item>
  <item>Search</item>
  <item>Submit new Algorithm</item>
 </menu>
</leftmenu>
As you can see, it is recursive (the second level menu item is parsed the same way as the first level menu). Here is what I am using to parset it out:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="menu">
 <div class="MenuOFF" onmouseover="on(this)" onmouseou="off(this)" onclick="minmax(this)"><xsl:value-of select="title"/></div>
 <div class="subMenu">
 <xsl:for-each select="menu">
  <xsl:apply-templates/>
 </xsl:for-each>
 <xsl:for-each select="item">
  <xsl:apply-templates/>
 </xsl:for-each>
 </div>
</xsl:template>

<xsl:template match="leftmenu/menu/item">
 <div class="itemOFF" onmouseover="on(this)" onmouseout="off(this)" onclick="lnk('')"><xsl:value-of select="menu/item"/></div>
</xsl:template>

</xsl:stylesheet>
But it doesn't appear to be working. None of the titles in the menu tags show up. Can someone help? Also, how would I print out the text to the item element inside the template for the item element? Thanks a lot. I appreciate it.
Evlich is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:58 PM.


Advertisement
Log in to turn off these ads.