letters
[librarian.git] / src / librarian / fb2 / footnotes.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 Wolne Lektury. 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         <!-- footnote body mode -->
15         <xsl:template match="pa|pe|pr|pt|ptrad" mode="footnotes">
16                 <!-- we number them absolutely -->
17                 <xsl:variable name="n" select="count(preceding::pa) + count(preceding::pe) + count(preceding::pr) + count(preceding::pt) + count(preceding::ptrad) + 1"/>
18
19                 <xsl:element name="section">
20                         <xsl:attribute name="id">fn<xsl:value-of select="$n"/></xsl:attribute>
21
22                         <p><xsl:apply-templates mode="inline"/>
23                 <xsl:if test="local-name() = 'pa'">
24                     <xsl:text> [przypis autorski]</xsl:text>
25                 </xsl:if>
26                 <xsl:if test="local-name() = 'pt'">
27                     <xsl:text> [przypis tłumacza]</xsl:text>
28                 </xsl:if>
29                 <xsl:if test="local-name() = 'pr'">
30                     <xsl:text> [przypis redakcyjny]</xsl:text>
31                 </xsl:if>
32                 <xsl:if test="local-name() = 'pe'">
33                     <xsl:text> [przypis edytorski]</xsl:text>
34                 </xsl:if>
35                 <xsl:if test="local-name() = 'ptrad'">
36                     <xsl:text> [przypis tradycyjny]</xsl:text>
37                 </xsl:if></p>
38                 </xsl:element>
39         </xsl:template>
40         <xsl:template match="text()" mode="footnotes"/>
41
42         <!-- footnote links -->
43         <xsl:template match="pa|pe|pr|pt|ptrad" mode="inline">
44                 <xsl:variable name="n" select="count(preceding::pa) + count(preceding::pe) + count(preceding::pr) + count(preceding::pt) + count(preceding::ptrad) + 1"/>
45                 <xsl:element name="a">
46                         <xsl:attribute name="type">note</xsl:attribute>
47                         <xsl:attribute name="l:href">#fn<xsl:value-of select="$n"/></xsl:attribute>
48
49                         <xsl:text>[</xsl:text>
50                         <xsl:value-of select="$n"/>
51                         <xsl:text>]</xsl:text>
52                 </xsl:element>
53         </xsl:template>
54 </xsl:stylesheet>