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

two column table with alternating row colors using xsl

Subject: two column table with alternating row colors using xsl xml and css
From: nicholse@xxxxxxxxxxxxxxxx
Date: Wed, 20 Aug 2003 01:03:28 -0700 (PDT)
xsl alternating row colors
Well I finally got it! Thanks for everyones input. Here is the xsl:
Eric


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fmp="http://www.filemaker.com/fmpdsoresult"
exclude-result-prefixes="fmp">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match="fmp:FMPDSORESULT">
<style>
.col1r0 { background-color: silver; color: black; width: 200;}
.col1r1 { color: gray; width: 75;}
.col2r0 { color: gray; width: 75;}
.col2r1 { background-color: silver; color: black; width: 200;}
</style>
<table>
<xsl:variable name="all_rows" select="fmp:ROW" />
<xsl:variable name="total" select="count($all_rows)" />
<xsl:for-each select="$all_rows[position() &lt;= ceiling($total div 2)]">
<xsl:sort select="fmp:Co" />
<tr>
<td class="col1r{position() mod 2}">
<b><xsl:value-of select="fmp:Co" /></b><br />
<xsl:value-of select="fmp:Address1" /><br />
<xsl:value-of select="fmp:City1" />, <xsl:value-of select="fmp:State1" />,
<xsl:value-of select="fmp:Zip1" />
<br />
<a>
<xsl:attribute name="href">javascript:var win =
window.open("http://<xsl:value-of select="fmp:WebPage" />")
</xsl:attribute>
<xsl:value-of select="fmp:WebPage" />
</a>
</td>
<td class="col1r{position() mod 2}">
<xsl:choose>
<xsl:when test="fmp:Phone1_Number">
(<xsl:value-of select="fmp:Phone1_Area_Code" />)
<xsl:value-of select="fmp:Phone1_Number" />
<br />
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</td>
<xsl:variable name="this_pos" select="position()" />
<xsl:variable name="next_item" select="$all_rows[$this_pos + floor($total
div 2)]" />
<td class="col2r{position() mod 2}">
<xsl:choose>
<xsl:when test="$next_item">
<b><xsl:value-of select="$next_item/fmp:Co" /></b><br />
<xsl:value-of select="$next_item/fmp:Address1" /><br />
<xsl:value-of select="$next_item/fmp:City1" />, <xsl:value-of
select="$next_item/fmp:State1" />, <xsl:value-of
select="$next_item/fmp:Zip1" />
<br />
<a>
<xsl:attribute name="href">javascript:var win =
window.open("http://<xsl:value-of select="$next_item/fmp:WebPage" />")
</xsl:attribute>
<xsl:value-of select="$next_item/fmp:WebPage" />
</a>
</xsl:when>
<xsl:otherwise>&#160;</xsl:otherwise>
</xsl:choose>
</td>
<td class="col2r{position() mod 2}">
<xsl:choose>
<xsl:when test="$next_item/fmp:Phone1_Number">
(<xsl:value-of select="$next_item/fmp:Phone1_Area_Code" />)
<xsl:value-of select="$next_item/fmp:Phone1_Number" />
<br />
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>

 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.