Re: [xsl] Alternating Odd and Even with a twist

Subject: Re: [xsl] Alternating Odd and Even with a twist
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Date: Thu, 17 Oct 2002 22:26:05 +0200
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="roweven">How are you?</class>
<item2>How are you?</item2>
but say there was no information where How are you?
I want it to go:
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.


XSL-List info and archive:

Current Thread