source: stylesheets/lfs-xsl/common.xsl@ cb02946

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 7.2 7.3 7.4 7.5 7.5-systemd 7.6 7.6-systemd 7.7 7.7-systemd 7.8 7.8-systemd 7.9 7.9-systemd 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since cb02946 was cb02946, checked in by Bruce Dubbs <bdubbs@…>, 12 years ago

Lots of spelling fixes.
Delete the no longer used lsb-bootscripts directory

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@9967 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 18.4 KB
Line 
1<?xml version='1.0' encoding='ISO-8859-1'?>
2
3<!--
4$LastChangedBy$
5$Date$
6-->
7
8<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
9 xmlns="http://www.w3.org/1999/xhtml"
10 version="1.0">
11
12 <!-- This stylesheet contains common params and templates for all outputs. -->
13
14 <!-- This file contains our localization strings (for internationalization) -->
15 <xsl:param name="local.l10n.xml" select="document('lfs-l10n.xml')"/>
16
17
18<!-- INDEX -->
19
20 <!-- Should the Index be generated? 1 = yes, 0 = no -->
21 <xsl:param name="generate.index" select="1"></xsl:param>
22
23 <!-- The indexing method used. Only 'basic' is supported by xsltproc -->
24 <xsl:param name="index.method" select="'basic'"></xsl:param>
25
26 <!-- The Index title:
27 We create this param to can have gentext support in both
28 the Index page title and links that point to the Index page.
29 It also allow us to change the title, if wanted.
30 Note: To change the title involves creating the appropriate
31 entries in lfs-l10n.xml -->
32 <xsl:param name="index-title">Index</xsl:param>
33
34 <!-- Index title generation. -->
35 <!-- The original template is in {docbook-xsl}/common/titles.xsl -->
36 <xsl:template match="index" mode="title.markup">
37 <xsl:param name="allow-anchors" select="0"/>
38 <xsl:call-template name="gentext">
39 <xsl:with-param name="key" select="$index-title"/>
40 </xsl:call-template>
41 </xsl:template>
42
43 <!-- indexterm:
44 Dropping unneeded anchors and fo:wraper elemments. -->
45 <!-- The original templates are in {docbook-xsl}/{xhtml,fo}/index.xsl -->
46 <xsl:template match="indexterm"/>
47
48<!-- -->
49
50<!-- LABELS -->
51
52 <!-- Are sections enumerated? 1 = yes, 0 = no -->
53 <xsl:param name="section.autolabel" select="1"/>
54
55 <!-- Do section labels include the component label? 1 = yes, 0 = no -->
56 <xsl:param name="section.label.includes.component.label" select="1"/>
57
58 <!-- sect1 label.markup:
59 Use lowercase roman numbers for sect1 in preface. -->
60 <!-- The original template is in {docbook-xsl}/common/labels.xsl -->
61 <xsl:template match="sect1" mode="label.markup">
62 <!-- if the parent is a component, maybe label that too -->
63 <xsl:variable name="parent.is.component">
64 <xsl:call-template name="is.component">
65 <xsl:with-param name="node" select=".."/>
66 </xsl:call-template>
67 </xsl:variable>
68 <xsl:variable name="component.label">
69 <xsl:if test="$section.label.includes.component.label != 0
70 and $parent.is.component != 0">
71 <xsl:variable name="parent.label">
72 <xsl:apply-templates select=".." mode="label.markup"/>
73 </xsl:variable>
74 <xsl:if test="$parent.label != ''">
75 <xsl:apply-templates select=".." mode="label.markup"/>
76 <xsl:apply-templates select=".." mode="intralabel.punctuation"/>
77 </xsl:if>
78 </xsl:if>
79 </xsl:variable>
80 <xsl:choose>
81 <xsl:when test="@label">
82 <xsl:value-of select="@label"/>
83 </xsl:when>
84 <xsl:when test="$section.autolabel != 0">
85 <xsl:copy-of select="$component.label"/>
86 <xsl:choose>
87 <xsl:when test="ancestor::preface">
88 <xsl:number format="i" count="sect1"/>
89 </xsl:when>
90 <xsl:otherwise>
91 <xsl:number format="1" count="sect1"/>
92 </xsl:otherwise>
93 </xsl:choose>
94 </xsl:when>
95 </xsl:choose>
96 </xsl:template>
97
98 <!-- sect2 label.markup:
99 Skip numeration for sect2 with empty title. -->
100 <!-- The original template is in {docbook-xsl}/common/labels.xsl
101 It match also sect3, sect4, and sect5, that are unchanged. -->
102 <xsl:template match="sect2" mode="label.markup">
103 <!-- label the parent -->
104 <xsl:variable name="parent.section.label">
105 <xsl:call-template name="label.this.section">
106 <xsl:with-param name="section" select=".."/>
107 </xsl:call-template>
108 </xsl:variable>
109 <xsl:if test="$parent.section.label != '0'">
110 <xsl:apply-templates select=".." mode="label.markup"/>
111 <xsl:apply-templates select=".." mode="intralabel.punctuation"/>
112 </xsl:if>
113 <xsl:choose>
114 <xsl:when test="@label">
115 <xsl:value-of select="@label"/>
116 </xsl:when>
117 <xsl:when test="$section.autolabel != 0">
118 <xsl:choose>
119 <!-- If the first sect2 isn't numbered, renumber the remainig sections -->
120 <xsl:when test="string-length(../sect2[1]/title) = 0">
121 <xsl:variable name="totalsect2">
122 <xsl:number count="sect2"/>
123 </xsl:variable>
124 <xsl:number value="$totalsect2 - 1"/>
125 </xsl:when>
126 <xsl:otherwise>
127 <xsl:number count="sect2"/>
128 </xsl:otherwise>
129 </xsl:choose>
130 </xsl:when>
131 </xsl:choose>
132 </xsl:template>
133
134 <!-- object.title.template:
135 Skip numeration for sectX > sect1 in preface. -->
136 <!-- The original template is in {docbook-xsl}/common/gentext.xsl. -->
137 <xsl:template match="section|sect1|sect2|sect3|sect4|sect5|simplesect|bridgehead"
138 mode="object.title.template">
139 <xsl:variable name="is.numbered">
140 <xsl:call-template name="label.this.section"/>
141 </xsl:variable>
142 <xsl:choose>
143 <xsl:when test="$is.numbered != 0 and not(ancestor::preface/sect1)">
144 <xsl:call-template name="gentext.template">
145 <xsl:with-param name="context" select="'title-numbered'"/>
146 <xsl:with-param name="name">
147 <xsl:call-template name="xpath.location"/>
148 </xsl:with-param>
149 </xsl:call-template>
150 </xsl:when>
151 <xsl:otherwise>
152 <xsl:call-template name="gentext.template">
153 <xsl:with-param name="context" select="'title-unnumbered'"/>
154 <xsl:with-param name="name">
155 <xsl:call-template name="xpath.location"/>
156 </xsl:with-param>
157 </xsl:call-template>
158 </xsl:otherwise>
159 </xsl:choose>
160 </xsl:template>
161
162<!-- -->
163
164<!-- XREF (see {xhtml,pdf}/xref.xsl) -->
165
166 <!-- mode object.xref.markup:
167 Propagate role to named template substitute-markup -->
168 <!-- The original template is in {docbook-xsl}/common/gentext.xsl -->
169 <xsl:template match="*" mode="object.xref.markup">
170 <xsl:param name="purpose"/>
171 <xsl:param name="xrefstyle"/>
172 <xsl:param name="referrer"/>
173 <xsl:param name="verbose" select="1"/>
174 <xsl:param name="role"/>
175 <xsl:variable name="template">
176 <xsl:choose>
177 <xsl:when test="starts-with(normalize-space($xrefstyle), 'select:')">
178 <xsl:call-template name="make.gentext.template">
179 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
180 <xsl:with-param name="purpose" select="$purpose"/>
181 <xsl:with-param name="referrer" select="$referrer"/>
182 </xsl:call-template>
183 </xsl:when>
184 <xsl:when test="starts-with(normalize-space($xrefstyle), 'template:')">
185 <xsl:value-of select="substring-after(normalize-space($xrefstyle), 'template:')"/>
186 </xsl:when>
187 <xsl:otherwise>
188 <xsl:apply-templates select="." mode="object.xref.template">
189 <xsl:with-param name="purpose" select="$purpose"/>
190 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
191 <xsl:with-param name="referrer" select="$referrer"/>
192 </xsl:apply-templates>
193 </xsl:otherwise>
194 </xsl:choose>
195 </xsl:variable>
196 <xsl:if test="$template = '' and $verbose != 0">
197 <xsl:message>
198 <xsl:text>object.xref.markup: empty xref template</xsl:text>
199 <xsl:text> for linkend="</xsl:text>
200 <xsl:value-of select="@id|@xml:id"/>
201 <xsl:text>" and @xrefstyle="</xsl:text>
202 <xsl:value-of select="$xrefstyle"/>
203 <xsl:text>"</xsl:text>
204 </xsl:message>
205 </xsl:if>
206 <xsl:call-template name="substitute-markup">
207 <xsl:with-param name="purpose" select="$purpose"/>
208 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
209 <xsl:with-param name="referrer" select="$referrer"/>
210 <xsl:with-param name="template" select="$template"/>
211 <xsl:with-param name="verbose" select="$verbose"/>
212 <xsl:with-param name="role" select="$role"/>
213 </xsl:call-template>
214 </xsl:template>
215
216 <!-- substitute-markup:
217 Propagate role to mode insert.title.markup -->
218 <!-- The original template is in {docbook-xsl}/common/gentext.xsl -->
219 <xsl:template name="substitute-markup">
220 <xsl:param name="template" select="''"/>
221 <xsl:param name="allow-anchors" select="'0'"/>
222 <xsl:param name="title" select="''"/>
223 <xsl:param name="subtitle" select="''"/>
224 <xsl:param name="docname" select="''"/>
225 <xsl:param name="label" select="''"/>
226 <xsl:param name="pagenumber" select="''"/>
227 <xsl:param name="purpose"/>
228 <xsl:param name="xrefstyle"/>
229 <xsl:param name="referrer"/>
230 <xsl:param name="verbose"/>
231 <xsl:param name="role"/>
232 <xsl:choose>
233 <xsl:when test="contains($template, '%')">
234 <xsl:value-of select="substring-before($template, '%')"/>
235 <xsl:variable name="candidate"
236 select="substring(substring-after($template, '%'), 1, 1)"/>
237 <xsl:choose>
238 <xsl:when test="$candidate = 't'">
239 <xsl:apply-templates select="." mode="insert.title.markup">
240 <xsl:with-param name="purpose" select="$purpose"/>
241 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
242 <xsl:with-param name="role" select="$role"/>
243 <xsl:with-param name="title">
244 <xsl:choose>
245 <xsl:when test="$title != ''">
246 <xsl:copy-of select="$title"/>
247 </xsl:when>
248 <xsl:otherwise>
249 <xsl:apply-templates select="." mode="title.markup">
250 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
251 <xsl:with-param name="verbose" select="$verbose"/>
252 </xsl:apply-templates>
253 </xsl:otherwise>
254 </xsl:choose>
255 </xsl:with-param>
256 </xsl:apply-templates>
257 </xsl:when>
258 <xsl:when test="$candidate = 's'">
259 <xsl:apply-templates select="." mode="insert.subtitle.markup">
260 <xsl:with-param name="purpose" select="$purpose"/>
261 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
262 <xsl:with-param name="subtitle">
263 <xsl:choose>
264 <xsl:when test="$subtitle != ''">
265 <xsl:copy-of select="$subtitle"/>
266 </xsl:when>
267 <xsl:otherwise>
268 <xsl:apply-templates select="." mode="subtitle.markup">
269 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
270 </xsl:apply-templates>
271 </xsl:otherwise>
272 </xsl:choose>
273 </xsl:with-param>
274 </xsl:apply-templates>
275 </xsl:when>
276 <xsl:when test="$candidate = 'n'">
277 <xsl:apply-templates select="." mode="insert.label.markup">
278 <xsl:with-param name="purpose" select="$purpose"/>
279 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
280 <xsl:with-param name="label">
281 <xsl:choose>
282 <xsl:when test="$label != ''">
283 <xsl:copy-of select="$label"/>
284 </xsl:when>
285 <xsl:otherwise>
286 <xsl:apply-templates select="." mode="label.markup"/>
287 </xsl:otherwise>
288 </xsl:choose>
289 </xsl:with-param>
290 </xsl:apply-templates>
291 </xsl:when>
292 <xsl:when test="$candidate = 'p'">
293 <xsl:apply-templates select="." mode="insert.pagenumber.markup">
294 <xsl:with-param name="purpose" select="$purpose"/>
295 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
296 <xsl:with-param name="pagenumber">
297 <xsl:choose>
298 <xsl:when test="$pagenumber != ''">
299 <xsl:copy-of select="$pagenumber"/>
300 </xsl:when>
301 <xsl:otherwise>
302 <xsl:apply-templates select="." mode="pagenumber.markup"/>
303 </xsl:otherwise>
304 </xsl:choose>
305 </xsl:with-param>
306 </xsl:apply-templates>
307 </xsl:when>
308 <xsl:when test="$candidate = 'o'">
309 <!-- olink target document title -->
310 <xsl:apply-templates select="." mode="insert.olink.docname.markup">
311 <xsl:with-param name="purpose" select="$purpose"/>
312 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
313 <xsl:with-param name="docname">
314 <xsl:choose>
315 <xsl:when test="$docname != ''">
316 <xsl:copy-of select="$docname"/>
317 </xsl:when>
318 <xsl:otherwise>
319 <xsl:apply-templates select="." mode="olink.docname.markup"/>
320 </xsl:otherwise>
321 </xsl:choose>
322 </xsl:with-param>
323 </xsl:apply-templates>
324 </xsl:when>
325 <xsl:when test="$candidate = 'd'">
326 <xsl:apply-templates select="." mode="insert.direction.markup">
327 <xsl:with-param name="purpose" select="$purpose"/>
328 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
329 <xsl:with-param name="direction">
330 <xsl:choose>
331 <xsl:when test="$referrer">
332 <xsl:variable name="referent-is-below">
333 <xsl:for-each select="preceding::xref">
334 <xsl:if test="generate-id(.) = generate-id($referrer)">1</xsl:if>
335 </xsl:for-each>
336 </xsl:variable>
337 <xsl:choose>
338 <xsl:when test="$referent-is-below = ''">
339 <xsl:call-template name="gentext">
340 <xsl:with-param name="key" select="'above'"/>
341 </xsl:call-template>
342 </xsl:when>
343 <xsl:otherwise>
344 <xsl:call-template name="gentext">
345 <xsl:with-param name="key" select="'below'"/>
346 </xsl:call-template>
347 </xsl:otherwise>
348 </xsl:choose>
349 </xsl:when>
350 <xsl:otherwise>
351 <xsl:message>Attempt to use %d in gentext with no referrer!</xsl:message>
352 </xsl:otherwise>
353 </xsl:choose>
354 </xsl:with-param>
355 </xsl:apply-templates>
356 </xsl:when>
357 <xsl:when test="$candidate = '%' ">
358 <xsl:text>%</xsl:text>
359 </xsl:when>
360 <xsl:otherwise>
361 <xsl:text>%</xsl:text><xsl:value-of select="$candidate"/>
362 </xsl:otherwise>
363 </xsl:choose>
364 <!-- recurse with the rest of the template string -->
365 <xsl:variable name="rest"
366 select="substring($template,
367 string-length(substring-before($template, '%'))+3)"/>
368 <xsl:call-template name="substitute-markup">
369 <xsl:with-param name="template" select="$rest"/>
370 <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
371 <xsl:with-param name="title" select="$title"/>
372 <xsl:with-param name="subtitle" select="$subtitle"/>
373 <xsl:with-param name="docname" select="$docname"/>
374 <xsl:with-param name="label" select="$label"/>
375 <xsl:with-param name="pagenumber" select="$pagenumber"/>
376 <xsl:with-param name="purpose" select="$purpose"/>
377 <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
378 <xsl:with-param name="referrer" select="$referrer"/>
379 <xsl:with-param name="verbose" select="$verbose"/>
380 <xsl:with-param name="role" select="$role"/>
381 </xsl:call-template>
382 </xsl:when>
383 <xsl:otherwise>
384 <xsl:value-of select="$template"/>
385 </xsl:otherwise>
386 </xsl:choose>
387 </xsl:template>
388
389<!-- -->
390
391<!-- Total packages size calculation -->
392
393 <!-- returnvalue:
394 If the tag is not empty, apply the original template.
395 Otherwise apply the calculation template. -->
396 <xsl:template match="returnvalue">
397 <xsl:choose>
398 <xsl:when test="count(*)&gt;0">
399 <xsl:apply-imports/>
400 </xsl:when>
401 <xsl:otherwise>
402 <xsl:call-template name="calculation">
403 <xsl:with-param name="scope" select="../../variablelist"/>
404 </xsl:call-template>
405 </xsl:otherwise>
406 </xsl:choose>
407 </xsl:template>
408
409 <!-- Self-made calculation template. -->
410 <xsl:template name="calculation">
411 <xsl:param name="scope"/>
412 <xsl:param name="total">0</xsl:param>
413 <xsl:param name="position">1</xsl:param>
414 <xsl:variable name="tokens" select="count($scope/varlistentry)"/>
415 <xsl:variable name="token" select="$scope/varlistentry[$position]/term/token"/>
416 <xsl:variable name="size" select="substring-before($token,' KB')"/>
417 <xsl:variable name="rawsize">
418 <xsl:choose>
419 <xsl:when test="contains($size,',')">
420 <xsl:value-of select="concat(substring-before($size,','),substring-after($size,','))"/>
421 </xsl:when>
422 <xsl:otherwise>
423 <xsl:value-of select="$size"/>
424 </xsl:otherwise>
425 </xsl:choose>
426 </xsl:variable>
427 <xsl:choose>
428 <xsl:when test="$position &lt;= $tokens">
429 <xsl:call-template name="calculation">
430 <xsl:with-param name="scope" select="$scope"/>
431 <xsl:with-param name="position" select="$position +1"/>
432 <xsl:with-param name="total" select="$total + $rawsize"/>
433 </xsl:call-template>
434 </xsl:when>
435 <xsl:otherwise>
436 <xsl:choose>
437 <xsl:when test="$total &lt; '1000'">
438 <xsl:value-of select="$total"/>
439 <xsl:text> KB</xsl:text>
440 </xsl:when>
441 <xsl:when test="$total &gt; '1000' and $total &lt; '5000'">
442 <xsl:value-of select="substring($total,1,1)"/>
443 <xsl:text>,</xsl:text>
444 <xsl:value-of select="substring($total,2)"/>
445 <xsl:text> KB</xsl:text>
446 </xsl:when>
447 <xsl:otherwise>
448 <xsl:value-of select="round($total div 1024)"/>
449 <xsl:text> MB</xsl:text>
450 </xsl:otherwise>
451 </xsl:choose>
452 </xsl:otherwise>
453 </xsl:choose>
454 </xsl:template>
455
456<!-- -->
457
458</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.