I've an html table written using xslt transformation that looks like this
<table>
<xsl:for-each select="someNode">
<xsl:if test="testThis">
<tr>
<!-- <xsl:call-template name="conditionalRowStyle"/> -->
<td>something</td>
</tr>
</xsl:if>
<tr>
<!-- <xsl:call-template name="conditionalRowStyle"/> -->
<td>this is always displayed</td>
</tr>
<xsl:if test="testThis2">
<tr>
<!-- <xsl:call-template name="conditionalRowStyle"/> -->
<td>something 2</td>
</tr>
</xsl:if>
....
</xsl:for-each>
<tr>
<!-- <xsl:call-template name="conditionalRowStyle"/> -->
<td>this is always displayed</td>
</tr>
</table>
I need a way to apply different classes oddRow/evenRow to tr elems.
<tr class="evenRow"> or <tr class="oddRow">
I tried to use a template like this after every <tr> elem
<xsl:template name="conditionalRowStyle">
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="(count(../preceding-sibling::tr) mod 2) = 0">oddrow</xsl:when>
<xsl:otherwise>evenrow</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:template>
but this is not working. any idea?