[xsl] Transpose of Table

Subject: [xsl] Transpose of Table
From: "Animesh Sharma" <asharma@xxxxxxxxxxxxxxxx>
Date: Wed, 24 Dec 2003 11:47:14 +0530
Hi,

I want to write a XSL which will output me the transpose of existing XHTML.

Suppose I have input something like:

<?xml version="1.0"?>
<html>
   <body>
      <p>Test Table</p>
	<table border="1">
		<TR>
			<TD>1 </TD>
			<TD>2 </TD>
			<TD>3 </TD>
		</TR>
		<TR>
			<TD>4 </TD>
			<TD>5 </TD>
			<TD>6 </TD>
		</TR>	
		<TR>
			<TD>7 </TD>
			<TD>8 </TD>
			<TD>9 </TD>
		</TR>	
	</table>  
 </body>
</html>

i.e

Test Table
1 2 3
4 5 6
7 8 9

I want to write an XSl which will give me transpose of above table and output will look like:

Test Table
1 4 7
2 5 8
3 6 9
 
i.e.
<?xml version="1.0"?>
<html>
   <body>
      <p>Test Table</p>
	<table border="1">
		<TR>
			<TD>1 </TD>
			<TD>4 </TD>
			<TD>5 </TD>
		</TR>
		<TR>
			<TD>2 </TD>
			<TD>5 </TD>
			<TD>8 </TD>
		</TR>	
		<TR>
			<TD>3 </TD>
			<TD>6 </TD>
			<TD>9 </TD>
		</TR>	
	</table>  
 </body>
</html>

Well, I want to write a generic XSL which can work for any n*n table.

Thanks and Regards,
Animesh

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread