<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="utf-8" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml"/>
<xsl:template match="/">
<xsl:apply-templates select="shop"/>
</xsl:template>
<!-- Шаблон для магазина -->
<xsl:template match="/shop">
<SCRIPT>
<xsl:comment>
<xsl:text disable-output-escaping="yes">
<![CDATA[
function show_hide_menu(id)
{
if (obj = document.getElementById(id))
{
obj.style.display == 'none' ? obj.style.display = 'block' : obj.style.display = 'none';
return false;
}
return true;
}
]]>
</xsl:text>
</xsl:comment>
</SCRIPT>
<xsl:variable name="parent_group_id" select="@current_group_id"/>
<!-- Выводим группы магазина -->
<ul class="super_menu">
<xsl:apply-templates select="//group[@parent=0]"/>
</ul>
</xsl:template>
<!-- Шаблон для групп товара -->
<xsl:template match="group">
<xsl:variable name="current_group_id" select="/shop/ТекущаяГруппа"/>
<li>
<xsl:if test="$current_group_id = @id">
<xsl:attribute name="id">active</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="$current_group_id = @id or count(.//group[@id=$current_group_id])=1 or count_all_groups > 0">
<!-- Определяем стиль вывода ссылки -->
<xsl:variable name="link_style">
<xsl:choose>
<!-- Выделяем текущую ссылку жирным (если это текущая страница) -->
<xsl:when test="$current_group_id = @id">active</xsl:when>
<!-- Выделяем текущую ссылку подчеркиванием (если это группа) -->
<xsl:when test="count_all_groups > 0">group</xsl:when>
<!-- Выделяем ссылку если и то и другое-->
<xsl:when test="$current_group_id = @id and count_all_groups > 0">active group</xsl:when>
<!-- Иначе обычный вывод с пустым стилем -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<a onClick="return show_hide_menu('{@id}'

;" href="{/shop/path}{fullpath}" class="{$link_style}">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
</xsl:when>
<xsl:otherwise>
<a onClick="return show_hide_menu('{@id}'

;" href="{/shop/path}{fullpath}">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
</xsl:otherwise>
</xsl:choose>
<!-- Если есть подгруппы -->
<xsl:if test="group">
<ul id="{@id}" style="display: none;" class="super_menu_2">
<xsl:apply-templates select="group"/>
</ul>
</xsl:if>
</li>
</xsl:template>
</xsl:stylesheet>