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