]> git.stg.codes - stg.git/blob - doc/xslt/slides/fo/plain.xsl
Fix raw ip tests
[stg.git] / doc / xslt / slides / fo / plain.xsl
1 <?xml version="1.0"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
4                 xmlns:rx="http://www.renderx.com/XSL/Extensions"
5                 version="1.0">
6
7 <!-- ********************************************************************
8      $Id: plain.xsl 8101 2008-08-03 18:35:14Z mzjn $
9      ********************************************************************
10
11      This file is part of the DocBook Slides Stylesheet distribution.
12      See ../README or http://docbook.sf.net/release/xsl/current/ for
13      copyright and other information.
14
15      ******************************************************************** -->
16
17 <xsl:import href="../../fo/docbook.xsl"/>
18 <xsl:import href="param.xsl"/>
19
20 <xsl:param name="alignment" select="'start'"/>
21
22 <xsl:include href="plain-titlepage.xsl"/>
23
24 <xsl:param name="local.l10n.xml" select="document('')"/>
25 <i18n xmlns="http://docbook.sourceforge.net/xmlns/l10n/1.0">
26   <l:l10n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" language="en">
27     <l:gentext key="Continued" text="(Continued)"/>
28     <l:context name="title">
29       <l:template name="slides" text="%t"/>
30       <l:template name="foilgroup" text="%t"/>
31       <l:template name="foil" text="%t"/>
32     </l:context>
33   </l:l10n>
34 </i18n>
35
36 <xsl:variable name="root.elements" select="' slides '"/>
37
38 <xsl:param name="preferred.mediaobject.role" select="'print'"/>
39
40 <xsl:param name="page.orientation" select="'landscape'"/>
41
42 <xsl:param name="body.font.master" select="24"/>
43
44 <xsl:attribute-set name="formal.title.properties"
45                    use-attribute-sets="normal.para.spacing">
46   <xsl:attribute name="font-weight">bold</xsl:attribute>
47   <xsl:attribute name="font-size">
48     <xsl:value-of select="$body.font.master * 1.2"/>
49     <xsl:text>pt</xsl:text>
50   </xsl:attribute>
51   <xsl:attribute name="hyphenate">false</xsl:attribute>
52   <xsl:attribute name="space-after.minimum">8pt</xsl:attribute>
53   <xsl:attribute name="space-after.optimum">6pt</xsl:attribute>
54   <xsl:attribute name="space-after.maximum">10pt</xsl:attribute>
55 </xsl:attribute-set>
56
57 <xsl:attribute-set name="list.block.spacing">
58   <xsl:attribute name="space-before.optimum">12pt</xsl:attribute>
59   <xsl:attribute name="space-before.minimum">8pt</xsl:attribute>
60   <xsl:attribute name="space-before.maximum">14pt</xsl:attribute>
61   <xsl:attribute name="space-after.optimum">0pt</xsl:attribute>
62   <xsl:attribute name="space-after.minimum">0pt</xsl:attribute>
63   <xsl:attribute name="space-after.maximum">0pt</xsl:attribute>
64 </xsl:attribute-set>
65
66 <xsl:attribute-set name="list.item.spacing">
67   <xsl:attribute name="space-before.optimum">6pt</xsl:attribute>
68   <xsl:attribute name="space-before.minimum">4pt</xsl:attribute>
69   <xsl:attribute name="space-before.maximum">8pt</xsl:attribute>
70 </xsl:attribute-set>
71
72 <xsl:attribute-set name="normal.para.spacing">
73   <xsl:attribute name="space-before.optimum">8pt</xsl:attribute>
74   <xsl:attribute name="space-before.minimum">6pt</xsl:attribute>
75   <xsl:attribute name="space-before.maximum">10pt</xsl:attribute>
76 </xsl:attribute-set>
77
78 <xsl:attribute-set name="slides.titlepage.recto.style">
79   <xsl:attribute name="font-family">
80     <xsl:value-of select="$slide.font.family"/>
81   </xsl:attribute>
82 </xsl:attribute-set>
83
84 <xsl:attribute-set name="slides.titlepage.verso.style">
85   <xsl:attribute name="font-family">
86     <xsl:value-of select="$slide.font.family"/>
87   </xsl:attribute>
88 </xsl:attribute-set>
89
90 <!-- ============================================================ -->
91
92 <xsl:param name="page.margin.top" select="'0.25in'"/>
93 <xsl:param name="region.before.extent" select="'0.75in'"/>
94 <xsl:param name="body.margin.top" select="'1in'"/>
95
96 <xsl:param name="region.after.extent" select="'0.5in'"/>
97 <xsl:param name="body.margin.bottom" select="'0.5in'"/>
98 <xsl:param name="page.margin.bottom" select="'0.25in'"/>
99
100 <xsl:param name="page.margin.inner" select="'0.25in'"/>
101 <xsl:param name="page.margin.outer" select="'0.25in'"/>
102 <xsl:param name="column.count.body" select="1"/>
103
104 <xsl:template name="user.pagemasters">
105   <fo:simple-page-master master-name="slides-titlepage-master"
106                          page-width="{$page.width}"
107                          page-height="{$page.height}"
108                          margin-top="{$page.margin.top}"
109                          margin-bottom="{$page.margin.bottom}"
110                          margin-left="{$page.margin.inner}"
111                          margin-right="{$page.margin.outer}">
112     <fo:region-body margin-bottom="0pt"
113                     margin-top="0pt"
114                     column-count="{$column.count.body}">
115     </fo:region-body>
116   </fo:simple-page-master>
117
118   <fo:simple-page-master master-name="slides-foil-master"
119                          page-width="{$page.width}"
120                          page-height="{$page.height}"
121                          margin-top="{$page.margin.top}"
122                          margin-bottom="{$page.margin.bottom}"
123                          margin-left="{$page.margin.inner}"
124                          margin-right="{$page.margin.outer}">
125     <fo:region-body margin-bottom="{$body.margin.bottom}"
126                     margin-top="{$body.margin.top}"
127                     column-count="{$column.count.body}">
128     </fo:region-body>
129     <fo:region-before region-name="xsl-region-before-foil"
130                       extent="{$region.before.extent}"
131                       display-align="before"/>
132     <fo:region-after region-name="xsl-region-after-foil"
133                      extent="{$region.after.extent}"
134                      display-align="after"/>
135   </fo:simple-page-master>
136
137   <fo:simple-page-master master-name="slides-foil-continued-master"
138                          page-width="{$page.width}"
139                          page-height="{$page.height}"
140                          margin-top="{$page.margin.top}"
141                          margin-bottom="{$page.margin.bottom}"
142                          margin-left="{$page.margin.inner}"
143                          margin-right="{$page.margin.outer}">
144     <fo:region-body margin-bottom="{$body.margin.bottom}"
145                     margin-top="{$body.margin.top}"
146                     column-count="{$column.count.body}">
147     </fo:region-body>
148     <fo:region-before region-name="xsl-region-before-foil-continued"
149                       extent="{$region.before.extent}"
150                       display-align="before"/>
151     <fo:region-after region-name="xsl-region-after-foil-continued"
152                      extent="{$region.after.extent}"
153                      display-align="after"/>
154   </fo:simple-page-master>
155
156   <fo:page-sequence-master master-name="slides-titlepage">
157     <fo:repeatable-page-master-alternatives>
158       <fo:conditional-page-master-reference master-reference="slides-titlepage-master"/>
159     </fo:repeatable-page-master-alternatives>
160   </fo:page-sequence-master>
161
162   <fo:page-sequence-master master-name="slides-foil">
163     <fo:repeatable-page-master-alternatives>
164       <fo:conditional-page-master-reference master-reference="slides-foil-master"
165                                             page-position="first"/>
166       <fo:conditional-page-master-reference master-reference="slides-foil-continued-master"/>
167     </fo:repeatable-page-master-alternatives>
168   </fo:page-sequence-master>
169 </xsl:template>
170
171 <xsl:template match="*" mode="running.head.mode">
172   <xsl:param name="master-reference" select="'unknown'"/>
173   <!-- use the foilgroup title if there is one -->
174   <fo:static-content flow-name="xsl-region-before-foil">
175     <fo:block background-color="white"
176               color="black"
177               font-size="{$foil.title.size}"
178               font-weight="bold"
179               text-align="center"
180               font-family="{$slide.title.font.family}">
181       <xsl:apply-templates select="title" mode="titlepage.mode"/>
182     </fo:block>
183   </fo:static-content>
184
185   <fo:static-content flow-name="xsl-region-before-foil-continued">
186     <fo:block background-color="white"
187               color="black"
188               font-size="{$foil.title.size}"
189               font-weight="bold"
190               text-align="center"
191               font-family="{$slide.title.font.family}">
192       <xsl:apply-templates select="title" mode="titlepage.mode"/>
193       <xsl:text> </xsl:text>
194       <xsl:call-template name="gentext">
195         <xsl:with-param name="key" select="'Continued'"/>
196       </xsl:call-template>
197     </fo:block>
198   </fo:static-content>
199 </xsl:template>
200
201 <xsl:template match="*" mode="running.foot.mode">
202   <xsl:param name="master-reference" select="'unknown'"/>
203
204   <xsl:variable name="last-slide"
205                 select="(//foil|//foilgroup)[last()]"/>
206
207   <xsl:variable name="last-id">
208     <xsl:choose>
209       <xsl:when test="$last-slide/@id">
210         <xsl:value-of select="$last-slide/@id"/>
211       </xsl:when>
212       <xsl:otherwise>
213         <xsl:value-of select="generate-id($last-slide)"/>
214       </xsl:otherwise>
215     </xsl:choose>
216   </xsl:variable>
217
218   <xsl:variable name="content">
219     <fo:table table-layout="fixed" width="100%"
220               xsl:use-attribute-sets="running.foot.properties">
221       <fo:table-column column-number="1" column-width="33%"/>
222       <fo:table-column column-number="2" column-width="34%"/>
223       <fo:table-column column-number="3" column-width="33%"/>
224       <fo:table-body>
225         <fo:table-row height="14pt">
226           <fo:table-cell text-align="left">
227             <fo:block>
228               <xsl:if test="self::foil">
229                 <xsl:choose>
230                   <xsl:when test="ancestor::foilgroup[1]/titleabbrev">
231                     <xsl:apply-templates select="ancestor::foilgroup[1]/titleabbrev"
232                                          mode="titlepage.mode"/>
233                   </xsl:when>
234                   <xsl:otherwise>
235                     <xsl:apply-templates select="ancestor::foilgroup[1]/title"
236                                          mode="titlepage.mode"/>
237                   </xsl:otherwise>
238                 </xsl:choose>
239               </xsl:if>
240             </fo:block>
241           </fo:table-cell>
242           <fo:table-cell text-align="center">
243             <fo:block>
244               <xsl:if test="/slides/slidesinfo/releaseinfo[@role='copyright']">
245                 <xsl:apply-templates select="/slides/slidesinfo/releaseinfo[@role='copyright']"
246                                      mode="value"/>
247                 <xsl:text>&#160;&#160;&#160;</xsl:text>
248               </xsl:if>
249               <xsl:apply-templates select="/slides/slidesinfo/copyright"
250                                    mode="titlepage.mode"/>
251             </fo:block>
252           </fo:table-cell>
253           <fo:table-cell text-align="right">
254             <fo:block>
255               <fo:page-number/>
256               <xsl:text>&#160;/&#160;</xsl:text>
257               <fo:page-number-citation ref-id="{$last-id}"/>
258             </fo:block>
259           </fo:table-cell>
260         </fo:table-row>
261       </fo:table-body>
262     </fo:table>
263   </xsl:variable>
264
265   <fo:static-content flow-name="xsl-region-after-foil">
266     <fo:block>
267       <xsl:copy-of select="$content"/>
268     </fo:block>
269   </fo:static-content>
270
271   <fo:static-content flow-name="xsl-region-after-foil-continued">
272     <fo:block>
273       <xsl:copy-of select="$content"/>
274     </fo:block>
275   </fo:static-content>
276 </xsl:template>
277
278 <xsl:template name="select.user.pagemaster">
279   <xsl:param name="element"/>
280   <xsl:param name="pageclass"/>
281   <xsl:param name="default-pagemaster"/>
282
283   <xsl:choose>
284     <xsl:when test="$element = 'slides'">slides-titlepage</xsl:when>
285     <xsl:otherwise>slides-foil</xsl:otherwise>
286   </xsl:choose>
287 </xsl:template>
288
289 <xsl:template match="slides">
290   <xsl:variable name="master-reference">
291     <xsl:call-template name="select.pagemaster"/>
292   </xsl:variable>
293
294   <fo:page-sequence hyphenate="{$hyphenate}"
295                     master-reference="{$master-reference}">
296     <xsl:attribute name="language">
297       <xsl:call-template name="l10n.language"/>
298     </xsl:attribute>
299
300     <xsl:apply-templates select="." mode="running.head.mode">
301       <xsl:with-param name="master-reference" select="$master-reference"/>
302     </xsl:apply-templates>
303     <xsl:apply-templates select="." mode="running.foot.mode">
304       <xsl:with-param name="master-reference" select="$master-reference"/>
305     </xsl:apply-templates>
306     <fo:flow flow-name="xsl-region-body">
307       <fo:block>
308         <xsl:call-template name="anchor">
309           <xsl:with-param name="conditional" select="0"/>
310         </xsl:call-template>
311         <xsl:call-template name="slides.titlepage"/>
312         <xsl:apply-templates select="speakernotes"/>
313       </fo:block>
314     </fo:flow>
315   </fo:page-sequence>
316   <xsl:apply-templates select="foil|foilgroup"/>
317 </xsl:template>
318
319 <xsl:template match="slidesinfo"/>
320
321 <xsl:template match="slides" mode="title.markup">
322   <xsl:param name="allow-anchors" select="'0'"/>
323   <xsl:apply-templates select="(slidesinfo/title|title)[1]"
324                        mode="title.markup">
325     <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
326   </xsl:apply-templates>
327 </xsl:template>
328
329 <!-- ============================================================ -->
330
331 <xsl:template name="foilgroup.titlepage">
332   <fo:block background-color="black"
333             color="white"
334             font-size="{$foil.title.size}"
335             font-weight="bold"
336             text-align="center"
337             padding-top="12pt"
338             padding-bottom="12pt"
339             space-after="1em">
340     <xsl:apply-templates select="title" mode="titlepage.mode"/>
341   </fo:block>
342 </xsl:template>
343
344 <xsl:template match="foilgroup">
345   <xsl:variable name="master-reference">
346     <xsl:call-template name="select.pagemaster"/>
347   </xsl:variable>
348
349   <fo:page-sequence hyphenate="{$hyphenate}"
350                     master-reference="{$master-reference}">
351     <xsl:call-template name="anchor">
352       <xsl:with-param name="conditional" select="0"/>
353     </xsl:call-template>
354     <xsl:attribute name="language">
355       <xsl:call-template name="l10n.language"/>
356     </xsl:attribute>
357
358     <xsl:apply-templates select="." mode="running.head.mode">
359       <xsl:with-param name="master-reference" select="$master-reference"/>
360     </xsl:apply-templates>
361     <xsl:apply-templates select="." mode="running.foot.mode">
362       <xsl:with-param name="master-reference" select="$master-reference"/>
363     </xsl:apply-templates>
364
365     <fo:flow flow-name="xsl-region-body">
366       <fo:block>
367         <xsl:if test="*[not(self::foil)]">
368           <fo:block xsl:use-attribute-sets="foil.properties" space-after="1em">
369             <xsl:apply-templates select="*[not(self::foil)]"/>
370           </fo:block>
371         </xsl:if>
372
373         <xsl:call-template name="foilgroup.titlepage"/>
374       </fo:block>
375     </fo:flow>
376   </fo:page-sequence>
377   <xsl:apply-templates select="foil"/>
378 </xsl:template>
379
380 <xsl:template match="foilgroup/title"/>
381 <xsl:template match="foilgroup/titleabbrev"/>
382
383 <xsl:template match="foilgroup/titleabbrev" mode="titlepage.mode">
384   <xsl:apply-templates/>
385 </xsl:template>
386
387 <xsl:template match="slides/foilgroup/title" mode="titlepage.mode">
388   <xsl:apply-templates/>
389 </xsl:template>
390
391 <xsl:template match="title" mode="foilgroup.titlepage.recto.mode">
392   <fo:block>
393     <fo:inline color="white">.</fo:inline>
394     <fo:block space-before="2in">
395       <xsl:apply-templates select="." mode="titlepage.mode"/>
396     </fo:block>
397   </fo:block>
398 </xsl:template>
399
400 <xsl:template match="foilgroupinfo"/>
401
402 <!-- ============================================================ -->
403
404 <!--
405 <xsl:template name="foil.titlepage">
406   <fo:block background-color="white"
407             color="black"
408             font-size="{$foil.title.size}"
409             font-weight="bold"
410             text-align="center"
411             padding-top="12pt"
412             padding-bottom="12pt"
413             space-after="1em">
414     <xsl:apply-templates select="title" mode="titlepage.mode"/>
415   </fo:block>
416 </xsl:template>
417 -->
418
419 <xsl:template match="foil">
420   <xsl:variable name="master-reference">
421     <xsl:call-template name="select.pagemaster"/>
422   </xsl:variable>
423
424   <fo:page-sequence hyphenate="{$hyphenate}"
425                     master-reference="{$master-reference}">
426     <xsl:call-template name="anchor">
427       <xsl:with-param name="conditional" select="0"/>
428     </xsl:call-template>
429     <xsl:attribute name="language">
430       <xsl:call-template name="l10n.language"/>
431     </xsl:attribute>
432
433     <xsl:apply-templates select="." mode="running.head.mode">
434       <xsl:with-param name="master-reference" select="$master-reference"/>
435     </xsl:apply-templates>
436     <xsl:apply-templates select="." mode="running.foot.mode">
437       <xsl:with-param name="master-reference" select="$master-reference"/>
438     </xsl:apply-templates>
439     <fo:flow flow-name="xsl-region-body">
440       <fo:block>
441         <fo:block xsl:use-attribute-sets="foil.properties">
442           <xsl:apply-templates/>
443         </fo:block>
444       </fo:block>
445     </fo:flow>
446   </fo:page-sequence>
447 </xsl:template>
448
449 <xsl:template match="foilinfo"/>
450 <xsl:template match="foil/title"/>
451 <xsl:template match="foil/subtitle">
452   <fo:block xsl:use-attribute-sets="foil.subtitle.properties">
453     <xsl:apply-templates/>
454   </fo:block>
455 </xsl:template>
456 <xsl:template match="foil/titleabbrev"/>
457
458 <!-- ============================================================ -->
459
460 <xsl:template match="slides" mode="label.markup">
461   <xsl:if test="@label">
462     <xsl:value-of select="@label"/>
463   </xsl:if>
464 </xsl:template>
465
466 <!-- ============================================================ -->
467
468 <xsl:template match="speakernotes">
469   <fo:block xsl:use-attribute-sets="speakernote.properties">
470     <xsl:apply-templates/>
471   </fo:block>
472 </xsl:template>
473
474 <!-- ============================================================ -->
475 <!-- Bookmarks -->
476
477 <!-- XEP -->
478
479 <xsl:template match="slides|foilgroup|foil[not(@role) or @role != 'ENDTITLE']"
480               mode="xep.outline">
481   <xsl:variable name="id">
482     <xsl:call-template name="object.id"/>
483   </xsl:variable>
484   <xsl:variable name="bookmark-label">
485     <xsl:apply-templates select="." mode="object.title.markup"/>
486   </xsl:variable>
487
488   <!-- Put the root element bookmark at the same level as its children -->
489   <!-- If the object is a set or book, generate a bookmark for the toc -->
490
491   <xsl:choose>
492     <xsl:when test="parent::*">
493       <rx:bookmark internal-destination="{$id}">
494         <rx:bookmark-label>
495           <xsl:value-of select="$bookmark-label"/>
496         </rx:bookmark-label>
497         <xsl:apply-templates select="*" mode="xep.outline"/>
498       </rx:bookmark>
499     </xsl:when>
500     <xsl:otherwise>
501       <xsl:if test="$bookmark-label != ''">
502         <rx:bookmark internal-destination="{$id}">
503           <rx:bookmark-label>
504             <xsl:value-of select="$bookmark-label"/>
505           </rx:bookmark-label>
506         </rx:bookmark>
507       </xsl:if>
508
509       <xsl:apply-templates select="*" mode="xep.outline"/>
510     </xsl:otherwise>
511   </xsl:choose>
512 </xsl:template>
513
514 <!-- Handling of xrefs -->
515
516 <xsl:template match="foil|foilgroup" mode="xref-to">
517   <xsl:param name="referrer"/>
518   <xsl:param name="xrefstyle"/>
519   
520   <xsl:apply-templates select="." mode="object.xref.markup">
521     <xsl:with-param name="purpose" select="'xref'"/>
522     <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
523     <xsl:with-param name="referrer" select="$referrer"/>
524   </xsl:apply-templates>
525 </xsl:template>
526
527
528 </xsl:stylesheet>