Hi, I have an xml document, which looks like this:
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<row>
<col name="Date">2005/02/11</col>
<col name="Code Churn">7266</col>
</row>
<row>
<col name="Date">2005/02/12</col>
<col name="Code Churn">564</col>
</row>
<row>
<col name="Date">2005/02/13</col>
<col name="Code Churn">54657</col>
</row>
</root>
I'm not sure this is the best way to store the tabular data, so please let me know if you feel there is a better way. Anyway, I am trying to output this in a table for a html document, so far I have this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:choose>
<xsl:when test="count(root/row) > 0">
<table style="table-layout:fixed; width:400px;">
<xsl:for-each select="root/row">
<tr>
<xsl:for-each select="col">
<td>
<xsl:value-of select="root/row/col" />
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</xsl:when>
<xsltherwise>
There is no data available
</xsltherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
But it doesnt seem to output the values, although it seems to create the table ok. I am also unsre as to how I can create the column headers at the top of the table.
Thanks!
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<row>
<col name="Date">2005/02/11</col>
<col name="Code Churn">7266</col>
</row>
<row>
<col name="Date">2005/02/12</col>
<col name="Code Churn">564</col>
</row>
<row>
<col name="Date">2005/02/13</col>
<col name="Code Churn">54657</col>
</row>
</root>
I'm not sure this is the best way to store the tabular data, so please let me know if you feel there is a better way. Anyway, I am trying to output this in a table for a html document, so far I have this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:choose>
<xsl:when test="count(root/row) > 0">
<table style="table-layout:fixed; width:400px;">
<xsl:for-each select="root/row">
<tr>
<xsl:for-each select="col">
<td>
<xsl:value-of select="root/row/col" />
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</xsl:when>
<xsltherwise>
There is no data available
</xsltherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
But it doesnt seem to output the values, although it seems to create the table ok. I am also unsre as to how I can create the column headers at the top of the table.
Thanks!