This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Trying to learn XSL


Hi Tucker:

I came up with the following code last week when attempting to do the
same thing you are.  It's not XSLT - Just plain ol' XSL.  I am a novice
myself, so there's probably a more elegant solution, especially if you
can use XSLT (I can't).

The basic structure of my table body elements is:

<TGROUP>
<TBODY>
<ROW>
<ENTRY></ENTRY>
<ENTRY></ENTRY>
</ROW>
<ROW>
<ENTRY></ENTRY>
<ENTRY></ENTRY>
</ROW>
</TBODY>
</TGROUP>

This segment of code is from within the table template, after the table
header has been dealt with:

	<xsl:for-each select="TGROUP/TBODY//ROW">
		<xsl:choose>
		<xsl:when expr="odd(this)">
		<TR CLASS="clsOddRow">
			<xsl:for-each select="ENTRY">
				<TD>
				<xsl:value-of select="." />
				</TD>
			</xsl:for-each>
		</TR>
		</xsl:when>
		<xsl:otherwise>
			<TR CLASS="clsEvenRow">
				<xsl:for-each select="ENTRY">
					<TD>
					<xsl:value-of select="." />
					</TD>
				</xsl:for-each>
			</TR>
		</xsl:otherwise>
		</xsl:choose>
	</xsl:for-each>

Here's the odd function used in the code above:

	<xsl:script><![CDATA[
	function odd(e) {
	    return absoluteChildNumber(e)%2 != 0;
	}
	]]></xsl:script>

The actual shading/coloring of the rows is done in a separate CSS file,
as, for our project, we wish to keep the specific formatting details out
the XSL.  Here's the segment of the CSS file that deals with clsOddRow:

	TR.clsOddRow
	{
	    BACKGROUND-COLOR: gray;
	}

Hope this helps a little.  You'd have to modify to deal with cells
rather than rows as is done here.  I welcome anyone's suggestions for
improvement (given my limitation to IE5 XSL only).

Christe

------------------------------

Date: Thu, 24 Feb 2000 18:04:39 -0600
From: Tucker Williams <tucker@handango.com>
Subject: Trying to learn XSL

I'm trying to play around with some XSL.  Someone else wrote this and
I'm
trying to figure out how to change it to my liking.  What I want to do
is
for every other table cell after the table header have the colors of the
table cell change every other cell.

<SNIP>


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]