xsl-list
[Top] [All Lists]

[xsl] When I have a parent / has a subcat

2010-07-26 16:46:47
How do I form the xsl so that I can put a "selected" class for the
parent of the child class I have currently selected?

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
    <xsl:output encoding="UTF-8" method="html" version="4.01"
omit-xml-declaration="yes"
        media-type="text/html"/>
    <xsl:param name="leftNavId"/>
    <xsl:template match="menu">
        <xsl:choose>
            <xsl:when test="$leftNavId = 'nothing'">
                <!--do nothing-->
            </xsl:when>
        </xsl:choose>
        <ul class="adxm menu">
        <xsl:apply-templates select="category"/>
        </ul>
    </xsl:template>

    <xsl:template match="category">
        <xsl:choose>
            <xsl:when test="$leftNavId = 'nothing'">
                <!--do nothing-->
            </xsl:when>
            <xsl:otherwise>
                <xsl:choose>
                    <xsl:when test="$leftNavId=(_at_)name">
                        <xsl:if test="(child::category)">
                            <xsl:for-each select="child::category">
                                <xsl:choose>
                                    <xsl:when
test="count(descendant::category) > 1">
                                        <li id="{(_at_)name}"
class="leftnav_parent">
                                            <xsl:call-template
name="leftNavParentCheck"/>
                                        </li>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <li class="leftnav_noflyout">
                                            <xsl:call-template
name="leftNavParentCheck"/>
                                        </li>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:for-each>
                        </xsl:if>
                    </xsl:when>
                </xsl:choose>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="leftNavParentCheck">
        <a href="{info//link}" title="{(_at_)display_name} ">
            <xsl:value-of select="@display_name"/>
        </a>
        <ul>
            <xsl:for-each select="descendant::category">
                <xsl:choose>
                    <xsl:when test="count(descendant::category) > 1">
                        <li class="">
                            <a href="{info//link}"
title="{(_at_)display_name} ">
                                <xsl:value-of select="@display_name"/>
                            </a>
                        </li>
                    </xsl:when>
                    <xsl:otherwise>
                        <li>
                            <a href="{info//link}"
title="{(_at_)display_name} ">
                                <xsl:value-of select="@display_name"/>
                            </a>
                        </li>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:for-each>
        </ul>
    </xsl:template>
</xsl:stylesheet>

~~~~~~~~~~~~~~~~~~
Dan Acuff
Developer
SureSource LLC
20 Constitution Blvd. South
Shelton, CT  06484

203.922.7546 direct
~~~~~~~~~~~~~~~~~~


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>