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

Re: Alternating Odd and Even with a twist

Subject: Re: Alternating Odd and Even with a twist
From: Kuhns Matt <kuhns_m@xxxxxxxxx>
Date: Fri, 18 Oct 2002 06:57:30 -0700 (PDT)
xsl position odd even
Kuhns Matt wrote:
> I want to alternate rows between a odd and even
class
> in my CSS. The twist is that If there is no
> information in the tag I don't want to print and I
> want to maintain my odd and even structure. The html
> would look like this
> <class="rowodd">Hi</class>
> <class="roweven">How are you?</class>
> <class="rowodd">Bye</class>
> xml:
> <item1>Hi</item1>
> <item2>How are you?</item2>
> <item3>Bye</item3>
> but say there was no information where How are you?
> I want it to go:
> <class="rowodd">Hi</class>
> <class="roweven">Bye</class>
> xml:
> <item1>Hi</item1>
> <item3>Bye</item3>
> I can get the text not to print, but how do I assign
> the classes? 

I hope your elements are *not* named item1, item2,
item3...
But if you really want:
  <xsl:for-each
select="*[substring(name(),1,4)='item']">
    <class>
      <xsl:choose>
        <xsl:when test="position() mod 2 = 0">
           <xsl:attribute
name="name">even</xsl:attribute>
        </xsl:when>
        <xsl:otherwise>
           <xsl:attribute
name="name">odd</xsl:attribute>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:apply-templates/>
    </class>
  </xsl:for-each>
(Beware: untested)

I'm not sure what the "twist" is, it's a standard
technique.

J.Pietschmann

I'm sorry my description was a little misleading:
<System>
<Network>Hi</Network>
<Client>How are you?</Client>
<Server>Bye</Server>
<System>
So you couldn't parse the string and get the string
"item"


__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.