How to form the xsl file
Posted: Wed May 06, 2015 10:24 am
Hello i have this HTML menu and xsl code but the xsl code is not working. Any boudy know how to form the xsl code for this HTML menu?
Thank you.
This is the xsl i have now, but it does not work:
Thank you.
Code: Select all
<!-- Nav -->
<nav class="nav">
<ul class="nav-list">
<li class="nav-item">
<a href="?=home">Home</a>
<ul class="nav-submenu">
<li class="nav-submenu-item">
<a href="?=submenu-1">Submenu item 1</a>
</li>
<li class="nav-submenu-item">
<a href="?=submenu-2">Submenu item 2</a>
</li>
<li class="nav-submenu-item">
<a href="?=submenu-3">Submenu item 3</a>
</li>
<li class="nav-submenu-item">
<a href="?=submenu-4">Submenu item 4</a>
</li>
</ul>
</li>
<li class="nav-item">
<a href="?=about">About</a>
</li>
<li class="nav-item">
<a href="?=services">Services</a>
<ul class="nav-submenu">
<li class="nav-submenu-item">
<a href="?=submenu-1">Submenu item 1</a>
</li>
<li class="nav-submenu-item">
<a href="?=submenu-2">Submenu item 2</a>
</li>
<li class="nav-submenu-item">
<a href="?=submenu-3">Submenu item 3</a>
</li>
<li class="nav-submenu-item">
<a href="?=submenu-4">Submenu item 4</a>
</li>
</ul>
</li>
<li class="nav-item">
<a href="?=portfolio">Portfolio</a>
</li>
<li class="nav-item">
<a href="?=testimonials">Testimonials</a>
</li>
<li class="nav-item">
<a href="?=contact">Contact</a>
</li>
</ul>
</nav>
<!-- /Nav -->
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:call-template name="menu" />
</xsl:template>
<xsl:template name="menu">
<ul class="nav-list>
<xsl:apply-templates select="MENU/ITEM" />
</ul>
</xsl:template>
<xsl:template match="ITEM">
<li class="nav-item">
<a href="{URL}"><xsl:value-of select="NAME"/><xsl:value-of select="TITLE"/></a>
<xsl:if test="ITEM">
<ul class="nav-submenu">
<li class="nav-submenu-item">
<xsl:apply-templates select="ITEM"/>
</ul>
</xsl:if>
</li>
</li>
</xsl:template>
</xsl:stylesheet>