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 & C++">
<item>Tutorials</item>
<item>References</item>
<item>Forms & Discussions</item>
<item>Samples & Program</item>
</menu>
<menu title="Java">
<item>Tutorials</item>
<item>References</item>
<item>Forms & Discussions</item>
<item>Samples & 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.