<?xml version="1.0"?>
<!--prod-imp.xsl-->
<!--XSLT 1.0 - http://www.CraneSoftwrights.com/training -->
<html xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:version="1.0">
****
This header is not recommended though it works for IE
****
	<head>
		<title>Product Sales Summary</title>
	</head>
	<body>
		<h2>Product Sales Summary</h2>
		<table summary="Product Sales Summary" border="1">
			<!--list products-->
			<th align="center">
****
Just output everything up to this point. Begin the HTML Table Header.
****
				<xsl:for-each select="//product">
					<td>
						<b>
							<xsl:value-of select="."/>
						</b>
					</td>
				</xsl:for-each>
****
Select each "product" and output the content of the element, bolded, between Table Cell separators
****

			</th>
			<!--list customers-->
			<xsl:for-each select="/sales/record/cust">
				<xsl:variable name="customer" select="."/>
 
****
Now build the Rows of the Table. An XSL variable is really just like an environment variable.
****

				<tr align="right">
					<td>
						<xsl:value-of select="@num"/>
					</td>
					<xsl:for-each select="//product">
						<!--each product-->
						<td>
							<xsl:value-of select="$customer/prodsale[@idref=current()/@id]"/>
						</td>
					</xsl:for-each>
				</tr>
			</xsl:for-each>
  
****
Build a Row, The first cell is the "customer number" one Cell for each product.In each Cell put the "content of the "prodsale" with the same "ID" as the product. Note one is blank.
****

			<!--summarize-->
			<tr align="right">
				<td>
					<b>Totals:</b>
				</td>
				<xsl:for-each select="//product">
					<xsl:variable name="pid" select="@id"/>
					<td>
						<i>
							<xsl:value-of select="sum(//prodsale[@idref=$pid])"/>
						</i>
					</td>
				</xsl:for-each>
			</tr>
****
Now build the last Row. The first Cell is just the string "Totals: The other Cell are computed by summing up all "prodsale" whos @idref is the @id of the Column's product
****

		</table>
	</body>
</html>
  
****
Finish up by outputting the remainder of the HTML
****