source: BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/fo/toc.xsl@ 6ecafc9

clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 6ecafc9 was f8c4e94, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added LFS XSL Stylesheets.

  • Property mode set to 100644
File size: 10.6 KB
Line 
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 version='1.0'>
5
6<!-- ********************************************************************
7 $Id$
8 ********************************************************************
9
10 This file is part of the XSL DocBook Stylesheet distribution.
11 See ../README or http://docbook.sf.net/release/xsl/current/ for
12 copyright and other information.
13
14 ******************************************************************** -->
15
16<!-- ==================================================================== -->
17
18<!-- FIXME: in the contexts where <toc> can occur, I think it's always
19 the case that a page-sequence is required. Is that true? -->
20
21<xsl:template match="toc">
22 <xsl:variable name="master-reference">
23 <xsl:call-template name="select.pagemaster"/>
24 </xsl:variable>
25
26 <xsl:choose>
27 <xsl:when test="*">
28 <xsl:if test="$process.source.toc != 0">
29 <!-- if the toc isn't empty, process it -->
30 <fo:page-sequence hyphenate="{$hyphenate}"
31 master-reference="{$master-reference}">
32 <xsl:attribute name="language">
33 <xsl:call-template name="l10n.language"/>
34 </xsl:attribute>
35 <xsl:attribute name="format">
36 <xsl:call-template name="page.number.format">
37 <xsl:with-param name="element" select="'toc'"/>
38 <xsl:with-param name="master-reference"
39 select="$master-reference"/>
40 </xsl:call-template>
41 </xsl:attribute>
42
43 <xsl:attribute name="initial-page-number">
44 <xsl:call-template name="initial.page.number">
45 <xsl:with-param name="element" select="'toc'"/>
46 <xsl:with-param name="master-reference"
47 select="$master-reference"/>
48 </xsl:call-template>
49 </xsl:attribute>
50
51 <xsl:attribute name="force-page-count">
52 <xsl:call-template name="force.page.count">
53 <xsl:with-param name="master-reference"
54 select="$master-reference"/>
55 </xsl:call-template>
56 </xsl:attribute>
57
58 <xsl:attribute name="hyphenation-character">
59 <xsl:call-template name="gentext">
60 <xsl:with-param name="key" select="'hyphenation-character'"/>
61 </xsl:call-template>
62 </xsl:attribute>
63 <xsl:attribute name="hyphenation-push-character-count">
64 <xsl:call-template name="gentext">
65 <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
66 </xsl:call-template>
67 </xsl:attribute>
68 <xsl:attribute name="hyphenation-remain-character-count">
69 <xsl:call-template name="gentext">
70 <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
71 </xsl:call-template>
72 </xsl:attribute>
73
74 <xsl:apply-templates select="." mode="running.head.mode">
75 <xsl:with-param name="master-reference" select="$master-reference"/>
76 </xsl:apply-templates>
77 <xsl:apply-templates select="." mode="running.foot.mode">
78 <xsl:with-param name="master-reference" select="$master-reference"/>
79 </xsl:apply-templates>
80
81 <fo:flow flow-name="xsl-region-body">
82 <xsl:call-template name="set.flow.properties">
83 <xsl:with-param name="element" select="local-name(.)"/>
84 <xsl:with-param name="master-reference"
85 select="$master-reference"/>
86 </xsl:call-template>
87
88 <fo:block xsl:use-attribute-sets="toc.margin.properties">
89 <xsl:call-template name="table.of.contents.titlepage"/>
90 <xsl:apply-templates/>
91 </fo:block>
92 </fo:flow>
93 </fo:page-sequence>
94 </xsl:if>
95 </xsl:when>
96 <xsl:otherwise>
97 <xsl:if test="$process.empty.source.toc != 0">
98 <fo:page-sequence hyphenate="{$hyphenate}"
99 master-reference="{$master-reference}">
100 <xsl:attribute name="language">
101 <xsl:call-template name="l10n.language"/>
102 </xsl:attribute>
103 <xsl:attribute name="format">
104 <xsl:call-template name="page.number.format">
105 <xsl:with-param name="element" select="'toc'"/>
106 <xsl:with-param name="master-reference"
107 select="$master-reference"/>
108 </xsl:call-template>
109 </xsl:attribute>
110
111 <xsl:attribute name="initial-page-number">
112 <xsl:call-template name="initial.page.number">
113 <xsl:with-param name="element" select="'toc'"/>
114 <xsl:with-param name="master-reference"
115 select="$master-reference"/>
116 </xsl:call-template>
117 </xsl:attribute>
118
119 <xsl:attribute name="hyphenation-character">
120 <xsl:call-template name="gentext">
121 <xsl:with-param name="key" select="'hyphenation-character'"/>
122 </xsl:call-template>
123 </xsl:attribute>
124 <xsl:attribute name="hyphenation-push-character-count">
125 <xsl:call-template name="gentext">
126 <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
127 </xsl:call-template>
128 </xsl:attribute>
129 <xsl:attribute name="hyphenation-remain-character-count">
130 <xsl:call-template name="gentext">
131 <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
132 </xsl:call-template>
133 </xsl:attribute>
134
135 <xsl:apply-templates select="." mode="running.head.mode">
136 <xsl:with-param name="master-reference" select="$master-reference"/>
137 </xsl:apply-templates>
138 <xsl:apply-templates select="." mode="running.foot.mode">
139 <xsl:with-param name="master-reference" select="$master-reference"/>
140 </xsl:apply-templates>
141
142 <fo:flow flow-name="xsl-region-body">
143 <xsl:choose>
144 <xsl:when test="parent::section
145 or parent::sect1
146 or parent::sect2
147 or parent::sect3
148 or parent::sect4
149 or parent::sect5">
150 <xsl:apply-templates select="parent::*"
151 mode="toc.for.section"/>
152 </xsl:when>
153 <xsl:when test="parent::article">
154 <xsl:apply-templates select="parent::*"
155 mode="toc.for.component"/>
156 </xsl:when>
157 <xsl:when test="parent::book
158 or parent::part">
159 <xsl:apply-templates select="parent::*"
160 mode="toc.for.division"/>
161 </xsl:when>
162 <xsl:when test="parent::set">
163 <xsl:apply-templates select="parent::*"
164 mode="toc.for.set"/>
165 </xsl:when>
166 <!-- there aren't any other contexts that allow toc -->
167 <xsl:otherwise>
168 <xsl:message>
169 <xsl:text>I don't know how to make a TOC in this context!</xsl:text>
170 </xsl:message>
171 </xsl:otherwise>
172 </xsl:choose>
173 </fo:flow>
174 </fo:page-sequence>
175 </xsl:if>
176 </xsl:otherwise>
177 </xsl:choose>
178</xsl:template>
179
180<xsl:template match="tocpart|tocchap
181 |toclevel1|toclevel2|toclevel3|toclevel4|toclevel5">
182 <xsl:apply-templates select="tocentry"/>
183 <xsl:if test="tocchap|toclevel1|toclevel2|toclevel3|toclevel4|toclevel5">
184 <fo:block start-indent="{count(ancestor::*)*2}pc">
185 <xsl:apply-templates select="tocchap|toclevel1|toclevel2|toclevel3|toclevel4|toclevel5"/>
186 </fo:block>
187 </xsl:if>
188</xsl:template>
189
190<xsl:template match="tocentry|tocfront|tocback">
191 <fo:block text-align-last="justify"
192 end-indent="2pc"
193 last-line-end-indent="-2pc">
194 <fo:inline keep-with-next.within-line="always">
195 <xsl:choose>
196 <xsl:when test="@linkend">
197 <fo:basic-link internal-destination="{@linkend}">
198 <xsl:apply-templates/>
199 </fo:basic-link>
200 </xsl:when>
201 <xsl:otherwise>
202 <xsl:apply-templates/>
203 </xsl:otherwise>
204 </xsl:choose>
205 </fo:inline>
206
207 <xsl:choose>
208 <xsl:when test="@linkend">
209 <fo:inline keep-together.within-line="always">
210 <xsl:text> </xsl:text>
211 <fo:leader leader-pattern="dots"
212 keep-with-next.within-line="always"/>
213 <xsl:text> </xsl:text>
214 <fo:basic-link internal-destination="{@linkend}">
215 <xsl:choose>
216 <xsl:when test="@pagenum">
217 <xsl:value-of select="@pagenum"/>
218 </xsl:when>
219 <xsl:otherwise>
220 <fo:page-number-citation ref-id="{@linkend}"/>
221 </xsl:otherwise>
222 </xsl:choose>
223 </fo:basic-link>
224 </fo:inline>
225 </xsl:when>
226 <xsl:when test="@pagenum">
227 <fo:inline keep-together.within-line="always">
228 <xsl:text> </xsl:text>
229 <fo:leader leader-pattern="dots"
230 keep-with-next.within-line="always"/>
231 <xsl:text> </xsl:text>
232 <xsl:value-of select="@pagenum"/>
233 </fo:inline>
234 </xsl:when>
235 <xsl:otherwise>
236 <!-- just the leaders, what else can I do? -->
237 <fo:inline keep-together.within-line="always">
238 <xsl:text> </xsl:text>
239 <fo:leader leader-pattern="space"
240 keep-with-next.within-line="always"/>
241 </fo:inline>
242 </xsl:otherwise>
243 </xsl:choose>
244 </fo:block>
245</xsl:template>
246
247<!-- ==================================================================== -->
248
249<xsl:template match="*" mode="toc.for.section">
250<!--
251 <xsl:call-template name="section.toc"/>
252-->
253</xsl:template>
254
255<xsl:template match="*" mode="toc.for.component">
256 <xsl:call-template name="component.toc"/>
257</xsl:template>
258
259<xsl:template match="*" mode="toc.for.section">
260<!--
261 <xsl:call-template name="section.toc"/>
262-->
263</xsl:template>
264
265<xsl:template match="*" mode="toc.for.division">
266 <xsl:call-template name="division.toc"/>
267</xsl:template>
268
269<xsl:template match="*" mode="toc.for.set">
270<!--
271 <xsl:call-template name="set.toc"/>
272-->
273</xsl:template>
274
275<!-- ==================================================================== -->
276
277<xsl:template match="lot|lotentry">
278</xsl:template>
279
280</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.