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 |
Michael Kay Saxonica
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] When I have a parent / has a , Dan Acuff | Thread | [xsl] xml:base URI ignored by docum, Lars Huttar |
[xsl] When I have a parent / has a , Dan Acuff | Date | [xsl] xml:base URI ignored by docum, Lars Huttar |
Month |