X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/cec81dc04a23808077505265a3f8bb0e9b6053cb..7f5ff5c99803e281dc90364cd6efb77b8d91fa26:/librarian/fb2/sections.xslt?ds=sidebyside diff --git a/librarian/fb2/sections.xslt b/librarian/fb2/sections.xslt index 7f34bc3..80ffb65 100644 --- a/librarian/fb2/sections.xslt +++ b/librarian/fb2/sections.xslt @@ -11,33 +11,37 @@ xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:l="http://www.w3.org/1999/xlink"> - <!-- a nice epigraph section --> - <xsl:template match="nota_red" mode="sections"> - <epigraph> - <xsl:apply-templates mode="para"/> - </epigraph> - </xsl:template> - - <!-- main text is split by headings --> - <xsl:template match="naglowek_rozdzial" mode="sections"> - <!-- - - This one's tricky - we need to sections text into sections. - In order to do that, all elements belonging to a single section - must have something in common. We assume that this common factor - is having the same number of following section headings. - - --> - - <section> - <xsl:apply-templates mode="para" - select="../*[count(following-sibling::naglowek_rozdzial) - = count(current()/following-sibling::naglowek_rozdzial)]"/> - </section> - </xsl:template> + <xsl:template name="section"> + <!-- All the <_section> are in the end. --> + <xsl:if test="count(*) > count(_section)"> + <section> + <xsl:choose> + <xsl:when test="(local-name() = 'liryka_l' or local-name() = 'liryka_lp') + and count(_section) = 0"> + <poem> + <xsl:apply-templates mode="para" /> + </poem> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates mode="para" /> + </xsl:otherwise> + </xsl:choose> + </section> + </xsl:if> + + <!-- Now, recursively, all the _section tags. --> + <xsl:apply-templates mode="section" select="_section" /> + </xsl:template> + + <xsl:template match="_section" mode="para" /> + <xsl:template match="_section" mode="section" > + <section> + <xsl:call-template name="section" /> + </section> + </xsl:template> <!-- actual headings --> - <xsl:template match="naglowek_rozdzial" mode="para"> + <xsl:template match="naglowek_czesc|naglowek_rozdzial|naglowek_podrozdzial|naglowek_akt|naglowek_scena" mode="para"> <title><p><xsl:apply-templates mode="inline"/></p></title> </xsl:template> </xsl:stylesheet>