Create menu using xml and xslt

A

Anthony

Hi all,

i have managed to create an asp.net menu using xml and xslt.. i am now
trying to highlite the selected path by sending in the path info and
hilite it using an xsl select choose function. My only problem now is
to highlight all parent nodes above the one selected. Does anyone have
any ideas as to achieve this..

XML DATA
..........................................................
<?xml version="1.0" ?>
<MenuData>
NEEDS TO BE HIGHLIGHTED <MenuGroup Menu="True" ID="About"
Label="About" URL="/1/about/" Image="about_thumb.jpg" Text="A history
of our its origins and pedigree">
FOUND AND HIGHLIGHTED <MenuItem Box="True" ID="About1"
Label="Introduction" URL="/1/about/introduction.aspx"
Image="about_intro_thumb.jpg" Text="A brief outline of the Group and
its composite parts"/>
</MenuGroup>
<MenuData>
...............................................


xslt:
-----------------------------------------------------
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:param name="sectionID" />
<xsl:param name="urlID" />
<xsl:template match="/MenuData/MenuGroup">
<xsl:if test="@ID=$sectionID">
<div class="divHeaderBlue">Sub Menu</div>
<div class="link-list">
<ul class="light">
<xsl:for-each select="MenuItem">
<xsl:choose>
<xsl:when test="@URL=$urlID">
<li class="blue">
<a>
<xsl:attribute name="href">
<xsl:value-of select="@URL" />
</xsl:attribute>
<xsl:value-of select="@Label" />
</a>
</li>
</xsl:when>
<xsl:blush:therwise>
<li>
<a>
<xsl:attribute name="href">
<xsl:value-of select="@URL" />
</xsl:attribute>
<xsl:value-of select="@Label" />
</a>
</li>
</xsl:blush:therwise>
</xsl:choose>

</xsl:for-each>
</ul>
</div>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
 
N

Nick Stansbury

Hi Anthony,

You could try Telerik's menu system (at www.telerik.com) - a working
example of what you are looking at is here:

http://www.telerik.com/r.a.d.menu/default.aspx?Tab=Examples&Example=Functionality/ShowPath

This sort of functionality in the menu system you've already built might
be a bit tricky. You could, for example, use a recursive function to iterate
through the parent node of each node and change it's style.

Something like:

function SetParentPath(MyNode as Node)
MyNode.Highlighted = true
if not MyNode.ParentNode is nothing then
SetParentPath(MyNode.ParentNode)
end if
end function

Telerik's RAD menu has this built in I think - but if it didn't then you
could easily implement a function like this. In your context you will need
to expose a property on each node object that you've written called
Highlighted - which changes the style etc.

Is this any help?

Regards,

Nick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top