I need to create an XML package that displays all sub categories under a root category by default. Also, if one of those sub categories is selected, then any child categories for that sub category should be shown.. hope that makes sense!
THe package below almost works, but not quite. The 'root' category is 161. If either category 161 or any descendant category is selected the navigation displays perfectly. However if the home page (no category), or any other categories that are not either 161 or a descendant are selected, nothing is displayed....
Can anyone offer any guidance here?
C#/VB.NET Code:
<xsl:template match="Entity">
<xsl:param name="prefix"></xsl:param>
<xsl:param name="eName" select="aspdnsf:GetMLValue(Name)" />
<!-- this will work as long as already in a sub category of lighting, if not nothing is displayed-->
<xsl:if test="ancestor::Entity/EntityID = 161">
<tr>
<td>
<xsl:if test="count(ancestor::Entity) = 1">
<xsl:attribute name="class">cat1</xsl:attribute>
</xsl:if>
<xsl:if test="count(ancestor::Entity) > 1">
<xsl:attribute name="class">cat2</xsl:attribute>
</xsl:if>
<xsl:value-of select="$prefix" />
<a href="{concat('c-',EntityID,'-',SEName,'.aspx')}">
<xsl:if test="EntityID = $CategoryID and count(ancestor::Entity) > 1">
<xsl:attribute name="class">lnkCat2</xsl:attribute>
</xsl:if>
<xsl:if test="EntityID != $CategoryID and count(ancestor::Entity) > 1">
<xsl:attribute name="class">lnkCat1</xsl:attribute>
</xsl:if>
<xsl:if test="EntityID = $CategoryID and count(ancestor::Entity) = 1">
<xsl:attribute name="class">lnkCatSelected</xsl:attribute>
</xsl:if>
<xsl:if test="EntityID != $CategoryID and count(ancestor::Entity) = 1">
<xsl:attribute name="class">lnkCat</xsl:attribute>
</xsl:if>
<xsl:value-of select="$eName"/>
</a>
</td>
</tr>
</xsl:if>
<xsl:if test="count(child::Entity)>0 and (EntityID = $CategoryID or descendant::Entity/EntityID = $CategoryID)">
<xsl:apply-templates select="Entity">
</xsl:apply-templates>
</xsl:if>
</xsl:template>