Listing 1:

 Contents of file oilconsumption.xml
<?xml version="1.0" encoding="utf-8" ?>
<worldoil>
  <!-- Table oilconsumption -->
    <oilconsumption>
        <Region>North America</Region>
        <Country>USA</Country>
        <y1965>11522</y1965>
        <y1966>12100</y1966>
        <y1967>12567</y1967>
        <y1968>13405</y1968>
        <y1969>14153</y1969>
        <y1970>14710</y1970>
        <y1971>15223</y1971>
        <y1972>16381</y1972>
        <y1973>17318</y1973>
        <y1974>16631</y1974>
        <y1975>16334</y1975>
        <y1976>17461</y1976>
        <y1977>18443</y1977>
        <y1978>18756</y1978>
        <y1979>18438</y1979>
        <y1980>17062</y1980>
        <y1981>16060</y1981>
        <y1982>15295</y1982>
        <y1983>15235</y1983>
        <y1984>15725</y1984>
        <y1985>15726</y1985>
        <y1986>16281</y1986>
        <y1987>16665</y1987>
        <y1988>17283</y1988>
        <y1989>17325</y1989>
        <y1990>16988</y1990>
        <y1991>16713</y1991>
        <y1992>17033</y1992>
        <y1993>17236</y1993>
        <y1994>17719</y1994>
        <y1995>17725</y1995>
        <y1996>18309</y1996>
        <y1997>18621</y1997>
        <y1998>18917</y1998>
        <y1999>19519</y1999>
        <y2000>19701</y2000>
        <y2001>19649</y2001>
        <y2002>19761</y2002>
        <y2003>20033</y2003>
        <y2004>20731</y2004>
        <y2005>20802</y2005>
        <y2006>20589</y2006>
    </oilconsumption>
...
</worldoil>

Listing 2:

Contents of file oilconsumptionmatrixtotal.xsl
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="worldoil">
    <data jsxid="jsxroot">
      <xsl:apply-templates/>
      <record>
        <xsl:attribute name="Region">World</xsl:attribute>
        <xsl:attribute name="Country">Total</xsl:attribute>
        <xsl:for-each select="oilconsumption[1]/*[ starts-with( name(), 'y' ) ]">
          <xsl:variable name="year" select="name()"/>
          <xsl:attribute name="{$year}">
            <xsl:value-of select="sum( /worldoil/oilconsumption/*[ name() = $year and string(number()) != 'NaN' ]
			 )"/>
          </xsl:attribute>
        </xsl:for-each>
      </record>
    </data>
  </xsl:template>

  <xsl:template match="oilconsumption">
    <xsl:element name="record">
      <xsl:attribute name="jsxid">
        <xsl:value-of select="position()"/>
      </xsl:attribute>
      <xsl:for-each select="*">
        <xsl:attribute name="{name()}">
          <xsl:value-of select="."/>
        </xsl:attribute>
      </xsl:for-each>
    </xsl:element>
  </xsl:template>

</xsl:stylesheet>>

Listing 3:

Value Template - valuetemplate1966.xsl
<xsl:template xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:choose>
    <xsl:when test="@y1966 > @y1965">
      <xsl:attribute name="style">color:red;</xsl:attribute>
    </xsl:when>
    <xsl:otherwise>
      <xsl:attribute name="style">color:green;</xsl:attribute>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:value-of select="{0}"/>
</xsl:template>