]> git.saurik.com Git - wxWidgets.git/blob - build/buildbot/tools/embedded.xsl
correct base for carbon is 10.6 max
[wxWidgets.git] / build / buildbot / tools / embedded.xsl
1 <?xml version="1.0" encoding="utf-8"?>
2
3 <!--
4 Name: embedded.xsl
5 Purpose: Used by check.sh for offline checking of the configuration.
6 Author: Mike Wetherell
7 Copyright: (c) 2007 Mike Wetherell
8 Licence: wxWindows licence
9 -->
10
11 <transform xmlns="http://www.w3.org/1999/XSL/Transform"
12 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
13 xmlns:XSL="XSL"
14 version="1.0">
15
16 <namespace-alias stylesheet-prefix="XSL" result-prefix="xsl"/>
17
18 <output indent="yes"/>
19
20 <variable
21 name="root"
22 select="//*[not(ancestor-or-self::*[name() != name(/*)])]"/>
23
24 <variable
25 name="includes"
26 select="$root[position() > 1]"/>
27
28 <variable
29 xmlns:func="http://exslt.org/functions"
30 name="top-level"
31 select="$root/xsl:import |
32 $root/xsl:include |
33 $root/xsl:attribute-set |
34 $root/xsl:character-map |
35 $root/xsl:decimal-format |
36 $root/xsl:function |
37 $root/xsl:import-schema |
38 $root/xsl:key |
39 $root/xsl:namespace-alias |
40 $root/xsl:output |
41 $root/xsl:param |
42 $root/xsl:preserve-space |
43 $root/xsl:strip-space |
44 $root/xsl:template |
45 $root/xsl:variable |
46 $root/func:function"/>
47
48 <template match="/">
49 <XSL:transform>
50 <copy-of select="$root/namespace::*"/>
51
52 <for-each select="$root/@xsl:*">
53 <attribute name="{local-name()}">
54 <value-of select="."/>
55 </attribute>
56 </for-each>
57
58 <for-each select="$top-level">
59 <if test="not(../ancestor::*/*[name() = name(current()) and @name = current()/@name])">
60 <apply-templates mode="copy-xsl" select="."/>
61 </if>
62 </for-each>
63
64 <apply-templates select="*"/>
65 </XSL:transform>
66 </template>
67
68 <template match="*">
69 <variable name="pattern">
70 <call-template name="coord-pattern"/>
71 </variable>
72
73 <variable name="is-xsl">
74 <call-template name="is-xsl"/>
75 </variable>
76
77 <XSL:template match="*[generate-id() = generate-id(document('', /){$pattern})]">
78 <copy-of select="namespace::*"/>
79 <choose>
80 <when test="$root/xsl:template[@name = name(current())]">
81 <call-template name="expand">
82 <with-param name="inside-xsl" select="$is-xsl = 'true'"/>
83 </call-template>
84 </when>
85 <when test="count($includes | .) = count($includes)">
86 <if test="node()">
87 <XSL:apply-templates select="node()"/>
88 </if>
89 </when>
90 <when test="count($top-level | .) != count($top-level)">
91 <call-template name="create-context"/>
92 </when>
93 </choose>
94 </XSL:template>
95
96 <if test="$is-xsl != 'true'">
97 <apply-templates select="node()"/>
98 </if>
99 </template>
100
101 <template match="text()"/>
102
103 <template match="@*">
104 <copy/>
105 </template>
106
107 <template mode="copy-xsl" match="*[//xsl:template[not(ancestor::*[name() != name(/*)])]/@name = name()]">
108 <choose>
109 <when test="ancestor::xsl:template[@name = name(current())]">
110 <copy>
111 <call-template name="copy-xsl-children"/>
112 </copy>
113 </when>
114 <otherwise>
115 <call-template name="expand">
116 <with-param name="inside-xsl" select="true()"/>
117 </call-template>
118 </otherwise>
119 </choose>
120 </template>
121
122 <template mode="copy-xsl" match="@*|node()">
123 <copy>
124 <call-template name="copy-xsl-children"/>
125 </copy>
126 </template>
127
128 <template name="copy-xsl-children">
129 <copy-of select="namespace::*"/>
130 <apply-templates mode="copy-xsl" select="@*|node()"/>
131 </template>
132
133 <template name="coord-pattern">
134 <param name="element" select="."/>
135
136 <for-each select="$element/ancestor-or-self::*">
137 <text>/*[</text>
138 <value-of select="count(preceding-sibling::*) + 1"/>
139 <text>]</text>
140 </for-each>
141 </template>
142
143 <template name="is-xsl">
144 <param name="element" select="."/>
145 <choose>
146 <when test="$element/self::xsl:*">
147 <value-of select="true()"/>
148 </when>
149 <otherwise>
150 <variable name="namespace" select="namespace-uri($element)"/>
151 <variable name="extension-namespaces">
152 <for-each select="$element/ancestor-or-self::*/@xsl:extension-element-prefixes">
153 <variable name="prefixes"
154 select="concat(' ', normalize-space(.), ' ')"/>
155 <variable name="namespaces"
156 select="../namespace::*[contains($prefixes, concat(' ', name(), ' ')) or
157 (name() = '' and contains($prefixes, ' #default '))]"/>
158 <value-of select="$namespaces[. = $namespace]"/>
159 </for-each>
160 </variable>
161 <value-of select="$extension-namespaces != ''"/>
162 </otherwise>
163 </choose>
164 </template>
165
166 <template name="expand">
167 <param name="inside-xsl"/>
168 <variable name="params" select="$root/xsl:template[@name = name(current())]/xsl:param"/>
169
170 <XSL:call-template name="{name()}">
171 <if test="node() and $params">
172 <XSL:with-param name="{$params[1]/@name}">
173 <choose>
174 <when test="$inside-xsl">
175 <apply-templates mode="copy-xsl" select="node()"/>
176 </when>
177 <otherwise>
178 <variable name="pattern">
179 <call-template name="coord-pattern"/>
180 </variable>
181 <XSL:apply-templates select="{$pattern}/node()"/>
182 </otherwise>
183 </choose>
184 </XSL:with-param>
185 </if>
186
187 <for-each select="@*">
188 <variable name="len" select="string-length(.)"/>
189 <choose>
190 <when test="substring(., 1, 1) = '{' and
191 substring(., $len, 1) = '}'">
192 <XSL:with-param name="{name()}"
193 select="{substring(., 2, $len - 2)}"/>
194 </when>
195 <otherwise>
196 <XSL:with-param name="{name()}">
197 <call-template name="avt"/>
198 </XSL:with-param>
199 </otherwise>
200 </choose>
201 </for-each>
202 </XSL:call-template>
203 </template>
204
205 <template name="create-context">
206 <param name="elements" select="ancestor-or-self::*
207 [last() - 1 > position()]
208 /preceding-sibling::xsl:variable | ."/>
209
210 <variable name="pattern">
211 <call-template name="coord-pattern">
212 <with-param name="element" select="$elements[1]"/>
213 </call-template>
214 </variable>
215
216 <variable name="parent-pattern">
217 <call-template name="coord-pattern">
218 <with-param name="element" select="$elements[1]/.."/>
219 </call-template>
220 </variable>
221
222 <XSL:for-each select="{$parent-pattern}/*">
223 <XSL:if test="count({$pattern} | .) = 1">
224 <variable name="is-xsl">
225 <call-template name="is-xsl">
226 <with-param name="element" select="$elements[1]"/>
227 </call-template>
228 </variable>
229 <choose>
230 <when test="$is-xsl = 'true'">
231 <apply-templates mode="copy-xsl" select="$elements[1]"/>
232 <if test="$elements[2]">
233 <call-template name="create-context">
234 <with-param name="elements" select="$elements[position() > 1]"/>
235 </call-template>
236 </if>
237 </when>
238 <otherwise>
239 <copy>
240 <apply-templates select="@*"/>
241 <if test="node()">
242 <XSL:apply-templates select="node()"/>
243 </if>
244 </copy>
245 </otherwise>
246 </choose>
247 </XSL:if>
248 </XSL:for-each>
249 </template>
250
251 <template name="before">
252 <param name="string"/>
253 <param name="target"/>
254
255 <variable name="apos">'</variable>
256 <variable name="quot">"</variable>
257
258 <variable name="posapos" select="string-length(substring-before(
259 concat($string, $apos), $apos))"/>
260 <variable name="posquot" select="string-length(substring-before(
261 concat($string, $quot), $quot))"/>
262 <variable name="postarg" select="string-length(substring-before(
263 concat($string, $target), $target))"/>
264
265 <choose>
266 <when test="$posapos = $postarg and $posquot = $postarg">
267 <value-of select="$string"/>
268 </when>
269 <when test="$posapos > $postarg and $posquot > $postarg">
270 <value-of select="substring($string, 1, $postarg)"/>
271 </when>
272 <otherwise>
273 <variable name="delim">
274 <choose>
275 <when test="$posquot > $posapos">'</when>
276 <otherwise>"</otherwise>
277 </choose>
278 </variable>
279
280 <value-of select="substring-before($string, $delim)"/>
281 <value-of select="$delim"/>
282
283 <variable name="mid" select="substring-after($string, $delim)"/>
284
285 <choose>
286 <when test="contains($mid, $delim)">
287 <value-of select="substring-before($mid, $delim)"/>
288 <value-of select="$delim"/>
289
290 <call-template name="before">
291 <with-param name="string"
292 select="substring-after($mid, $delim)"/>
293 <with-param name="target"
294 select="$target"/>
295 </call-template>
296 </when>
297 <otherwise>
298 <value-of select="$mid"/>
299 </otherwise>
300 </choose>
301 </otherwise>
302 </choose>
303 </template>
304
305 <template name="avt">
306 <param name="string" select="."/>
307
308 <variable name="before1" select="substring-before(concat($string, '{'), '{')"/>
309 <variable name="len1" select="string-length($before1)"/>
310
311 <variable name="before2" select="substring-before(concat($string, '}}'), '}}')"/>
312 <variable name="len2" select="string-length($before2)"/>
313
314 <choose>
315 <when test="$before1 = $string and $before2 = $string">
316 <value-of select="$string"/>
317 </when>
318 <when test="$len2 &lt; $len1">
319 <value-of select="$before2"/>
320 <text>}</text>
321 <call-template name="avt">
322 <with-param name="string" select="substring($string, $len2 + 3)"/>
323 </call-template>
324 </when>
325 <when test="substring($string, $len1 + 2, 1) = '{'">
326 <value-of select="$before1"/>
327 <text>{</text>
328 <call-template name="avt">
329 <with-param name="string" select="substring($string, $len1 + 3)"/>
330 </call-template>
331 </when>
332 <otherwise>
333 <variable name="mid" select="substring($string, $len1 + 2)"/>
334 <variable name="expr">
335 <call-template name="before">
336 <with-param name="string" select="$mid"/>
337 <with-param name="target">}</with-param>
338 </call-template>
339 </variable>
340 <value-of select="$before1"/>
341 <XSL:copy-of select="{$expr}"/>
342 <call-template name="avt">
343 <with-param name="string" select="substring($mid, string-length($expr) + 2)"/>
344 </call-template>
345 </otherwise>
346 </choose>
347 </template>
348
349 </transform>