Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 8th, 2006, 08:25 AM
Registered User
Join Date: Apr 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default hi xml toggle effect

Thanks to allof u how have given pain to see my problem
i have an xml file having this tructure


the xslt file is this
   <table class="spec_item_table">

                <xsl:for-each select="specifications/row">
                  <tr class="spec_item_odd">
                      <xsl:value-of select="heading"></xsl:value-of>
                      <xsl:value-of select="data"></xsl:value-of>

my problem is that for each row it should show different colors like
row1:grey color

for that i used
 <tr class="spec_item_odd">

bit it will have same for all the rows so i can achive this in xml .thanks
in advance

Old September 8th, 2006, 09:04 AM
joefawcett's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

Usually a combination of the mod operator and the position() function will help. An easy way:
<tr class="spec_item_{(position() mod 2)}">
Then you need two CSS classes, spec_item_0 for even rows, spec-item_1 for odd rows.

Alternatively use xsl:call-template, or xsl:function in version 2.0 that returns odd or even:
  <xsl:template name="oddOrEven">
    <xsl:param name="position"/>
      <xsl:when test="$position mod 2 = 0">even</xsl:when>
Then do:
<xsl:for-each select="specifications/row">
<xsl:attribute name="class">
<xsl:text>spec_item_</xsl:text><xsl:call-template name="oddOrEven">
        <xsl:with-param name="position" select="position()"/>
      <xsl:value-of select="heading"></xsl:value-of>
      <xsl:value-of select="data"></xsl:value-of>

Joe (Microsoft MVP - XML)

Similar Threads
Thread Thread Starter Forum Replies Last Post
Toggle/Drilldown help...please!!! s15199d Reporting Services 4 March 24th, 2006 04:11 PM
Toggle CheckBox g_vamsi_krish ASP.NET 1.0 and 1.1 Basics 1 February 13th, 2006 03:00 AM
Toggle Buttons ctekk2005 Access 3 June 15th, 2005 03:36 AM
Toggle Key calvados VB.NET 2002/2003 Basics 2 December 17th, 2004 10:55 AM
Language toggle dsunmedia PHP How-To 2 August 2nd, 2004 11:00 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.