你可以试试这个 XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:php="http://php.net/xsl" exclude-result-prefixes="php" version="1.0">
<xsl:output method="html" version="1.0" encoding="utf-8" indent="yes" omit-xml-declaration="no"/>
<xsl:template match="/">
<div id="menu">
<ul id="mega">
<xsl:for-each select="//Menu/MainMenu">
<xsl:choose>
<xsl:when test="@isdisplay=1 and @iscategory=1">
<xsl:element name="li">
<xsl:attribute name="style">
border-left:#ffffff 1px solid;
</xsl:attribute>
<xsl:attribute name="class">
<xsl:value-of select="@class"/>
</xsl:attribute>
<xsl:variable name="name">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php',$name,'','','')"/>
</xsl:attribute>
<xsl:value-of select="@displayname"/>
</xsl:element>
<xsl:if test="count(SubMenu) > 0">
<xsl:choose>
<xsl:when test="@name='Outdoor Gear'">
<div>
<xsl:apply-templates select="//Menu/MainMenu[@name='Outdoor Gear']">
</xsl:apply-templates>
</div>
</xsl:when>
<xsl:when test="@name='Clothing / Footwear'">
<div style="width:490px !important;">
<xsl:apply-templates select="//Menu/MainMenu[@name='Clothing / Footwear']"></xsl:apply-templates>
</div>
</xsl:when>
<xsl:when test="@name='Electronics'">
<div style="width:200px !important;">
<xsl:apply-templates select="//Menu/MainMenu[@name='Electronics']"></xsl:apply-templates>
</div>
</xsl:when>
<xsl:when test="@name='Gifts'">
<div style="width:200px !important;">
<xsl:apply-templates select="//Menu/MainMenu[@name='Gifts']"></xsl:apply-templates>
</div>
</xsl:when>
<xsl:when test="@name='Petzl'">
<div style="width:200px !important;">
<xsl:apply-templates select="//Menu/MainMenu[@name='Petzl']"></xsl:apply-templates>
</div>
</xsl:when>
</xsl:choose>
</xsl:if>
</xsl:element>
</xsl:when>
<xsl:when test="@isdisplay=1 and @iscategory=0">
<xsl:element name="li">
<xsl:attribute name="style">
border-left:#ffffff 1px solid;
</xsl:attribute>
<xsl:attribute name="class">
<xsl:value-of select="@class"/>
</xsl:attribute>
<xsl:variable name="name">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','',$name,'','','')"/>
</xsl:attribute>
<xsl:value-of select="@displayname"/>
</xsl:element>
</xsl:element>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</ul>
</div>
</xsl:template>
<xsl:template match="//Menu/MainMenu[@name='Outdoor Gear']">
<span class="main">
<h2>
<xsl:variable name="name">
<xsl:value-of select="SubMenu[@name='Water Sport']/@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,'','')"/>
</xsl:attribute>
<xsl:value-of select="SubMenu[@name='Water Sport']/@displayname" disable-output-escaping="yes"/>
</xsl:element>
</h2>
<xsl:for-each select="SubMenu[@name='Water Sport']/SubSubMenu">
<xsl:if test="@isdisplay=1">
<span class="inner">
<xsl:variable name="name">
<xsl:value-of select="//Menu/MainMenu[@name='Outdoor Gear']/SubMenu[@name='Water Sport']/@name"/>
</xsl:variable>
<xsl:variable name="name1">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,'')"/>
</xsl:attribute>
<xsl:value-of select="@displayname" disable-output-escaping="yes"/>
</xsl:element>
</span>
</xsl:if>
<xsl:for-each select="ChildMenu">
<xsl:if test="@isdisplay=1">
<span class="inner">
<xsl:variable name="name">
<xsl:value-of select="../../@name"/>
</xsl:variable>
<xsl:variable name="name1">
<xsl:value-of select="../@name"/>
</xsl:variable>
<xsl:variable name="name2">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,$name2)"/>
</xsl:attribute>
<xsl:value-of select="@displayname" disable-output-escaping="yes"/>
</xsl:element>
</span>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
<br clear="all" />
<h2>
<xsl:variable name="name">
<xsl:value-of select="SubMenu[@name='Archery']/@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,'','')"/>
</xsl:attribute>
<xsl:value-of select="SubMenu[@name='Archery']/@displayname" disable-output-escaping="yes"/>
</xsl:element>
</h2>
<xsl:for-each select="SubMenu[@name='Archery']/SubSubMenu">
<xsl:if test="@isdisplay=1">
<span class="inner">
<xsl:variable name="name">
<xsl:value-of select="//Menu/MainMenu[@name='Outdoor Gear']/SubMenu[@name='Archery']/@name"/>
</xsl:variable>
<xsl:variable name="name1">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,'')"/>
</xsl:attribute>
<xsl:value-of select="@displayname" disable-output-escaping="yes"/>
</xsl:element>
</span>
</xsl:if>
<xsl:for-each select="ChildMenu">
<xsl:if test="@isdisplay=1">
<span class="inner">
<xsl:variable name="name">
<xsl:value-of select="../../@name"/>
</xsl:variable>
<xsl:variable name="name1">
<xsl:value-of select="../@name"/>
</xsl:variable>
<xsl:variable name="name2">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,$name2)"/>
</xsl:attribute>
<xsl:value-of select="@displayname" disable-output-escaping="yes"/>
</xsl:element>
</span>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
<h2>
<xsl:variable name="name">
<xsl:value-of select="SubMenu[@name='Climbing']/@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,'','')"/>
</xsl:attribute>
<xsl:value-of select="SubMenu[@name='Climbing']/@displayname" disable-output-escaping="yes"/>
</xsl:element>
</h2>
<xsl:for-each select="SubMenu[@name='Climbing']/SubSubMenu">
<xsl:if test="@isdisplay=1">
<span class="inner">
<xsl:variable name="name">
<xsl:value-of select="//Menu/MainMenu[@name='Outdoor Gear']/SubMenu[@name='Climbing']/@name"/>
</xsl:variable>
<xsl:variable name="name1">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,'')"/>
</xsl:attribute>
<xsl:value-of select="@displayname" disable-output-escaping="yes"/>
</xsl:element>
</span>
</xsl:if>
<xsl:for-each select="ChildMenu">
<xsl:if test="@isdisplay=1">
<span class="inner">
<xsl:variable name="name">
<xsl:value-of select="../../@name"/>
</xsl:variable>
<xsl:variable name="name1">
<xsl:value-of select="../@name"/>
</xsl:variable>
<xsl:variable name="name2">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,$name2)"/>
</xsl:attribute>
<xsl:value-of select="@displayname" disable-output-escaping="yes"/>
</xsl:element>
</span>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
<br clear="all" />
<h2>
<xsl:variable name="name">
<xsl:value-of select="SubMenu[@name='Fishing']/@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,'','')"/>
</xsl:attribute>
<xsl:value-of select="SubMenu[@name='Fishing']/@displayname" disable-output-escaping="yes"/>
</xsl:element>
</h2>
<xsl:for-each select="SubMenu[@name='Fishing']/SubSubMenu">
<xsl:if test="@isdisplay=1">
<span class="inner">
<xsl:variable name="name">
<xsl:value-of select="//Menu/MainMenu[@name='Outdoor Gear']/SubMenu[@name='Fishing']/@name"/>
</xsl:variable>
<xsl:variable name="name1">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,'')"/>
</xsl:attribute>
<xsl:value-of select="@displayname" disable-output-escaping="yes"/>
</xsl:element>
</span>
</xsl:if>
<xsl:for-each select="ChildMenu">
<xsl:if test="@isdisplay=1">
<span class="inner">
<xsl:variable name="name">
<xsl:value-of select="../../@name"/>
</xsl:variable>
<xsl:variable name="name1">
<xsl:value-of select="../@name"/>
</xsl:variable>
<xsl:variable name="name2">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,$name2)"/>
</xsl:attribute>
<xsl:value-of select="@displayname" disable-output-escaping="yes"/>
</xsl:element>
</span>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</span>
<span class="main">
<h2>
<xsl:variable name="name">
<xsl:value-of select="SubMenu[@name='Track / Field / Court / Indoors']/@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,'','')"/>
</xsl:attribute>
<xsl:value-of select="SubMenu[@name='Track / Field / Court / Indoors']/@displayname" disable-output-escaping="yes"/>
</xsl:element>
</h2>
<xsl:for-each select="SubMenu[@name='Track / Field / Court / Indoors']/SubSubMenu">
<xsl:if test="@isdisplay=1">
<span class="inner">
<xsl:variable name="name">
<xsl:value-of select="//Menu/MainMenu[@name='Outdoor Gear']/SubMenu[@name='Track / Field / Court / Indoors']/@name"/>
</xsl:variable>
<xsl:variable name="name1">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,'')"/>
</xsl:attribute>
<xsl:value-of select="@displayname" disable-output-escaping="yes"/>
</xsl:element>
</span>
</xsl:if>
<xsl:for-each select="ChildMenu">
<xsl:if test="@isdisplay=1">
<span class="inner">
<xsl:variable name="name">
<xsl:value-of select="../../@name"/>
</xsl:variable>
<xsl:variable name="name1">
<xsl:value-of select="../@name"/>
</xsl:variable>
<xsl:variable name="name2">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,$name2)"/>
</xsl:attribute>
<xsl:value-of select="@displayname" disable-output-escaping="yes"/>
</xsl:element>
</span>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
<br clear="all" />
<h2>
<xsl:variable name="name">
<xsl:value-of select="SubMenu[@name='Hiking and Camping']/@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,'','')"/>
</xsl:attribute>
<xsl:value-of select="SubMenu[@name='Hiking and Camping']/@displayname" disable-output-escaping="yes"/>
</xsl:element>
</h2>
<xsl:for-each select="SubMenu[@name='Hiking and Camping']/SubSubMenu">
<xsl:if test="@isdisplay=1">
<span class="inner">
<xsl:variable name="name">
<xsl:value-of select="//Menu/MainMenu[@name='Outdoor Gear']/SubMenu[@name='Hiking and Camping']/@name"/>
</xsl:variable>
<xsl:variable name="name1">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,'')"/>
</xsl:attribute>
<xsl:value-of select="@displayname" disable-output-escaping="yes"/>
</xsl:element>
</span>
</xsl:if>
<xsl:for-each select="ChildMenu">
<xsl:if test="@isdisplay=1">
<span class="inner">
<xsl:variable name="name">
<xsl:value-of select="../../@name"/>
</xsl:variable>
<xsl:variable name="name1">
<xsl:value-of select="../@name"/>
</xsl:variable>
<xsl:variable name="name2">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,$name2)"/>
</xsl:attribute>
<xsl:value-of select="@displayname" disable-output-escaping="yes"/>
</xsl:element>
</span>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</span>
</xsl:template>
<xsl:template match="//Menu/MainMenu[@name='Clothing / Footwear']">
<span class="main">
<h2>
<xsl:variable name="name">
<xsl:value-of select="SubMenu[@name='Mountain Running']/@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Clothing / Footwear',$name,'','')"/>
</xsl:attribute>
<xsl:value-of select="SubMenu[@name='Mountain Running']/@displayname" disable-output-escaping="yes"/>
</xsl:element>
</h2>
<xsl:for-each select="SubMenu[@name='Mountain Running']/SubSubMenu">
<xsl:if test="@isdisplay=1">
<span class="inner">
<xsl:variable name="name">
<xsl:value-of select="../@name"/>
</xsl:variable>
<xsl:variable name="name1">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Clothing / Footwear',$name,$name1,'')"/>
</xsl:attribute>
<xsl:value-of select="@displayname" disable-output-escaping="yes"/>
</xsl:element>
</span>
</xsl:if>
<xsl:for-each select="ChildMenu">
<xsl:if test="@isdisplay=1">
<span class="inner">
<xsl:variable name="name">
<xsl:value-of select="../../@name"/>
</xsl:variable>
<xsl:variable name="name1">
<xsl:value-of select="../@name"/>
</xsl:variable>
<xsl:variable name="name2">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Clothing / Footwear',$name,$name1,$name2)"/>
</xsl:attribute>
<xsl:value-of select="@displayname" disable-output-escaping="yes"/>
</xsl:element>
</span>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</span>
</xsl:template>
<xsl:template match="//Menu/MainMenu[@name='Electronics']">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td height="5"></td>
</tr>
<xsl:for-each select="SubMenu">
<tr>
<td class="">
<xsl:variable name="name">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Electronics',$name,'','')"/>
</xsl:attribute>
<xsl:value-of select="@displayname" disable-output-escaping="yes"/>
</xsl:element>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="//Menu/MainMenu[@name='Gifts']">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td height="5"></td>
</tr>
<xsl:for-each select="SubMenu">
<tr>
<td class="">
<xsl:variable name="name">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Gifts',$name,'','')"/>
</xsl:attribute>
<xsl:value-of select="@displayname" disable-output-escaping="yes"/>
</xsl:element>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="//Menu/MainMenu[@name='Petzl']">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td height="5"></td>
</tr>
<xsl:for-each select="SubMenu">
<tr>
<td class="">
<xsl:variable name="name">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Petzl',$name,'','')"/>
</xsl:attribute>
<xsl:value-of select="@displayname" disable-output-escaping="yes"/>
</xsl:element>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
如果您遇到任何问题,请告诉我。