<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" version="4.0"/>
<xsl:param name="mode"/>

   <xsl:template match="/*">
      <html>
         <head>
            <title>
               <xsl:value-of select="description/title-info/book-title"/>
            </title>
            <style>
               body{text-align:justify}
               .pagebreak{page-break-before:always}
            </style>
         </head>
         
         <body>
         
				<xsl:choose>	
					<xsl:when test="self::*[$mode = 'about']">
		            <h4 align="center">&#1040;&#1085;&#1085;&#1086;&#1090;&#1072;&#1094;&#1080;&#1103;</h4>
						<xsl:apply-templates mode="about"/>
					</xsl:when>
					<xsl:when test="self::*[$mode = 'toc']">
		            <h4 align="center">&#1057;&#1086;&#1076;&#1077;&#1088;&#1078;&#1072;&#1085;&#1080;&#1077;</h4>
						<xsl:apply-templates mode="toc"/>
					</xsl:when>
					<xsl:when test="self::*[$mode = 'content']">
						<xsl:apply-templates mode="content"/>
					</xsl:when>
					<xsl:when test="self::*[$mode = 'notes']">
		            <h4 align="center">&#1055;&#1088;&#1080;&#1084;&#1077;&#1095;&#1072;&#1085;&#1080;&#1103;</h4>
						<xsl:apply-templates select="//note" mode="notes"/>
					</xsl:when>
				</xsl:choose>
	
         </body>
      </html>
   </xsl:template>



<!-- pagebreak -->
    <xsl:template match="pagebreak">
       <div class="pagebreak"></div>
    </xsl:template>
<!-- subtitle -->
    <xsl:template match="subtitle">
       <h5 align="center"><font face="Tahoma"><xsl:apply-templates /></font></h5>
    </xsl:template>
<!-- strong -->
    <xsl:template match="strong">
       <b><xsl:apply-templates/></b>
    </xsl:template>
<!-- p -->
    <xsl:template match="p">
       <p><font face="Tahoma"><xsl:apply-templates/></font></p>
    </xsl:template>
<!-- empty-line -->
    <xsl:template match="empty-line">
       <br/>
    </xsl:template>
<!-- note -->
    <xsl:template match="note">
       <a href="xml2lit_notes#{generate-id()}"><sup><xsl:value-of select="@name"/></sup></a>
       <a name="{generate-id()}"></a>
    </xsl:template>
<!-- epigraph -->
    <xsl:template match="epigraph">
       <div align="right"><i><xsl:apply-templates /></i></div>
    </xsl:template>
<!-- epigraph/text-author -->
    <xsl:template match="epigraph/text-author">
       <i><xsl:apply-templates /></i>
    </xsl:template>
<!-- cite -->
   <xsl:template match="cite">
		"...<br/>
      <xsl:apply-templates />
		<xsl:choose>
			<xsl:when test="not(text-author)">
				..."
			</xsl:when>
			<xsl:otherwise>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
<!-- cite/text-author -->
	<xsl:template match="cite/text-author">
		..."<br/>
      <i><xsl:apply-templates /></i><br/><br/>
	</xsl:template>
<!-- poem -->
   <xsl:template match="poem">
		<xsl:if test="not(title)">
      <blockquote><h5><xsl:value-of select="@title" /></h5></blockquote>
		</xsl:if>
      <xsl:apply-templates />
  </xsl:template>
<!-- poem/title -->
    <xsl:template match="poem/title">
       <blockquote><h5><xsl:apply-templates /></h5></blockquote>
    </xsl:template>
<!-- stanza -->
   <xsl:template match="stanza">
      <blockquote>
      <xsl:apply-templates />
      </blockquote>
   </xsl:template>
<!-- v -->
    <xsl:template match="v">
       &#160;&#160;<font face="Tahoma"><xsl:apply-templates /></font><br/>
    </xsl:template>
<!-- image -->
    <xsl:template match="image">
       <div align="center">
          <img border="0">
             <xsl:attribute name="src"><xsl:value-of select="@name"/></xsl:attribute>
          </img>
       </div>
    </xsl:template>

<!-- ***** FictionBook::ABOUT ***** -->
<!-- description -->
   <xsl:template match="description" mode="about">
      <xsl:apply-templates mode="about" />
   </xsl:template>
<!-- title-info -->
   <xsl:template match="title-info" mode="about">
      <xsl:apply-templates mode="about" />
   </xsl:template>
<!-- annotation -->
   <xsl:template match="annotation" mode="about">
      <xsl:apply-templates />
   </xsl:template>
<!-- default -->
	<xsl:template match="*" mode="about"/>

<!-- ***** FictionBook::CONTENT ***** -->
<!-- description -->
   <xsl:template match="description" mode="content">
      <xsl:apply-templates  mode="content"/>
   </xsl:template>
<!-- body -->
   <xsl:template match="body" mode="content">
      <xsl:apply-templates />
   </xsl:template>
<!-- section -->
   <xsl:template match="section">
      <h4 align="center" id="TOC_{generate-id()}"><font face="Tahoma"><xsl:value-of select="@title" /></font></h4>
      <xsl:apply-templates/>
      <div class="pagebreak"></div>
  </xsl:template>
<!-- section/title -->
    <xsl:template match="section/title">
       <h5><font face="Tahoma"><xsl:apply-templates /></font></h5>
    </xsl:template>
<!-- default -->
	<xsl:template match="*" mode="content"/>
    
<!-- ***** FictionBook::NOTES ***** -->
<!-- note -->
    <xsl:template match="//note" mode="notes">
       <a href="xml2lit_book#{generate-id()}"><sup><xsl:value-of select="@NAME | @name"/></sup></a> 
       <a name="{generate-id()}"><xsl:apply-templates /></a><br/>
    </xsl:template>
<!-- default -->
	<xsl:template match="*" mode="notes" />

<!-- ***** FictionBook::TOC ***** -->
<!-- body -->
   <xsl:template match="body" mode="toc">
      <xsl:apply-templates mode="toc" />
   </xsl:template>
<!-- section -->
	<xsl:template match="section" mode="toc">
		<a href="xml2lit_book#TOC_{generate-id()}">
			<font face="Tahoma"><xsl:value-of select="@title" /></font>
		</a><br/>
		<xsl:apply-templates mode="toc" />
	</xsl:template>
<!-- section/section -->
	<xsl:template match="section/section" mode="toc">
		&#160;&#160;
		<a href="xml2lit_book#TOC_{generate-id()}">
			<font face="Tahoma"><xsl:value-of select="@title" /></font>
		</a><br/>
		<xsl:apply-templates mode="toc" />
	</xsl:template>
<!-- default -->
	<xsl:template match="*" mode="toc"/>

</xsl:stylesheet>


