[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

every tenth row change bgcolor

Subject: every tenth row change bgcolor
From: Jarkko Moilanen <Jarkko.Moilanen@xxxxxx>
Date: Fri, 6 Jun 2003 13:20:11 +0300 (EEST)
tr class
Ok, I've managed to get this far:

XML:

<?xml version="1.0" encoding="UTF-8"?>
<Report>

 <Row>white</Row>
 <Row>white</Row>
 <Row>white</Row>
 <Row>white</Row>
 <Row>white</Row>
 <Row>white</Row>
 <Row>white</Row>
 <Row>white</Row>
 <Row>white</Row>
 <Row>white</Row> <!-- 10 -->

 <Row>blue</Row>
 <Row>blue</Row>
 <Row>blue</Row>
 <Row>blue</Row>
 <Row>blue</Row>
 <Row>blue</Row>
 <Row>blue</Row>
 <Row>blue</Row>
 <Row>blue</Row>
 <Row>blue</Row> <!-- 20 -->

 <Row>white</Row>
 <Row>white</Row>
 <Row>white</Row>
 <Row>white</Row>
 <Row>white</Row>
 <Row>white</Row>
 <Row>white</Row>
 <Row>white</Row>
 <Row>white</Row>
 <Row>white</Row> <!-- 30 -->

</Report>

XSLT:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<!-- Root template of my stylesheet -->
   <xsl:template match="/">
     <html>
       <head>
          <title>Color rows</title>
	<style type="text/css">
	.r0 {background-color: white}
   	.r1 {background-color: blue}
	</style>
       </head>
       <body>
	<table border="1">
	<xsl:apply-templates/>
	</table>
       </body>
     </html>
   </xsl:template>

   <xsl:template match="Row">
     <tr class="r{(floor(position() div 20) mod 2)}">
       <xsl:apply-templates/>
     </tr>
   </xsl:template>

</xsl:stylesheet>

Current result:
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Cool XSLT App</title>
<style type="text/css">
	.r0 {background-color: white}
   	.r1 {background-color: blue}
	</style>
</head>
<body>
<table border="1">

 <tr class="r0">white</tr>
 <tr class="r0">white</tr>
 <tr class="r0">white</tr>
 <tr class="r0">white</tr>
 <tr class="r0">white</tr>
 <tr class="r0">white</tr>
 <tr class="r0">white</tr>
 <tr class="r0">white</tr>
 <tr class="r0">white</tr>
 <tr class="r1">white</tr>

 <tr class="r1">blue</tr>
 <tr class="r1">blue</tr>
 <tr class="r1">blue</tr>
 <tr class="r1">blue</tr>
 <tr class="r1">blue</tr>
 <tr class="r1">blue</tr>
 <tr class="r1">blue</tr>
 <tr class="r1">blue</tr>
 <tr class="r1">blue</tr>
 <tr class="r0">blue</tr>

 <tr class="r0">white</tr>
 <tr class="r0">white</tr>
 <tr class="r0">white</tr>
 <tr class="r0">white</tr>
 <tr class="r0">white</tr>
 <tr class="r0">white</tr>
 <tr class="r0">white</tr>
 <tr class="r0">white</tr>
 <tr class="r0">white</tr>
 <tr class="r1">white</tr>

</table>
</body>
</html>


1. The question is that why in the first group is only 9 rows?

2. In this part : (floor(position() div 20) mod 2),
   Am I saying something like modulate the group of
   20 by 0 and 1 values? Quess not, but have to suggest something =)

Cheers,
Jarkko

****************************************************************
Jarkko Moilanen          "Erehtyminen on inhimillista,
Researcher                mutta todella suuret mokat
jm60697@xxxxxx            vaativat tietokoneen käyttöä."
www.uta.fi/~jm60697
GSM: +358 50 3766 927
****************************************************************
* ITCM | Information Technology and Crisis Management
* http://www.itcm.org
****************************************************************






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.