ba07aa29e4abc0d7955ae85df98248ca94308746
[wolnelektury.git] / lib / librarian / book2txt.xslt
1 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2     xmlns:wl="http://wolnelektury.pl/functions" >
3
4 <xsl:output encoding="utf-8" method="text" />
5
6 <!-- ============================================================================== -->
7 <!-- = MASTER TAG                                                                 = -->
8 <!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
9 <!-- ============================================================================== -->
10 <xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
11 <xsl:text>Kodowanie znaków w dokumencie: UTF-8.
12 -----
13 Publikacja zrealizowana w ramach projektu Wolne Lektury (http://wolnelektury.pl/). Reprodukcja cyfrowa wykonana przez
14 Bibliotekę Narodową z egzemplarza pochodzącego ze zbiorów BN. Ten utwór nie jest chroniony prawem autorskim i znajduje
15 się w domenie publicznej, co oznacza, że możesz go swobodnie wykorzystywać, publikować i rozpowszechniać.
16
17 Wersja lektury w opracowaniu merytorycznym i krytycznym (przypisy i motywy) dostępna jest na stronie %s.
18 -----
19
20
21 </xsl:text>
22 <xsl:if test="nazwa_utworu"><xsl:apply-templates select="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul" mode="header" /></xsl:if>
23 <xsl:text>
24
25 </xsl:text>
26 <xsl:apply-templates />
27 </xsl:template>
28
29
30 <!-- ==================================================================================== -->
31 <!-- = BLOCK TAGS                                                                       = -->
32 <!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
33 <!-- ==================================================================================== -->
34 <xsl:template match="nota">
35 <xsl:apply-templates />
36 </xsl:template>
37
38 <xsl:template match="lista_osob">
39 <xsl:text>
40
41
42 </xsl:text>
43 <xsl:value-of select="naglowek_listy" />
44 <xsl:apply-templates select="lista_osoba" />
45 <xsl:text>
46 </xsl:text>
47 </xsl:template>
48
49 <xsl:template match="dedykacja">
50 <xsl:text>
51
52 </xsl:text>
53 <xsl:apply-templates />
54 </xsl:template>
55
56 <xsl:template match="kwestia">
57 <xsl:apply-templates select="strofa|akap|didaskalia" />
58 </xsl:template>
59
60 <xsl:template match="dlugi_cytat|poezja_cyt">
61 <xsl:text>
62 </xsl:text>
63 <xsl:apply-templates />
64 </xsl:template>
65
66 <xsl:template match="motto">
67 <xsl:text>
68
69 </xsl:text>
70 <xsl:apply-templates mode="inline" /><xsl:text>
71
72 </xsl:text>
73 </xsl:template>
74
75
76 <!-- ========================================== -->
77 <!-- = PARAGRAPH TAGS                         = -->
78 <!-- = (can contain inline and special tags)  = -->
79 <!-- ========================================== -->
80 <!-- Title page -->
81 <xsl:template match="autor_utworu" mode="header">
82 <xsl:text>
83
84 </xsl:text>
85 <xsl:apply-templates mode="inline" />
86 </xsl:template>
87
88 <xsl:template match="nazwa_utworu" mode="header">
89 <xsl:text>
90
91 </xsl:text>
92 <xsl:apply-templates mode="inline" />
93 </xsl:template>
94
95 <xsl:template match="dzielo_nadrzedne" mode="header">
96 <xsl:text>
97 </xsl:text>
98 <xsl:apply-templates mode="inline" />
99 </xsl:template>
100
101 <xsl:template match="podtytul" mode="header">
102 <xsl:text>
103 </xsl:text>
104 <xsl:apply-templates mode="inline" />
105 </xsl:template>
106
107 <!-- Section headers (included in index)-->
108 <xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
109 <xsl:text>
110
111
112
113
114 </xsl:text>
115 <xsl:apply-templates mode="inline" />
116 </xsl:template>
117
118 <xsl:template match="naglowek_scena|naglowek_rozdzial">
119 <xsl:text>
120
121
122
123 </xsl:text>
124 <xsl:apply-templates mode="inline" />
125 </xsl:template>
126
127 <xsl:template match="naglowek_osoba|naglowek_podrozdzial">
128 <xsl:text>
129
130
131 </xsl:text>
132 <xsl:apply-templates mode="inline" />
133 </xsl:template>
134
135 <!-- Other paragraph tags -->
136 <xsl:template match="miejsce_czas">
137 <xsl:text>
138
139
140
141 </xsl:text>
142 <xsl:apply-templates mode="inline" />
143 </xsl:template>
144
145 <xsl:template match="didaskalia">
146 <xsl:text>
147
148 / </xsl:text><xsl:apply-templates mode="inline" /><xsl:text> /</xsl:text>
149 </xsl:template>
150
151 <xsl:template match="lista_osoba">
152 <xsl:text>
153  * </xsl:text>
154 <xsl:apply-templates mode="inline" />
155 </xsl:template>
156
157 <xsl:template match="akap|akap_dialog|akap_cd">
158 <xsl:text>
159
160 </xsl:text>
161 <xsl:apply-templates mode="inline" />
162 </xsl:template>
163
164 <xsl:template match="strofa">
165 <xsl:text>
166
167 </xsl:text>
168     <xsl:choose>
169         <xsl:when test="count(br) > 0">     
170             <xsl:call-template name="verse">
171                 <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
172                 <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
173             </xsl:call-template>    
174             <xsl:for-each select="br">          
175                         <!-- Each BR tag "consumes" text after it -->
176                 <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
177                 <xsl:call-template name="verse">
178                     <xsl:with-param name="verse-content" 
179                         select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
180                     <xsl:with-param name="verse-type" select="following-sibling::*[count(preceding-sibling::br) = $lnum+1 and (name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd')][1]" />
181                 </xsl:call-template>
182             </xsl:for-each>
183         </xsl:when>
184         <xsl:otherwise>
185             <xsl:call-template name="verse">
186                 <xsl:with-param name="verse-content" select="text() | node()" />
187                 <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
188              </xsl:call-template>           
189         </xsl:otherwise>
190     </xsl:choose>
191 </xsl:template>
192
193 <xsl:template name="verse">
194     <xsl:param name="verse-content" />
195     <xsl:param name="verse-type" />
196         <xsl:choose>
197             <xsl:when test="name($verse-type) = 'wers_akap'">
198                 <xsl:text>  </xsl:text>
199             </xsl:when>
200             <xsl:when test="name($verse-type) = 'wers_wciety'">
201                 <xsl:choose>
202                     <xsl:when test="$verse-content/@typ">
203                         <xsl:text>    </xsl:text>
204                     </xsl:when>
205                     <xsl:otherwise>
206                         <xsl:text>  </xsl:text>
207                     </xsl:otherwise>
208                 </xsl:choose>
209             </xsl:when>
210             <xsl:when test="name($verse-type) = 'wers_cd'">
211                 <xsl:text>                        </xsl:text>
212             </xsl:when>
213         </xsl:choose>
214         <xsl:apply-templates select="$verse-content" mode="inline" />
215 </xsl:template>
216
217 <xsl:template match="motto_podpis">
218 <xsl:apply-templates mode="inline" />
219 </xsl:template>
220
221
222 <!-- ================================================ -->
223 <!-- = INLINE TAGS                                  = -->
224 <!-- = (contain other inline tags and special tags) = -->
225 <!-- ================================================ -->
226 <!-- Annotations -->
227 <xsl:template match="pa|pe|pr|pt" mode="inline" />
228
229 <!-- Other inline tags -->
230 <xsl:template match="mat" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
231
232 <xsl:template match="didask_tekst" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
233
234 <xsl:template match="slowo_obce" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
235
236 <xsl:template match="tytul_dziela" mode="inline">
237 <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
238 </xsl:template>
239
240 <xsl:template match="wyroznienie" mode="inline">
241 <xsl:text>*</xsl:text><xsl:apply-templates mode="inline" /><xsl:text>*</xsl:text>
242 </xsl:template>
243
244 <xsl:template match="osoba" mode="inline">
245 <xsl:apply-templates mode="inline" />
246 </xsl:template>
247
248
249 <!-- ============================================== -->
250 <!-- = STANDALONE TAGS                            = -->
251 <!-- = (cannot contain any other tags)            = -->
252 <!-- ============================================== -->
253 <xsl:template match="sekcja_swiatlo">
254 <xsl:text>
255
256
257
258 </xsl:text>
259 </xsl:template>
260
261 <xsl:template match="sekcja_asterysk">
262 <xsl:text>
263
264 *
265
266 </xsl:text>
267 </xsl:template>
268
269 <xsl:template match="separator_linia">
270 <xsl:text>
271
272 ------------------------------------------------
273
274 </xsl:text>
275 </xsl:template>
276
277
278 <!-- ================ -->
279 <!-- = SPECIAL TAGS = -->
280 <!-- ================ -->
281 <!-- Themes -->
282 <xsl:template match="begin" mode="inline" />
283
284 <xsl:template match="end" mode="inline" />
285
286 <xsl:template match="begin|end" />
287
288 <xsl:template match="motyw" mode="inline" />
289
290
291 <!-- ================ -->
292 <!-- = IGNORED TAGS = -->
293 <!-- ================ -->
294 <xsl:template match="extra|uwaga" />
295 <xsl:template match="extra|uwaga" mode="inline" />
296
297
298 <!-- ======== -->
299 <!-- = TEXT = -->
300 <!-- ======== -->
301 <xsl:template match="text()" />
302 <xsl:template match="text()" mode="inline">
303     <xsl:value-of select="wl:substitute_entities(.)" />
304 </xsl:template>
305
306
307 </xsl:stylesheet>
308