[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

Subject: Re: How do I do a table in XSL
From: Kevin.Hooke@xxxxxxxx
Date: Fri, 16 Apr 1999 13:24:23 -0700
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


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.