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 | <xsl:choose>
|
---|
40 | <xsl:when test="$multibuild = 'true'">
|
---|
41 | <xsl:variable name="currentbits" select="substring-before(concat($bits, ','), ',')" />
|
---|
42 | <xsl:variable name="remainingbits" select="substring-after($bits, ',')" />
|
---|
43 | <xsl:call-template name="package-stub">
|
---|
44 | <xsl:with-param name="id" select="$id" />
|
---|
45 | <xsl:with-param name="idsuffix">
|
---|
46 | <xsl:if test="$remainingbits">
|
---|
47 | <xsl:value-of select="concat('-', $currentbits)" />
|
---|
48 | </xsl:if>
|
---|
49 | </xsl:with-param>
|
---|
50 | <xsl:with-param name="bits" select="substring-before(concat($bits, ','), ',')" />
|
---|
51 | <xsl:with-param name="multi"><xsl:text>multi</xsl:text></xsl:with-param>
|
---|
52 | </xsl:call-template>
|
---|
53 | <xsl:if test="$remainingbits">
|
---|
54 | <xsl:text>
|
---|
55 |
|
---|
56 | </xsl:text>
|
---|
57 | <xsl:call-template name="package-iterator">
|
---|
58 | <xsl:with-param name="id" select="$id" />
|
---|
59 | <xsl:with-param name="multibuild" select="$multibuild" />
|
---|
60 | <xsl:with-param name="bits" select="$remainingbits" />
|
---|
61 | </xsl:call-template>
|
---|
62 | </xsl:if>
|
---|
63 | </xsl:when>
|
---|
64 | <xsl:otherwise>
|
---|
65 | <xsl:call-template name="package-stub">
|
---|
66 | <xsl:with-param name="id" select="$id" />
|
---|
67 | <xsl:with-param name="idsuffix" />
|
---|
68 | <xsl:with-param name="bits" select="substring-before(concat($bits, ','), ',')" />
|
---|
69 | <xsl:with-param name="multi"><xsl:text>single</xsl:text></xsl:with-param>
|
---|
70 | </xsl:call-template>
|
---|
71 | </xsl:otherwise>
|
---|
72 | </xsl:choose>
|
---|
73 | </xsl:template>
|
---|
74 |
|
---|
75 | <xsl:template name="package-stub">
|
---|
76 | <xsl:param name="id" /> <!-- Base ID of the resulting package -->
|
---|
77 | <xsl:param name="idsuffix" /> <!-- Suffix to attach to the end of the ID for this perticular instance -->
|
---|
78 | <xsl:param name="bits" /> <!-- Which bit sizes to create a package for -->
|
---|
79 | <xsl:param name="multi" /> <!-- multi/single build -->
|
---|
80 |
|
---|
81 | <xsl:for-each select="sect1">
|
---|
82 | <xsl:copy>
|
---|
83 | <xsl:attribute name="id">
|
---|
84 | <xsl:value-of select="concat($id, $idsuffix)" />
|
---|
85 | </xsl:attribute>
|
---|
86 | <xsl:attribute name="role">
|
---|
87 | <xsl:text>package</xsl:text>
|
---|
88 | </xsl:attribute>
|
---|
89 | <xsl:attribute name="condition">
|
---|
90 | <xsl:value-of select="$multi" />
|
---|
91 | </xsl:attribute>
|
---|
92 | <xsl:processing-instruction name="dbhtml">
|
---|
93 | <xsl:text>filename="</xsl:text>
|
---|
94 | <xsl:value-of select="concat($id, $idsuffix)" />
|
---|
95 | <xsl:text>.html"</xsl:text>
|
---|
96 | </xsl:processing-instruction>
|
---|
97 | <xsl:choose>
|
---|
98 | <xsl:when test="$bits = '32'">
|
---|
99 | <xsl:apply-templates select="@*|node()" mode="filter-bits-32" />
|
---|
100 | </xsl:when>
|
---|
101 | <xsl:when test="$bits = 'n32'">
|
---|
102 | <xsl:apply-templates select="@*|node()" mode="filter-bits-n32" />
|
---|
103 | </xsl:when>
|
---|
104 | <xsl:when test="$bits = '64'">
|
---|
105 | <xsl:apply-templates select="@*|node()" mode="filter-bits-64" />
|
---|
106 | </xsl:when>
|
---|
107 | </xsl:choose>
|
---|
108 | </xsl:copy>
|
---|
109 | </xsl:for-each>
|
---|
110 | </xsl:template>
|
---|
111 |
|
---|
112 | <!-- Apply the profile to the 32bit package -->
|
---|
113 |
|
---|
114 | <xsl:template match="//sect1/title" mode="filter-bits-32">
|
---|
115 | <xsl:element name="title">
|
---|
116 | <xsl:copy-of select="@*|node()" />
|
---|
117 | <xsl:if test="contains($clfs.multilib, ',')">
|
---|
118 | <xsl:text> - 32Bit</xsl:text>
|
---|
119 | </xsl:if>
|
---|
120 | </xsl:element>
|
---|
121 | </xsl:template>
|
---|
122 |
|
---|
123 | <xsl:template match="@*|node()" mode="filter-bits-32">
|
---|
124 | <xsl:variable name="ismultilib">
|
---|
125 | <xsl:choose>
|
---|
126 | <xsl:when test="contains($clfs.multilib, ',')">
|
---|
127 | <xsl:text>true</xsl:text>
|
---|
128 | </xsl:when>
|
---|
129 | <xsl:otherwise>
|
---|
130 | <xsl:text>false</xsl:text>
|
---|
131 | </xsl:otherwise>
|
---|
132 | </xsl:choose>
|
---|
133 | </xsl:variable>
|
---|
134 | <xsl:if test="(string-length(@c:arch) = 0) or contains(concat(',',@c:arch,','), concat(',', $clfs.arch, ','))">
|
---|
135 | <xsl:if test="(string-length(@c:multilib) = 0) or contains(concat(',',@c:multilib,','), concat(',', $ismultilib, ','))">
|
---|
136 | <xsl:if test="(string-length(@c:bits) = 0) or contains(concat(',',@c:bits,','), ',32,')">
|
---|
137 | <xsl:copy>
|
---|
138 | <xsl:apply-templates select="@*|node()" mode="filter-bits-32" />
|
---|
139 | </xsl:copy>
|
---|
140 | </xsl:if>
|
---|
141 | </xsl:if>
|
---|
142 | </xsl:if>
|
---|
143 | </xsl:template>
|
---|
144 |
|
---|
145 | <xsl:template match="@c:arch" mode="filter-bits-32" />
|
---|
146 | <xsl:template match="@c:bits" mode="filter-bits-32" />
|
---|
147 | <xsl:template match="@c:multilib" mode="filter-bits-32" />
|
---|
148 |
|
---|
149 | <!-- Apply the profile to the n32 package -->
|
---|
150 |
|
---|
151 | <xsl:template match="//sect1/title" mode="filter-bits-n32">
|
---|
152 | <xsl:element name="title">
|
---|
153 | <xsl:copy-of select="@*|node()" />
|
---|
154 | <xsl:if test="contains($clfs.multilib, ',')">
|
---|
155 | <xsl:text> - N32</xsl:text>
|
---|
156 | </xsl:if>
|
---|
157 | </xsl:element>
|
---|
158 | </xsl:template>
|
---|
159 |
|
---|
160 | <xsl:template match="@*|node()" mode="filter-bits-n32">
|
---|
161 | <xsl:variable name="ismultilib">
|
---|
162 | <xsl:choose>
|
---|
163 | <xsl:when test="contains($clfs.multilib, ',')">
|
---|
164 | <xsl:text>true</xsl:text>
|
---|
165 | </xsl:when>
|
---|
166 | <xsl:otherwise>
|
---|
167 | <xsl:text>false</xsl:text>
|
---|
168 | </xsl:otherwise>
|
---|
169 | </xsl:choose>
|
---|
170 | </xsl:variable>
|
---|
171 | <xsl:if test="(string-length(@c:arch) = 0) or contains(concat(',',@c:arch,','), concat(',', $clfs.arch, ','))">
|
---|
172 | <xsl:if test="(string-length(@c:multilib) = 0) or contains(concat(',',@c:multilib,','), concat(',', $ismultilib, ','))">
|
---|
173 | <xsl:if test="(string-length(@c:bits) = 0) or contains(concat(',',@c:bits,','), ',n32,')">
|
---|
174 | <xsl:copy>
|
---|
175 | <xsl:apply-templates select="@*|node()" mode="filter-bits-n32" />
|
---|
176 | </xsl:copy>
|
---|
177 | </xsl:if>
|
---|
178 | </xsl:if>
|
---|
179 | </xsl:if>
|
---|
180 | </xsl:template>
|
---|
181 |
|
---|
182 | <xsl:template match="@c:arch" mode="filter-bits-n32" />
|
---|
183 | <xsl:template match="@c:bits" mode="filter-bits-n32" />
|
---|
184 | <xsl:template match="@c:multilib" mode="filter-bits-n32" />
|
---|
185 |
|
---|
186 | <!-- Apply the profile to the 64bit package -->
|
---|
187 |
|
---|
188 | <xsl:template match="//sect1/title" mode="filter-bits-64">
|
---|
189 | <xsl:element name="title">
|
---|
190 | <xsl:copy-of select="@*|node()" />
|
---|
191 | <xsl:if test="contains($clfs.multilib, ',')">
|
---|
192 | <xsl:text> - 64Bit</xsl:text>
|
---|
193 | </xsl:if>
|
---|
194 | </xsl:element>
|
---|
195 | </xsl:template>
|
---|
196 |
|
---|
197 | <xsl:template match="@*|node()" mode="filter-bits-64">
|
---|
198 | <xsl:variable name="ismultilib">
|
---|
199 | <xsl:choose>
|
---|
200 | <xsl:when test="contains($clfs.multilib, ',')">
|
---|
201 | <xsl:text>true</xsl:text>
|
---|
202 | </xsl:when>
|
---|
203 | <xsl:otherwise>
|
---|
204 | <xsl:text>false</xsl:text>
|
---|
205 | </xsl:otherwise>
|
---|
206 | </xsl:choose>
|
---|
207 | </xsl:variable>
|
---|
208 | <xsl:if test="(string-length(@c:arch) = 0) or contains(concat(',',@c:arch,','), concat(',', $clfs.arch, ','))">
|
---|
209 | <xsl:if test="(string-length(@c:multilib) = 0) or contains(concat(',',@c:multilib,','), concat(',', $ismultilib, ','))">
|
---|
210 | <xsl:if test="(string-length(@c:bits) = 0) or contains(concat(',',@c:bits,','), ',64,')">
|
---|
211 | <xsl:copy>
|
---|
212 | <xsl:apply-templates select="@*|node()" mode="filter-bits-64" />
|
---|
213 | </xsl:copy>
|
---|
214 | </xsl:if>
|
---|
215 | </xsl:if>
|
---|
216 | </xsl:if>
|
---|
217 | </xsl:template>
|
---|
218 |
|
---|
219 | <xsl:template match="@c:arch" mode="filter-bits-64" />
|
---|
220 | <xsl:template match="@c:bits" mode="filter-bits-64" />
|
---|
221 | <xsl:template match="@c:multilib" mode="filter-bits-64" />
|
---|
222 |
|
---|
223 | <!-- Apply the profile filter to the entire document -->
|
---|
224 | <xsl:template match="//*[@c:arch]|//*[@c:multilib]">
|
---|
225 | <xsl:variable name="ismultilib">
|
---|
226 | <xsl:choose>
|
---|
227 | <xsl:when test="contains($clfs.multilib, ',')">
|
---|
228 | <xsl:text>true</xsl:text>
|
---|
229 | </xsl:when>
|
---|
230 | <xsl:otherwise>
|
---|
231 | <xsl:text>false</xsl:text>
|
---|
232 | </xsl:otherwise>
|
---|
233 | </xsl:choose>
|
---|
234 | </xsl:variable>
|
---|
235 | <xsl:if test="(string-length(@c:arch) = 0) or contains(concat(',',@c:arch,','), concat(',', $clfs.arch, ','))">
|
---|
236 | <xsl:if test="(string-length(@c:multilib) = 0) or contains(concat(',',@c:multilib,','), concat(',', $ismultilib, ','))">
|
---|
237 | <xsl:copy>
|
---|
238 | <xsl:apply-templates select="@*|node()" />
|
---|
239 | </xsl:copy>
|
---|
240 | </xsl:if>
|
---|
241 | </xsl:if>
|
---|
242 | </xsl:template>
|
---|
243 |
|
---|
244 | <!-- Remove the profileing attributes for the remaining objects -->
|
---|
245 | <xsl:template match="@c:arch" />
|
---|
246 | <xsl:template match="@c:bits" />
|
---|
247 | <xsl:template match="@c:multilib" />
|
---|
248 |
|
---|
249 | </xsl:stylesheet>
|
---|