source: BLFS/xsl/make_book.xsl@ 532ede6

2.4 ablfs-more legacy new_features trunk
Last change on this file since 532ede6 was e576789, checked in by Pierre Labastie <pierre@…>, 11 years ago

Merge ablfs branch. Normally, jhalfs should not perform differently
for building LFS

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