RE: Another Alternate table-row background color quest
My mistake in the response (above). position() keeps in step with the position of a node wrt its position in a [selected] nodeset, not just its position in the original document. It's properties such as prior-sibling, etc, that don't change from their original values. The upshot being that you don't need node-set() for what you're trying to do.
The following XSL picks out just the nodes of interest, adding a 0/1 according as the picked-out node is even/odd in the new nodeset. The (position() - 1) business is just to translate position() to be 0-based. Just to verify, you may want to change the selection below to nodes that you know are even/odd in the input XML, and still see that they take on 0/1 attributes based on their position in the newly-selected nodeset.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:apply-templates select="/Codes/Code[Name = 30 or Name=50 or Name=60]"/>
<xsl:template match="Code"> <xsl:copy> <xsl:attribute name="color"> <xsl:value-of select="(position() - 1) mod 2"/> </xsl:attribute> <xsl:copy-of select="*"/> </xsl:copy> </xsl:template>
Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format