zoppotrump
Programmer
Hi
I'm trying to put an xml data file into a table via a xslt stylesheet. I've created the table in the xsl code and it is putting all of the data from the xml file into one column (as opposed to each field in its respective columns). Can anybody help??
I've added the code to the xsl file at the bottom
THANKS!!
<xsl:stylesheet xmlns:xsl=" version="1.0">
<xsl:template match="/">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="200%" id="AutoNumber1">
<tr><th>Artist</th><th>CD Title</th><th>Price</th>
<th>Format</th><th>Genre</th><th>No. of Discs</th>
<th>Release Date</th><th>Shipping</th><th>Picture</th></tr>
<xsl:for-each select="//product">
<tr>
<td width="10%" bgcolor="#88DBF5">
<xsl:apply-templates select="Artist" />
</td>
<td width="10%" bgcolor="#88DBF5">
<xsl:apply-templates select="CDTitle" />
</td>
<td width="10%" bgcolor="#88DBF5">
<xsl:apply-templates select="Price" />
</td>
<td width="10%" bgcolor="#88DBF5">
<xsl:apply-templates select="Format" />
</td>
<td width="10%" bgcolor="#88DBF5">
<xsl:apply-templates select="Genre" />
</td>
<td width="10%" bgcolor="#88DBF5">
<xsl:apply-templates select="noDiscs" />
</td>
<td width="10%" bgcolor="#88DBF5">
<xsl:apply-templates select="releaseDate" />
</td>
<td width="10%" bgcolor="#88DBF5">
<xsl:apply-templates select="Shipping" />
</td>
<td width="10%" bgcolor="#88DBF5">
<xsl:apply-templates select="albumPicture" />
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="*">
<div class="product">
<xsl:value-of select="." />
</div>
</xsl:template>
<xsl:template match="Artist">
<tr>
<td>
<hr size="1" width="100" align="left" color="#003366" />
<b><xsl:value-of select="." /> </b> <br />
</td>
</tr>
</xsl:template>
<xsl:template match="CDTitle">
<tr>
<td>
<xsl:value-of select="." /> <br />
</td>
</tr>
</xsl:template>
<xsl:template match="Price">
<tr>
<td>
<b>$ <xsl:value-of select="." /> </b><br />
</td>
</tr>
</xsl:template>
<xsl:template match="Format">
<tr>
<td>
<xsl:value-of select="." /> <br />
</td>
</tr>
</xsl:template>
<xsl:template match="Genre">
<tr>
<td>
<xsl:value-of select="." /> <br />
</td>
</tr>
</xsl:template>
<xsl:template match="noDiscs">
<tr>
<td>
<xsl:value-of select="." /> <br />
</td>
</tr>
</xsl:template>
<xsl:template match="releaseDate">
<tr>
<td>
<xsl:value-of select="." /> <br />
</td>
</tr>
</xsl:template>
<xsl:template match="Shipping">
<tr>
<td>
<xsl:value-of select="." /> <br />
</td>
</tr>
</xsl:template>
<xsl:template match="albumPicture">
<tr>
<td>
<img>
<xsl:attribute name="src">
<xsl:value-of select="." />
</xsl:attribute>
<xsl:attribute name="align">left</xsl:attribute>
</img>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
I'm trying to put an xml data file into a table via a xslt stylesheet. I've created the table in the xsl code and it is putting all of the data from the xml file into one column (as opposed to each field in its respective columns). Can anybody help??
I've added the code to the xsl file at the bottom
THANKS!!
<xsl:stylesheet xmlns:xsl=" version="1.0">
<xsl:template match="/">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="200%" id="AutoNumber1">
<tr><th>Artist</th><th>CD Title</th><th>Price</th>
<th>Format</th><th>Genre</th><th>No. of Discs</th>
<th>Release Date</th><th>Shipping</th><th>Picture</th></tr>
<xsl:for-each select="//product">
<tr>
<td width="10%" bgcolor="#88DBF5">
<xsl:apply-templates select="Artist" />
</td>
<td width="10%" bgcolor="#88DBF5">
<xsl:apply-templates select="CDTitle" />
</td>
<td width="10%" bgcolor="#88DBF5">
<xsl:apply-templates select="Price" />
</td>
<td width="10%" bgcolor="#88DBF5">
<xsl:apply-templates select="Format" />
</td>
<td width="10%" bgcolor="#88DBF5">
<xsl:apply-templates select="Genre" />
</td>
<td width="10%" bgcolor="#88DBF5">
<xsl:apply-templates select="noDiscs" />
</td>
<td width="10%" bgcolor="#88DBF5">
<xsl:apply-templates select="releaseDate" />
</td>
<td width="10%" bgcolor="#88DBF5">
<xsl:apply-templates select="Shipping" />
</td>
<td width="10%" bgcolor="#88DBF5">
<xsl:apply-templates select="albumPicture" />
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="*">
<div class="product">
<xsl:value-of select="." />
</div>
</xsl:template>
<xsl:template match="Artist">
<tr>
<td>
<hr size="1" width="100" align="left" color="#003366" />
<b><xsl:value-of select="." /> </b> <br />
</td>
</tr>
</xsl:template>
<xsl:template match="CDTitle">
<tr>
<td>
<xsl:value-of select="." /> <br />
</td>
</tr>
</xsl:template>
<xsl:template match="Price">
<tr>
<td>
<b>$ <xsl:value-of select="." /> </b><br />
</td>
</tr>
</xsl:template>
<xsl:template match="Format">
<tr>
<td>
<xsl:value-of select="." /> <br />
</td>
</tr>
</xsl:template>
<xsl:template match="Genre">
<tr>
<td>
<xsl:value-of select="." /> <br />
</td>
</tr>
</xsl:template>
<xsl:template match="noDiscs">
<tr>
<td>
<xsl:value-of select="." /> <br />
</td>
</tr>
</xsl:template>
<xsl:template match="releaseDate">
<tr>
<td>
<xsl:value-of select="." /> <br />
</td>
</tr>
</xsl:template>
<xsl:template match="Shipping">
<tr>
<td>
<xsl:value-of select="." /> <br />
</td>
</tr>
</xsl:template>
<xsl:template match="albumPicture">
<tr>
<td>
<img>
<xsl:attribute name="src">
<xsl:value-of select="." />
</xsl:attribute>
<xsl:attribute name="align">left</xsl:attribute>
</img>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>