fix expected html output to contain secX anchors
[librarian.git] / librarian / fb2 / sections.xslt
1 <?xml version="1.0" encoding="utf-8"?>
2 <!--
3
4         This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
5         Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
6
7 -->
8 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
9         xmlns:wl="http://wolnelektury.pl/functions"
10         xmlns:dc="http://purl.org/dc/elements/1.1/"
11         xmlns="http://www.gribuser.ru/xml/fictionbook/2.0"
12         xmlns:l="http://www.w3.org/1999/xlink">
13
14         <!-- a nice epigraph section -->
15         <xsl:template match="dedykacja|nota|nota_red" mode="sections">
16                 <epigraph>
17                         <xsl:apply-templates mode="para"/>
18                         <!-- XXX: <strofa/> can be here as well -->
19                 </epigraph>
20         </xsl:template>
21
22         <!-- main text is split by headings -->
23         <xsl:template match="naglowek_rozdzial" mode="sections">
24                 <!--
25
26                 This one's tricky - we need to sections text into sections.
27                 In order to do that, all elements belonging to a single section
28                 must have something in common. We assume that this common factor
29                 is having the same number of following section headings.
30
31                 -->
32
33                 <section>
34                         <xsl:apply-templates mode="para"
35                                 select="../*[count(following-sibling::naglowek_rozdzial)
36                                         = count(current()/following-sibling::naglowek_rozdzial)]"/>
37                 </section>
38         </xsl:template>
39
40         <!-- actual headings -->
41         <xsl:template match="naglowek_rozdzial" mode="para">
42                 <title><p><xsl:apply-templates mode="inline"/></p></title>
43         </xsl:template>
44 </xsl:stylesheet>