Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 20th, 2007, 10:25 AM
Registered User
 
Join Date: Jun 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default onmouseover____ displays the child nodes of the 1s

Hi,

I am designing a menu where when I mouseover the parent menu, its corresponding submenu gets displayed.

But the problem is whenever i mouseover any of the parent node, the child nodes of the 1st parent in the xml gets displayed.
Somehow the div that contains the child nodes always contain the child nodes of the 1st parent.

Menu.xsl:

<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<xsl:apply-templates select="MainMenu"/>
</xsl:template>

<xsl:template match="MainMenu">
<xsl:apply-templates select="item" mode="MainMenu"/>
</xsl:template>

<xsl:template match="item" mode="MainMenu">


<a class="MainMenuLink" >
<xsl:attribute name="href">
<xsl:value-of select="@url"/>
</xsl:attribute>
<xsl:attribute name="onmouseover_">
<xsl:if test="./SubMenu >
document.getElementById('HoverMenu').style.display ='block';
</xsl:if>
</xsl:attribute>
<xsl:value-of select="@label"/>
</a>

<xsl:if test="./SubMenu">
<div id="HoverMenu" >
<xsl:apply-templates select="SubMenu" />
</div>
</xsl:if>


</xsl:template>

<xsl:template match="SubMenu" >
<xsl:apply-templates select="item" mode="HoverMenu"/>
</xsl:template>

<xsl:template match="item" mode="HoverMenu">
<div id ="HoverMenuItem">
<a >
<xsl:attribute name="href">
<xsl:value-of select="@url"/>
</xsl:attribute>
<xsl:value-of select="@label"/>

</a>
</div>
</xsl:template>

</xsl:stylesheet>



menu.xml:
<?xml version="1.0" encoding="utf-8" ?>
- <MainMenu>
- <item label="Tutorial" url="default.aspx">
- <SubMenu>
<item label="HTML" />
<item label="XHTML" />
<item label="CSS" />
<item label="XML" />
<item label="XSL" />
</SubMenu>
</item>
<item label="Scripting" url="default.aspx" />
- <item label="Validation" url="default.aspx">
- <SubMenu>
<item label="JavaScript" />
<item label="VBScript" />
</SubMenu>
</item>
</MainMenu>

I wrote the following onmouseover____ document.getElementById('HoverMenu').style.display ='block'; where 'HoverMenu' is the div that contains the child nodes.
But when I mouseover any of the parent node , the 'HoverMenu'displays only the child nodes of 1st parent node.

Somehow the getElementById('HoverMenu') assigns the ID to all the parent menu.which should be unique . All my parent nodes (main menu) are dynamically generated from XML .

Please suggest how I can get the correct child nodes in 'HoverMenu' when I mouseover its corresponding parent menu.
 
Old June 20th, 2007, 12:08 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I would recommend designing and debugging your HTML first, and then writing the XSLT to generate the HTML once you know that it works.

Your problem here looks like an HTML problem rather than an XSLT problem.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
not able to print out the child nodes eruditionist XSLT 7 October 30th, 2008 10:33 AM
text and child nodes eepyoga XSLT 1 April 8th, 2008 12:45 PM
Retrieveal of child nodes.... nathilson21 Classic ASP XML 0 May 7th, 2007 04:54 AM
Trying to group child nodes aalbetski XSLT 3 November 18th, 2006 01:29 PM
counting child nodes Tomi XSLT 1 September 6th, 2006 03:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.