[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How do I do a table in XSL
>>From: lbolen@xxxxxxxxxxxxxxxxxxxxxxxxxx (Lori Bolen) >>Date: Thu, 15 Apr 1999 11:21:45 -0500 >> >>How do I display the following table using XSL? I am using >>Internet Explorer 5.0. So far I have figured out how to >>display everything except the following table. Lori - I'm not sure what you are referring to here as you seem to have a mix of your own XML tags and some HTML tags, so if you are putting this straight into IE5 it will just ignore the tags it does not recognize. If you restructure your XML something like this: <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="test table.xsl"?> <tabledata> <thead> <entry>Col1 header</entry> <entry>Col2 header</entry> <entry>Col3 header</entry> </thead> <tbody> <row> <entry>Col 1</entry> <entry>Col 2</entry> <entry>Col 3</entry> </row> <row> <entry span="3">Row 2 spans all columns.</entry> </row> </tbody> </tabledata> Then you could use a stylesheet something similar to this to get some valid HTML output to display the data as an HTML table (I'm not saying this is the best way and I may have over complicated things here, but it should point you in the right direction): <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template><xsl:apply-templates/></xsl:template> <xsl:template match="/"> <HTML> <p><b>HTML Table</b></p> <xsl:apply-templates select="tabledata"/> </HTML> </xsl:template> <xsl:template match="tabledata"> <table> <xsl:apply-templates select="./thead"/> <xsl:apply-templates select="./tbody"/> </table> </xsl:template> <xsl:template match="thead"> <thead> <xsl:apply-templates select="./entry" mode="thead"/> </thead> </xsl:template> <xsl:template match="entry" mode="thead"> <th><xsl:value-of select="."/></th> </xsl:template> <xsl:template match="tbody"> <tbody> <xsl:apply-templates select="./row"/> </tbody> </xsl:template> <xsl:template match="row"> <tr><xsl:apply-templates select="entry" mode="tbody"/></tr> </xsl:template> <xsl:template match="entry" mode="tbody"> <td><xsl:value-of select="."/></td> </xsl:template> </xsl:stylesheet> Hope this helps, Keivn Hooke XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|