|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
XSL: applying style to alternating rows
I'd like to generate a simple HTML table, where every second row is light grey. How can I do this with XSL?
__________________
Hello, old friend... |
|
#2
|
||||
|
||||
|
In your CSS just define oddRow and evenRow.
This can go in a template that matches a data element that belongs in a row: Code:
<xsl:variable name="rowClass">
<xsl:call-template name="getTableRowClass"/>
</xsl:variable>
<tr class="{$rowClass}">
...
</tr>
Here is the common template that would most likely be put in an imported file: Code:
<xsl:template name="getTableRowClass"> <xsl:choose> <xsl:when test="position() mod 2 = 1"> <xsl:text>oddRow</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>evenRow</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> |
|
#3
|
||||
|
||||
|
Awesome! That's exactly what I need.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > XSL: applying style to alternating rows |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|