Subject: Re: [xsl] Hello - how do I use the count function properly? From: David Frey <dpfrey@xxxxxxx> Date: Fri, 17 Sep 2010 13:26:20 -0700 |
I don't think the count function does what you think it does. The count function gives the number of nodes in the node-set you pass to it. The position function is probably of more use to you in this case. ----- Original Message ----- From: Dan Acuff <dacuff@xxxxxxxxxxxxxx> Date: Friday, September 17, 2010 1:01 pm Subject: [xsl] Hello - how do I use the count function properly? To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > 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> > > <xsl:value-of > select="@display_name"/> <img src="{descendant::image}" alt=""/> > > </h2> > > <span>Shop Now</span> > > </div> > </xsl:when> > <xsl:otherwise> > <div class="cat_module"> > <h2> > > <xsl:value-of > select="@display_name"/> <img src="{descendant::image}" alt=""/> > > </h2> > > <span>Shop Now</span> > > </div> > </xsl:otherwise> > </xsl:choose> > </xsl:for-each> > </xsl:template> > > Dan Acuff
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Hello - how do I use the coun, Dan Acuff | Thread | Re: [xsl] Hello - how do I use the , Michael Kay |
[xsl] Hello - how do I use the coun, Dan Acuff | Date | Re: [xsl] Hello - how do I use the , Michael Kay |
Month |