[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Hello - how do I use the count function properly?

Subject: Re: Hello - how do I use the count function properly?
From: David Frey <dpfrey@xxxxxxx>
Date: Fri, 17 Sep 2010 13:26:20 -0700
Re:  Hello - how do I use the count function properly?
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:  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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.