[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: Thu, 7 Aug 2003 02:40:26 -0700 (PDT)
xsl alternating rows
XSL-List@xxxxxxxxxxxxxxxxxxxxxx
two column table with alternating row colors using xsl xml and css
I would like to create a balanced two column table with alternating row
colors sorted by business excluding html pre data for data non existant in
the xml elements like () in the phone number. I am using the processor php
extension http://nona.net/software/phplibxslt/:

<?
dl("php_libxslt.so");
$transformed = libxslt_transform($xmlstring, $xsltstring);
?>
:

The data will come from xml:
<?xml version="1.0" encoding="UTF-8" ?>
<FMPDSORESULT xmlns="http://www.filemaker.com/fmpdsoresult">
<ERRORCODE>0</ERRORCODE>
<DATABASE>Contacts-Master.fp5</DATABASE>
<LAYOUT></LAYOUT>
<ROW MODID="2" RECORDID="1">
<Co>Abbott Tinkers (Pat)</Co>
<Address1>736 Santa Anna Ave</Address1>
<City1>Miggs</City1>
<State1>CA</State1>
<Zip1>94430-9999</Zip1>
<Phone1_Area_Code>555</Phone1_Area_Code>
<Phone1_Number>121-7679</Phone1_Number>
</ROW>
<ROW MODID="2" RECORDID="2">
<Co>Aderbouy Specialty</Co>
<Address1>1557 Hemmy Drive</Address1>
<City1>Jesper</City1>
<State1>CA</State1>
<Zip1>99251</Zip1>
<Phone1_Area_Code></Phone1_Area_Code><! if phone number is missing exclude
output of "(   )">
<Phone1_Number></Phone1_Number><! what if this tag is "<Phone1_Number/>"?>
</ROW>
<! etcetera...>
</FMPDSORESULT>
:

I have tried a xsl like the following which works fine but dosent
implement two columns, sorting by business and alternating color rows. I
am also not sure how fancy I can get with this processor. Every time I try
to modify this xsl the processor returns raw xml to the browser. Tis is
the default behaviour if there are errors encountered:
<?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="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match="fmp:FMPDSORESULT">
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<TABLE>
<TR><TD><B>Contractors</B></TD><TD></TD></TR>
<xsl:for-each select="fmp:ROW">
<TR>
<TD>
<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 />
</TD>
<TD>
(<xsl:value-of select="fmp:Phone1_Area_Code" />)<xsl:value-of
select="fmp:Phone1_Number" />
<BR />
</TD>
</TR>
</xsl:for-each>
</TABLE>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
:

I read that using css with table or tr tags can cause browser
crashes/display problems at http://css.nu/examples/table-example.html .
Need I be worried?. I have not attempted an external css but maybe
something like this?:

tr.address_row {background-color: #FFFFFF;}
tr.address_row_alternate {background-color: #FFFFFF;}

I want the html/xhtml output to resemble this:
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="2">
<TR VALIGN="top" CLASS="address_row" BGCOLOR="#FFFFFF">
<!altenating color would be EFEFEF>
<TD WIDTH="100%">
<B>
<!Co>company</B>
<BR>
<DIV CLASS="address">
<!address>address
<BR>
<!city>city, <!state>state <!zip>zip<BR>
</DIV>
</TD>
<TD VALIGN="bottom" nowrap>
<!phone>phone<BR>
</TD>
</TR>
</TABLE>
:

Is it safe/stable to impliment the templates from
http://xsltsl.sourceforge.net/ ? Would this provide functionality that
would help enable what I am trying to accomplish? I am struggling but
learning alot. Any advice or help is much appreciated!
Eric

 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.