We help IT Professionals succeed at work.
Get Started

XSLT menu

Last Modified: 2013-11-19
Hi again!

I have an xml file for a menu (below):


Then i have this xslt file with a javascript for a dropdown menu (below):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

<xsl:template match="MenuItems/*">

<xsl:variable name="NodeName">
<xsl:value-of select="name(current())"/>
<script lang="javascript" type="text/javascript" >
 function HideShowDiv(divid)
      var divlayer = document.getElementById(divid);
      if(divlayer.style.display == "block")
      divlayer.style.display = "none";
      divlayer.style.display = "block"
  function ChangeBg(tdid)
  var td = document.getElementById(tdid);
  td.style.background = "#3399ff";
  td.style.color= "white";
  function ReturnBg(tdid)
  var td = document.getElementById(tdid);
  td.style.background = "white";
  td.style.color = "black";
<h1><xsl:value-of select="Menu/Title"/></h1>
<table border="1" width="150px" >
<td onmousedown="HideShowDiv('{$NodeName}')" align="Center"><xsl:value-of select="$NodeName"/></td>
<div style="OVERFLOW:AUTO; width=150px;height=100px; display:none" runat="server" id="{$NodeName}" >
<xsl:for-each select="node()">
<xsl:variable name="ChildNodeName">
<xsl:value-of select="./child::node()"/>
<td onmouseover="ChangeBg('{$ChildNodeName}')"
 id="{$ChildNodeName}" onmouseleave="ReturnBg('{$ChildNodeName}')"
 width="150px" align="center"><xsl:value-of select="$ChildNodeName"/></td>


I have a set of html files such as ALBUMS.html, SINGLES.html and i need to have hyperlinks from a subitem in the xml file such as <SubItem>Albums</SubItem> to a html file such as ALBUMS.html and so on for each individual sub item.
I've looked at xlink but can't get it to work.  Can anybody help me with this?
Watch Question
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE