This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: doubt regarding position() mod 2
- From: "Michael Kay" <michael dot h dot kay at ntlworld dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Tue, 23 Apr 2002 08:57:06 +0100
- Subject: RE: [xsl] doubt regarding position() mod 2
- Reply-to: xsl-list at lists dot mulberrytech dot com
> In my XSL, I tried using a test condition <xsl:if
> test="position() mod 2 = 1">,
> This test condition should return true for any item element
> that is an odd-numbered item child of its parent and hence
> 'Meat' and 'Chocolate' should be diplayed in the same color
> whereas 'Dairy' should be in a different color.
> However, I am getting all these in the same color.
You probably forgot to strip out the whitespace text nodes, which means that
the children of an element will have whitespace text nodes at odd numbered
positions and element nodes at even numbered positions.
Use <xsl:strip-space elements="*"/>
Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list