Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XSLT and HTML

 
Arsalan Lodhi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
how can I change color of rows dynamically because my rows are printed within xslt template match and If i hardcode the color then how can I change the color of a next row ?
any idea
arsalan
 
Mapraputa Is
Leverager of our synergies
Sheriff
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you need to alternate between two colors, you can use this idiom:
<tr>
<xsl:choose>
<xsl:when test='position() mod 2 = 0'>
<xsl:attribute name='BGCOLOR'>white</xsl:attribute>
</xsl:when>
<xsltherwise>
<xsl:attribute name='BGCOLOR'>gray</xsl:attribute>
</xsltherwise>
</xsl:choose>
<td> <!-- stuff for columns --> </td>
</tr>
(shamelessly stolen from: Khun Yee Fung. "XSLT: Working with XML and HTML")
If it is not what you want, then you should tell us more about your requirements - what exactly means "change color of rows dynamically"?
[This message has been edited by Mapraputa Is (edited July 08, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic