Subject: [xsl] Hello - how do I use the count function properly? From: "Dan Acuff" <dacuff@xxxxxxxxxxxxxx> Date: Fri, 17 Sep 2010 16:01:05 -0400 |
I have sample xml: <category name="mens_apparel" display_name="Mens"> <info> <keyword>C1</keyword> <link>/category/mens_apparel</link> <titletag></titletag> <images> <image/> </images> <metaDescription></metaDescription> </info> <category name="mens_shirts" display_name="Shirts"> <info> <keyword>IHMTEE</keyword> <link>/products/mens_apparel/mens_shirts</link> <titletag></titletag> <images> <image/> </images> <metaDescription></metaDescription> </info> </category> <category name="mens_sweatshirts" display_name="Sweatshirts"> <info> <keyword>IHMSWEAT</keyword> <link>/products/mens_apparel/mens_sweatshirts</link> <titletag></titletag> <images> <image/> </images> <metaDescription></metaDescription> </info> </category> <category name="mens_outerwear" display_name="Outerwear"> <info> <keyword>IHMOUT</keyword> <link>/products/mens_apparel/mens_outerwear</link> <titletag></titletag> <images> <image/> </images> <metaDescription></metaDescription> </info> </category> <category name="mens_accessories" display_name="Accessories"> <info> <keyword>IHMACC</keyword> <link>/products/mens_apparel/mens_accessories</link> <titletag></titletag> <images> <image/> </images> <metaDescription></metaDescription> </info> </category> </category> And on every 4th subcategory I just want to set the margin-right: 0px. Here is the XSL and my attempt. Please guide me. <xsl:template match="category"> <xsl:for-each select="child::category"> <xsl:choose> <xsl:when test="count(/child::category)=4 or count(/child::category)=8"> <div class="cat_module" style="margin-right: 0px !important"> <h2> <a href="{descendant::link}"> <xsl:value-of select="@display_name"/> <img src="{descendant::image}" alt=""/> </a> </h2> <a href="{descendant::link}"> <span>Shop Now</span> </a> </div> </xsl:when> <xsl:otherwise> <div class="cat_module"> <h2> <a href="{descendant::link}"> <xsl:value-of select="@display_name"/> <img src="{descendant::image}" alt=""/> </a> </h2> <a href="{descendant::link}"> <span>Shop Now</span> </a> </div> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template> Dan Acuff
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] selecting following attri, Lars Huttar | Thread | Re: [xsl] Hello - how do I use the , David Frey |
Re: [xsl] selecting following attri, David Carlisle | Date | Re: [xsl] Hello - how do I use the , David Frey |
Month |