1 <?xml version="1.0" encoding="utf-8"?>
5 Purpose: Used by check.sh for offline checking of the configuration.
7 Copyright: (c) 2007 Mike Wetherell
8 Licence: wxWindows licence
11 <transform xmlns="http://www.w3.org/1999/XSL/Transform"
12 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
16 <namespace-alias stylesheet-prefix="XSL" result-prefix="xsl"/>
18 <output indent="yes"/>
22 select="//*[not(ancestor-or-self::*[name() != name(/*)])]"/>
26 select="$root[position() > 1]"/>
29 xmlns:func="http://exslt.org/functions"
31 select="$root/xsl:import |
33 $root/xsl:attribute-set |
34 $root/xsl:character-map |
35 $root/xsl:decimal-format |
37 $root/xsl:import-schema |
39 $root/xsl:namespace-alias |
42 $root/xsl:preserve-space |
43 $root/xsl:strip-space |
46 $root/func:function"/>
50 <copy-of select="$root/namespace::*"/>
52 <for-each select="$root/@xsl:*">
53 <attribute name="{local-name()}">
54 <value-of select="."/>
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="."/>
64 <apply-templates select="*"/>
69 <variable name="pattern">
70 <call-template name="coord-pattern"/>
73 <variable name="is-xsl">
74 <call-template name="is-xsl"/>
77 <XSL:template match="*[generate-id() = generate-id(document('', /){$pattern})]">
78 <copy-of select="namespace::*"/>
80 <when test="$root/xsl:template[@name = name(current())]">
81 <call-template name="expand">
82 <with-param name="inside-xsl" select="$is-xsl = 'true'"/>
85 <when test="count($includes | .) = count($includes)">
87 <XSL:apply-templates select="node()"/>
90 <when test="count($top-level | .) != count($top-level)">
91 <call-template name="create-context"/>
96 <if test="$is-xsl != 'true'">
97 <apply-templates select="node()"/>
101 <template match="text()"/>
103 <template match="@*">
107 <template mode="copy-xsl" match="*[//xsl:template[not(ancestor::*[name() != name(/*)])]/@name = name()]">
109 <when test="ancestor::xsl:template[@name = name(current())]">
111 <call-template name="copy-xsl-children"/>
115 <call-template name="expand">
116 <with-param name="inside-xsl" select="true()"/>
122 <template mode="copy-xsl" match="@*|node()">
124 <call-template name="copy-xsl-children"/>
128 <template name="copy-xsl-children">
129 <copy-of select="namespace::*"/>
130 <apply-templates mode="copy-xsl" select="@*|node()"/>
133 <template name="coord-pattern">
134 <param name="element" select="."/>
136 <for-each select="$element/ancestor-or-self::*">
138 <value-of select="count(preceding-sibling::*) + 1"/>
143 <template name="is-xsl">
144 <param name="element" select="."/>
146 <when test="$element/self::xsl:*">
147 <value-of select="true()"/>
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]"/>
161 <value-of select="$extension-namespaces != ''"/>
166 <template name="expand">
167 <param name="inside-xsl"/>
168 <variable name="params" select="$root/xsl:template[@name = name(current())]/xsl:param"/>
170 <XSL:call-template name="{name()}">
171 <if test="node() and $params">
172 <XSL:with-param name="{$params[1]/@name}">
174 <when test="$inside-xsl">
175 <apply-templates mode="copy-xsl" select="node()"/>
178 <variable name="pattern">
179 <call-template name="coord-pattern"/>
181 <XSL:apply-templates select="{$pattern}/node()"/>
187 <for-each select="@*">
188 <variable name="len" select="string-length(.)"/>
190 <when test="substring(., 1, 1) = '{' and
191 substring(., $len, 1) = '}'">
192 <XSL:with-param name="{name()}"
193 select="{substring(., 2, $len - 2)}"/>
196 <XSL:with-param name="{name()}">
197 <call-template name="avt"/>
205 <template name="create-context">
206 <param name="elements" select="ancestor-or-self::*
207 [last() - 1 > position()]
208 /preceding-sibling::xsl:variable | ."/>
210 <variable name="pattern">
211 <call-template name="coord-pattern">
212 <with-param name="element" select="$elements[1]"/>
216 <variable name="parent-pattern">
217 <call-template name="coord-pattern">
218 <with-param name="element" select="$elements[1]/.."/>
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]"/>
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]"/>
240 <apply-templates select="@*"/>
242 <XSL:apply-templates select="node()"/>
251 <template name="before">
252 <param name="string"/>
253 <param name="target"/>
255 <variable name="apos">'</variable>
256 <variable name="quot">"</variable>
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))"/>
266 <when test="$posapos = $postarg and $posquot = $postarg">
267 <value-of select="$string"/>
269 <when test="$posapos > $postarg and $posquot > $postarg">
270 <value-of select="substring($string, 1, $postarg)"/>
273 <variable name="delim">
275 <when test="$posquot > $posapos">'</when>
276 <otherwise>"</otherwise>
280 <value-of select="substring-before($string, $delim)"/>
281 <value-of select="$delim"/>
283 <variable name="mid" select="substring-after($string, $delim)"/>
286 <when test="contains($mid, $delim)">
287 <value-of select="substring-before($mid, $delim)"/>
288 <value-of select="$delim"/>
290 <call-template name="before">
291 <with-param name="string"
292 select="substring-after($mid, $delim)"/>
293 <with-param name="target"
298 <value-of select="$mid"/>
305 <template name="avt">
306 <param name="string" select="."/>
308 <variable name="before1" select="substring-before(concat($string, '{'), '{')"/>
309 <variable name="len1" select="string-length($before1)"/>
311 <variable name="before2" select="substring-before(concat($string, '}}'), '}}')"/>
312 <variable name="len2" select="string-length($before2)"/>
315 <when test="$before1 = $string and $before2 = $string">
316 <value-of select="$string"/>
318 <when test="$len2 < $len1">
319 <value-of select="$before2"/>
321 <call-template name="avt">
322 <with-param name="string" select="substring($string, $len2 + 3)"/>
325 <when test="substring($string, $len1 + 2, 1) = '{'">
326 <value-of select="$before1"/>
328 <call-template name="avt">
329 <with-param name="string" select="substring($string, $len1 + 3)"/>
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>
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)"/>