This commit is contained in:
Kovid Goyal 2011-03-06 08:39:53 -07:00
parent a94fe3adad
commit d68aaddbb4

View File

@ -19,21 +19,21 @@
######################################################################### #########################################################################
--> -->
<xsl:output method="xml" encoding="UTF-8"/> <xsl:output method="xml" encoding="UTF-8"/>
<xsl:key name="note-link" match="fb:section" use="@id"/> <xsl:key name="note-link" match="fb:section" use="@id"/>
<xsl:template match="/*"> <xsl:template match="/*">
<html> <html>
<head> <head>
<xsl:if test="fb:description/fb:title-info/fb:lang = 'ru'"> <xsl:if test="fb:description/fb:title-info/fb:lang = 'ru'">
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8"/> <meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8"/>
</xsl:if> </xsl:if>
<title> <title>
<xsl:value-of select="fb:description/fb:title-info/fb:book-title"/> <xsl:value-of select="fb:description/fb:title-info/fb:book-title"/>
</title> </title>
<style type="text/css"> <style type="text/css">
a { color : #0002CC } a { color : #0002CC }
a:hover { color : #BF0000 } a:hover { color : #BF0000 }
body { background-color : #FEFEFE; color : #000000; font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; text-align : justify } body { background-color : #FEFEFE; color : #000000; font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; text-align : justify }
@ -62,90 +62,90 @@
.epigraph{width:50%; margin-left : 35%;} .epigraph{width:50%; margin-left : 35%;}
div.paragraph { text-align: justify; text-indent: 2em; } div.paragraph { text-align: justify; text-indent: 2em; }
</style> </style>
<link rel="stylesheet" type="text/css" href="inline-styles.css" /> <link rel="stylesheet" type="text/css" href="inline-styles.css" />
</head> </head>
<body> <body>
<xsl:for-each select="fb:description/fb:title-info/fb:annotation"> <xsl:for-each select="fb:description/fb:title-info/fb:annotation">
<div> <div>
<xsl:call-template name="annotation"/> <xsl:call-template name="annotation"/>
</div> </div>
<hr/> <hr/>
</xsl:for-each> </xsl:for-each>
<!-- BUILD TOC --> <!-- BUILD TOC -->
<ul> <ul>
<xsl:apply-templates select="fb:body" mode="toc"/> <xsl:apply-templates select="fb:body" mode="toc"/>
</ul> </ul>
<hr/> <hr/>
<!-- END BUILD TOC --> <!-- END BUILD TOC -->
<!-- BUILD BOOK --> <!-- BUILD BOOK -->
<xsl:for-each select="fb:body"> <xsl:for-each select="fb:body">
<xsl:if test="position()!=1"> <xsl:if test="position()!=1">
<hr/> <hr/>
</xsl:if> </xsl:if>
<xsl:if test="@name"> <xsl:if test="@name">
<h4 align="center"> <h4 align="center">
<xsl:value-of select="@name"/> <xsl:value-of select="@name"/>
</h4> </h4>
</xsl:if> </xsl:if>
<!-- <xsl:apply-templates /> --> <!-- <xsl:apply-templates /> -->
<xsl:apply-templates/> <xsl:apply-templates/>
</xsl:for-each> </xsl:for-each>
</body> </body>
</html> </html>
</xsl:template> </xsl:template>
<!-- author template --> <!-- author template -->
<xsl:template name="author"> <xsl:template name="author">
<xsl:value-of select="fb:first-name"/> <xsl:value-of select="fb:first-name"/>
<xsl:text disable-output-escaping="no">&#032;</xsl:text> <xsl:text disable-output-escaping="no">&#032;</xsl:text>
<xsl:value-of select="fb:middle-name"/>&#032; <xsl:value-of select="fb:middle-name"/>&#032;
<xsl:text disable-output-escaping="no">&#032;</xsl:text> <xsl:text disable-output-escaping="no">&#032;</xsl:text>
<xsl:value-of select="fb:last-name"/> <xsl:value-of select="fb:last-name"/>
<br/> <br/>
</xsl:template> </xsl:template>
<!-- secuence template --> <!-- secuence template -->
<xsl:template name="sequence"> <xsl:template name="sequence">
<LI/> <LI/>
<xsl:value-of select="@name"/> <xsl:value-of select="@name"/>
<xsl:if test="@number"> <xsl:if test="@number">
<xsl:text disable-output-escaping="no">,&#032;#</xsl:text> <xsl:text disable-output-escaping="no">,&#032;#</xsl:text>
<xsl:value-of select="@number"/> <xsl:value-of select="@number"/>
</xsl:if> </xsl:if>
<xsl:if test="fb:sequence"> <xsl:if test="fb:sequence">
<ul> <ul>
<xsl:for-each select="fb:sequence"> <xsl:for-each select="fb:sequence">
<xsl:call-template name="sequence"/> <xsl:call-template name="sequence"/>
</xsl:for-each> </xsl:for-each>
</ul> </ul>
</xsl:if> </xsl:if>
<!-- <br/> --> <!-- <br/> -->
</xsl:template> </xsl:template>
<!-- toc template --> <!-- toc template -->
<xsl:template match="fb:section|fb:body" mode="toc"> <xsl:template match="fb:section|fb:body" mode="toc">
<xsl:choose> <xsl:choose>
<xsl:when test="name()='body' and position()=1 and not(fb:title)"> <xsl:when test="name()='body' and position()=1 and not(fb:title)">
<xsl:apply-templates select="fb:section" mode="toc"/> <xsl:apply-templates select="fb:section" mode="toc"/>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<li> <li>
<a href="#TOC_{generate-id()}"><xsl:value-of select="normalize-space(fb:title/fb:p[1] | @name)"/></a> <a href="#TOC_{generate-id()}"><xsl:value-of select="normalize-space(fb:title/fb:p[1] | @name)"/></a>
<xsl:if test="fb:section"> <xsl:if test="fb:section">
<ul><xsl:apply-templates select="fb:section" mode="toc"/></ul> <ul><xsl:apply-templates select="fb:section" mode="toc"/></ul>
</xsl:if> </xsl:if>
</li> </li>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:template> </xsl:template>
<!-- description --> <!-- description -->
<xsl:template match="fb:description"> <xsl:template match="fb:description">
<xsl:apply-templates/> <xsl:apply-templates/>
</xsl:template> </xsl:template>
<!-- body --> <!-- body -->
<xsl:template match="fb:body"> <xsl:template match="fb:body">
<div><xsl:apply-templates/></div> <div><xsl:apply-templates/></div>
</xsl:template> </xsl:template>
<xsl:template match="fb:section"> <xsl:template match="fb:section">
<xsl:variable name="section_has_title"> <xsl:variable name="section_has_title">
<xsl:choose> <xsl:choose>
<xsl:when test="./fb:title"><xsl:value-of select="generate-id()" /></xsl:when> <xsl:when test="./fb:title"><xsl:value-of select="generate-id()" /></xsl:when>
@ -164,15 +164,15 @@
<xsl:apply-templates> <xsl:apply-templates>
<xsl:with-param name="section_toc_id" select="$section_has_title" /> <xsl:with-param name="section_toc_id" select="$section_has_title" />
</xsl:apply-templates> </xsl:apply-templates>
</xsl:template> </xsl:template>
<!-- section/title --> <!-- section/title -->
<xsl:template match="fb:section/fb:title|fb:poem/fb:title"> <xsl:template match="fb:section/fb:title|fb:poem/fb:title">
<xsl:param name="section_toc_id" /> <xsl:param name="section_toc_id" />
<xsl:choose> <xsl:choose>
<xsl:when test="count(ancestor::node()) &lt; 9"> <xsl:when test="count(ancestor::node()) &lt; 9">
<xsl:element name="{concat('h',count(ancestor::node())-3)}"> <xsl:element name="{concat('h',count(ancestor::node())-3)}">
<xsl:if test="../@id"> <xsl:if test="../@id">
<xsl:attribute name="id"><xsl:value-of select="../@id" /></xsl:attribute> <xsl:attribute name="id"><xsl:value-of select="../@id" /></xsl:attribute>
</xsl:if> </xsl:if>
@ -181,79 +181,79 @@
<xsl:attribute name="id">TOC_<xsl:value-of select="$section_toc_id"/></xsl:attribute> <xsl:attribute name="id">TOC_<xsl:value-of select="$section_toc_id"/></xsl:attribute>
</xsl:element> </xsl:element>
</xsl:if> </xsl:if>
<a name="TOC_{generate-id()}"></a> <a name="TOC_{generate-id()}"></a>
<xsl:if test="@id"> <xsl:if test="@id">
<xsl:element name="a"> <xsl:element name="a">
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute> <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
</xsl:element> </xsl:element>
</xsl:if> </xsl:if>
<xsl:apply-templates/> <xsl:apply-templates/>
</xsl:element> </xsl:element>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:element name="h6"> <xsl:element name="h6">
<xsl:if test="@id"> <xsl:if test="@id">
<xsl:element name="a"> <xsl:element name="a">
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute> <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
</xsl:element> </xsl:element>
</xsl:if> </xsl:if>
<xsl:apply-templates/> <xsl:apply-templates/>
</xsl:element> </xsl:element>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:template> </xsl:template>
<!-- section/title --> <!-- section/title -->
<xsl:template match="fb:body/fb:title"> <xsl:template match="fb:body/fb:title">
<xsl:element name="h1"> <xsl:element name="h1">
<xsl:apply-templates /> <xsl:apply-templates />
</xsl:element> </xsl:element>
</xsl:template> </xsl:template>
<xsl:template match="fb:title/fb:p"> <xsl:template match="fb:title/fb:p">
<xsl:apply-templates/><xsl:text disable-output-escaping="no">&#032;</xsl:text><br/> <xsl:apply-templates/><xsl:text disable-output-escaping="no">&#032;</xsl:text><br/>
</xsl:template> </xsl:template>
<!-- subtitle --> <!-- subtitle -->
<xsl:template match="fb:subtitle"> <xsl:template match="fb:subtitle">
<xsl:if test="@id"> <xsl:if test="@id">
<xsl:element name="a"> <xsl:element name="a">
<xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute> <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
</xsl:element> </xsl:element>
</xsl:if> </xsl:if>
<h5> <h5>
<xsl:apply-templates/> <xsl:apply-templates/>
</h5> </h5>
</xsl:template> </xsl:template>
<!-- p --> <!-- p -->
<xsl:template match="fb:p"> <xsl:template match="fb:p">
<xsl:element name="div"> <xsl:element name="div">
<xsl:attribute name="class">paragraph</xsl:attribute> <xsl:attribute name="class">paragraph</xsl:attribute>
<xsl:if test="@id"> <xsl:if test="@id">
<xsl:element name="a"> <xsl:element name="a">
<xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute> <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
</xsl:element> </xsl:element>
</xsl:if> </xsl:if>
<xsl:if test="@style"> <xsl:if test="@style">
<xsl:attribute name="style"><xsl:value-of select="@style"/></xsl:attribute> <xsl:attribute name="style"><xsl:value-of select="@style"/></xsl:attribute>
</xsl:if> </xsl:if>
<xsl:apply-templates/> <xsl:apply-templates/>
</xsl:element> </xsl:element>
</xsl:template> </xsl:template>
<!-- strong --> <!-- strong -->
<xsl:template match="fb:strong"> <xsl:template match="fb:strong">
<b><xsl:apply-templates/></b> <b><xsl:apply-templates/></b>
</xsl:template> </xsl:template>
<!-- emphasis --> <!-- emphasis -->
<xsl:template match="fb:emphasis"> <xsl:template match="fb:emphasis">
<i> <xsl:apply-templates/></i> <i> <xsl:apply-templates/></i>
</xsl:template> </xsl:template>
<!-- style --> <!-- style -->
<xsl:template match="fb:style"> <xsl:template match="fb:style">
<span class="{@name}"><xsl:apply-templates/></span> <span class="{@name}"><xsl:apply-templates/></span>
</xsl:template> </xsl:template>
<!-- empty-line --> <!-- empty-line -->
<xsl:template match="fb:empty-line"> <xsl:template match="fb:empty-line">
<br/> <br/>
</xsl:template> </xsl:template>
<!-- super/sub-scripts --> <!-- super/sub-scripts -->
<xsl:template match="fb:sup"> <xsl:template match="fb:sup">
<sup><xsl:apply-templates/></sup> <sup><xsl:apply-templates/></sup>
@ -261,140 +261,140 @@
<xsl:template match="fb:sub"> <xsl:template match="fb:sub">
<sub><xsl:apply-templates/></sub> <sub><xsl:apply-templates/></sub>
</xsl:template> </xsl:template>
<!-- link --> <!-- link -->
<xsl:template match="fb:a"> <xsl:template match="fb:a">
<xsl:element name="a"> <xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute> <xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute>
<xsl:attribute name="title"> <xsl:attribute name="title">
<xsl:choose> <xsl:choose>
<xsl:when test="starts-with(@xlink:href,'#')"><xsl:value-of select="key('note-link',substring-after(@xlink:href,'#'))/fb:p"/></xsl:when> <xsl:when test="starts-with(@xlink:href,'#')"><xsl:value-of select="key('note-link',substring-after(@xlink:href,'#'))/fb:p"/></xsl:when>
<xsl:otherwise><xsl:value-of select="key('note-link',@xlink:href)/fb:p"/></xsl:otherwise> <xsl:otherwise><xsl:value-of select="key('note-link',@xlink:href)/fb:p"/></xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:attribute> </xsl:attribute>
<xsl:choose> <xsl:choose>
<xsl:when test="(@type) = 'note'"> <xsl:when test="(@type) = 'note'">
<sup> <sup>
<xsl:apply-templates/> <xsl:apply-templates/>
</sup> </sup>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:apply-templates/> <xsl:apply-templates/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:element> </xsl:element>
</xsl:template> </xsl:template>
<!-- annotation --> <!-- annotation -->
<xsl:template name="annotation"> <xsl:template name="annotation">
<xsl:if test="@id"> <xsl:if test="@id">
<xsl:element name="a"> <xsl:element name="a">
<xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute> <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
</xsl:element> </xsl:element>
</xsl:if> </xsl:if>
<h3>Annotation</h3> <h3>Annotation</h3>
<xsl:apply-templates/> <xsl:apply-templates/>
</xsl:template> </xsl:template>
<!-- tables --> <!-- tables -->
<xsl:template match="fb:table"> <xsl:template match="fb:table">
<table> <table>
<xsl:apply-templates/> <xsl:apply-templates/>
</table> </table>
</xsl:template> </xsl:template>
<xsl:template match="fb:tr"> <xsl:template match="fb:tr">
<tr><xsl:apply-templates/></tr> <tr><xsl:apply-templates/></tr>
</xsl:template> </xsl:template>
<xsl:template match="fb:td"> <xsl:template match="fb:td">
<xsl:element name="td"> <xsl:element name="td">
<xsl:if test="@align"> <xsl:if test="@align">
<xsl:attribute name="align"><xsl:value-of select="@align"/></xsl:attribute> <xsl:attribute name="align"><xsl:value-of select="@align"/></xsl:attribute>
</xsl:if> </xsl:if>
<xsl:apply-templates/> <xsl:apply-templates/>
</xsl:element> </xsl:element>
</xsl:template> </xsl:template>
<!-- epigraph --> <!-- epigraph -->
<xsl:template match="fb:epigraph"> <xsl:template match="fb:epigraph">
<blockquote class="epigraph"> <blockquote class="epigraph">
<xsl:if test="@id"> <xsl:if test="@id">
<xsl:element name="a"> <xsl:element name="a">
<xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute> <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
</xsl:element> </xsl:element>
</xsl:if> </xsl:if>
<xsl:apply-templates/> <xsl:apply-templates/>
</blockquote> </blockquote>
</xsl:template> </xsl:template>
<!-- epigraph/text-author --> <!-- epigraph/text-author -->
<xsl:template match="fb:epigraph/fb:text-author"> <xsl:template match="fb:epigraph/fb:text-author">
<blockquote> <blockquote>
<i><xsl:apply-templates/></i> <i><xsl:apply-templates/></i>
</blockquote> </blockquote>
</xsl:template> </xsl:template>
<!-- cite --> <!-- cite -->
<xsl:template match="fb:cite"> <xsl:template match="fb:cite">
<blockquote> <blockquote>
<xsl:if test="@id"> <xsl:if test="@id">
<xsl:element name="a"> <xsl:element name="a">
<xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute> <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
</xsl:element> </xsl:element>
</xsl:if> </xsl:if>
<xsl:apply-templates/> <xsl:apply-templates/>
</blockquote> </blockquote>
</xsl:template> </xsl:template>
<!-- cite/text-author --> <!-- cite/text-author -->
<xsl:template match="fb:text-author"> <xsl:template match="fb:text-author">
<blockquote> <blockquote>
<i> <xsl:apply-templates/></i></blockquote> <i> <xsl:apply-templates/></i></blockquote>
</xsl:template> </xsl:template>
<!-- date --> <!-- date -->
<xsl:template match="fb:date"> <xsl:template match="fb:date">
<xsl:choose> <xsl:choose>
<xsl:when test="not(@value)"> <xsl:when test="not(@value)">
&#160;&#160;&#160;<xsl:apply-templates/> &#160;&#160;&#160;<xsl:apply-templates/>
<br/> <br/>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
&#160;&#160;&#160;<xsl:value-of select="@value"/> &#160;&#160;&#160;<xsl:value-of select="@value"/>
<br/> <br/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:template> </xsl:template>
<!-- poem --> <!-- poem -->
<xsl:template match="fb:poem"> <xsl:template match="fb:poem">
<blockquote> <blockquote>
<xsl:if test="@id"> <xsl:if test="@id">
<xsl:element name="a"> <xsl:element name="a">
<xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute> <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
</xsl:element> </xsl:element>
</xsl:if> </xsl:if>
<xsl:apply-templates/> <xsl:apply-templates/>
</blockquote> </blockquote>
</xsl:template> </xsl:template>
<!-- stanza --> <!-- stanza -->
<xsl:template match="fb:stanza"> <xsl:template match="fb:stanza">
<xsl:apply-templates/> <xsl:apply-templates/>
<br/> <br/>
</xsl:template> </xsl:template>
<!-- v --> <!-- v -->
<xsl:template match="fb:v"> <xsl:template match="fb:v">
<xsl:if test="@id"> <xsl:if test="@id">
<xsl:element name="a"> <xsl:element name="a">
<xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute> <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
</xsl:element> </xsl:element>
</xsl:if> </xsl:if>
<xsl:apply-templates/><br/> <xsl:apply-templates/><br/>
</xsl:template> </xsl:template>
<!-- image --> <!-- image -->
<xsl:template match="fb:image"> <xsl:template match="fb:image">
<div align="center"> <div align="center">
<img border="1"> <img border="1">
<xsl:choose> <xsl:choose>
<xsl:when test="starts-with(@xlink:href,'#')"> <xsl:when test="starts-with(@xlink:href,'#')">
<xsl:attribute name="src"><xsl:value-of select="substring-after(@xlink:href,'#')"/></xsl:attribute> <xsl:attribute name="src"><xsl:value-of select="substring-after(@xlink:href,'#')"/></xsl:attribute>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:attribute name="src"><xsl:value-of select="@xlink:href"/></xsl:attribute> <xsl:attribute name="src"><xsl:value-of select="@xlink:href"/></xsl:attribute>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</img> </img>
</div> </div>
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>