[xsl] Grouping adjacent columns in a table

Subject: [xsl] Grouping adjacent columns in a table
From: Kevin Bird <kevin.bird@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 15 Jan 2010 15:05:06 +0000
Hello

I have an XHTML table which can have an arbitrary number of columns and rows.

For display purposes, I need to reduce the number of columns by grouping
adjacent duplicate columns.

Therefore.

<table border="1" rules="all">
	<thead>
<tr>
	<th>A</th>
	<th>B</th>
	<th>C</th>
	<th>D</th>
	<th>E</th>
</tr>
	</thead>
	<tbody>
<tr>
	<td>100</td>
	<td>100</td>
	<td>200</td>
	<td>200</td>
	<td>300</td>
</tr>
<tr>
	<td>400</td>
	<td>500</td>
	<td>500</td>
	<td>500</td>
	<td>500</td>
</tr>
<tr>
	<td>600</td>
	<td>600</td>
	<td>700</td>
	<td>700</td>
	<td>800</td>
</tr>
<tr>
	<td>900</td>
	<td>900</td>
	<td>900</td>
	<td>900</td>
	<td>900</td>
</tr>
	</tbody>
</table>

becomes

<table border="1" rules="all">
	<thead>
<tr>
	<th>A</th>
	<th>B</th>
	<th>C,D</th>
	<th>E</th>
</tr>
	</thead>
	<tbody>
<tr>
	<td>100</td>
	<td>100</td>
	<td>200</td>
	<td>300</td>
</tr>
<tr>
	<td>400</td>
	<td>500</td>
	<td>500</td>
	<td>500</td>
</tr>
<tr>
	<td>600</td>
	<td>600</td>
	<td>700</td>
	<td>800</td>
</tr>
<tr>
	<td>900</td>
	<td>900</td>
	<td>900</td>
	<td>900</td>
</tr>
	</tbody>
</table>

as columns 'C' and 'D' contain duplicate values. The real data could contain
up to 50 columns and grouping could span several columns.

I can utilise a XSLT 2.0 solution.

Any help you be appreciated.

--
Kevin

Current Thread