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

Subject: Re: [xsl] When I have a parent / has a subcat
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Mon, 26 Jul 2010 23:09:31 +0100
You've given us a cryptic statement of requirements, a pile of XSLT code that may or may not have any relevance to these requirements, no indication of your input, and no indication of your desired output, and no indication as to why you find it difficult or what approaches you have tried to solve it. Put yourselves in the shoes of people trying to help you - what information do you think they might need?

Michael Kay
Saxonica

On 26/07/2010 22:46, Dan Acuff wrote:
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=@name">
                         <xsl:if test="(child::category)">
                             <xsl:for-each select="child::category">
                                 <xsl:choose>
                                     <xsl:when
test="count(descendant::category)>  1">
                                         <li id="{@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="{@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="{@display_name} ">
                                 <xsl:value-of select="@display_name"/>
                             </a>
                         </li>
                     </xsl:when>
                     <xsl:otherwise>
                         <li>
                             <a href="{info//link}"
title="{@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
~~~~~~~~~~~~~~~~~~

Current Thread