1<?xml version="1.0"?>
2<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3
4  <xsl:output method="html" encoding="utf-8"/>
5
6  <xsl:template match="salesdata">
7    <xsl:variable name="max" select="50"/>
8
9    <html>
10      <body bgcolor="#ffffff">
11      <table border="0">
12        <tr>
13          <td colspan="{count(year)}" align="center">Sales By Region</td>
14        </tr>
15        <tr>
16          <xsl:for-each select="year">
17            <td valign="top">
18              <table border="0" cellpadding="2" cellspacing="0">
19                <tr>
20                  <xsl:for-each select="region">
21                    <xsl:variable name="color">
22                      <xsl:choose>
23                        <xsl:when test="name='west'">#0000ff</xsl:when>
24                        <xsl:when test="name='central'">#ff00ff</xsl:when>
25                        <xsl:when test="name='east'">#00ff00</xsl:when>
26                      </xsl:choose>
27                    </xsl:variable>
28                    <td valign="top">
29                      <table border="0" cellpadding="0" cellspacing="0">
30                        <tr height="{5 * ($max - sales)}">
31                          <td bgcolor="#ffffff" width="10" height="{5 * ($max - sales)}">
32                            <xsl:text disable-output-escaping="yes">&amp;#160;</xsl:text>
33                          </td>
34                        </tr>
35                        <tr height="{5 * sales}">
36                          <td bgcolor="{$color}" width="10" height="{5 * sales}">
37                            <xsl:text disable-output-escaping="yes">&amp;#160;</xsl:text>
38                          </td>
39                        </tr>
40
41                      </table>
42                    </td>
43                  </xsl:for-each>
44                </tr>
45                <tr>
46                  <td colspan="{count(region)}" align="center">
47                    <xsl:value-of select="year"/>
48                  </td>
49                </tr>
50              </table>
51            </td>
52          </xsl:for-each>
53        </tr>
54      </table>
55    </body>
56    </html>
57
58  </xsl:template>
59
60</xsl:stylesheet>
61