source: BOOK/stylesheets/clfs-profile.xsl@ 5c560cb

Last change on this file since 5c560cb was 5c560cb, checked in by Joe Ciccone <jciccone@…>, 15 years ago

This is the first part of the 2nd format to use as a simplification.
This format proposes using a completely custom stylesheet. Instead
of trying to merge together with docbook. The first attempt works it
is just extremely problematic. This is much easier, and it is the goal
anyway.

  • Property mode set to 100644
File size: 12.7 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:c="http://schema.cross-lfs.org/book"
4 version="1.0">
5
6 <!-- Declare our output type -->
7 <xsl:output method="xml"
8 indent="no"
9 omit-xml-declaration="no"
10 encoding="utf-8"
11 doctype-public="-//OASIS//DTD DocBook XML V4.5//EN"
12 doctype-system="http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" />
13
14 <xsl:param name="clfs.arch" select="''" />
15 <xsl:param name="clfs.multilib" select="''" />
16
17 <!-- Apply the other templates -->
18 <xsl:template match="@*|node()" priority="-1">
19 <xsl:copy>
20 <xsl:apply-templates select="@*|node()" />
21 </xsl:copy>
22 </xsl:template>
23
24 <!-- Build the package xml -->
25 <xsl:template match="//c:package">
26 <xsl:param name="id" select="@id" />
27 <xsl:param name="multibuild" select="@c:multibuild" />
28 <xsl:call-template name="package-iterator">
29 <xsl:with-param name="id" select="$id" />
30 <xsl:with-param name="multibuild" select="$multibuild" />
31 <xsl:with-param name="bits" select="$clfs.multilib" />
32 </xsl:call-template>
33 </xsl:template>
34
35 <xsl:template name="package-iterator">
36 <xsl:param name="id" /> <!-- Base ID of the resulting package -->
37 <xsl:param name="multibuild" /> <!-- Do we need to install for each bitsize? -->
38 <xsl:param name="bits" /> <!-- Which bit sizes to create a package for -->
39
40 <xsl:variable name="currentbits" select="substring-before(concat($bits, ','), ',')" />
41 <xsl:variable name="remainingbits" select="substring-after($bits, ',')" />
42
43 <xsl:if test="not(boolean($remainingbits) and $multibuild = 'false')">
44 <xsl:call-template name="package-stub">
45 <xsl:with-param name="id" select="$id" />
46 <xsl:with-param name="idsuffix">
47 <xsl:if test="$remainingbits">
48 <xsl:value-of select="concat('-', $currentbits)" />
49 </xsl:if>
50 </xsl:with-param>
51 <xsl:with-param name="bits" select="substring-before(concat($bits, ','), ',')" />
52 <xsl:with-param name="multibuild" select="$multibuild" />
53 </xsl:call-template>
54 </xsl:if>
55
56 <xsl:if test="$remainingbits">
57 <xsl:text>
58
59 </xsl:text>
60 <xsl:call-template name="package-iterator">
61 <xsl:with-param name="id" select="$id" />
62 <xsl:with-param name="multibuild" select="$multibuild" />
63 <xsl:with-param name="bits" select="$remainingbits" />
64 </xsl:call-template>
65 </xsl:if>
66
67 </xsl:template>
68
69 <xsl:template name="package-stub">
70 <xsl:param name="id" /> <!-- Base ID of the resulting package -->
71 <xsl:param name="idsuffix" /> <!-- Suffix to attach to the end of the ID for this perticular instance -->
72 <xsl:param name="bits" /> <!-- Which bit sizes to create a package for -->
73 <xsl:param name="multibuild" /> <!-- Are there multiple instances of this package? -->
74
75 <!-- Translate the package into a sect1 -->
76 <xsl:element name="sect1">
77
78 <!-- Set the ID of the target Sect1 -->
79 <xsl:attribute name="id">
80 <xsl:value-of select="concat($id, $idsuffix)" />
81 </xsl:attribute>
82
83 <!-- New Line -->
84 <xsl:text>
85</xsl:text>
86
87 <!-- Set the Target Filename -->
88 <xsl:processing-instruction name="dbhtml">
89 <xsl:text>filename=&quot;</xsl:text>
90 <xsl:value-of select="concat($id, $idsuffix)" />
91 <xsl:text>.html&quot;</xsl:text>
92 </xsl:processing-instruction>
93
94 <!-- New Line x2 -->
95 <xsl:text>
96
97</xsl:text>
98
99 <!-- Determine if the title is going to have a suffix or not -->
100 <xsl:variable name="titlesuffix">
101 <xsl:if test="contains($clfs.multilib, ',') and ($multibuild = 'true')">
102 <xsl:choose>
103 <xsl:when test="$bits = '32'">
104 <xsl:text>32Bit</xsl:text>
105 </xsl:when>
106 <xsl:when test="$bits = 'n32'">
107 <xsl:text>N32</xsl:text>
108 </xsl:when>
109 <xsl:when test="$bits = '64'">
110 <xsl:text>64Bit</xsl:text>
111 </xsl:when>
112 </xsl:choose>
113 </xsl:if>
114 </xsl:variable>
115
116 <!-- title: Write out a new title tag -->
117 <xsl:element name="title">
118 <xsl:value-of select="c:title" />
119 <xsl:text>-</xsl:text>
120 <xsl:value-of select="c:version" />
121 <xsl:if test="string-length($titlesuffix) > 0">
122 <xsl:text> - </xsl:text>
123 <xsl:value-of select="$titlesuffix"/>
124 </xsl:if>
125 </xsl:element><!-- title -->
126
127 <!-- New Line x2 -->
128 <xsl:text>
129
130</xsl:text>
131
132 <!-- indexterm: Add the Intex Entry for this package -->
133 <xsl:element name="indexterm">
134 <xsl:attribute name="zone">
135 <xsl:value-of select="concat($id, $idsuffix)" />
136 </xsl:attribute>
137 <xsl:text>
138 </xsl:text>
139 <xsl:element name="primary">
140 <xsl:attribute name="sortas">
141 <xsl:text>a-</xsl:text>
142 <xsl:value-of select="c:title" />
143 </xsl:attribute>
144 <xsl:value-of select="c:title" />
145 </xsl:element>
146 <xsl:if test="string-length($titlesuffix) > 0">
147 <xsl:text>
148 </xsl:text>
149 <xsl:element name="secondary">
150 <xsl:value-of select="$titlesuffix" />
151 </xsl:element>
152 </xsl:if>
153 <xsl:text>
154</xsl:text>
155 </xsl:element><!-- indexterm -->
156
157 <!-- New Line x2 -->
158 <xsl:text>
159
160</xsl:text>
161
162 <!-- sect2[role="installation"]: Add the sect2 for the package header -->
163 <xsl:element name="sect2">
164 <xsl:attribute name="role">
165 <xsl:text>installation</xsl:text>
166 </xsl:attribute>
167 <xsl:text>
168 </xsl:text>
169 <xsl:element name="title" />
170 <xsl:text>
171 </xsl:text>
172 <xsl:element name="para">
173 <xsl:copy-of select="c:description/@*|c:description/node()" />
174 </xsl:element>
175 <xsl:text>
176</xsl:text>
177 </xsl:element>
178
179 <!-- New Line x2 -->
180 <xsl:text>
181
182</xsl:text>
183
184 </xsl:element><!-- Sect1 -->
185
186<!--
187 <xsl:for-each select="sect1">
188
189 <xsl:copy>
190
191 <xsl:attribute name="id">
192 <xsl:value-of select="concat($id, $idsuffix)" />
193 </xsl:attribute>
194
195 <xsl:processing-instruction name="dbhtml">
196 <xsl:text>filename=&quot;</xsl:text>
197 <xsl:value-of select="concat($id, $idsuffix)" />
198 <xsl:text>.html&quot;</xsl:text>
199 </xsl:processing-instruction>
200
201 <xsl:variable name="titlesuffix">
202 <xsl:if test="contains($clfs.multilib, ',') and ($multibuild = 'true')">
203 <xsl:choose>
204 <xsl:when test="$bits = '32'">
205 <xsl:text>32Bit</xsl:text>
206 </xsl:when>
207 <xsl:when test="$bits = 'n32'">
208 <xsl:text>N32</xsl:text>
209 </xsl:when>
210 <xsl:when test="$bits = '64'">
211 <xsl:text>64Bit</xsl:text>
212 </xsl:when>
213 </xsl:choose>
214 </xsl:if>
215 </xsl:variable>
216
217 <xsl:for-each select="title">
218 <xsl:element name="title">
219 <xsl:copy-of select="@*|node()" />
220 <xsl:if test="string-length($titlesuffix) > 0">
221 <xsl:text> - </xsl:text>
222 <xsl:value-of select="$titlesuffix"/>
223 </xsl:if>
224 </xsl:element>
225 </xsl:for-each>
226
227 <xsl:element name="indexterm">
228 <xsl:attribute name="zone">
229 <xsl:value-of select="concat($id, $idsuffix)" />
230 </xsl:attribute>
231 <xsl:element name="primary">
232 <xsl:attribute name="sortas">
233 <xsl:text>a-</xsl:text>
234 <xsl:value-of select="title" />
235 </xsl:attribute>
236 <xsl:value-of select="title" />
237 </xsl:element>
238 <xsl:if test="string-length($titlesuffix) > 0">
239 <xsl:element name="secondary">
240 <xsl:value-of select="$titlesuffix" />
241 </xsl:element>
242 </xsl:if>
243 </xsl:element>
244
245 <xsl:choose>
246 <xsl:when test="$bits = '32'">
247 <xsl:apply-templates select="@*|node()[not(self::title)]" mode="filter-bits-32" />
248 </xsl:when>
249 <xsl:when test="$bits = 'n32'">
250 <xsl:apply-templates select="@*|node()[not(self::title)]" mode="filter-bits-n32" />
251 </xsl:when>
252 <xsl:when test="$bits = '64'">
253 <xsl:apply-templates select="@*|node()[not(self::title)]" mode="filter-bits-64" />
254 </xsl:when>
255 </xsl:choose>
256
257 </xsl:copy>
258
259 </xsl:for-each>
260-->
261
262 </xsl:template>
263
264 <!-- Apply the profile to the 32bit package -->
265
266 <xsl:template match="@*|node()" mode="filter-bits-32">
267 <xsl:variable name="ismultilib">
268 <xsl:choose>
269 <xsl:when test="contains($clfs.multilib, ',')">
270 <xsl:text>true</xsl:text>
271 </xsl:when>
272 <xsl:otherwise>
273 <xsl:text>false</xsl:text>
274 </xsl:otherwise>
275 </xsl:choose>
276 </xsl:variable>
277 <xsl:if test="(string-length(@c:arch) = 0) or contains(concat(',',@c:arch,','), concat(',', $clfs.arch, ','))">
278 <xsl:if test="(string-length(@c:multilib) = 0) or contains(concat(',',@c:multilib,','), concat(',', $ismultilib, ','))">
279 <xsl:if test="(string-length(@c:bits) = 0) or contains(concat(',',@c:bits,','), ',32,')">
280 <xsl:copy>
281 <xsl:apply-templates select="@*|node()" mode="filter-bits-32" />
282 </xsl:copy>
283 </xsl:if>
284 </xsl:if>
285 </xsl:if>
286 </xsl:template>
287
288 <xsl:template match="@c:arch" mode="filter-bits-32" />
289 <xsl:template match="@c:bits" mode="filter-bits-32" />
290 <xsl:template match="@c:multilib" mode="filter-bits-32" />
291
292 <!-- Apply the profile to the n32 package -->
293
294 <xsl:template match="@*|node()" mode="filter-bits-n32">
295 <xsl:variable name="ismultilib">
296 <xsl:choose>
297 <xsl:when test="contains($clfs.multilib, ',')">
298 <xsl:text>true</xsl:text>
299 </xsl:when>
300 <xsl:otherwise>
301 <xsl:text>false</xsl:text>
302 </xsl:otherwise>
303 </xsl:choose>
304 </xsl:variable>
305 <xsl:if test="(string-length(@c:arch) = 0) or contains(concat(',',@c:arch,','), concat(',', $clfs.arch, ','))">
306 <xsl:if test="(string-length(@c:multilib) = 0) or contains(concat(',',@c:multilib,','), concat(',', $ismultilib, ','))">
307 <xsl:if test="(string-length(@c:bits) = 0) or contains(concat(',',@c:bits,','), ',n32,')">
308 <xsl:copy>
309 <xsl:apply-templates select="@*|node()" mode="filter-bits-n32" />
310 </xsl:copy>
311 </xsl:if>
312 </xsl:if>
313 </xsl:if>
314 </xsl:template>
315
316 <xsl:template match="@c:arch" mode="filter-bits-n32" />
317 <xsl:template match="@c:bits" mode="filter-bits-n32" />
318 <xsl:template match="@c:multilib" mode="filter-bits-n32" />
319
320 <!-- Apply the profile to the 64bit package -->
321
322 <xsl:template match="@*|node()" mode="filter-bits-64">
323 <xsl:variable name="ismultilib">
324 <xsl:choose>
325 <xsl:when test="contains($clfs.multilib, ',')">
326 <xsl:text>true</xsl:text>
327 </xsl:when>
328 <xsl:otherwise>
329 <xsl:text>false</xsl:text>
330 </xsl:otherwise>
331 </xsl:choose>
332 </xsl:variable>
333 <xsl:if test="(string-length(@c:arch) = 0) or contains(concat(',',@c:arch,','), concat(',', $clfs.arch, ','))">
334 <xsl:if test="(string-length(@c:multilib) = 0) or contains(concat(',',@c:multilib,','), concat(',', $ismultilib, ','))">
335 <xsl:if test="(string-length(@c:bits) = 0) or contains(concat(',',@c:bits,','), ',64,')">
336 <xsl:copy>
337 <xsl:apply-templates select="@*|node()" mode="filter-bits-64" />
338 </xsl:copy>
339 </xsl:if>
340 </xsl:if>
341 </xsl:if>
342 </xsl:template>
343
344 <xsl:template match="@c:arch" mode="filter-bits-64" />
345 <xsl:template match="@c:bits" mode="filter-bits-64" />
346 <xsl:template match="@c:multilib" mode="filter-bits-64" />
347
348 <!-- Apply the profile filter to the entire document -->
349 <xsl:template match="//*[@c:arch]|//*[@c:multilib]">
350 <xsl:variable name="ismultilib">
351 <xsl:choose>
352 <xsl:when test="contains($clfs.multilib, ',')">
353 <xsl:text>true</xsl:text>
354 </xsl:when>
355 <xsl:otherwise>
356 <xsl:text>false</xsl:text>
357 </xsl:otherwise>
358 </xsl:choose>
359 </xsl:variable>
360 <xsl:if test="(string-length(@c:arch) = 0) or contains(concat(',',@c:arch,','), concat(',', $clfs.arch, ','))">
361 <xsl:if test="(string-length(@c:multilib) = 0) or contains(concat(',',@c:multilib,','), concat(',', $ismultilib, ','))">
362 <xsl:copy>
363 <xsl:apply-templates select="@*|node()" />
364 </xsl:copy>
365 </xsl:if>
366 </xsl:if>
367 </xsl:template>
368
369 <!-- Remove the profileing attributes for the remaining objects -->
370 <xsl:template match="@c:arch" />
371 <xsl:template match="@c:bits" />
372 <xsl:template match="@c:multilib" />
373
374</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.