Page 1 of 1

How to form the xsl file

Posted: Wed May 06, 2015 10:24 am
by Patrik iden
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.

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 -->
This is the xsl i have now, but it does not work:

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>

Re: How to form the xsl file

Posted: Wed May 06, 2015 10:59 am
by Pablo
I'm sorry I cannot help you write xsl files, for me that would also take some time to try to see what works.
However your current version does not seems to be valid.

For example:

Code: Select all

<ul class="nav-submenu">
<li class="nav-submenu-item">
<xsl:apply-templates select="ITEM"/>
</ul>
is missing a closing </li>

Re: How to form the xsl file

Posted: Wed May 06, 2015 3:50 pm
by Patrik iden
OK. Thank's anyway.