This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Every other row with a different twist
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] Every other row with a different twist
- From: David Carlisle <davidc at nag dot co dot uk>
- Date: Tue, 16 Jan 2001 23:30:01 GMT
- References: <5.0.2.1.0.20010116152415.01d1dd60@mail7.circleserve.net>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Your three fields address/name employer/name employer/tel
appear to be in document order (if they are in the document)
does your DTD enforce that?
If so you can get away with
<xsl:template match="person">
<table>
<xsl:apply-templates select="
address/name | employer/name | employer/tel"/>
</table>
</xsl:template>
<xsl:template match="address/name">
<tr class="rowstyle{position() mod 2}">
<td>Person's home city:</td>
<td><xsl:value-of select="address/name"/></td>
</tr>
</xsl:template>
etc
plus suitable css for .rowstyle0 and .rowstyle1
If you can't be sure of the order, you can do two passes, first
generating the output tree into a node set and using a node-set
extension function provided by most xsl systems to add the attributes
later.
Alternatively of course you could do the colouring in the client with a
bit of javascript that coloured each row depending on its position
(but its too late at night for me to think javascript now)
David
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list