1 Replies - 602 Views - Last Post: 07 December 2010 - 08:53 PM

#1 DivineGuardian  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 15
  • Joined: 28-July 09

Having problem with xslt in html output table

Posted 07 December 2010 - 01:41 AM

Hi people,

I am stuck with figuring out the code to display the title html table correct. So i need abit of help to let me understand it is done. So the problem here lies with the row spam of the table in the xsl file.

This is my xml file
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="items.xsl" ?>
<Catalog>
	<Collection series="Hi5 Series">
		<Product>
			<Name>Fun with Sounds</Name>
			<Media Type="VCR      " Date="6/16/2004" Qty="1" Price="16.00"/>
		</Product>
		<Product>
			<Name>Fun with Colors and Shapes</Name>
			<Media Type="DVD      " Date="6/11/2003" Qty="1" Price="29.50"/>
		</Product>
		<Product>
			<Name>Fun with Maths</Name>
			<Media Type="VCD      " Date="6/15/2003" Qty="3" Price="20.50"/>
			<Media Type="DVD      " Date="6/18/2002" Qty="3" Price="69.00"/>
		</Product>
	</Collection>
	<Collection series="GarField Series">
		<Product>
			<Name>Home Alone Adventure</Name>
			<Media Type="Cassette  " Date="6/11/2003" Qty="4" Price="10.00"/>
			<Media Type="Video Tape" Date="5/14/2004" Qty="5" Price="17.50"/>
			<Media Type="VCD       " Date="6/21/2003" Qty="5" Price="16.00"/>
			<Media Type="DVD       " Date="6/24/2004" Qty="2" Price="27.50"/>
		</Product>
		<Product>
			<Name>Playful Odie</Name>
			<Media Type="Video Tape" Date="5/14/2004" Qty="2" Price="11.00"/>
			<Media Type="VCD       " Date="6/21/2003" Qty="1" Price="16.00"/>
			<Media Type="DVD       " Date="6/11/2002" Qty="1" Price="28.00"/>
		</Product>
		<Product>
			<Name>Who's the Master</Name>
			<Media Type="Video Tape" Date="6/21/2003" Qty="1" Price="14.50"/>
		</Product>
	</Collection>
	<Collection series="MR Bean Series">
		<Product>
			<Name>Back to School</Name>
			<Media Type="VCD      " Date="6/11/2004" Qty="1" Price="42.50"/>
			<Media Type="DVD      " Date="6/15/2003" Qty="1" Price="45.50"/>
		</Product>
		<Product>
			<Name>Just his Luck</Name>
			<Media Type="Video Tape" Date="6/11/2004" Qty="1" Price="37.50"/>
			<Media Type="VCD       " Date="6/15/2003" Qty="1" Price="19.00"/>
			<Media Type="DVD       " Date="6/18/2002" Qty="1" Price="29.50"/>
		</Product>
	</Collection>
</Catalog>



This is my xsl file
 <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<xsl:output method="html" version="4.0"></xsl:output>
	<xsl:param name="group" select="//Collection"></xsl:param>
		<xsl:template match="/">
			<html>
				<head>
					<title>Entertainment Inventories</title>
				</head>
				<body>
				<table border="0">
					<tr>
						<th colspan="3" align="left">
							<h2 style="color:#FF0000">Entertainment Pte Ltd</h2><br/>
						</th>
					</tr>
					<tr>
						<td>
							<img alt="" src="logo.jpg"></img>
						</td>
						<td width="200">
						</td>
						<td>
						<table border="1" bordercolor="ff8040">
							<tbody>
								<tr>
									<th colspan="2">Inventories Summary</th>
								</tr>
								<tr>
									<td bgcolor="FF8040" style="color:ffffff">Filter</td><td width="40">?</td>
								</tr>
								<tr>
									<td bgcolor="FF8040" style="color:ffffff">No. Title</td><td width="40"> ?</td>
								</tr>
								<tr>
									<td bgcolor="FF8040" style="color:ffffff">Quantity</td><td width="40"> ?</td>
								</tr>
								<tr>
									<td bgcolor="ff8040" style="color:ffffff">Total Asset</td><td width="40">?</td>
								</tr>
							</tbody>
						</table>
						</td>
						</tr>
					</table>
						<h3 style="color:0000ff">Hi 5 Series</h3>
					
						<hr color="0000ff"></hr>
							<table border="1"  bordercolor="c85a17">
								<tr>
								
									<th>Song/Movie Title</th>
									<th>Media type</th>
									<th>Price</th>
									<th>Qty</th>
									<th>Total</th>
									
								</tr>
								
									<xsl:apply-templates select="$group"></xsl:apply-templates>
								
								<tr>
									<td align="right" colspan="3">Total:</td><td></td><td></td>
								</tr>
								
							</table>
							
						<h3 style="color:0000ff">GarField Series</h3>
						<hr color="0000ff"></hr>
							<table border="1" bordercolor="c85a17">
								<tr>
									<th>Song/Movie Title</th>
									<th>Media type</th>
									<th>Price</th>
									<th>Qty</th>
									<th>Total</th>
								</tr>
								
							</table>
					
					
						<h3 style="color:0000ff">Mr Bean Series</h3>					
						<hr color="0000ff"></hr>
					
					
						
							<table border="1" bordercolor="c85a17">
								<tr>
									<th>Song/Movie Title</th>
									<th>Media type</th>
									<th>Price</th>
									<th>Qty</th>
									<th>Total</th>
								</tr>
								
							</table>
					</body>
				
			</html>
		</xsl:template> 
		<xsl:template match="Collection" >
		<xsl:apply-templates select="Product"></xsl:apply-templates>
			</xsl:template>
		<xsl:template match="Media">
			<tr>
				<td rowspan="{count(../Media)}" valign="top" >
					<xsl:value-of select="../Name"></xsl:value-of>
				</td>
				
			</tr>
		</xsl:template>
</xsl:stylesheet>



Current Result
Posted Image

Expected Result - i am hoping to get the expected result in the red circle.
Posted Image

This post has been edited by DivineGuardian: 07 December 2010 - 01:51 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Having problem with xslt in html output table

#2 drhowarddrfine  Icon User is offline

  • D.I.C Regular

Reputation: 39
  • View blog
  • Posts: 275
  • Joined: 28-July 10

Re: Having problem with xslt in html output table

Posted 07 December 2010 - 08:53 PM

Not sure if this is the solution but your color values need a # sign in front of them: 'style="color:#00ffff"'.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1