mike-obrien.net Curriculum Vitae Blog Labs
Thursday, December 21, 2006

The XSL below illustrates how to alternate color using the mod operator and setting the style class. This allows to to create a general ledger look.

    <xsl:template match="log/entry">
        <div>
            <xsl:if test="position() mod 2 = 1">
                <xsl:attribute name="class">LogEntryHighlight</xsl:attribute>
            </xsl:if>
            <xsl:if test="position() mod 2 = 0">
                <xsl:attribute name="class">LogEntry</xsl:attribute>
            </xsl:if>
            <xsl:value-of select="."/>
        </div>    
    </xsl:template>