At first,
thank you to all contributors up to now! I am going to incorporate as much as
possible of what I have learned form your posts up to now.
Andrew, I fear, your solution, which I tried and studied -- and I learned from
it! --, does not work properly if there is a rowspan in the table, which forces
a cell in the next row tto be pushed to the right. In your input sample there
are only rowspans at the end of rows, so you can quite accurately calculate the
column number form the preceding-siblings. Using the input below you get
different length rows and cells with identical row/col attributes.
This input:
<table>
<tr>
<td colspan="2" rowspan="2" width="70%">I</td>
<td colspan="2" width="30%">II</td>
</tr>
<tr>
<td width="20%">III</td>
<td rowspan="3" width="10%">IV</td>
</tr>
<tr>
<td colspan="3" width="90%">V</td>
</tr>
<tr>
<td width="40%">VI</td>
<td width="30%">VII</td>
<td width="20%">VIII</td>
</tr>
</table>
using the XSL at
http://www.biglist.com/lists/xsl-list/archives/200402/msg00447.html
creates this final output:
<table border="1">
<tr>
<td row="1" col="1">.</td>
<td row="1" col="2">.</td>
<td row="1" col="3">.</td>
<td row="1" col="4">.</td>
</tr>
<tr>
<td row="2" col="1">.</td>
<td row="2" col="2">.</td>
</tr>
<tr>
<td row="3" col="1">.</td>
<td row="3" col="2">.</td>
<td row="3" col="2">.</td>
<td row="3" col="3">.</td>
</tr>
<tr>
<td row="4" col="1">.</td>
<td row="4" col="2">.</td>
<td row="4" col="2">.</td>
<td row="4" col="3">.</td>
</tr>
</table>
Thank you so far!
- Michael
On 16.03.2004 (15:56 Uhr +0000), Andrew Welch wrote:
The main problem is the use of colspan and rowspan, which makes it
hard for any cell to know to which column it belongs. One has to
render the table from start to finish to learn that for each cell.
I put forward a solution to a similar problem a while back:
http://www.biglist.com/lists/xsl-list/archives/200402/msg00447.html
This basically 'normalises' a table to remove the rowspans and colspans.
The technique is to process the table horizontally to remove the
colspans and the vertically to remove the rowspans.
For your problem, I would normalise the table into a variable, copying
through any width values that are for a single cell (that is, a width
value on an <entry> with no colspan specified). You should then have at
least one definite width value per column.
The processing complexity should be proportional to your input, rather
than exponential (which Im guessing your solution is) so you should
notice a dramatic performance improvement.
--
_____________________________________________________________
Dipl.-Ing. Michael Müller-Hillebrand
"Mehr Effizienz für Wissensarbeiter" --> http://cap-studio.de
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list