Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

putting xml data into table

Status
Not open for further replies.

zoppotrump

Programmer
Oct 20, 2003
2
AU
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=&quot; version=&quot;1.0&quot;>

<xsl:template match=&quot;/&quot;>


<table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;border-collapse: collapse&quot; bordercolor=&quot;#111111&quot; width=&quot;200%&quot; id=&quot;AutoNumber1&quot;>
<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=&quot;//product&quot;>
<tr>
<td width=&quot;10%&quot; bgcolor=&quot;#88DBF5&quot;>
<xsl:apply-templates select=&quot;Artist&quot; />
</td>
<td width=&quot;10%&quot; bgcolor=&quot;#88DBF5&quot;>
<xsl:apply-templates select=&quot;CDTitle&quot; />
</td>
<td width=&quot;10%&quot; bgcolor=&quot;#88DBF5&quot;>
<xsl:apply-templates select=&quot;Price&quot; />
</td>
<td width=&quot;10%&quot; bgcolor=&quot;#88DBF5&quot;>
<xsl:apply-templates select=&quot;Format&quot; />
</td>
<td width=&quot;10%&quot; bgcolor=&quot;#88DBF5&quot;>
<xsl:apply-templates select=&quot;Genre&quot; />
</td>
<td width=&quot;10%&quot; bgcolor=&quot;#88DBF5&quot;>
<xsl:apply-templates select=&quot;noDiscs&quot; />
</td>
<td width=&quot;10%&quot; bgcolor=&quot;#88DBF5&quot;>
<xsl:apply-templates select=&quot;releaseDate&quot; />
</td>
<td width=&quot;10%&quot; bgcolor=&quot;#88DBF5&quot;>
<xsl:apply-templates select=&quot;Shipping&quot; />
</td>
<td width=&quot;10%&quot; bgcolor=&quot;#88DBF5&quot;>
<xsl:apply-templates select=&quot;albumPicture&quot; />
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>

<xsl:template match=&quot;*&quot;>
<div class=&quot;product&quot;>
<xsl:value-of select=&quot;.&quot; />
</div>
</xsl:template>

<xsl:template match=&quot;Artist&quot;>
<tr>
<td>
<hr size=&quot;1&quot; width=&quot;100&quot; align=&quot;left&quot; color=&quot;#003366&quot; />
<b><xsl:value-of select=&quot;.&quot; /> </b> <br />
</td>
</tr>
</xsl:template>
<xsl:template match=&quot;CDTitle&quot;>
<tr>
<td>
<xsl:value-of select=&quot;.&quot; /> <br />
</td>
</tr>
</xsl:template>
<xsl:template match=&quot;Price&quot;>
<tr>
<td>
<b>$ <xsl:value-of select=&quot;.&quot; /> </b><br />
</td>
</tr>
</xsl:template>
<xsl:template match=&quot;Format&quot;>
<tr>
<td>
<xsl:value-of select=&quot;.&quot; /> <br />
</td>
</tr>
</xsl:template>
<xsl:template match=&quot;Genre&quot;>
<tr>
<td>
<xsl:value-of select=&quot;.&quot; /> <br />
</td>
</tr>
</xsl:template>
<xsl:template match=&quot;noDiscs&quot;>
<tr>
<td>
<xsl:value-of select=&quot;.&quot; /> <br />
</td>
</tr>
</xsl:template>
<xsl:template match=&quot;releaseDate&quot;>
<tr>
<td>
<xsl:value-of select=&quot;.&quot; /> <br />
</td>
</tr>
</xsl:template>
<xsl:template match=&quot;Shipping&quot;>
<tr>
<td>
<xsl:value-of select=&quot;.&quot; /> <br />
</td>
</tr>
</xsl:template>
<xsl:template match=&quot;albumPicture&quot;>
<tr>
<td>
<img>
<xsl:attribute name=&quot;src&quot;>
<xsl:value-of select=&quot;.&quot; />
</xsl:attribute>
<xsl:attribute name=&quot;align&quot;>left</xsl:attribute>
</img>
</td>
</tr>
</xsl:template>

</xsl:stylesheet>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top