...

View Full Version : Parsing help please...



Evlich
12-22-2002, 10:36 PM
Ok, I am having problems trying to figure this whole XSL thing out. Here is what my XML doc looks like:


<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:


<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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum