I have an issue where we need to perform a transformation of an input XHTML document in order to better display the page on mobile devices. Every input document has a multitude of HTML tables, with a specific ID. In one such table, I need to identify a cell in order to not only modify its "colspan" attribute, but also the "colspan" attributes of the cells either side of it. I cannot modify the input HTML, this is acquired externally. I can only transform it.
In every case of the cell I am trying to transform, it has a blank cell to the left and right of it, both with a "colspan = 2" attribute. I need to make it so that this middle cell has a "colspan=4" attribute, the left cell has a "colspan=1" attribute, and the right cell to be removed.
I have been using an XSLT and so far managed to achieve a number of other transforms with my document, so I know this must be possible somehow. An example table is given below.
An example of a table I have:
<html>
<body>
<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
<td>row 1, cell 3</td>
<td>row 1, cell 4</td>
<td>row 1, cell 5</td>
</tr>
<tr>
<td colspan = "2">row 2, cell 1</td>
<td>Cell I Need</td>
<td colspan = "2">row 2, cell 3</td>
</tr>
<tr>
<td>row 3, cell 1</td>
<td>row 3, cell 2</td>
<td>row 3, cell 3</td>
<td>row 3, cell 4</td>
<td>row 3, cell 5</td>
</tr>
</table>
The table I need:
<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
<td>row 1, cell 3</td>
<td>row 1, cell 4</td>
<td>row 1, cell 5</td>
</tr>
<tr>
<td colspan = "1">row 2, cell 1</td>
<td colspan = "4">Cell I Need</td>
</tr>
<tr>
<td>row 3, cell 1</td>
<td>row 3, cell 2</td>
<td>row 3, cell 3</td>
<td>row 3, cell 4</td>
<td>row 3, cell 5</td>
</tr>
</table>
</body>
<html>
Any suggestions on how to identify and transform this cell using XSLT would be greatly appreciated.
Many thanks, Christian