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[(_at_)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(_at_)mulberrytech(_dot_)com
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