<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="book">
<html>
<head>
<title><xsl:apply-templates select="@title"/></title>
   <link rel='stylesheet'>
      <xsl:attribute name='href'>
         <xsl:apply-templates select="@style"/>.css
      </xsl:attribute>
   </link>
</head>
<body>
   <xsl:for-each select='chapter/heading'>
      <h1><xsl:apply-templates/></h1>
   </xsl:for-each>

   <xsl:apply-templates/>
</body>
</html>
</xsl:template>

<!--
<xsl:template match="chapter/heading[@style='italic']">
     <i><xsl:apply-templates/></i>
</xsl:template>
-->

<xsl:template match="chapter/heading">
<h2>
  <xsl:number count='chapter'/>
  <xsl:if test="@style='italic'">
     <i><xsl:apply-templates/></i>
  </xsl:if>
  <xsl:if test="not(@style='italic')">
     <b><xsl:apply-templates/></b>
  </xsl:if>
</h2>
</xsl:template>

<xsl:template match="section/heading">
<h4><xsl:apply-templates/></h4>
</xsl:template>

</xsl:stylesheet>