1 <?xml version="1.0" encoding="utf-8"?>
3 Copyright © 2009,2010 Łukasz Rekucki
5 This file is part of WL2PDF
7 WL2PDF is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Affero General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 WL2PDF is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Affero General Public License for more details.
17 You should have received a copy of the GNU Affero General Public License
18 along with WL2PDF. If not, see <http://www.gnu.org/licenses/>.
20 <xsl:stylesheet version="2.0"
22 xmlns:wlml="http://nowoczesnapolska.org.pl/ML/Lektury/1.1"
24 xmlns:xs="http://www.w3.org/2001/XMLSchema"
25 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
27 xmlns:fo="http://www.w3.org/1999/XSL/Format"
28 xmlns:wlf="http://wolnelektury.pl/functions" >
31 <!-- generic template parameters -->
32 <xsl:param name="base-font-size" select="xs:integer(12)" />
33 <xsl:param name="base-font" select="'DejaVu Serif'" />
35 <xsl:variable name="footnote-font-size" select="$base-font-size - 2" />
36 <xsl:variable name="header-font-size" select="$base-font-size" />
38 <xsl:include href="wl2fo_pagemaster.xsl" />
40 <xsl:output method="xml"
43 omit-xml-declaration = "yes" />
46 <!-- main templates -->
47 <xsl:template match="/">
49 <xsl:call-template name="layout-masters" />
51 <fo:page-sequence master-reference="book-titles">
52 <xsl:call-template name="title-page" />
57 master-reference="main"
58 initial-page-number="1"
59 force-page-count="even">
62 <!-- RUNNING HEADERS -->
65 flow-name="xsl-footnote-separator">
66 <fo:block text-align-last="justify"><fo:leader leader-pattern="rule"/></fo:block>
70 flow-name="odd-after" font-family="{$base-font}" text-align="center">
77 flow-name="even-after" font-family="{$base-font}" text-align="center">
85 flow-name="even-before"
86 font-family="DejaVu Serif"
89 <fo:block border-bottom-width="0.2mm"
90 border-bottom-style="solid"
91 border-bottom-color="black">
92 <fo:retrieve-marker retrieve-class-name="odd-header" />
97 flow-name="odd-before"
98 font-family="DejaVu Serif"
101 <fo:block border-after-width="0.2mm"
102 border-after-style="solid"
103 border-after-color="black">
104 <fo:retrieve-marker retrieve-class-name="even-header" />
109 flow-name="xsl-region-body"
110 font-family="{$base-font}"
111 font-size="{concat($base-font-size, 'pt')}"
112 line-height-shift-adjustment="disregard-shifts" >
114 <fo:marker marker-class-name="even-header">
115 <xsl:value-of select="//wlml:author" />
117 <fo:marker marker-class-name="odd-header">
118 <xsl:value-of select="//wlml:title" />
121 <xsl:apply-templates select="//wlml:main-text" />
127 <xsl:template match="wlml:main-text">
128 <xsl:apply-templates select="child::*" />
132 PROZA: elementy proste
135 <xsl:template match="wlml:chapter">
136 <fo:block text-align="left" font-size="300%"
138 page-break-before="right">
140 <fo:marker marker-class-name="even-header">
141 <xsl:apply-templates select="node()" />
143 <xsl:apply-templates select="node()" />
147 <xsl:template match="wlml:p">
150 hyphenate="true" line-height="1.5"
154 <xsl:apply-templates select="child::node()" />
158 <xsl:template match="wlml:pd">
159 <fo:block text-align="justify" hyphenate="true" line-height="1.5"
163 >—<fo:character character="⁠" /><fo:character character=" " /><xsl:apply-templates select="child::node()" />
170 <xsl:template match="wlml:stanza">
171 <fo:block space-before="1.5em" space-after="1.5em" keep-together.within-page="50">
172 <xsl:apply-templates select="child::node()" />
176 <xsl:template match="wlml:v|wlml:vc">
177 <fo:block line-height="1.4"><xsl:apply-templates select="node()" /></fo:block>
180 <xsl:template match="wlml:vi">
182 <fo:block line-height="1.4">
183 <xsl:attribute name="text-indent">
185 <xsl:when test="@size">
186 <xsl:value-of select="concat(xs:string(xs:integer(@size)), 'em')" />
188 <xsl:otherwise>1em</xsl:otherwise>
191 <xsl:apply-templates select="node()" />
199 <xsl:template match="wlml:drama-line">
200 <xsl:apply-templates select="child::node()" />
203 <xsl:template match="wlml:drama-line/wlml:person">
206 text-transform="uppercase"
208 keep-with-next.within-page="always"
209 keep-with-previous.within-page="0">
210 <xsl:apply-templates select="node()" />
214 <xsl:template match="wlml:drama-line/wlml:stanza" priority="10">
215 <fo:block space-before="0.5em" space-after="1.5em"
216 keep-together.within-page="50"
217 keep-with-previous.within-page="10" >
218 <xsl:apply-templates select="child::node()" />
222 <xsl:template match="wlml:person-list">
223 <fo:block keep-together.within-page="100"
224 break-before="page" break-after="page">
225 <fo:block text-transform="uppercase"
226 font-weight="bold" font-size="150%"
227 line-height="1.4" space-after="2em">
228 <xsl:value-of select="wlml:caption" />
230 <xsl:apply-templates select="wlml:person" />
234 <xsl:template match="wlml:person">
235 <fo:block space-after="1em">
236 <xsl:apply-templates select="child::node()" />
244 <xsl:template match="wlml:foreign">
245 <fo:inline font-style="italic">
246 <xsl:apply-templates select="node()" />
247 </fo:inline><fo:character character=" " />
254 <xsl:template match="wlml:anchor">
255 <xsl:variable name="annot" select="/wlml:doc/wlml:annotations/wlml:annotation[@refs = current()/@id]" />
257 <fo:inline vertical-align="super" font-size="0.75em"><xsl:number from="wlml:main-text|wlml:chapter" level="any" />) </fo:inline>
258 <!-- <fo:inline>* </fo:inline> -->
261 font-weight="normal" font-style="normal"
262 font-size="{concat($footnote-font-size, 'pt')}"
263 text-align="justify" text-indent="1.5em" space-after="1em">
264 <xsl:number level="any" from="wlml:main-text|wlml:chapter"/>)<fo:character character=" " />
266 <xsl:if test="$annot/wlml:definition">
267 <fo:inline letter-spacing="0.1em"><xsl:apply-templates select="$annot/wlml:definition/node()" /></fo:inline>
268 <fo:character character=" " />—<fo:character character=" " />
271 <xsl:apply-templates select="$annot/wlml:body/node()" />
277 <xsl:template match="*" />
280 <xsl:template match="text()">
281 <xsl:value-of select="wlf:enchance-for-print(.)" />
284 <xsl:function name="wlf:enchance-for-print">
285 <xsl:param name="text" />
286 <xsl:value-of select="wlf:reduce-tokens(wlf:map-text-tokens(tokenize($text, '\s+')))" />
289 <!-- Some usefull functions -->
292 <xsl:function name="wlf:map-text-tokens">
293 <xsl:param name="tokens" />
294 <xsl:for-each select="$tokens">
295 <xsl:sequence select='
305 "\.\.+", "…") ' />
309 <xsl:function name="wlf:reduce-tokens">
310 <xsl:param name="tokens" />
311 <xsl:for-each select="0 to count($tokens)">
312 <xsl:variable name="cur" select="$tokens[current()]" />
313 <xsl:variable name="next" select="$tokens[current()+1]" />
315 <xsl:when test="not($cur)" />
316 <xsl:when test="$next = '—'">
317 <xsl:value-of select="concat($cur, ' ')" />
319 <xsl:when test="$cur = '—'">
320 <xsl:value-of select="concat($cur, ' ')" />
322 <xsl:when test="$next and string-length($cur) = 1">
323 <!-- non breaking space -->
324 <xsl:value-of select="concat($cur, ' ')" />
326 <xsl:when test="$next">
327 <xsl:value-of select="concat($cur, ' ')" />
330 <xsl:value-of select="$cur" />