source: BLFS/xsl/make_book.xsl@ 46d25bc

ablfs
Last change on this file since 46d25bc was 63fc514, checked in by Pierre Labastie <pierre@…>, 13 years ago

Initial modificaiton of BLFS tools

  • Property mode set to 100644
File size: 10.0 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 id in the list.
38 Those nodes can be sect1 (normal case),
39 sect2 (python modules or DBus bindings)
40 bridgehead (perl modules)
41 para (dependency of perl modules).
42 The templates after this one treat each of those cases-->
43 <xsl:template name="apply-list">
44 <xsl:param name="list" select="''"/>
45 <xsl:if test="string-length($list) &gt; 0">
46 <xsl:choose>
47 <xsl:when test="contains($list,' ')">
48 <xsl:apply-templates select="id(substring-before($list,' '))"/>
49 <xsl:call-template name="apply-list">
50 <xsl:with-param name="list"
51 select="substring-after($list,' ')"/>
52 </xsl:call-template>
53 </xsl:when>
54 <xsl:otherwise>
55 <xsl:apply-templates select="id($list)"/>
56 </xsl:otherwise>
57 </xsl:choose>
58 </xsl:if>
59 </xsl:template>
60
61<!-- The normal case : just copy to the book. Exceptions are if there
62 is a xref, so use a special "mode" template -->
63 <xsl:template match="sect1">
64 <xsl:apply-templates select="." mode="sect1"/>
65 </xsl:template>
66
67 <xsl:template match="processing-instruction()" mode="sect1">
68 <xsl:copy-of select="."/>
69 </xsl:template>
70
71<!-- Any node which has no xref descendant is copied verbatim. If there
72 is an xref descendant, output the node and recurse. -->
73 <xsl:template match="*" mode="sect1">
74 <xsl:choose>
75 <xsl:when test="self::xref">
76 <xsl:choose>
77 <xsl:when test="contains(concat(' ',normalize-space($list),' '),
78 concat(' ',@linkend,' '))">
79 <xsl:choose>
80 <xsl:when test="@linkend='x-window-system' or @linkend='xorg7'">
81 <xref linkend="xorg7-server"/>
82 </xsl:when>
83 <xsl:when test="@linkend='server-mail'">
84 <xref linkend="{$MTA}"/>
85 </xsl:when>
86 <xsl:otherwise>
87 <xsl:copy-of select="."/>
88 </xsl:otherwise>
89 </xsl:choose>
90 </xsl:when>
91 <xsl:otherwise>
92 <xsl:choose>
93 <xsl:when test="@linkend='bootscripts'">
94 <xsl:copy-of select="."/>
95 </xsl:when>
96 <xsl:otherwise>
97 <xsl:value-of select="@linkend"/> (in full book)
98 </xsl:otherwise>
99 </xsl:choose>
100 </xsl:otherwise>
101 </xsl:choose>
102 </xsl:when>
103 <xsl:when test=".//xref">
104 <xsl:element name="{name()}">
105 <xsl:for-each select="attribute::*">
106 <xsl:attribute name="{name()}">
107 <xsl:value-of select="."/>
108 </xsl:attribute>
109 </xsl:for-each>
110 <xsl:apply-templates mode="sect1"/>
111 </xsl:element>
112 </xsl:when>
113 <xsl:otherwise>
114 <xsl:copy-of select="."/>
115 </xsl:otherwise>
116 </xsl:choose>
117 </xsl:template>
118
119<!-- Python modules and DBus bindings -->
120 <xsl:template match="sect2">
121 <xsl:apply-templates select='.' mode="sect2"/>
122 </xsl:template>
123
124 <xsl:template match="*" mode="sect2">
125 <xsl:choose>
126 <xsl:when test="self::sect2">
127 <xsl:element name="sect1">
128 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
129 <xsl:attribute name="xreflabel"><xsl:value-of select="@xreflabel"/></xsl:attribute>
130 <xsl:processing-instruction name="dbhtml">filename="<xsl:value-of
131 select="@id"/>.html"</xsl:processing-instruction>
132 <xsl:apply-templates mode="sect2"/>
133 </xsl:element>
134 </xsl:when>
135 <xsl:when test="self::sect3">
136 <xsl:element name="sect2">
137 <xsl:attribute name="role">
138 <xsl:value-of select="@role"/>
139 </xsl:attribute>
140 <xsl:apply-templates mode="sect2"/>
141 </xsl:element>
142 </xsl:when>
143 <xsl:when test="self::bridgehead">
144 <xsl:element name="bridgehead">
145 <xsl:attribute name="renderas">
146 <xsl:if test="@renderas='sect4'">sect3</xsl:if>
147 <xsl:if test="@renderas='sect5'">sect4</xsl:if>
148 </xsl:attribute>
149 <xsl:value-of select='.'/>
150 </xsl:element>
151 </xsl:when>
152 <xsl:when test="self::xref">
153 <xsl:choose>
154 <xsl:when test="contains(concat(' ',normalize-space($list),' '),
155 concat(' ',@linkend,' '))">
156 <xsl:choose>
157 <xsl:when test="@linkend='x-window-system' or @linkend='xorg7'">
158 <xref linkend="xorg7-server"/>
159 </xsl:when>
160 <xsl:when test="@linkend='server-mail'">
161 <xref linkend="{$MTA}"/>
162 </xsl:when>
163 <xsl:otherwise>
164 <xsl:copy-of select="."/>
165 </xsl:otherwise>
166 </xsl:choose>
167 </xsl:when>
168 <xsl:otherwise>
169 <xsl:value-of select="@linkend"/> (in full book)
170 </xsl:otherwise>
171 </xsl:choose>
172 </xsl:when>
173 <xsl:when test=".//xref">
174 <xsl:element name="{name()}">
175 <xsl:for-each select="attribute::*">
176 <xsl:attribute name="{name()}">
177 <xsl:value-of select="."/>
178 </xsl:attribute>
179 </xsl:for-each>
180 <xsl:apply-templates mode="sect2"/>
181 </xsl:element>
182 </xsl:when>
183 <xsl:otherwise>
184 <xsl:copy-of select="."/>
185 </xsl:otherwise>
186 </xsl:choose>
187 </xsl:template>
188
189<!-- Perl modules : transform them to minimal sect1. Use a template
190 for installation instructions -->
191 <xsl:template match="bridgehead">
192 <xsl:element name="sect1">
193 <xsl:attribute name="id"><xsl:value-of select="./@id"/></xsl:attribute>
194 <xsl:attribute name="xreflabel"><xsl:value-of select="./@xreflabel"/></xsl:attribute>
195 <xsl:processing-instruction name="dbhtml">
196 filename="<xsl:value-of select="@id"/>.html"</xsl:processing-instruction>
197 <title><xsl:value-of select="./@xreflabel"/></title>
198 <sect2 role="package">
199 <title>Introduction to <xsl:value-of select="@id"/></title>
200 <bridgehead renderas="sect3">Package Information</bridgehead>
201 <itemizedlist spacing="compact">
202 <listitem>
203 <para>Download (HTTP): <xsl:copy-of select="./following-sibling::itemizedlist[1]/listitem/para/ulink"/></para>
204 </listitem>
205 <listitem>
206 <para>Download (FTP): <ulink url=" "/></para>
207 </listitem>
208 </itemizedlist>
209 </sect2>
210 <xsl:choose>
211 <xsl:when test="following-sibling::itemizedlist[1]//xref[@linkend='perl-standard-install'] | following-sibling::itemizedlist[1]/preceding-sibling::para//xref[@linkend='perl-standard-install']">
212 <xsl:apply-templates mode="perl-install" select="id('perl-standard-install')"/>
213 </xsl:when>
214 <xsl:otherwise>
215 <sect2 role="installation">
216 <title>Installation of <xsl:value-of select="@xreflabel"/></title>
217 <para>Run the following commands:</para>
218 <for-each select="following-sibling::bridgehead/preceding-sibling::screen[not(@role)]">
219 <xsl:copy-of select="."/>
220 </for-each>
221 <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
222 <for-each select="following-sibling::bridgehead/preceding-sibling::screen[@role='root']">
223 <xsl:copy-of select="."/>
224 </for-each>
225 </sect2>
226 </xsl:otherwise>
227 </xsl:choose>
228 </xsl:element>
229 </xsl:template>
230
231<!-- The case of depdendencies of perl modules. Same treatment
232 as for perl modules. Just easier because always perl standard -->
233 <xsl:template match="para">
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">filename="<xsl:value-of
238 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="./ulink"/></para>
246 </listitem>
247 <listitem>
248 <para>Download (FTP): <ulink url=" "/></para>
249 </listitem>
250 </itemizedlist>
251 </sect2>
252 <xsl:apply-templates mode="perl-install" select="id('perl-standard-install')"/>
253 </xsl:element>
254 </xsl:template>
255
256<!-- copy of the perl standard installation instructions:
257 suppress id (otherwise not unique) and note (which we
258 do not want to apply -->
259 <xsl:template match="sect2" mode="perl-install">
260 <sect2 role="installation">
261 <xsl:for-each select="./*">
262 <xsl:if test="not(self::note)">
263 <xsl:copy-of select="."/>
264 </xsl:if>
265 </xsl:for-each>
266 </sect2>
267 </xsl:template>
268</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.