<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"> <xsl:output method="xml" indent="yes" encoding="utf-8"/> <!-- Find the root node called Menus and call MenuListing for its children --> <xsl:template match="/Menus"> <MenuItems> <xsl:call-template name="MenuListing" /> </MenuItems> <xsl:for-each select="Menus"> <xsl:choose> <xsl:when test="Name!=''"> <xsl:text>HomePage</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>HomePage</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template> <!-- Allow for recusive child node processing --> <xsl:template name="MenuListing"> <xsl:apply-templates select="Menu" /> </xsl:template> <xsl:template match="Menu"> <MenuItem> <!-- Convert Menu child elements to MenuItem attributes --> <xsl:attribute name="MenuText"> <xsl:value-of select="Name"/> </xsl:attribute> <xsl:attribute name="tooltip"> <xsl:value-of select="ToolTip"/> </xsl:attribute> <xsl:attribute name="destUrl"> <xsl:value-of select="NavigateUrl"/> </xsl:attribute> <!-- Call MenuListing if there are child Menu nodes --> <xsl:if test="count(Menu) > 0"> <xsl:call-template name="MenuListing" /> </xsl:if> </MenuItem> <!--</xsl:for-each>--> </xsl:template> </xsl:stylesheet>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)