[xsl] XML to HTML table

Subject: [xsl] XML to HTML table
From: "Modha Kumar" <modha@xxxxxxxxxxx>
Date: Sun, 14 Nov 2004 09:15:53 +0000
Hi All

Sorry I do not know how to post response to my previous question. But I managed to go a little bit (?) further, but need help to do the core part of it.

I have a XML file from which I need to create HTML table.


<table> <row> <name> row1</name> <green>col2</green> <red></red> </row> <row> <name> row2</name> <green>col3</green> <red>col1</red> </row> <row> <name> row3</name> <green></green> <red>col1</red> </row> </table>

If there are n row elements it is a nXn table.
If the element in the row <green> or <red> is not empty I have to place a green or red marker (lets say a green / red dot) in
the column for that row. The value of these elements is one of the rownames.



Here is what I did so far grid.xml: ---------- <?xml version="1.0" encoding="ISO-8859-1"?> <!-- Edited with XML Spy v4.2 --> <?xml-stylesheet type="text/xsl" href="gridx.xsl"?> <grid> <row> <name> row1</name> <green>col2</green> <red></red> </row> <row> <name> row2</name> <green>col3</green> <red>col1</red> </row> <row> <name> row3</name> <green></green> <red>col1</red> </row> </grid>

grid.xsl
---------
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited with XML Spy v4.2 -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/">
<html>
<body>
<h2>My XXXXX</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>---</th>
<xsl:for-each select="grid/row">
<th><xsl:value-of select="name" /></th>
</xsl:for-each>
</tr>


<xsl:for-each select="grid/row">
<tr>
	<td bgcolor="#9acd32"><xsl:value-of select="name" /></td>

</tr>
</xsl:for-each>

 </table>
 </body>
 </html>
 </xsl:template>
 </xsl:stylesheet>

_________________________________________________________________
NRIs - Free money transfer to India. Fly to India for free! http://acm.bridgeovertw.com/hdfc/qr/landingpage/sep04/index.htm?sitecode=610|394 Apply Now.


Current Thread