• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get XSL table with alternating rows highlighted

 
Rajitha Ereddy
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have one more doubt in XSL if any one can help i would be thankful to you.Its like i have a table called transaction and the XML for that perticular table is as given:
<Transaction>
<TransactionDate>10/02/1999</TransactionDate>
<TransactionDescription>Interest paid</TransactionDescription>
<Sequence>Transaction Sequence Number</Sequence>
<Amount>50.00</Amount>
<Balance>2000.00</Balance>
</Transaction>

so for this table i want the xsl insuch a way that the alternate rows bgcolors should be diff like if even No: rows are blue in color i want the odd No: rows to be in yellow color so iam doing it using the position method but it is not working and my XSL goes like this:

<xsl:template match="Transaction">
<xsl:variable name="var">
<xsl:choose>
<xsl:when test=" position( ) mod 2 = 0">bgcolor=#FF6600</xsl:when>
<xsl therwise>bgcolor=#FFFFFF</xsl therwise>
</xsl:choose>
</xsl:variable>
<tr valign="top">
<xsl:attribute name="bgcolor"><xsl:value-of select="$var"/></xsl:attribute>
<td width="23%" align="center">
<xsl:value-of select="TransactionDate"/>
</td>
<td width="23%" align="center">
<xsl:value-of select="TransactionDescription"/>
</td>
<td width="23%" align="center">
<xsl:value-of select="Amount"/>
</td>
<td width="23%" align="center">
<xsl:value-of select="Balance"/>
</td>
<td width="40%">
<table border="0" cellspacing="1" cellpadding="1" width="677">
<tr>
<td width="103" height="21" bgcolor="#FFFFFF">
<xsl:value-of select="TransactionDate"/>
<font size="2" face="arial" color="#003366">
<xsl:value-of select="TransactionDate"/>
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
</font>
</td>
<td width="322" height="21" bgcolor="#FFFFFF">
<font size="2" face="arial" color="#003366">
<xsl:value-of select="TransactionDescription"/>
</font>
</td>
<td width="98" height="21" bgcolor="#FFFFFF">
<font size="2" face="arial" color="#003366">
<xsl:value-of select="Amount"/>
</font>
</td>
<td width="101" height="21" bgcolor="#FFFFFF">
<font size="2" face="arial" color="#003366">
<xsl:value-of select="Balance"/>
</font>
</td>
</tr>
<!--</xsl:for-each>-->
</table>
</td>
</tr>
</xsl:template>

So if possible can anyone tell how it can be achieved and i will be very thankful for that.Anyway thanks in advance.
Regards,
Rajitha.
 
prabhu palanisamy
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use xsl:script to get alternate bg colors
regards
prabhu
 
Jane Griscti
Ranch Hand
Posts: 3141
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rajitha,
Khun Yee Fung has an example of how to do this in his book XSLT: Working with XML and HTML

It works quite nicely.
Hope it helps.
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
[This message has been edited by Jane Griscti (edited March 09, 2001).]
 
Rajitha Ereddy
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jane Griscti,
Thanks for the code and its working.
Regards,
Rajitha.
 
Kamil Nishijima
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not getting this error
Unknown method. -->position()<-- mod 2 = 0
could I see the position function please?

[This message has been edited by Kamil Nishijima (edited July 17, 2001).]
 
Mapraputa Is
Leverager of our synergies
Sheriff
Posts: 10065
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Old versions MSXML did not support all functions. Do you use Internet Explorer for XSLT transformation?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic