[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: What is a good way to style and show tabular data

Subject: RE: What is a good way to style and show tabular data [snip]
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 19 Aug 2003 17:03:22 -0400
tabular data control mailto
Abhishek,

If your stylesheet can tell ahead of time how many rows/columns a table will need, a transposition of vertical to horizontal isn't hard.

Given the data you provided:

At 03:39 PM 8/19/2003, you wrote:
<Matrix HeadFlow="V|H" HeadExists="1" HeadCount="4" DataCount="1">
        <MatrixHeadArray>
                <MatrixHeadCell i="1">Standard 1</MatrixHeadCell>
                <MatrixHeadCell i="2">Maximum 2</MatrixHeadCell>
                <MatrixHeadCell i="3">Standard 3</MatrixHeadCell>
                <MatrixHeadCell i="4">Maximum 4</MatrixHeadCell>
        </MatrixHeadArray>
        <MatrixDataArray j="1">
                <MatrixDataCell i="1" j="1">1024 MB </MatrixDataCell>
                <MatrixDataCell i="2" j="1">32GB</MatrixDataCell>
                <MatrixDataCell i="3" j="1">512 MB </MatrixDataCell>
                <MatrixDataCell i="4" j="1">32GB</MatrixDataCell>
        </MatrixDataArray>
</Matrix>

The vertical table you want will be 2 columns wide (one for the header, one for each j) and 4 rows deep (one for each i).


If your table is always normalized first (thanks), this is the same as the count of MatrixHeadCell children of MatrixHeadArray in depth (rows), by the count of MatrixHeadArray + count of MatrixDataArray in width (columns).

You can iterate over each of these node sets to build your vertical table. First you iterate over the rows; within that you iterate over the columns to insert the cells into each row.

<xsl:template match="Matrix">
  <xsl:variable name="thisMatrix" select="."/>
  <table>
    <xsl:for-each select="MatrixHeadArray/MatrixHeadCell">
      <xsl:variable name="thisRow" select="@i"/>
      <!-- we generate our rows here -->
      <tr>
        <!-- now we need our cells -->
        <td class="head"><!-- our first cell is just our header -->
          <xsl:value-of select="."/>
        </td>
        <!-- we need another cell for each column -->
        <xsl:for-each select="$Matrix/MatrixDataArray">
          <td class="body">
             <xsl:value-of select="MatrixDataCell[@i=$thisRow]"/>
          </td>
        </xsl:for-each>
      </tr>
    </xsl:for-each>
  </table>
</xsl:template>

If your tables going in aren't regular, the problem gets much tougher, but it appears that you have good control of the data going in.

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================


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.