source: BLFS/xsl/gen_pkg_list.xsl@ 78d4779

2.4 ablfs-more legacy trunk
Last change on this file since 78d4779 was d020649, checked in by Pierre Labastie <pierre@…>, 9 years ago

Fix exchanged lines in BLFS/xsl/gen_pkg_list.xsl

  • Property mode set to 100644
File size: 13.8 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2
3<!-- $Id: gen_pkg_list.xsl 21 2012-02-16 15:06:19Z labastie $ -->
4<!-- Takes the blfs-full.xml file and extract a list
5 of packages obeying packdesc.dtd + looks for already
6 installed packages in the tracking file (stringparam
7 'installed-packages') -->
8
9<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10 version="1.0">
11
12 <xsl:param name="installed-packages" select="'../lib/instpkg.xml'"/>
13
14 <xsl:output method="xml"
15 encoding='ISO-8859-1'
16 doctype-system="./packdesc.dtd"/>
17
18<!-- specialCases.xsl is generated by a shell script:
19 allows for cases where version begins with a letter
20 and when there is no version (such as xorg7 packages) -->
21 <xsl:include href="./specialCases.xsl"/>
22
23 <xsl:template match="/">
24 <princList>
25 <xsl:text>&#xA;&#xA;</xsl:text>
26<!-- How to have blfs-bootscripts versionned? Do not know, so
27 avoid it (TODO ?) -->
28 <xsl:apply-templates select="//part[not(@id='introduction')]"/>
29 </princList>
30 </xsl:template>
31
32 <xsl:template match="part">
33 <xsl:if test="count(.//*[contains(translate(@xreflabel,
34 '123456789',
35 '000000000'),
36 '-0')
37 ]) &gt; 0">
38 <xsl:text> </xsl:text>
39 <list>
40 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
41 <xsl:text>&#xA; </xsl:text>
42 <xsl:element name="name">
43 <xsl:value-of select="title"/>
44 </xsl:element>
45 <xsl:text>&#xA;&#xA;</xsl:text>
46 <xsl:apply-templates select="chapter"/>
47 <xsl:text> </xsl:text>
48 </list>
49 <xsl:text>&#xA;&#xA;</xsl:text>
50 </xsl:if>
51 </xsl:template>
52
53 <xsl:template match="chapter">
54 <xsl:if test="count(.//*[contains(translate(@xreflabel,
55 '123456789',
56 '000000000'),
57 '-0')
58 ]) &gt; 0">
59 <xsl:text> </xsl:text>
60 <sublist>
61 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
62 <xsl:text>&#xA; </xsl:text>
63 <xsl:element name="name">
64 <xsl:value-of select="title"/>
65 </xsl:element>
66 <xsl:text>&#xA;</xsl:text>
67 <xsl:apply-templates select=".//sect1">
68 <xsl:sort select="@id"/>
69 </xsl:apply-templates>
70 <xsl:text> </xsl:text>
71 </sublist><xsl:text>&#xA;&#xA;</xsl:text>
72 </xsl:if>
73 </xsl:template>
74
75 <xsl:template match="sect1">
76 <xsl:choose>
77<!-- This test is to find sections containing modules (PERL, Python
78 DBus,...) -->
79 <xsl:when
80 test="not(contains(translate(@xreflabel,
81 '123456789',
82 '000000000'),
83 '-0')) and
84 count(descendant::node()[contains(translate(@xreflabel,
85 '123456789',
86 '000000000'),
87 '-0')
88 ]) &gt; 0">
89 <xsl:text> </xsl:text>
90 <package><xsl:text>&#xA; </xsl:text>
91 <xsl:element name="name">
92 <xsl:value-of select="title"/>
93 </xsl:element>
94 <xsl:text>&#xA;</xsl:text>
95<!-- Do not use .//*, which would include self. -->
96 <xsl:apply-templates
97 select="descendant::node()[contains(translate(@xreflabel,
98 '123456789',
99 '000000000'),
100 '-0')
101 ]"
102 mode="normal">
103 <xsl:sort select="@id"/>
104 </xsl:apply-templates>
105 <xsl:text> </xsl:text>
106 </package><xsl:text>&#xA;&#xA;</xsl:text>
107 </xsl:when>
108 <xsl:otherwise>
109<!-- Calls the template of specialCases.xsl,
110 which calls the "normal" template when the
111 case is normal. -->
112 <xsl:apply-templates select='.' mode="special">
113 <xsl:sort select="@id"/>
114 </xsl:apply-templates>
115 </xsl:otherwise>
116 </xsl:choose>
117 </xsl:template>
118
119 <xsl:template match="*" mode="normal">
120 <xsl:variable name="version">
121 <xsl:call-template name="version">
122 <xsl:with-param name="label" select="./@xreflabel"/>
123 </xsl:call-template>
124 </xsl:variable>
125 <xsl:choose>
126<!-- If there is a "sect1" ancestor, this means that
127 we have a module -->
128 <xsl:when test="ancestor::sect1">
129 <xsl:text> </xsl:text>
130 <module><xsl:text>&#xA; </xsl:text>
131 <xsl:element name="name">
132 <xsl:value-of select="./@id"/>
133 </xsl:element>
134 <xsl:text>&#xA; </xsl:text>
135 <xsl:element name="version">
136 <xsl:value-of select="$version"/>
137 </xsl:element>
138 <xsl:if
139 test="document($installed-packages)//package[name=current()/@id]">
140 <xsl:text>&#xA; </xsl:text>
141 <xsl:element name="inst-version">
142 <xsl:value-of
143 select="document(
144 $installed-packages
145 )//package[name=current()/@id]/version"/>
146 </xsl:element>
147 </xsl:if>
148<!-- Dependencies -->
149<!-- First the case of python modules or d-bus bindings -->
150 <xsl:if test="self::sect2">
151<!-- dependencies -->
152 <xsl:apply-templates select=".//para[@role='required' or
153 @role='recommended' or
154 @role='optional']"
155 mode="dependency"/>
156 </xsl:if>
157<!-- For python modules, the preceding module is an optional dep -->
158 <xsl:if test="ancestor::sect1[@id='python-modules']">
159 <xsl:apply-templates
160 select="preceding-sibling::sect2[@role='package']
161 //listitem[para/xref/@linkend=current()/@id]"
162 mode="prec-dep"/>
163 </xsl:if>
164<!-- Now the case of perl modules: let us test our XSLT abilities.
165 Well, "use the sibling, Luke" -->
166 <xsl:if test="self::bridgehead">
167 <xsl:apply-templates select="following-sibling::itemizedlist[1]
168 /listitem/itemizedlist/listitem"
169 mode="perlmod-dep">
170 <xsl:sort select="position()"
171 data-type="number"
172 order="descending"/>
173 </xsl:apply-templates>
174 </xsl:if>
175<!-- End dependencies -->
176 <xsl:text>&#xA; </xsl:text>
177 </module><xsl:text>&#xA;</xsl:text>
178 </xsl:when>
179 <xsl:otherwise>
180 <xsl:text> </xsl:text>
181 <package><xsl:text>&#xA; </xsl:text>
182 <xsl:element name="name">
183 <xsl:value-of select="./@id"/>
184 </xsl:element>
185 <xsl:text>&#xA; </xsl:text>
186 <xsl:element name="version">
187 <xsl:value-of select="$version"/>
188 </xsl:element>
189 <xsl:if
190 test="document($installed-packages)//package[name=current()/@id]">
191 <xsl:text>&#xA; </xsl:text>
192 <xsl:element name="inst-version">
193 <xsl:value-of
194 select="document(
195 $installed-packages
196 )//package[name=current()/@id]/version"/>
197 </xsl:element>
198 </xsl:if>
199<!-- Dependencies -->
200<!-- If in Xorg (not anymore) or KDE chapter, consider that the preceding
201 package is the first dependency (not always noted in the book)-->
202 <xsl:if test="ancestor::chapter[@id='kde4-core'
203 or @id='xfce-core'
204 or @id='lxqt-desktop'
205 or @id='lxde-desktop']
206 and preceding-sibling::sect1[1]">
207 <xsl:text>
208 </xsl:text>
209 <xsl:element name="dependency">
210 <xsl:attribute name="status">required</xsl:attribute>
211 <xsl:attribute name="name">
212 <xsl:value-of select="preceding-sibling::sect1[1]/@id"/>
213 </xsl:attribute>
214 <xsl:attribute name="type">ref</xsl:attribute>
215 </xsl:element>
216 </xsl:if>
217 <xsl:apply-templates select=".//para[@role='required' or
218 @role='recommended' or
219 @role='optional']"
220 mode="dependency"/>
221<!-- End dependencies -->
222 <xsl:text>&#xA; </xsl:text>
223 </package><xsl:text>&#xA;</xsl:text>
224 </xsl:otherwise>
225 </xsl:choose>
226 </xsl:template>
227
228 <xsl:template name="version">
229 <xsl:param name="label" select="abc-2"/>
230 <xsl:variable name="start" select="string-length(substring-before(translate($label,'123456789','000000000'),'-0'))+2"/>
231 <xsl:variable name="prelim-ver" select="substring($label,$start)"/>
232 <xsl:choose>
233 <xsl:when test="contains($prelim-ver,'onfiguration')"/>
234 <xsl:when test="contains($prelim-ver,'escription')"/>
235 <xsl:when test="contains($prelim-ver,'EggDBus')">
236 <xsl:value-of select="substring-before($prelim-ver,' (EggDBus)')"/>
237 </xsl:when>
238 <xsl:when test="contains($label,'JDK')">
239 <xsl:value-of select="translate($prelim-ver,' ','_')"/>
240 </xsl:when>
241 <xsl:otherwise>
242 <xsl:value-of select="$prelim-ver"/>
243 </xsl:otherwise>
244 </xsl:choose>
245 </xsl:template>
246
247 <xsl:template match="para" mode="dependency">
248 <xsl:variable name="status" select="./@role"/>
249<!-- First internal dependencies -->
250 <xsl:for-each select="./xref">
251 <xsl:choose>
252<!-- Avoid depending of myself -->
253 <xsl:when test="ancestor::*[@id=current()/@linkend]"/>
254<!-- Call list expansion when we have an xorg7 series of packages -->
255 <xsl:when test="contains(@linkend,'xorg7-')">
256 <xsl:call-template name="expand-deps">
257 <xsl:with-param name="section">
258 <xsl:value-of select="@linkend"/>
259 </xsl:with-param>
260 <xsl:with-param name="status">
261 <xsl:value-of select="$status"/>
262 </xsl:with-param>
263 </xsl:call-template>
264 </xsl:when>
265 <xsl:otherwise>
266 <xsl:text>
267 </xsl:text>
268 <xsl:element name="dependency">
269 <xsl:attribute name="status">
270 <xsl:value-of select="$status"/>
271 </xsl:attribute>
272 <xsl:attribute name="name">
273 <xsl:value-of select="@linkend"/>
274 </xsl:attribute>
275 <xsl:attribute name="type">ref</xsl:attribute>
276 </xsl:element>
277 </xsl:otherwise>
278 </xsl:choose>
279 </xsl:for-each>
280<!-- then external dependencies -->
281 <xsl:for-each select="./ulink">
282 <xsl:text>
283 </xsl:text>
284 <xsl:element name="dependency">
285 <xsl:attribute name="status">
286 <xsl:value-of select="$status"/>
287 </xsl:attribute>
288 <xsl:attribute name="name">
289 <xsl:value-of select="translate(normalize-space(text()),' ','-')"/>
290 </xsl:attribute>
291 <xsl:attribute name="type">link</xsl:attribute>
292 </xsl:element>
293 </xsl:for-each>
294 </xsl:template>
295
296 <xsl:template match="listitem" mode="prec-dep">
297 <xsl:if test="preceding-sibling::listitem">
298 <xsl:text>
299 </xsl:text>
300 <xsl:element name="dependency">
301<!-- the dep on the preceding package used to be required for python.
302 It seems optional now -->
303 <xsl:attribute name="status">optional</xsl:attribute>
304 <xsl:attribute name="name">
305 <xsl:value-of select="preceding-sibling::listitem[1]//@linkend"/>
306 </xsl:attribute>
307 <xsl:attribute name="type">ref</xsl:attribute>
308 </xsl:element>
309 </xsl:if>
310 </xsl:template>
311
312 <xsl:template match="listitem" mode="perlmod-dep">
313 <xsl:param name="glue" select="'&#xA; '"/>
314 <xsl:choose>
315 <xsl:when test="para/xref|para[@id]/ulink">
316 <xsl:value-of select="$glue"/>
317 <xsl:element name="dependency">
318 <xsl:attribute name="status">
319 <xsl:choose>
320 <xsl:when
321 test="count(./para/text()[contains(string(),
322 'ptional')
323 ]
324 )&gt;0">optional</xsl:when>
325 <xsl:otherwise>required</xsl:otherwise>
326 </xsl:choose>
327 </xsl:attribute>
328 <xsl:attribute name="name">
329 <xsl:if test="para/xref">
330 <xsl:value-of select="para/xref/@linkend"/>
331 </xsl:if>
332 <xsl:if test="para/ulink">
333 <xsl:value-of select="para/@id"/>
334 </xsl:if>
335 </xsl:attribute>
336 <xsl:attribute name="type">
337 <xsl:if test="para/xref">ref</xsl:if>
338 <xsl:if test="para/ulink">link</xsl:if>
339 </xsl:attribute>
340 <xsl:apply-templates select="itemizedlist/listitem"
341 mode="perlmod-dep">
342 <xsl:sort select="position()"
343 data-type="number"
344 order="descending"/>
345 <xsl:with-param name="glue" select="concat($glue,' ')"/>
346 </xsl:apply-templates>
347 </xsl:element>
348 </xsl:when>
349 <xsl:otherwise>
350 <xsl:apply-templates select="itemizedlist/listitem"
351 mode="perlmod-dep">
352 <xsl:sort select="position()"
353 data-type="number"
354 order="descending"/>
355 <xsl:with-param name="glue" select="$glue"/>
356 </xsl:apply-templates>
357 </xsl:otherwise>
358 </xsl:choose>
359 </xsl:template>
360
361</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.