putting xml data into tables
Hi
I'm trying to display the contents of an xml data file in a table via an xslt stylesheet. Its not exactly working at this point. So far I can only get the xml data to display in one column, not in individual cells. Can anybody help??
I've included the code of the xsl file at the bottom....
THANKS!!
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 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">
<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>
</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>
Thankyou!
I've worked it out now. Ta..
you are welcome.....
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks