[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] two column table with alternating row colors using xsl xml and css


Subject: Re: [xsl] two column table with alternating row colors using xsl xml and css
From: Américo Albuquerque <melinor@xxxxxxx>
Date: Thu, 07 Aug 2003 12:29:48 +0100 (WEST)

Hi.

try this:
  <xsl:template match="fmp:FMPDSORESULT">
    <html>
      <head>
        <title/>
        <style>
         <!-- this is just an example, you can change this to whatever you like -->
         .r0 { background-color: silver; color: black; }
         .r1 { color: gray; }
        </style>
      </head>
      <body>
        <table>
          <tr>
            <td>
              <b>Contractors</b>
            </td>
            <td>&#160;</td>
          </tr>
          <xsl:apply-templates select="fmp:ROW"/>
        </table>
      </body>
    </html>
  </xsl:template>
  <xsl:template match="fmp:ROW">
    <tr class="r{position() mod 2}">
      <td class="r{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/>
      </td>
      <td class="r{position() mod 2}"> (<xsl:value-of select="fmp:Phone1_Area_Code"/>)
<xsl:value-of select="fmp:Phone1_Number"/>
        <br/>
      </td>
    </tr>
  </xsl:template>


Regards,
Americo Albuquerque

Citando nicholse@xxxxxxxxxxxxxxxx:

} 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
} 
} 



----------------------------------------
This message is intended only for the use of the Addressee and may contain information
that is CONFIDENTIAL. If you are not the intended recipient, you are hereby
notified that any dissemination of this communication is strictly prohibited. If you
have received this communication in error, please notify us immediately and erase all
copies of the message and its attachments.

Thank you. 

___________________________________________________________________

O SAPO já está livre de vírus com a Panda Software, fique você também!
Clique em: http://antivirus.sapo.pt


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



Current Thread
Keywords