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