source: BLFS/xsl/make_book.xsl@ 90bfcb92

2.4
Last change on this file since 90bfcb92 was 56178ba, checked in by Pierre Labastie <pierre@…>, 8 years ago

Add a few forgotten keywords properties

  • Property mode set to 100644
File size: 19.5 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2
3<!-- $Id$ -->
4
5<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
6 version="1.0">
7
8 <xsl:param name="list" select="''"/>
9 <xsl:param name="MTA" select="'sendmail'"/>
10
11<!-- Check whether the book is sysv or systemd -->
12 <xsl:variable name="rev">
13 <xsl:choose>
14 <xsl:when test="//bookinfo/title/phrase[@revision='systemd']">
15 <xsl:text>systemd</xsl:text>
16 </xsl:when>
17 <xsl:otherwise>
18 <xsl:text>sysv</xsl:text>
19 </xsl:otherwise>
20 </xsl:choose>
21 </xsl:variable>
22
23 <xsl:output
24 method="xml"
25 encoding="ISO-8859-1"
26 doctype-system="http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"/>
27
28 <xsl:template match="/">
29 <book>
30 <xsl:copy-of select="/book/bookinfo"/>
31 <preface>
32 <?dbhtml filename="preface.html"?>
33 <title>Preface</title>
34 <xsl:choose>
35 <xsl:when test="$rev='sysv'">
36 <xsl:copy-of select="id('bootscripts')"/>
37 </xsl:when>
38 <xsl:otherwise>
39 <xsl:copy-of select="id('systemd-units')"/>
40 </xsl:otherwise>
41 </xsl:choose>
42 </preface>
43 <chapter>
44 <?dbhtml filename="chapter.html"?>
45 <title>Installing packages in dependency build order</title>
46 <xsl:call-template name="apply-list">
47 <xsl:with-param name="list" select="normalize-space($list)"/>
48 </xsl:call-template>
49 </chapter>
50 <xsl:copy-of select="id('CC')"/>
51 <xsl:copy-of select="id('MIT')"/>
52 <index/>
53 </book>
54 </xsl:template>
55
56<!-- apply-templates for each item in the list.
57 Normally, those items are id of nodes.
58 Those nodes can be sect1 (normal case),
59 sect2 (python modules or DBus bindings)
60 bridgehead (perl modules)
61 para (dependency of perl modules).
62 The templates after this one treat each of those cases.
63 However, some items are xorg package names, and not id.
64 We need special instructions in that case.
65 The difficulty is that some of those names *are* id's,
66 because they are referenced in the index.
67 Hopefully, none of those id's are sect{1,2}, bridgehead or para...-->
68 <xsl:template name="apply-list">
69 <xsl:param name="list" select="''"/>
70 <xsl:if test="string-length($list) &gt; 0">
71 <xsl:choose>
72 <xsl:when test="contains($list,' ')">
73 <xsl:call-template name="apply-list">
74 <xsl:with-param name="list"
75 select="substring-before($list,' ')"/>
76 </xsl:call-template>
77 <xsl:call-template name="apply-list">
78 <xsl:with-param name="list"
79 select="substring-after($list,' ')"/>
80 </xsl:call-template>
81 </xsl:when>
82 <xsl:otherwise>
83 <xsl:choose>
84 <xsl:when test="not(id($list)[self::sect1 or self::sect2 or self::para or self::bridgehead])">
85 <xsl:apply-templates
86 select="//sect1[contains(@id,'xorg7')
87 and contains(string(.//userinput),
88 concat($list,'-'))]"
89 mode="xorg">
90 <xsl:with-param name="package" select="$list"/>
91 </xsl:apply-templates>
92 </xsl:when>
93 <xsl:otherwise>
94 <xsl:apply-templates select="id($list)"/>
95 </xsl:otherwise>
96 </xsl:choose>
97 </xsl:otherwise>
98 </xsl:choose>
99 </xsl:if>
100 </xsl:template>
101
102<!-- The normal case : just copy to the book. Exceptions are if there
103 is a xref, so use a special "mode" template -->
104 <xsl:template match="sect1">
105 <xsl:apply-templates select="." mode="sect1"/>
106 </xsl:template>
107
108 <xsl:template match="processing-instruction()" mode="sect1">
109 <xsl:copy-of select="."/>
110 </xsl:template>
111
112<!-- Any node which has no xref descendant is copied verbatim. If there
113 is an xref descendant, output the node and recurse. -->
114 <xsl:template match="*" mode="sect1">
115 <xsl:choose>
116 <xsl:when test="self::xref">
117 <xsl:choose>
118 <xsl:when test="contains(concat(' ',normalize-space($list),' '),
119 concat(' ',@linkend,' '))">
120 <xsl:choose>
121 <xsl:when test="@linkend='x-window-system' or @linkend='xorg7'">
122 <xref linkend="xorg7-server"/>
123 </xsl:when>
124 <xsl:when test="@linkend='server-mail'">
125 <xref linkend="{$MTA}"/>
126 </xsl:when>
127 <xsl:otherwise>
128 <xsl:copy-of select="."/>
129 </xsl:otherwise>
130 </xsl:choose>
131 </xsl:when>
132 <xsl:otherwise>
133 <xsl:choose>
134 <xsl:when test="@linkend='bootscripts' or
135 @linkend='systemd-units'">
136 <xsl:copy-of select="."/>
137 </xsl:when>
138 <xsl:otherwise>
139 <xsl:value-of select="@linkend"/> (in full book)
140 </xsl:otherwise>
141 </xsl:choose>
142 </xsl:otherwise>
143 </xsl:choose>
144 </xsl:when>
145 <xsl:when test=".//xref">
146 <xsl:element name="{name()}">
147 <xsl:for-each select="attribute::*">
148 <xsl:attribute name="{name()}">
149 <xsl:value-of select="."/>
150 </xsl:attribute>
151 </xsl:for-each>
152 <xsl:apply-templates mode="sect1"/>
153 </xsl:element>
154 </xsl:when>
155 <xsl:otherwise>
156 <xsl:copy-of select="."/>
157 </xsl:otherwise>
158 </xsl:choose>
159 </xsl:template>
160
161<!-- Python modules and DBus bindings -->
162 <xsl:template match="sect2">
163 <xsl:apply-templates select='.' mode="sect2"/>
164 </xsl:template>
165
166 <xsl:template match="*" mode="sect2">
167 <xsl:choose>
168 <xsl:when test="self::sect2">
169 <xsl:element name="sect1">
170 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
171 <xsl:attribute name="xreflabel"><xsl:value-of select="@xreflabel"/></xsl:attribute>
172 <xsl:processing-instruction name="dbhtml">filename="<xsl:value-of
173 select="@id"/>.html"</xsl:processing-instruction>
174 <xsl:apply-templates mode="sect2"/>
175 </xsl:element>
176 </xsl:when>
177 <xsl:when test="self::sect3">
178 <xsl:element name="sect2">
179 <xsl:attribute name="role">
180 <xsl:value-of select="@role"/>
181 </xsl:attribute>
182 <xsl:apply-templates mode="sect2"/>
183 </xsl:element>
184 </xsl:when>
185 <xsl:when test="self::bridgehead">
186 <xsl:element name="bridgehead">
187 <xsl:attribute name="renderas">
188 <xsl:if test="@renderas='sect4'">sect3</xsl:if>
189 <xsl:if test="@renderas='sect5'">sect4</xsl:if>
190 </xsl:attribute>
191 <xsl:value-of select='.'/>
192 </xsl:element>
193 </xsl:when>
194 <xsl:when test="self::xref">
195 <xsl:choose>
196 <xsl:when test="contains(concat(' ',normalize-space($list),' '),
197 concat(' ',@linkend,' '))">
198 <xsl:choose>
199 <xsl:when test="@linkend='x-window-system' or @linkend='xorg7'">
200 <xref linkend="xorg7-server"/>
201 </xsl:when>
202 <xsl:when test="@linkend='server-mail'">
203 <xref linkend="{$MTA}"/>
204 </xsl:when>
205 <xsl:otherwise>
206 <xsl:copy-of select="."/>
207 </xsl:otherwise>
208 </xsl:choose>
209 </xsl:when>
210 <xsl:otherwise>
211 <xsl:value-of select="@linkend"/> (in full book)
212 </xsl:otherwise>
213 </xsl:choose>
214 </xsl:when>
215 <xsl:when test=".//xref">
216 <xsl:element name="{name()}">
217 <xsl:for-each select="attribute::*">
218 <xsl:attribute name="{name()}">
219 <xsl:value-of select="."/>
220 </xsl:attribute>
221 </xsl:for-each>
222 <xsl:apply-templates mode="sect2"/>
223 </xsl:element>
224 </xsl:when>
225 <xsl:otherwise>
226 <xsl:copy-of select="."/>
227 </xsl:otherwise>
228 </xsl:choose>
229 </xsl:template>
230
231<!-- Perl modules : transform them to minimal sect1. Use a template
232 for installation instructions -->
233 <xsl:template match="bridgehead">
234 <xsl:element name="sect1">
235 <xsl:attribute name="id"><xsl:value-of select="./@id"/></xsl:attribute>
236 <xsl:attribute name="xreflabel"><xsl:value-of select="./@xreflabel"/></xsl:attribute>
237 <xsl:processing-instruction name="dbhtml">
238 filename="<xsl:value-of select="@id"/>.html"</xsl:processing-instruction>
239 <title><xsl:value-of select="./@xreflabel"/></title>
240 <sect2 role="package">
241 <title>Introduction to <xsl:value-of select="@id"/></title>
242 <bridgehead renderas="sect3">Package Information</bridgehead>
243 <itemizedlist spacing="compact">
244 <listitem>
245 <para>Download (HTTP): <xsl:copy-of select="./following-sibling::itemizedlist[1]/listitem/para/ulink"/></para>
246 </listitem>
247 <listitem>
248 <para>Download (FTP): <ulink url=" "/></para>
249 </listitem>
250 </itemizedlist>
251 </sect2>
252 <xsl:choose>
253 <xsl:when test="following-sibling::itemizedlist[1]//xref[@linkend='perl-standard-install'] | following-sibling::itemizedlist[1]/preceding-sibling::para//xref[@linkend='perl-standard-install']">
254 <xsl:apply-templates mode="perl-install" select="id('perl-standard-install')"/>
255 </xsl:when>
256 <xsl:otherwise>
257 <sect2 role="installation">
258 <title>Installation of <xsl:value-of select="@xreflabel"/></title>
259 <para>Run the following commands:</para>
260 <for-each select="following-sibling::bridgehead/preceding-sibling::screen[not(@role)]">
261 <xsl:copy-of select="."/>
262 </for-each>
263 <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
264 <for-each select="following-sibling::bridgehead/preceding-sibling::screen[@role='root']">
265 <xsl:copy-of select="."/>
266 </for-each>
267 </sect2>
268 </xsl:otherwise>
269 </xsl:choose>
270 </xsl:element>
271 </xsl:template>
272
273<!-- The case of depdendencies of perl modules. Same treatment
274 as for perl modules. Just easier because always perl standard -->
275 <xsl:template match="para">
276 <xsl:element name="sect1">
277 <xsl:attribute name="id"><xsl:value-of select="./@id"/></xsl:attribute>
278 <xsl:attribute name="xreflabel"><xsl:value-of select="./@xreflabel"/></xsl:attribute>
279 <xsl:processing-instruction name="dbhtml">filename="<xsl:value-of
280 select="@id"/>.html"</xsl:processing-instruction>
281 <title><xsl:value-of select="./@xreflabel"/></title>
282 <sect2 role="package">
283 <title>Introduction to <xsl:value-of select="@id"/></title>
284 <bridgehead renderas="sect3">Package Information</bridgehead>
285 <itemizedlist spacing="compact">
286 <listitem>
287 <para>Download (HTTP): <xsl:copy-of select="./ulink"/></para>
288 </listitem>
289 <listitem>
290 <para>Download (FTP): <ulink url=" "/></para>
291 </listitem>
292 </itemizedlist>
293 </sect2>
294 <xsl:apply-templates mode="perl-install" select="id('perl-standard-install')"/>
295 </xsl:element>
296 </xsl:template>
297
298<!-- copy of the perl standard installation instructions:
299 suppress id (otherwise not unique) and note (which we
300 do not want to apply -->
301 <xsl:template match="sect2" mode="perl-install">
302 <sect2 role="installation">
303 <xsl:for-each select="./*">
304 <xsl:if test="not(self::note)">
305 <xsl:copy-of select="."/>
306 </xsl:if>
307 </xsl:for-each>
308 </sect2>
309 </xsl:template>
310
311<!-- we have got an xorg package. We are at the installation page
312 but now we need to make an autonomous page from the global
313 one -->
314 <xsl:template match="sect1" mode="xorg">
315 <xsl:param name="package"/>
316 <xsl:variable name="tarball">
317 <xsl:call-template name="tarball">
318 <xsl:with-param name="package" select="concat(' ',$package,'-')"/>
319 <xsl:with-param name="cat-md5"
320 select="string(.//userinput[starts-with(string(),'cat ')])"/>
321 </xsl:call-template>
322 </xsl:variable>
323 <xsl:variable name="md5sum">
324 <xsl:call-template name="md5sum">
325 <xsl:with-param name="package" select="concat(' ',$package,'-')"/>
326 <xsl:with-param name="cat-md5"
327 select=".//userinput[starts-with(string(),'cat ')]"/>
328 </xsl:call-template>
329 </xsl:variable>
330 <xsl:variable name="download-dir">
331 <xsl:call-template name="download-dir">
332 <xsl:with-param name="package" select="concat(' ',$package,'-')"/>
333 <xsl:with-param name="cat-md5"
334 select=".//userinput[starts-with(string(),'cat ')]"/>
335 </xsl:call-template>
336 </xsl:variable>
337 <xsl:variable name="install-instructions">
338 <xsl:call-template name="inst-instr">
339 <xsl:with-param name="inst-instr"
340 select=".//userinput[starts-with(string(),'for ')]"/>
341 </xsl:call-template>
342 </xsl:variable>
343 <xsl:element name="sect1">
344 <xsl:attribute name="id"><xsl:value-of select="$package"/></xsl:attribute>
345 <xsl:processing-instruction name="dbhtml">
346 filename="<xsl:value-of select='$package'/>.html"
347 </xsl:processing-instruction>
348 <title><xsl:value-of select="$package"/></title>
349 <sect2 role="package">
350 <title>Introduction to <xsl:value-of select="$package"/></title>
351 <bridgehead renderas="sect3">Package Information</bridgehead>
352 <itemizedlist spacing="compact">
353 <listitem>
354 <para>Download (HTTP): <xsl:element name="ulink">
355 <xsl:attribute name="url">
356 <xsl:value-of
357 select=".//para[contains(string(),'(HTTP)')]/ulink/@url"/>
358 <xsl:value-of select="$download-dir"/>
359 <xsl:value-of select="$tarball"/>
360 </xsl:attribute>
361 </xsl:element>
362 </para>
363 </listitem>
364 <listitem>
365 <para>Download (FTP): <xsl:element name="ulink">
366 <xsl:attribute name="url">
367 <xsl:value-of
368 select=".//para[contains(string(),'(FTP)')]/ulink/@url"/>
369 <xsl:value-of select="$download-dir"/>
370 <xsl:value-of select="$tarball"/>
371 </xsl:attribute>
372 </xsl:element>
373 </para>
374 </listitem>
375 <listitem>
376 <para>
377 Download MD5 sum: <xsl:value-of select="$md5sum"/>
378 </para>
379 </listitem>
380 </itemizedlist>
381 <!-- If there is an additional download, we need to output that -->
382 <xsl:if test=".//bridgehead[contains(string(),'Additional')]">
383 <xsl:copy-of
384 select=".//bridgehead[contains(string(),'Additional')]"/>
385 <xsl:copy-of
386 select=".//bridgehead[contains(string(),'Additional')]
387 /following-sibling::itemizedlist[1]"/>
388 </xsl:if>
389 </sect2>
390 <sect2 role="installation">
391 <title>Installation of <xsl:value-of select="$package"/></title>
392
393 <para>
394 Install <application><xsl:value-of select="$package"/></application>
395 by running the following commands:
396 </para>
397
398 <screen><userinput>packagedir=<xsl:value-of
399 select="substring-before($tarball,'.tar.bz2')"/>
400 <xsl:text>&#xA;</xsl:text>
401 <xsl:value-of select="substring-before($install-instructions,
402 'as_root')"/>
403 </userinput></screen>
404
405 <para>
406 Now as the <systemitem class="username">root</systemitem> user:
407 </para>
408 <screen role='root'>
409 <userinput><xsl:value-of select="substring-after(
410 $install-instructions,
411 'as_root')"/>
412 </userinput>
413 </screen>
414 </sect2>
415 </xsl:element><!-- sect1 -->
416
417 </xsl:template>
418
419<!-- get the tarball name from the text that comes from the .md5 file -->
420 <xsl:template name="tarball">
421 <xsl:param name="package"/>
422 <xsl:param name="cat-md5"/>
423<!-- DEBUG
424<xsl:message><xsl:text>Entering "tarball" template:
425 package is: </xsl:text>
426<xsl:value-of select="$package"/><xsl:text>
427 cat-md5 is: </xsl:text>
428<xsl:value-of select="$cat-md5"/>
429</xsl:message>
430END DEBUG -->
431 <xsl:choose>
432 <xsl:when test="contains(substring-before($cat-md5,$package),'&#xA;')">
433 <xsl:call-template name="tarball">
434 <xsl:with-param name="package" select="$package"/>
435 <xsl:with-param name="cat-md5"
436 select="substring-after($cat-md5,'&#xA;')"/>
437 </xsl:call-template>
438 </xsl:when>
439 <xsl:when test="contains(substring-before($cat-md5,$package),' ')">
440 <xsl:call-template name="tarball">
441 <xsl:with-param name="package" select="$package"/>
442 <xsl:with-param name="cat-md5"
443 select="substring-after($cat-md5,' ')"/>
444 </xsl:call-template>
445 </xsl:when>
446 <xsl:otherwise>
447 <xsl:copy-of select="substring-after(
448 substring-before($cat-md5,'&#xA;'),' ')"/>
449 </xsl:otherwise>
450 </xsl:choose>
451 </xsl:template>
452<!-- get the download dirname from the text that comes from the .md5 file -->
453 <xsl:template name="download-dir">
454 <xsl:param name="package"/>
455 <xsl:param name="cat-md5"/>
456 <xsl:choose>
457 <xsl:when test="not(@id='xorg7-legacy')">
458 <xsl:copy-of select="''"/>
459 </xsl:when>
460 <xsl:when test="contains(substring-before($cat-md5,$package),'&#xA;')">
461 <xsl:call-template name="download-dir">
462 <xsl:with-param name="package" select="$package"/>
463 <xsl:with-param name="cat-md5"
464 select="substring-after($cat-md5,'&#xA;')"/>
465 </xsl:call-template>
466 </xsl:when>
467 <xsl:when test="contains(substring-before($cat-md5,$package),' ')">
468 <xsl:call-template name="download-dir">
469 <xsl:with-param name="package" select="$package"/>
470 <xsl:with-param name="cat-md5"
471 select="substring-after($cat-md5,' ')"/>
472 </xsl:call-template>
473 </xsl:when>
474 <xsl:otherwise>
475 <xsl:copy-of select="substring-before($cat-md5,' ')"/>
476 </xsl:otherwise>
477 </xsl:choose>
478 </xsl:template>
479<!-- same for md5sum -->
480 <xsl:template name="md5sum">
481 <xsl:param name="package"/>
482 <xsl:param name="cat-md5"/>
483 <xsl:choose>
484 <xsl:when test="contains(substring-before($cat-md5,$package),'&#xA;')">
485 <xsl:call-template name="md5sum">
486 <xsl:with-param name="package" select="$package"/>
487 <xsl:with-param name="cat-md5"
488 select="substring-after($cat-md5,'&#xA;')"/>
489 </xsl:call-template>
490 </xsl:when>
491 <xsl:otherwise>
492 <xsl:copy-of select="substring-before($cat-md5,' ')"/>
493 </xsl:otherwise>
494 </xsl:choose>
495 </xsl:template>
496
497 <xsl:template name="inst-instr">
498 <xsl:param name="inst-instr"/>
499 <xsl:choose>
500 <xsl:when test="contains($inst-instr,'pushd')">
501 <xsl:call-template name="inst-instr">
502 <xsl:with-param name="inst-instr"
503 select="substring-after(
504 substring-after($inst-instr,'pushd'),
505 '&#xA;')"/>
506 </xsl:call-template>
507 </xsl:when>
508 <xsl:otherwise>
509 <xsl:copy-of select="substring-before($inst-instr,'popd')"/>
510 </xsl:otherwise>
511 </xsl:choose>
512 </xsl:template>
513</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.