1 <?xml version="1.0" encoding="US-ASCII"?>
2 <!--This file was created automatically by xsl2profile-->
3 <!--from the DocBook XSL stylesheets.-->
4 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:ng="http://docbook.org/docbook-ng" xmlns:db="http://docbook.org/ns/docbook" xmlns:exslt="http://exslt.org/common" exslt:dummy="dummy" ng:dummy="dummy" db:dummy="dummy" extension-element-prefixes="exslt" exclude-result-prefixes="db ng exsl exslt" version="1.0">
6 <!-- It is important to use indent="no" here, otherwise verbatim -->
7 <!-- environments get broken by indented tags...at least when the -->
8 <!-- callout extension is used...at least with some processors -->
9 <xsl:output method="xml" indent="no"/>
11 <!-- ********************************************************************
12 $Id: docbook.xsl 9988 2015-09-17 20:22:22Z bobstayton $
13 ********************************************************************
15 This file is part of the XSL DocBook Stylesheet distribution.
16 See ../README or http://docbook.sf.net/release/xsl/current/ for
17 copyright and other information.
19 ******************************************************************** -->
21 <!-- ==================================================================== -->
24 <xsl:include href="../VERSION.xsl"/>
25 <xsl:include href="param.xsl"/>
26 <xsl:include href="../lib/lib.xsl"/>
27 <xsl:include href="../common/l10n.xsl"/>
28 <xsl:include href="../common/common.xsl"/>
29 <xsl:include href="../common/utility.xsl"/>
30 <xsl:include href="../common/labels.xsl"/>
31 <xsl:include href="../common/titles.xsl"/>
32 <xsl:include href="../common/subtitles.xsl"/>
33 <xsl:include href="../common/gentext.xsl"/>
34 <xsl:include href="../common/olink.xsl"/>
35 <xsl:include href="../common/targets.xsl"/>
36 <xsl:include href="../common/pi.xsl"/>
37 <xsl:include href="autotoc.xsl"/>
38 <xsl:include href="autoidx.xsl"/>
39 <xsl:include href="lists.xsl"/>
40 <xsl:include href="callout.xsl"/>
41 <xsl:include href="verbatim.xsl"/>
42 <xsl:include href="graphics.xsl"/>
43 <xsl:include href="xref.xsl"/>
44 <xsl:include href="formal.xsl"/>
45 <xsl:include href="table.xsl"/>
46 <xsl:include href="htmltbl.xsl"/>
47 <xsl:include href="sections.xsl"/>
48 <xsl:include href="inline.xsl"/>
49 <xsl:include href="footnote.xsl"/>
50 <xsl:include href="fo.xsl"/>
51 <xsl:include href="fo-rtf.xsl"/>
52 <xsl:include href="info.xsl"/>
53 <xsl:include href="keywords.xsl"/>
54 <xsl:include href="division.xsl"/>
55 <xsl:include href="index.xsl"/>
56 <xsl:include href="toc.xsl"/>
57 <xsl:include href="refentry.xsl"/>
58 <xsl:include href="math.xsl"/>
59 <xsl:include href="admon.xsl"/>
60 <xsl:include href="component.xsl"/>
61 <xsl:include href="biblio.xsl"/>
62 <xsl:include href="biblio-iso690.xsl"/>
63 <xsl:include href="glossary.xsl"/>
64 <xsl:include href="block.xsl"/>
65 <xsl:include href="task.xsl"/>
66 <xsl:include href="qandaset.xsl"/>
67 <xsl:include href="synop.xsl"/>
68 <xsl:include href="titlepage.xsl"/>
69 <xsl:include href="titlepage.templates.xsl"/>
70 <xsl:include href="pagesetup.xsl"/>
71 <xsl:include href="pi.xsl"/>
72 <xsl:include href="spaces.xsl"/>
73 <xsl:include href="ebnf.xsl"/>
74 <xsl:include href="../html/chunker.xsl"/>
75 <xsl:include href="annotations.xsl"/>
76 <xsl:include href="publishers.xsl"/>
77 <xsl:include href="../common/stripns.xsl"/>
79 <xsl:include href="fop.xsl"/>
80 <xsl:include href="fop1.xsl"/>
81 <xsl:include href="xep.xsl"/>
82 <xsl:include href="axf.xsl"/>
83 <xsl:include href="ptc.xsl"/>
85 <xsl:param name="stylesheet.result.type" select="'fo'"/>
87 <!-- ==================================================================== -->
89 <xsl:key name="id" match="*" use="@id|@xml:id"/>
91 <!-- ==================================================================== -->
93 <xsl:template match="*">
95 <xsl:text>Element </xsl:text>
96 <xsl:value-of select="local-name(.)"/>
97 <xsl:text> in namespace '</xsl:text>
98 <xsl:value-of select="namespace-uri(.)"/>
99 <xsl:text>' encountered</xsl:text>
100 <xsl:if test="parent::*">
101 <xsl:text> in </xsl:text>
102 <xsl:value-of select="name(parent::*)"/>
104 <xsl:text>, but no template matches.</xsl:text>
107 <fo:block color="red">
108 <xsl:text><</xsl:text>
109 <xsl:value-of select="name(.)"/>
110 <xsl:text>></xsl:text>
111 <xsl:apply-templates/>
112 <xsl:text></</xsl:text>
113 <xsl:value-of select="name(.)"/>
114 <xsl:text>></xsl:text>
118 <!-- Update this list if new root elements supported -->
119 <xsl:variable name="root.elements" select="' appendix article bibliography book chapter colophon dedication glossary index part preface qandaset refentry reference sect1 section set setindex '"/>
121 <xslo:include xmlns:xslo="http://www.w3.org/1999/XSL/Transform" href="../profiling/profile-mode.xsl"/><xslo:variable xmlns:xslo="http://www.w3.org/1999/XSL/Transform" name="profiled-content"><xslo:choose><xslo:when test="$exsl.node.set.available != 0 and namespace-uri(/*) = 'http://docbook.org/ns/docbook'"><xslo:variable name="no.namespace"><xslo:apply-templates select="/*" mode="stripNS"/></xslo:variable><xslo:call-template name="log.message"><xslo:with-param name="level">Note</xslo:with-param><xslo:with-param name="source"><xslo:call-template name="get.doc.title"/></xslo:with-param><xslo:with-param name="context-desc"><xslo:text>namesp. cut</xslo:text></xslo:with-param><xslo:with-param name="message"><xslo:text>stripped namespace before processing</xslo:text></xslo:with-param></xslo:call-template><xslo:apply-templates select="exslt:node-set($no.namespace)" mode="profile"/></xslo:when><xslo:otherwise><xslo:apply-templates select="/" mode="profile"/></xslo:otherwise></xslo:choose></xslo:variable><xslo:variable xmlns:xslo="http://www.w3.org/1999/XSL/Transform" name="profiled-nodes" select="exslt:node-set($profiled-content)"/><xsl:template match="/">
122 <!-- * Get a title for current doc so that we let the user -->
123 <!-- * know what document we are processing at this point. -->
124 <xsl:variable name="doc.title">
125 <xsl:call-template name="get.doc.title"/>
128 <!-- fix namespace if necessary -->
129 <xsl:when test="false()"/>
130 <!-- Can't process unless namespace fixed with exsl node-set()-->
131 <xsl:when test="false()"/>
134 <xsl:when test="$rootid != ''">
135 <xsl:variable name="root.element" select="key('id', $rootid)"/>
137 <xsl:when test="count($root.element) = 0">
138 <xsl:message terminate="yes">
139 <xsl:text>ID '</xsl:text>
140 <xsl:value-of select="$rootid"/>
141 <xsl:text>' not found in document.</xsl:text>
144 <xsl:when test="not(contains($root.elements, concat(' ', local-name($root.element), ' ')))">
145 <xsl:message terminate="yes">
146 <xsl:text>ERROR: Document root element ($rootid=</xsl:text>
147 <xsl:value-of select="$rootid"/>
148 <xsl:text>) for FO output </xsl:text>
149 <xsl:text>must be one of the following elements:</xsl:text>
150 <xsl:value-of select="$root.elements"/>
153 <!-- Otherwise proceed -->
155 <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'">
156 <xsl:apply-templates select="$root.element" mode="collect.targets"/>
158 <xsl:if test="$collect.xref.targets != 'only'">
159 <xsl:apply-templates select="$root.element" mode="process.root"/>
164 <!-- Otherwise process the document root element -->
166 <xsl:variable name="document.element" select="*[1]"/>
168 <xsl:when test="not(contains($root.elements, concat(' ', local-name($document.element), ' ')))">
169 <xsl:message terminate="yes">
170 <xsl:text>ERROR: Document root element for FO output </xsl:text>
171 <xsl:text>must be one of the following elements:</xsl:text>
172 <xsl:value-of select="$root.elements"/>
175 <!-- Otherwise proceed -->
177 <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'">
178 <xsl:apply-templates select="$profiled-nodes" mode="collect.targets"/>
180 <xsl:if test="$collect.xref.targets != 'only'">
181 <xsl:apply-templates select="$profiled-nodes" mode="process.root"/>
191 <xsl:template match="*" mode="process.root">
192 <xsl:variable name="document.element" select="self::*"/>
194 <xsl:call-template name="root.messages"/>
196 <xsl:variable name="title">
198 <xsl:when test="$document.element/title | $document.element/info/title">
199 <xsl:value-of select="($document.element/title | $document.element/info/title)[1]"/>
201 <xsl:otherwise>[could not find document title]</xsl:otherwise>
205 <!-- Include all id values in XEP output -->
206 <xsl:if test="$xep.extensions != 0">
207 <xsl:processing-instruction name="xep-pdf-drop-unused-destinations">false</xsl:processing-instruction>
210 <fo:root xsl:use-attribute-sets="root.properties">
211 <xsl:attribute name="language">
212 <xsl:call-template name="l10n.language">
213 <xsl:with-param name="target" select="/*[1]"/>
217 <xsl:if test="$xep.extensions != 0">
218 <xsl:call-template name="xep-pis"/>
219 <xsl:call-template name="xep-document-information"/>
221 <xsl:if test="$axf.extensions != 0">
222 <xsl:call-template name="axf-document-information"/>
225 <xsl:call-template name="setup.pagemasters"/>
227 <xsl:if test="$fop1.extensions != 0">
228 <xsl:call-template name="fop1-document-information"/>
229 <xsl:apply-templates select="$document.element" mode="fop1.foxdest"/>
232 <!-- generate bookmark tree -->
233 <xsl:call-template name="generate.bookmarks"/>
235 <xsl:apply-templates select="$document.element"/>
239 <xsl:template name="generate.bookmarks">
240 <xsl:variable name="document.element" select="self::*"/>
242 <xsl:when test="$show.bookmarks = 0">
243 <!-- omit bookmarks -->
245 <xsl:when test="$xsl1.1.bookmarks != 0">
246 <!-- use standard bookmark elements -->
247 <xsl:variable name="bookmarks">
248 <xsl:apply-templates select="$document.element" mode="bookmark"/>
250 <xsl:if test="string($bookmarks) != ''">
252 <xsl:copy-of select="$bookmarks"/>
259 <xsl:when test="$fop.extensions != 0">
260 <xsl:apply-templates select="$document.element" mode="fop.outline"/>
264 <xsl:when test="$fop1.extensions != 0">
265 <xsl:variable name="bookmarks">
266 <xsl:apply-templates select="$document.element" mode="fop1.outline"/>
268 <xsl:if test="string($bookmarks) != ''">
270 <xsl:copy-of select="$bookmarks"/>
275 <!-- RenderX XEP 4.6 and earlier -->
276 <xsl:when test="$xep.extensions != 0">
277 <xsl:variable name="bookmarks">
278 <xsl:apply-templates select="$document.element" mode="xep.outline"/>
280 <xsl:if test="string($bookmarks) != ''">
281 <rx:outline xmlns:rx="http://www.renderx.com/XSL/Extensions">
282 <xsl:copy-of select="$bookmarks"/>
287 <!-- PTC Arbortext -->
288 <xsl:when test="$arbortext.extensions != 0">
289 <xsl:variable name="bookmarks">
290 <xsl:apply-templates select="$document.element" mode="ati.xsl11.bookmarks"/>
292 <xsl:if test="string($bookmarks) != ''">
294 <xsl:copy-of select="$bookmarks"/>
303 <xsl:variable name="bookmarks.state">
305 <xsl:when test="$bookmarks.collapse != 0">hide</xsl:when>
306 <xsl:otherwise>show</xsl:otherwise>
310 <xsl:template match="*" mode="bookmark">
311 <xsl:apply-templates select="*" mode="bookmark"/>
314 <xsl:template match="set|book|part|reference| preface|chapter|appendix|article|topic |glossary|bibliography|index|setindex |refentry |sect1|sect2|sect3|sect4|sect5|section" mode="bookmark">
316 <xsl:variable name="id">
317 <xsl:call-template name="object.id"/>
319 <xsl:variable name="bookmark-label">
320 <xsl:apply-templates select="." mode="object.title.markup"/>
323 <!-- Put the root element bookmark at the same level as its children -->
324 <!-- If the object is a set or book, generate a bookmark for the toc -->
327 <xsl:when test="self::index and $generate.index = 0"/>
328 <xsl:when test="parent::*">
329 <fo:bookmark internal-destination="{$id}">
330 <xsl:attribute name="starting-state">
331 <xsl:value-of select="$bookmarks.state"/>
334 <xsl:value-of select="normalize-space($bookmark-label)"/>
336 <xsl:apply-templates select="*" mode="bookmark"/>
340 <fo:bookmark internal-destination="{$id}">
341 <xsl:attribute name="starting-state">
342 <xsl:value-of select="$bookmarks.state"/>
345 <xsl:value-of select="normalize-space($bookmark-label)"/>
349 <xsl:variable name="toc.params">
350 <xsl:call-template name="find.path.params">
351 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
355 <xsl:if test="contains($toc.params, 'toc') and (book|part|reference|preface|chapter|appendix|article|topic |glossary|bibliography|index|setindex |refentry |sect1|sect2|sect3|sect4|sect5|section)">
356 <fo:bookmark internal-destination="toc...{$id}">
358 <xsl:call-template name="gentext">
359 <xsl:with-param name="key" select="'TableofContents'"/>
364 <xsl:apply-templates select="*" mode="bookmark"/>
369 <xsl:template name="root.messages">
370 <!-- redefine this any way you'd like to output messages -->
371 <!-- DO NOT OUTPUT ANYTHING FROM THIS TEMPLATE -->
373 <xsl:text>Making </xsl:text>
374 <xsl:value-of select="$page.orientation"/>
375 <xsl:text> pages on </xsl:text>
376 <xsl:value-of select="$paper.type"/>
377 <xsl:text> paper (</xsl:text>
378 <xsl:value-of select="$page.width"/>
379 <xsl:text>x</xsl:text>
380 <xsl:value-of select="$page.height"/>
381 <xsl:text>)</xsl:text>
385 <!-- ==================================================================== -->