[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?
Dan,
The other issue here is your duplication of code, when the only difference between the two branches is the presence of the @style attribute in one. Consider something like this: <xsl:template match="category"> <xsl:for-each select="child::category"> <div class="cat_module"> <xsl:if test="position() mod 4 = 0"> <xsl:attribute name="style"> <xsl:text>margin-right: 0px !important</xsl:text> </xsl:attribute> </xsl:if> <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:for-each> </xsl:template> Cheers, Wendell At 04:01 PM 9/17/2010, you wrote: <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> ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|