]> git.evergreen-ils.org Git - working/Evergreen.git/blob - stylesheets/evergreen_docbook_files/docbook-xsl-1.75.2/fo/docbook.xsl
Evergreen Version Fix to reflect the new EG releases 2.0.10 and 1.6.1.9
[working/Evergreen.git] / stylesheets / evergreen_docbook_files / docbook-xsl-1.75.2 / fo / docbook.xsl
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                 xmlns:exsl="http://exslt.org/common"
4                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
5                 xmlns:ng="http://docbook.org/docbook-ng"
6                 xmlns:db="http://docbook.org/ns/docbook"
7                 exclude-result-prefixes="db ng exsl"
8                 version='1.0'>
9
10 <!-- It is important to use indent="no" here, otherwise verbatim -->
11 <!-- environments get broken by indented tags...at least when the -->
12 <!-- callout extension is used...at least with some processors -->
13 <xsl:output method="xml" indent="no"/>
14
15 <!-- ********************************************************************
16      $Id: docbook.xsl 8414 2009-04-18 22:40:23Z bobstayton $
17      ********************************************************************
18
19      This file is part of the XSL DocBook Stylesheet distribution.
20      See ../README or http://docbook.sf.net/release/xsl/current/ for
21      copyright and other information.
22
23      ******************************************************************** -->
24
25 <!-- ==================================================================== -->
26
27 <xsl:include href="../VERSION"/>
28 <xsl:include href="param.xsl"/>
29 <xsl:include href="../lib/lib.xsl"/>
30 <xsl:include href="../common/l10n.xsl"/>
31 <xsl:include href="../common/common.xsl"/>
32 <xsl:include href="../common/utility.xsl"/>
33 <xsl:include href="../common/labels.xsl"/>
34 <xsl:include href="../common/titles.xsl"/>
35 <xsl:include href="../common/subtitles.xsl"/>
36 <xsl:include href="../common/gentext.xsl"/>
37 <xsl:include href="../common/olink.xsl"/>
38 <xsl:include href="../common/targets.xsl"/>
39 <xsl:include href="../common/pi.xsl"/>
40 <xsl:include href="autotoc.xsl"/>
41 <xsl:include href="autoidx.xsl"/>
42 <xsl:include href="lists.xsl"/>
43 <xsl:include href="callout.xsl"/>
44 <xsl:include href="verbatim.xsl"/>
45 <xsl:include href="graphics.xsl"/>
46 <xsl:include href="xref.xsl"/>
47 <xsl:include href="formal.xsl"/>
48 <xsl:include href="table.xsl"/>
49 <xsl:include href="htmltbl.xsl"/>
50 <xsl:include href="sections.xsl"/>
51 <xsl:include href="inline.xsl"/>
52 <xsl:include href="footnote.xsl"/>
53 <xsl:include href="fo.xsl"/>
54 <xsl:include href="fo-rtf.xsl"/>
55 <xsl:include href="info.xsl"/>
56 <xsl:include href="keywords.xsl"/>
57 <xsl:include href="division.xsl"/>
58 <xsl:include href="index.xsl"/>
59 <xsl:include href="toc.xsl"/>
60 <xsl:include href="refentry.xsl"/>
61 <xsl:include href="math.xsl"/>
62 <xsl:include href="admon.xsl"/>
63 <xsl:include href="component.xsl"/>
64 <xsl:include href="biblio.xsl"/>
65 <xsl:include href="biblio-iso690.xsl"/>
66 <xsl:include href="glossary.xsl"/>
67 <xsl:include href="block.xsl"/>
68 <xsl:include href="task.xsl"/>
69 <xsl:include href="qandaset.xsl"/>
70 <xsl:include href="synop.xsl"/>
71 <xsl:include href="titlepage.xsl"/>
72 <xsl:include href="titlepage.templates.xsl"/>
73 <xsl:include href="pagesetup.xsl"/>
74 <xsl:include href="pi.xsl"/>
75 <xsl:include href="spaces.xsl"/>
76 <xsl:include href="ebnf.xsl"/>
77 <xsl:include href="../html/chunker.xsl"/>
78 <xsl:include href="annotations.xsl"/>
79 <xsl:include href="../common/stripns.xsl"/>
80
81 <xsl:include href="fop.xsl"/>
82 <xsl:include href="fop1.xsl"/>
83 <xsl:include href="passivetex.xsl"/>
84 <xsl:include href="xep.xsl"/>
85 <xsl:include href="axf.xsl"/>
86 <xsl:include href="ptc.xsl"/>
87
88 <xsl:param name="stylesheet.result.type" select="'fo'"/>
89
90 <!-- ==================================================================== -->
91
92 <xsl:key name="id" match="*" use="@id|@xml:id"/>
93
94 <!-- ==================================================================== -->
95
96 <xsl:template match="*">
97   <xsl:message>
98     <xsl:text>Element </xsl:text>
99     <xsl:value-of select="local-name(.)"/>
100     <xsl:text> in namespace '</xsl:text>
101     <xsl:value-of select="namespace-uri(.)"/>
102     <xsl:text>' encountered</xsl:text>
103     <xsl:if test="parent::*">
104       <xsl:text> in </xsl:text>
105       <xsl:value-of select="name(parent::*)"/>
106     </xsl:if>
107     <xsl:text>, but no template matches.</xsl:text>
108   </xsl:message>
109   
110   <fo:block color="red">
111     <xsl:text>&lt;</xsl:text>
112     <xsl:value-of select="name(.)"/>
113     <xsl:text>&gt;</xsl:text>
114     <xsl:apply-templates/> 
115     <xsl:text>&lt;/</xsl:text>
116     <xsl:value-of select="name(.)"/>
117     <xsl:text>&gt;</xsl:text>
118   </fo:block>
119 </xsl:template>
120
121 <!-- Update this list if new root elements supported -->
122 <xsl:variable name="root.elements" select="' appendix article bibliography book chapter colophon dedication glossary index part preface qandaset refentry reference sect1 section set setindex '"/>
123
124 <xsl:template match="/">
125   <!-- * Get a title for current doc so that we let the user -->
126   <!-- * know what document we are processing at this point. -->
127   <xsl:variable name="doc.title">
128     <xsl:call-template name="get.doc.title"/>
129   </xsl:variable>
130   <xsl:choose>
131     <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
132          toss the namespace and continue.  Use the docbook5 namespaced
133          stylesheets for DocBook5 if you don't want to use this feature.-->
134     <xsl:when test="$exsl.node.set.available != 0
135                     and (*/self::ng:* or */self::db:*)">
136       <xsl:call-template name="log.message">
137         <xsl:with-param name="level">Note</xsl:with-param>
138         <xsl:with-param name="source" select="$doc.title"/>
139         <xsl:with-param name="context-desc">
140           <xsl:text>namesp. cut</xsl:text>
141         </xsl:with-param>
142         <xsl:with-param name="message">
143           <xsl:text>stripped namespace before processing</xsl:text>
144         </xsl:with-param>
145       </xsl:call-template>
146       <xsl:variable name="nons">
147         <xsl:apply-templates mode="stripNS"/>
148       </xsl:variable>
149       <xsl:call-template name="log.message">
150         <xsl:with-param name="level">Note</xsl:with-param>
151         <xsl:with-param name="source" select="$doc.title"/>
152         <xsl:with-param name="context-desc">
153           <xsl:text>namesp. cut</xsl:text>
154         </xsl:with-param>
155         <xsl:with-param name="message">
156           <xsl:text>processing stripped document</xsl:text>
157         </xsl:with-param>
158       </xsl:call-template>
159       <xsl:apply-templates select="exsl:node-set($nons)"/>
160     </xsl:when>
161     <!-- Can't process unless namespace removed -->
162     <xsl:when test="*/self::ng:* or */self::db:*">
163       <xsl:message terminate="yes">
164         <xsl:text>Unable to strip the namespace from DB5 document,</xsl:text>
165         <xsl:text> cannot proceed.</xsl:text>
166       </xsl:message>
167     </xsl:when>
168     <xsl:otherwise>
169       <xsl:choose>
170         <xsl:when test="$rootid != ''">
171           <xsl:variable name="root.element" select="key('id', $rootid)"/>
172           <xsl:choose>
173             <xsl:when test="count($root.element) = 0">
174               <xsl:message terminate="yes">
175                 <xsl:text>ID '</xsl:text>
176                 <xsl:value-of select="$rootid"/>
177                 <xsl:text>' not found in document.</xsl:text>
178               </xsl:message>
179             </xsl:when>
180             <xsl:when test="not(contains($root.elements, concat(' ', local-name($root.element), ' ')))">
181               <xsl:message terminate="yes">
182                 <xsl:text>ERROR: Document root element ($rootid=</xsl:text>
183                 <xsl:value-of select="$rootid"/>
184                 <xsl:text>) for FO output </xsl:text>
185                 <xsl:text>must be one of the following elements:</xsl:text>
186                 <xsl:value-of select="$root.elements"/>
187               </xsl:message>
188             </xsl:when>
189             <!-- Otherwise proceed -->
190             <xsl:otherwise>
191               <xsl:if test="$collect.xref.targets = 'yes' or
192                             $collect.xref.targets = 'only'">
193                 <xsl:apply-templates select="$root.element"
194                                      mode="collect.targets"/>
195               </xsl:if>
196               <xsl:if test="$collect.xref.targets != 'only'">
197                 <xsl:apply-templates select="$root.element"
198                                      mode="process.root"/>
199               </xsl:if>
200             </xsl:otherwise>
201           </xsl:choose>
202         </xsl:when>
203         <!-- Otherwise process the document root element -->
204         <xsl:otherwise>
205           <xsl:variable name="document.element" select="*[1]"/>
206           <xsl:choose>
207             <xsl:when test="not(contains($root.elements,
208                      concat(' ', local-name($document.element), ' ')))">
209               <xsl:message terminate="yes">
210                 <xsl:text>ERROR: Document root element for FO output </xsl:text>
211                 <xsl:text>must be one of the following elements:</xsl:text>
212                 <xsl:value-of select="$root.elements"/>
213               </xsl:message>
214             </xsl:when>
215             <!-- Otherwise proceed -->
216             <xsl:otherwise>
217               <xsl:if test="$collect.xref.targets = 'yes' or
218                             $collect.xref.targets = 'only'">
219                 <xsl:apply-templates select="/"
220                                      mode="collect.targets"/>
221               </xsl:if>
222               <xsl:if test="$collect.xref.targets != 'only'">
223                 <xsl:apply-templates select="/"
224                                      mode="process.root"/>
225               </xsl:if>
226             </xsl:otherwise>
227           </xsl:choose>
228         </xsl:otherwise>
229       </xsl:choose>
230     </xsl:otherwise>
231   </xsl:choose>
232 </xsl:template>
233
234 <xsl:template match="*" mode="process.root">
235   <xsl:variable name="document.element" select="self::*"/>
236
237   <xsl:call-template name="root.messages"/>
238
239   <xsl:variable name="title">
240     <xsl:choose>
241       <xsl:when test="$document.element/title[1]">
242         <xsl:value-of select="$document.element/title[1]"/>
243       </xsl:when>
244       <xsl:otherwise>[could not find document title]</xsl:otherwise>
245     </xsl:choose>
246   </xsl:variable>
247   
248   <!-- Include all id values in XEP output -->
249   <xsl:if test="$xep.extensions != 0">
250     <xsl:processing-instruction 
251      name="xep-pdf-drop-unused-destinations">false</xsl:processing-instruction>
252   </xsl:if>
253
254   <fo:root xsl:use-attribute-sets="root.properties">
255     <xsl:attribute name="language">
256       <xsl:call-template name="l10n.language">
257         <xsl:with-param name="target" select="/*[1]"/>
258       </xsl:call-template>
259     </xsl:attribute>
260
261     <xsl:if test="$xep.extensions != 0">
262       <xsl:call-template name="xep-pis"/>
263       <xsl:call-template name="xep-document-information"/>
264     </xsl:if>
265     <xsl:if test="$axf.extensions != 0">
266       <xsl:call-template name="axf-document-information"/>
267     </xsl:if>
268
269     <xsl:call-template name="setup.pagemasters"/>
270
271     <xsl:if test="$fop.extensions != 0">
272       <xsl:apply-templates select="$document.element" mode="fop.outline"/>
273     </xsl:if>
274
275     <xsl:if test="$fop1.extensions != 0">
276       <xsl:call-template name="fop1-document-information"/>
277       <xsl:variable name="bookmarks">
278         <xsl:apply-templates select="$document.element" 
279                              mode="fop1.outline"/>
280       </xsl:variable>
281       <xsl:if test="string($bookmarks) != ''">
282         <fo:bookmark-tree>
283           <xsl:copy-of select="$bookmarks"/>
284         </fo:bookmark-tree>
285       </xsl:if>
286     </xsl:if>
287
288     <xsl:if test="$xep.extensions != 0">
289       <xsl:variable name="bookmarks">
290         <xsl:apply-templates select="$document.element" mode="xep.outline"/>
291       </xsl:variable>
292       <xsl:if test="string($bookmarks) != ''">
293         <rx:outline xmlns:rx="http://www.renderx.com/XSL/Extensions">
294           <xsl:copy-of select="$bookmarks"/>
295         </rx:outline>
296       </xsl:if>
297     </xsl:if>
298
299     <xsl:if test="$arbortext.extensions != 0 and $ati.xsl11.bookmarks != 0">
300       <xsl:variable name="bookmarks">
301         <xsl:apply-templates select="$document.element"
302                              mode="ati.xsl11.bookmarks"/>
303       </xsl:variable>
304       <xsl:if test="string($bookmarks) != ''">
305         <fo:bookmark-tree>
306           <xsl:copy-of select="$bookmarks"/>
307         </fo:bookmark-tree>
308       </xsl:if>
309     </xsl:if>
310
311     <xsl:apply-templates select="$document.element"/>
312   </fo:root>
313 </xsl:template>
314
315 <xsl:template name="root.messages">
316   <!-- redefine this any way you'd like to output messages -->
317   <!-- DO NOT OUTPUT ANYTHING FROM THIS TEMPLATE -->
318   <xsl:message>
319     <xsl:text>Making </xsl:text>
320     <xsl:value-of select="$page.orientation"/>
321     <xsl:text> pages on </xsl:text>
322     <xsl:value-of select="$paper.type"/>
323     <xsl:text> paper (</xsl:text>
324     <xsl:value-of select="$page.width"/>
325     <xsl:text>x</xsl:text>
326     <xsl:value-of select="$page.height"/>
327     <xsl:text>)</xsl:text>
328   </xsl:message>
329 </xsl:template>
330
331 <!-- ==================================================================== -->
332
333 </xsl:stylesheet>