|
1 <?xml version="1.0"?> |
|
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://www.w3.org/1999/XSL/Transform-" version="1.0" |
|
3 xmlns:s="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" |
|
4 xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:exslt="http://exslt.org/common"> |
|
5 <xsl:output method="xml" indent="yes"/> |
|
6 <xsl:param name="Model-Transform" select="'draw.xsl'"/> <!-- the location of the model.xsl relative to where the *output* of this transform is stored--> |
|
7 <xsl:param name="Verbose" select="0"/> <!-- Verbosity level of messages. Set to 1 (or higher) to get runtime comments --> |
|
8 <xsl:namespace-alias stylesheet-prefix="a" result-prefix="xsl"/> |
|
9 |
|
10 <xsl:variable name="color" select="/model/layout/info[@type='color']"/> |
|
11 <xsl:variable name="borders" select="/model/layout/info[@type='border']"/> |
|
12 <xsl:variable name="overlay" select="/model/layout/info[@type='overlay']"/> |
|
13 <xsl:variable name="style" select="/model/layout/info[@type='style']"/> |
|
14 |
|
15 <xsl:template name="make-match-list"><xsl:param name="list"/><xsl:param name="suffix"/> |
|
16 <xsl:choose> |
|
17 <xsl:when test="0"/> |
|
18 </xsl:choose> |
|
19 <xsl:value-of select="concat(substring-before(concat($list,' '),' '),$suffix)"/> |
|
20 <xsl:if test="contains($list,' ')"> |
|
21 <xsl:text>|</xsl:text> |
|
22 <xsl:call-template name="make-match-list"> |
|
23 <xsl:with-param name="list" select="substring-after($list,' ')"/> |
|
24 <xsl:with-param name="suffix" select="$suffix"/> |
|
25 </xsl:call-template> |
|
26 </xsl:if> |
|
27 </xsl:template> |
|
28 |
|
29 <xsl:template match="/model"> |
|
30 <a:stylesheet version="1.0" exclude-result-prefixes="s exslt"> |
|
31 <xsl:for-each select="document(@shapes,.)/shapes/namespace::*"><xsl:copy-of select="."/></xsl:for-each> |
|
32 <a:include href="{$Model-Transform}"/> |
|
33 <xsl:apply-templates select="document(@shapes,.)/*"/> |
|
34 |
|
35 <!-- this is a bit redundant: i think it's only necessary for the cmp. Either that or it can be used for the component, and the stuff to |
|
36 make the defaults for all components should be removed from model.xsl --> |
|
37 <xsl:if test="$borders"> <!-- if there are borders defined in the model.xml, use those to shape the cmp borders, not the shapes.xml --> |
|
38 <!-- default border --> |
|
39 <xsl:for-each select="document($borders/@href,$borders)/values/@default"> |
|
40 <!-- if the default is a type, create the actual reference. If it's a reference leave it alone --> |
|
41 <!-- this can only ever apply to components, so ignore any other rank --> |
|
42 <a:template match="component[not(@generator-border)]|cmp[not(@generator-border)]" mode="shape"> |
|
43 <xsl:if test="not(starts-with(.,'#'))">#Border</xsl:if> |
|
44 <xsl:value-of select="."/> |
|
45 </a:template> |
|
46 </xsl:for-each> |
|
47 </xsl:if> |
|
48 |
|
49 <xsl:if test="$overlay"> <!-- if there are patterns defined in the model.xml, use those to shape the cmp overlays, not the shapes.xml |
|
50 this should always have higher priority than templates from the shapes.xml --> |
|
51 <!-- default overlay (usually there will be no default))--> |
|
52 <xsl:for-each select="document($overlay/@href,$overlay)/values/@default"> |
|
53 <!-- if the default is a type, create the actual reference. If it's a reference leave it alone --> |
|
54 <xsl:variable name="match"> |
|
55 <xsl:call-template name="make-match-list"> |
|
56 <xsl:with-param name="list"> |
|
57 <xsl:value-of select="normalize-space(../@rank)"/> |
|
58 <xsl:if test="not(../@rank)">*</xsl:if> |
|
59 <xsl:if test="../@rank = 'component'"> cmp</xsl:if> |
|
60 </xsl:with-param> |
|
61 <xsl:with-param name="suffix">[not(@generator-overlay|meta/generator-overlay)]</xsl:with-param> |
|
62 </xsl:call-template> |
|
63 </xsl:variable> |
|
64 <a:template match="{$match}" mode="overlays" priority="1"> |
|
65 <o> |
|
66 <xsl:if test="not(starts-with(.,'#'))">#Pattern</xsl:if> |
|
67 <xsl:value-of select="."/> |
|
68 </o> |
|
69 </a:template> |
|
70 </xsl:for-each> |
|
71 </xsl:if> |
|
72 |
|
73 <xsl:if test="$color"> |
|
74 <xsl:for-each select="document($color/@href,$color)/values/@default"> |
|
75 <xsl:variable name="match"> |
|
76 <xsl:call-template name="make-match-list"> |
|
77 <xsl:with-param name="list"> |
|
78 <xsl:value-of select="normalize-space(../@rank)"/> |
|
79 <xsl:if test="not(../@rank)">*</xsl:if> |
|
80 <xsl:if test="../@rank = 'component'"> cmp</xsl:if> |
|
81 </xsl:with-param> |
|
82 <xsl:with-param name="suffix">[not(@generator-color|meta/generator-color)]</xsl:with-param> |
|
83 </xsl:call-template> |
|
84 </xsl:variable> |
|
85 <a:template match="{$match}" mode="display-style-color" priority="1"> |
|
86 <xsl:value-of select="."/> |
|
87 </a:template> |
|
88 </xsl:for-each> |
|
89 </xsl:if> |
|
90 |
|
91 <!-- values files with styles override any styles in the shapes file |
|
92 Also if there are no styles in the shapes file, don't try to look for them --> |
|
93 <xsl:if test="not(document(@shapes)/shapes/styles) or layout/info[@type='style' and @href]"> |
|
94 <a:template match="component" mode="display-style-aux"/> <!-- no default styles --> |
|
95 </xsl:if> |
|
96 |
|
97 <xsl:for-each select="link[@expr] | layout/link[@expr]"> <!-- link should be in the layout section, but in earlier version was diretcly under model. Support both --> |
|
98 <xsl:variable name="extra"> |
|
99 <xsl:call-template name="computed-values"> |
|
100 <xsl:with-param name="text" select="@expr"/> |
|
101 </xsl:call-template> |
|
102 </xsl:variable> |
|
103 <a:template mode="has-link"> |
|
104 <xsl:attribute name="match"> |
|
105 <xsl:text>*[@id</xsl:text> |
|
106 <xsl:if test="$extra!=''"> and (<xsl:value-of select="$extra"/>)</xsl:if> |
|
107 <xsl:text>]</xsl:text> |
|
108 </xsl:attribute> |
|
109 <xsl:text>1</xsl:text> |
|
110 </a:template> |
|
111 |
|
112 <a:template mode="link-label"> |
|
113 <xsl:attribute name="match"> |
|
114 <xsl:text>*[@id</xsl:text> |
|
115 <xsl:if test="$extra!=''"> and (<xsl:value-of select="$extra"/>)</xsl:if> |
|
116 <xsl:text>]</xsl:text> |
|
117 </xsl:attribute> |
|
118 <a:attribute name="target"> |
|
119 <xsl:value-of select="@target"/> |
|
120 <xsl:if test="not(@target)">details</xsl:if> |
|
121 </a:attribute> |
|
122 <xsl:if test="@title"> |
|
123 <a:attribute name="title"> |
|
124 <xsl:value-of select="@title"/> |
|
125 </a:attribute> |
|
126 </xsl:if> |
|
127 <a:attribute name="xlink:href"> |
|
128 <xsl:call-template name="computed-label"> |
|
129 <xsl:with-param name="text" select="@expr"/> |
|
130 </xsl:call-template> |
|
131 </a:attribute> |
|
132 </a:template> |
|
133 </xsl:for-each> |
|
134 |
|
135 <a:template match="SystemDefinition" mode="shapes"> |
|
136 <xsl:variable name="defs" select="s:defs"/> <!-- all defs in the shapes document --> |
|
137 <!-- check the overlay docs for all referred IDs. Make a list of all that are not defined the shapes doc --> |
|
138 <xsl:variable name="undefinedP"> |
|
139 <xsl:for-each select="document($overlay/@href)/*"> |
|
140 <xsl:for-each select="@default | //item/@value"> |
|
141 <xsl:value-of select="concat(' ',.,' ')"/> |
|
142 </xsl:for-each> |
|
143 </xsl:for-each> |
|
144 <xsl:for-each select="document(@shapes)/shapes/patterns/overlay[@type]"> |
|
145 <xsl:value-of select="concat(' ',@type,' ')"/> |
|
146 </xsl:for-each> |
|
147 </xsl:variable> |
|
148 <!-- check the borders docs for all referred IDs. Make a list of all that are not defined the shapes doc --> |
|
149 <xsl:variable name="undefinedB"> |
|
150 <xsl:for-each select="document($borders/@href)/*"> |
|
151 <xsl:for-each select="@default | //item/@value"> |
|
152 <xsl:value-of select="concat(' ',.,' ')"/> |
|
153 </xsl:for-each> |
|
154 </xsl:for-each> |
|
155 <xsl:for-each select="document(@shapes)/shapes/borders/border/@type"> |
|
156 <xsl:value-of select="concat(' ',.,' ')"/> |
|
157 </xsl:for-each> |
|
158 </xsl:variable> |
|
159 |
|
160 <!-- ignore all patterns not defined: should make a warning eventually. |
|
161 Also nice to check to see if any ref'd ID's (eg #xxx) are defined --> |
|
162 |
|
163 <!-- no 'reference' pattern defined, so use the default one --> |
|
164 <xsl:if test="contains($undefinedP,' radial-grad ')"><a:call-template name="default-new-pattern"/></xsl:if> |
|
165 <!-- no 'new' pattern defined, so use the default one --> |
|
166 <xsl:if test="contains($undefinedP,' striped-diag-up ')"><a:call-template name="default-ref-pattern"/></xsl:if> |
|
167 <!-- no 'deprecated' pattern defined, so use the default one --> |
|
168 <xsl:if test="contains($undefinedP,' big-X ')"><a:call-template name="default-X-pattern"/></xsl:if> |
|
169 |
|
170 <xsl:choose> <!-- can use navctrl patterns in style, so check and include if there --> |
|
171 <xsl:when test="contains($undefinedP,' outgrad ') or contains($undefinedP,' ingrad ')"> |
|
172 <a:call-template name="nav-control-patterns"/> |
|
173 </xsl:when> |
|
174 <xsl:otherwise> |
|
175 <a:if test="not(@static='true') and @navctrl"> |
|
176 <a:call-template name="nav-control-patterns"/> |
|
177 </a:if> |
|
178 </xsl:otherwise> |
|
179 </xsl:choose> |
|
180 |
|
181 <!-- borders defined --> |
|
182 <!-- if no borders were defined at all, throw in the default ones --> |
|
183 <xsl:if test="contains($undefinedB,' box ') or normalize-space($undefinedB)=''"><a:call-template name="default-box-border"/></xsl:if> |
|
184 <xsl:if test="contains($undefinedB,' box-clipLB ') or normalize-space($undefinedB)=''"><a:call-template name="default-clipLB-border"/></xsl:if> |
|
185 <xsl:if test="contains($undefinedB,' box-clipLT ') or normalize-space($undefinedB)=''"><a:call-template name="default-clipLT-border"/></xsl:if> |
|
186 <xsl:if test="contains($undefinedB,' box-clipRB ') or normalize-space($undefinedB)=''"><a:call-template name="default-clipRB-border"/></xsl:if> |
|
187 <xsl:if test="contains($undefinedB,' box-clipRT ') or normalize-space($undefinedB)=''"><a:call-template name="default-clipRT-border"/></xsl:if> |
|
188 <xsl:if test="contains($undefinedB,' box-clipAll ') or normalize-space($undefinedB)=''"><a:call-template name="default-clipAll-border"/></xsl:if> |
|
189 <xsl:if test="contains($undefinedB,' round ')"><a:call-template name="default-round-border"/></xsl:if> |
|
190 <xsl:if test="contains($undefinedB,' hexagon ')"><a:call-template name="default-hexagon-border"/></xsl:if> |
|
191 |
|
192 <xsl:for-each select="document(@shapes)/shapes"> |
|
193 <xsl:copy-of select="s:defs/*"/> |
|
194 <xsl:apply-templates select="borders|colors[@type!='background']|patterns" mode="defines"/> |
|
195 </xsl:for-each> |
|
196 |
|
197 |
|
198 </a:template> |
|
199 |
|
200 <a:template match="*[@label-ref]" mode="eval-label"> |
|
201 <!-- next two lines are hacks to ensure this works if called accidently from a node-set or wrong file--> |
|
202 <a:if test="not(ancestor::SystemDefinition) and @label"><a:value-of select="@label"/></a:if> |
|
203 <a:if test="not(ancestor::SystemDefinition) and not(@label)"><a:value-of select="."/></a:if> |
|
204 <a:variable name="id" select="@label-ref"/> |
|
205 <xsl:variable name="abbrevs" select="document(/model/layout/info/@href,/)/display-names//abbrev"/> <!-- the abbreviations list --> |
|
206 <a:for-each select="ancestor::SystemDefinition"> |
|
207 <a:choose> |
|
208 <xsl:apply-templates mode="make-label-eval" select="//legend[contains(@label,'}') and not(@literal='yes' or @literal='true')]"> |
|
209 <xsl:with-param name="abbrevs" select="$abbrevs"/> |
|
210 </xsl:apply-templates> |
|
211 <xsl:apply-templates mode="make-label-eval" select="//note[contains(.,'}') and not(@literal='yes' or @literal='true')]"> |
|
212 <xsl:with-param name="abbrevs" select="$abbrevs"/> |
|
213 </xsl:apply-templates> |
|
214 <xsl:for-each select="document(layout/info/@href | @shapes,.)"> |
|
215 <xsl:apply-templates mode="make-label-eval" select="//*[(contains(@label,'}') and not(@literal='yes' or @literal='true')) or @count]"> |
|
216 <xsl:with-param name="abbrevs" select="$abbrevs"/> |
|
217 </xsl:apply-templates> |
|
218 <xsl:apply-templates mode="make-label-eval" select="/shapes/examples/cmp[contains(text(),'}') and not(@literal='yes' or @literal='true')]"> |
|
219 <xsl:with-param name="abbrevs" select="$abbrevs"/> |
|
220 </xsl:apply-templates> |
|
221 </xsl:for-each> |
|
222 </a:choose> |
|
223 </a:for-each> |
|
224 </a:template> |
|
225 </a:stylesheet> |
|
226 </xsl:template> |
|
227 |
|
228 <xsl:template mode="make-label-count" match="*"/> |
|
229 <xsl:template mode="make-label-count" match="*[@value and @count]"><xsl:param name="abbrevs"/> |
|
230 <a:number format="{@count}"> |
|
231 <xsl:attribute name="value">count(key('use-<xsl:apply-templates select=".." mode="style-id"/>','<xsl:value-of select="@value"/>'))</xsl:attribute> |
|
232 <xsl:if test="$abbrevs/../@xml:lang"> |
|
233 <xsl:attribute name="lang"><xsl:value-of select="$abbrevs/../@xml:lang"/></xsl:attribute> |
|
234 </xsl:if> |
|
235 </a:number> |
|
236 </xsl:template> |
|
237 |
|
238 <xsl:template mode="make-label-count" match="*[@count and @rule]"><xsl:param name="abbrevs"/> |
|
239 <a:variable name="count"> |
|
240 <a:apply-templates> |
|
241 <xsl:attribute name="select"> |
|
242 <xsl:choose> |
|
243 <xsl:when test="not(../@match)">//component</xsl:when> <!-- the default --> |
|
244 <!-- this rest might not work in all cases --> |
|
245 <xsl:when test="contains(../@match,'|')"> |
|
246 <!-- this is ugly and might actually break some cases: just prefix all pipe-separated bits by // --> |
|
247 <xsl:text>//</xsl:text> |
|
248 <xsl:call-template name="replace"> |
|
249 <xsl:with-param name="text" select="../@match"/> |
|
250 <xsl:with-param name="from">|</xsl:with-param> |
|
251 <xsl:with-param name="to">|//</xsl:with-param> |
|
252 </xsl:call-template> |
|
253 </xsl:when> |
|
254 <xsl:otherwise>//<xsl:value-of select="../@match"/> <!-- should work, unless the path is something unexpected --> |
|
255 </xsl:otherwise> |
|
256 </xsl:choose> |
|
257 </xsl:attribute> |
|
258 <xsl:attribute name="mode">show-unused-<xsl:value-of select="concat(name(..),../@type)"/></xsl:attribute> |
|
259 <a:with-param name="n" select="$id"/> |
|
260 </a:apply-templates> |
|
261 </a:variable> |
|
262 <a:number format="{@count}" value="string-length($count)"> |
|
263 <xsl:if test="$abbrevs/../@xml:lang"> |
|
264 <xsl:attribute name="lang"><xsl:value-of select="$abbrevs/../@xml:lang"/></xsl:attribute> |
|
265 </xsl:if> |
|
266 </a:number> |
|
267 </xsl:template> |
|
268 |
|
269 <xsl:template mode="make-label-eval" match="*"><xsl:param name="abbrevs"/> |
|
270 <a:when> |
|
271 <xsl:attribute name="test">$id='<xsl:apply-templates select="." mode="style-id"/>'</xsl:attribute> |
|
272 <xsl:if test="@literal='yes' or @literal='true'"> |
|
273 <xsl:call-template name="local-label"><xsl:with-param name="abbrevs" select="$abbrevs"/></xsl:call-template> |
|
274 </xsl:if> |
|
275 <xsl:if test="not(@literal='yes' or @literal='true')"> |
|
276 <xsl:call-template name="computed-label"> |
|
277 <xsl:with-param name="text"> |
|
278 <xsl:call-template name="local-label"><xsl:with-param name="abbrevs" select="$abbrevs"/></xsl:call-template> |
|
279 </xsl:with-param> |
|
280 </xsl:call-template> |
|
281 </xsl:if> |
|
282 <xsl:apply-templates mode="make-label-count" select="."> |
|
283 <xsl:with-param name="abbrevs" select="$abbrevs"/> |
|
284 </xsl:apply-templates> |
|
285 </a:when> |
|
286 </xsl:template> |
|
287 |
|
288 <xsl:template name="local-label"><xsl:param name="abbrevs"/> |
|
289 <xsl:variable name="val"> |
|
290 <xsl:value-of select="@label"/> |
|
291 <xsl:if test="not(@label) and (self::cmp or self::note)"><xsl:value-of select="text()"/></xsl:if> |
|
292 </xsl:variable> |
|
293 <xsl:variable name="match" select="$abbrevs[@name=$val]"/> <!-- nothing will have an ID, so don't try to match --> |
|
294 <xsl:choose> |
|
295 <xsl:when test="$match"><xsl:value-of select="$match/@abbrev"/></xsl:when> |
|
296 <xsl:otherwise><xsl:value-of select="$val"/></xsl:otherwise> |
|
297 </xsl:choose> |
|
298 </xsl:template> |
|
299 |
|
300 |
|
301 <xsl:template name="computed-label"> <xsl:param name="text" select="@label"/> |
|
302 <xsl:choose> |
|
303 <xsl:when test="contains($text,'{')"> |
|
304 <a:text><xsl:value-of select="substring-before($text,'{')"/></a:text> |
|
305 <xsl:variable name="eval" select="substring-before(substring-after($text,'{'),'}')"/> |
|
306 <xsl:choose> |
|
307 <xsl:when test="starts-with($eval,'@') and string-length($eval)=string-length(translate($eval,'=/ *()[]','')) "> <!-- if this passes, then this will generally just be an attribute --> |
|
308 <a:apply-templates select="{$eval}" mode="as-text"/> |
|
309 </xsl:when> |
|
310 <xsl:otherwise><a:value-of select="{$eval}"/></xsl:otherwise> |
|
311 </xsl:choose> |
|
312 <xsl:call-template name="computed-label"> |
|
313 <xsl:with-param name="text" select="substring-after(substring-after($text,'{'),'}')"/> |
|
314 </xsl:call-template> |
|
315 </xsl:when> |
|
316 <xsl:when test="$text!=''"><a:text><xsl:value-of select="$text"/></a:text></xsl:when> |
|
317 </xsl:choose> |
|
318 </xsl:template> |
|
319 |
|
320 |
|
321 <xsl:template name="computed-values"><xsl:param name="text" select="@label"/><xsl:param name="join"> and </xsl:param> |
|
322 <xsl:if test="contains($text,'{')"> |
|
323 <xsl:value-of select="substring-before(substring-after($text,'{'),'}')"/> |
|
324 <xsl:if test="contains(substring-after(substring-after($text,'{'),'}'),'}')"> |
|
325 <xsl:value-of select="$join"/> |
|
326 <xsl:call-template name="computed-values"> |
|
327 <xsl:with-param name="text" select="substring-after(substring-after($text,'{'),'}')"/> |
|
328 </xsl:call-template> |
|
329 </xsl:if> |
|
330 </xsl:if> |
|
331 </xsl:template> |
|
332 |
|
333 |
|
334 |
|
335 <xsl:template match="/shapes"> |
|
336 <xsl:comment>Shapes</xsl:comment> |
|
337 <xsl:for-each select="styles|colors|patterns|borders"> |
|
338 <xsl:if test="@use or not(*)"> |
|
339 <xsl:variable name="id"><xsl:apply-templates select="." mode="style-id"/></xsl:variable> |
|
340 <a:key name="{name()}-{$id}" match="group[@style-id='{$id}']/*" use="@lookup"/> |
|
341 <xsl:choose> |
|
342 <xsl:when test="@use"> |
|
343 <a:key name="use-{$id}" > |
|
344 <xsl:copy-of select=" @use"/> |
|
345 <xsl:call-template name="match-syntax"/> |
|
346 </a:key> |
|
347 </xsl:when> |
|
348 </xsl:choose> |
|
349 </xsl:if> |
|
350 </xsl:for-each> |
|
351 |
|
352 <xsl:if test="not($borders)"> <!-- borders must be defined in shapes.xml or values files, never both--> |
|
353 <xsl:apply-templates select="borders"/> |
|
354 </xsl:if> |
|
355 |
|
356 <xsl:apply-templates select="colors"/> |
|
357 |
|
358 <xsl:apply-templates select="patterns"/> |
|
359 <xsl:for-each select="patterns"> |
|
360 <a:template match="*" mode="overlay-{1 + count(preceding::patterns)}" priority="-8"/> |
|
361 <a:template match="*" mode="show-unused-{name()}-{1 + count(preceding::patterns)}" priority="-8"/> |
|
362 </xsl:for-each> |
|
363 |
|
364 <xsl:if test="patterns"> |
|
365 <a:template match="*" mode="overlays"> |
|
366 <xsl:for-each select="patterns"> |
|
367 <a:apply-templates select="." mode="overlay-{position()}"/> |
|
368 </xsl:for-each> |
|
369 </a:template> |
|
370 <a:template match="*" mode="show-unused-patterns"><a:param name="n"/> |
|
371 <xsl:for-each select="patterns[(not(@show-unused='yes') or (*/@count)) and */@rule]"> |
|
372 <a:apply-templates select="." mode="show-unused-{name(.)}-{count(preceding::patterns) + 1}"> |
|
373 <a:with-param name="n" select="$n"/> |
|
374 </a:apply-templates> |
|
375 </xsl:for-each> |
|
376 </a:template> |
|
377 </xsl:if> |
|
378 |
|
379 |
|
380 <!-- concatenate all default styles for legend items --> |
|
381 <a:template match="cmp[not(@generated-style) and not(meta/generated-style)]" mode="display-style-aux"> |
|
382 <xsl:for-each select="styles/style[not(@rule|@value)]"><xsl:value-of select="."/>;</xsl:for-each> |
|
383 </a:template> |
|
384 |
|
385 <!-- create style attribute in the general case--> |
|
386 <a:template match="*" mode="display-style-aux"> |
|
387 <xsl:for-each select="styles"> |
|
388 <a:apply-templates select="." mode="display-style-{position()}"/> |
|
389 </xsl:for-each> |
|
390 </a:template> |
|
391 |
|
392 <!-- default to nothing for each style. This will be overriden later if necesssary --> |
|
393 <xsl:for-each select="styles"> |
|
394 <a:template match="*" mode="display-style-{position()}"/> |
|
395 </xsl:for-each> |
|
396 |
|
397 <xsl:apply-templates select="styles"/> |
|
398 |
|
399 <xsl:for-each select="(borders|styles|patterns|colors)[(not(@show-unused='yes') and not(*/@rule) and *[@label and not(@value)]) ]"> |
|
400 <!-- check to see if labelled defaults of a look-up list are shown --> |
|
401 <a:template> <!-- default match is component --> |
|
402 <xsl:call-template name="match-syntax"/> |
|
403 <xsl:attribute name="mode">show-unused-<xsl:value-of select="concat(name(),@type)"/> |
|
404 <xsl:if test="self::colors[not(@type)]">background</xsl:if> |
|
405 <xsl:if test="self::patterns">-<xsl:value-of select="count(preceding-sibling::patterns) + 1"/></xsl:if> |
|
406 </xsl:attribute> |
|
407 <a:param name="n"/> |
|
408 <a:if> |
|
409 <xsl:attribute name="test"><xsl:text>not(</xsl:text> |
|
410 <xsl:for-each select="*[@value]"><xsl:value-of select="../@use"/>='<xsl:value-of select="@value"/>'<xsl:if test="position()!=last()"> or </xsl:if></xsl:for-each> |
|
411 <xsl:text>)</xsl:text> |
|
412 </xsl:attribute>*</a:if> |
|
413 </a:template> |
|
414 </xsl:for-each> |
|
415 |
|
416 <!-- only needed for options with rule. Options with lookup values are checked elsewhere --> |
|
417 <xsl:for-each select="(borders|styles|patterns|colors)[(not(@show-unused='yes') or (*/@count)) and */@rule]"> |
|
418 <a:template> <!-- default match is component --> |
|
419 <xsl:call-template name="match-syntax"/> |
|
420 <xsl:attribute name="mode">show-unused-<xsl:value-of select="concat(name(),@type)"/> |
|
421 <xsl:if test="self::colors[not(@type)]">background</xsl:if> |
|
422 <xsl:if test="self::patterns">-<xsl:value-of select="count(preceding-sibling::patterns) + 1"/></xsl:if> |
|
423 </xsl:attribute> |
|
424 <a:param name="n"/> |
|
425 <xsl:call-template name="declare-vars"/> |
|
426 <a:choose> |
|
427 <xsl:for-each select="*[@rule]"> |
|
428 <a:when> |
|
429 <xsl:attribute name="test"><xsl:apply-templates select="." mode="when-test"/></xsl:attribute> |
|
430 <a:if> |
|
431 <xsl:attribute name="test">$n='<xsl:apply-templates select="." mode="style-id"/>'</xsl:attribute> |
|
432 <xsl:text>*</xsl:text> |
|
433 </a:if> |
|
434 </a:when> |
|
435 </xsl:for-each> |
|
436 <xsl:for-each select="*[not(@rule|@value)]"> |
|
437 <a:when> |
|
438 <xsl:attribute name="test">$n='<xsl:apply-templates select="." mode="style-id"/>'</xsl:attribute> |
|
439 <xsl:text>*</xsl:text> |
|
440 </a:when> |
|
441 </xsl:for-each> |
|
442 </a:choose> |
|
443 </a:template> |
|
444 </xsl:for-each> |
|
445 |
|
446 </xsl:template> |
|
447 |
|
448 <!-- remove all quoted parens --> |
|
449 <xsl:template name="replace-quotes"><xsl:param name="text" select="."/> |
|
450 <xsl:choose> |
|
451 <xsl:when test="contains($text,'"')"> |
|
452 <xsl:value-of select="substring-before($text,'"')"/> |
|
453 <xsl:text> </xsl:text> |
|
454 <xsl:value-of select="translate(substring-before(substring-after($text,'"'),'"'),'()',' ')"/> |
|
455 <xsl:text> </xsl:text> |
|
456 <xsl:call-template name="replace-quotes"> |
|
457 <xsl:with-param name="text" select="substring-after(substring-after($text,'"'),'"')"/> |
|
458 </xsl:call-template> |
|
459 </xsl:when> |
|
460 <xsl:when test='contains($text,"'")'> |
|
461 <xsl:value-of select='substring-before($text,"'")'/> |
|
462 <xsl:text> </xsl:text> |
|
463 <xsl:value-of select='translate(substring-before(substring-after($text,"'"),"'"),"()"," ")'/> |
|
464 <xsl:text> </xsl:text> |
|
465 <xsl:call-template name="replace-quotes"> |
|
466 <xsl:with-param name="text" select='substring-after(substring-after($text,"'"),"'")'/> |
|
467 </xsl:call-template> |
|
468 </xsl:when> |
|
469 <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise> |
|
470 </xsl:choose> |
|
471 </xsl:template> |
|
472 |
|
473 <!-- replace all instances of $from with $to --> |
|
474 <xsl:template name="replace"><xsl:param name="text"/><xsl:param name="from"/><xsl:param name="to"/> |
|
475 <xsl:choose> |
|
476 <xsl:when test="contains($text,$from)"> |
|
477 <xsl:value-of select="substring-before($text,$from)"/> |
|
478 <xsl:value-of select="$to"/> |
|
479 <xsl:call-template name="replace"> |
|
480 <xsl:with-param name="text" select="substring-after($text,$from)"/> |
|
481 <xsl:with-param name="from" select="$from"/> |
|
482 <xsl:with-param name="to" select="$to"/> |
|
483 </xsl:call-template> |
|
484 </xsl:when> |
|
485 <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise> |
|
486 </xsl:choose> |
|
487 </xsl:template> |
|
488 |
|
489 <xsl:template name="param-length"><xsl:param name="text"/> |
|
490 <xsl:variable name="close-idx" select="string-length(substring-before($text,')'))"/> |
|
491 <xsl:choose> |
|
492 <xsl:when test="not(contains($text,')'))"><xsl:message terminate="yes">badly-formatted funtion: <xsl:value-of select="$text"/></xsl:message></xsl:when> |
|
493 <xsl:when test="contains($text,'(')"> |
|
494 <xsl:variable name="open-idx" select="string-length(substring-before($text,'('))"/> |
|
495 <xsl:choose> |
|
496 <xsl:when test="$close-idx < $open-idx"><xsl:value-of select="$close-idx"/></xsl:when> |
|
497 <xsl:otherwise> |
|
498 <xsl:variable name="len"> |
|
499 <xsl:call-template name="param-length"> |
|
500 <xsl:with-param name="text" select="substring($text,2+$open-idx)"/> |
|
501 </xsl:call-template> |
|
502 </xsl:variable> |
|
503 <xsl:value-of select="2 + $open-idx + $len"/> |
|
504 </xsl:otherwise> |
|
505 </xsl:choose> |
|
506 </xsl:when> |
|
507 <xsl:otherwise><xsl:value-of select="$close-idx"/></xsl:otherwise> |
|
508 </xsl:choose> |
|
509 </xsl:template> |
|
510 |
|
511 |
|
512 <xsl:template name="need-current"><xsl:param name="arg"/> |
|
513 <xsl:variable name="bad">'/"</xsl:variable> |
|
514 <xsl:if test="translate(substring($arg,1,1),$bad,'')!='' ">current()/</xsl:if> |
|
515 </xsl:template> |
|
516 |
|
517 <xsl:template name="replace-function"><xsl:param name="text" select="."/> |
|
518 <xsl:param name="function" select="'VERSION'"/> |
|
519 <xsl:param name="before">count(exslt:node-set($Versions)/*[contains(concat(' ',.,' '),concat(' ',</xsl:param> |
|
520 <xsl:param name="after">,' '))]/preceding-sibling::*)</xsl:param> |
|
521 <xsl:param name="default">current()/ancestor::SystemDefinition/@ver</xsl:param> |
|
522 <xsl:param name="need-current" select="1"/> |
|
523 <xsl:param name="extra"/> |
|
524 <xsl:variable name="func" select="concat($function,'(')"/> |
|
525 <xsl:variable name="t"> |
|
526 <xsl:call-template name="replace-quotes"> |
|
527 <xsl:with-param name="text" select="$text"/> |
|
528 </xsl:call-template> |
|
529 </xsl:variable> |
|
530 <xsl:choose> |
|
531 <xsl:when test="contains($t,$func)"> |
|
532 <xsl:value-of select="substring($text,1,string-length(substring-before($t,$func)))"/> |
|
533 <xsl:variable name="pre" select="1 + string-length($func) + string-length(substring-before($t,$func))"/> |
|
534 <xsl:variable name="a" select="substring($t,$pre)"/> |
|
535 <xsl:variable name="r" select="substring($text,$pre)"/> |
|
536 <xsl:variable name="len"> |
|
537 <xsl:call-template name="param-length"> |
|
538 <xsl:with-param name="text" select="$a"/> |
|
539 </xsl:call-template> |
|
540 </xsl:variable> |
|
541 <xsl:variable name="arg"> |
|
542 <xsl:if test="$need-current"> |
|
543 <xsl:call-template name="need-current"> |
|
544 <xsl:with-param name="arg" select="substring($r,1,$len)"/> |
|
545 </xsl:call-template> |
|
546 </xsl:if> <!-- this needs work --> |
|
547 <xsl:value-of select="substring($r,1,$len)"/> |
|
548 </xsl:variable> |
|
549 <xsl:value-of select="$before"/> |
|
550 <xsl:choose> |
|
551 <xsl:when test="normalize-space($arg)=''"><xsl:value-of select="$default"/></xsl:when> |
|
552 <xsl:otherwise><xsl:value-of select="$arg"/></xsl:otherwise> |
|
553 </xsl:choose> |
|
554 <xsl:value-of select="$extra"/> |
|
555 <xsl:choose> |
|
556 <xsl:when test="$extra =''"/> |
|
557 <xsl:when test="normalize-space($arg)=''"><xsl:value-of select="$default"/></xsl:when> |
|
558 <xsl:otherwise><xsl:value-of select="$arg"/></xsl:otherwise> |
|
559 </xsl:choose> |
|
560 <xsl:value-of select="$after"/> |
|
561 <xsl:call-template name="replace-function"> |
|
562 <xsl:with-param name="text" select="substring($r,$len+2)"/> |
|
563 <xsl:with-param name="function" select="$function"/> |
|
564 <xsl:with-param name="before" select="$before"/> |
|
565 <xsl:with-param name="default" select="$default"/> |
|
566 <xsl:with-param name="after" select="$after"/> |
|
567 <xsl:with-param name="need-current" select="$need-current"/> |
|
568 <xsl:with-param name="extra" select="$extra"/> |
|
569 </xsl:call-template> |
|
570 </xsl:when> |
|
571 <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise> |
|
572 </xsl:choose> |
|
573 </xsl:template> |
|
574 |
|
575 <xsl:template match="*[@rule]" mode="varname"><xsl:value-of select="name()"/>-var-<xsl:value-of select="count(preceding::*[@variable])"/></xsl:template> |
|
576 <xsl:template match="*/@rule"><xsl:param name="text" select="."/> |
|
577 <xsl:variable name="fixed0"> |
|
578 <xsl:call-template name="replace-function"> |
|
579 <xsl:with-param name="text" select="$text"/> |
|
580 </xsl:call-template> |
|
581 </xsl:variable> |
|
582 <xsl:variable name="fixed1"> |
|
583 <xsl:call-template name="replace-function"> |
|
584 <xsl:with-param name="text" select="$fixed0"/> |
|
585 <xsl:with-param name="function">CLASS</xsl:with-param> |
|
586 <xsl:with-param name="before">contains(concat(' ',normalize-space(@class),' '),concat(' ',</xsl:with-param> |
|
587 <xsl:with-param name="default">1</xsl:with-param> |
|
588 <xsl:with-param name="after">,' '))</xsl:with-param> |
|
589 <xsl:with-param name="need-current" select="0"/> |
|
590 </xsl:call-template> |
|
591 </xsl:variable> |
|
592 <xsl:variable name="fixed2"> |
|
593 <xsl:call-template name="replace-function"> |
|
594 <xsl:with-param name="text" select="$fixed1"/> |
|
595 <xsl:with-param name="function">NAMESPACE</xsl:with-param> |
|
596 <xsl:with-param name="before">concat(ancestor-or-self::*/namespace::*[name()=substring-before(</xsl:with-param> |
|
597 <xsl:with-param name="extra">,':')],ancestor::SystemDefinition/@id-namespace[not(contains(</xsl:with-param> |
|
598 <xsl:with-param name="default">''</xsl:with-param> |
|
599 <xsl:with-param name="after">,':'))])</xsl:with-param> |
|
600 </xsl:call-template> |
|
601 </xsl:variable> |
|
602 <xsl:variable name="fixed"> |
|
603 <xsl:call-template name="replace-function"> |
|
604 <xsl:with-param name="text" select="$fixed2"/> |
|
605 <xsl:with-param name="function">VARIABLE</xsl:with-param> |
|
606 <xsl:with-param name="before"></xsl:with-param> |
|
607 <xsl:with-param name="default">$<xsl:apply-templates select=".." mode="varname"/></xsl:with-param> |
|
608 <xsl:with-param name="after"></xsl:with-param> |
|
609 <xsl:with-param name="need-current" select="0"/> |
|
610 </xsl:call-template> |
|
611 </xsl:variable> |
|
612 <xsl:value-of select="$fixed"/> |
|
613 </xsl:template> |
|
614 |
|
615 <!--=========== basic SVG definitions ==============--> |
|
616 |
|
617 |
|
618 <xsl:template match="color" mode="id"> |
|
619 <xsl:value-of select="concat(../@type,count(preceding::color[../@type]))"/> |
|
620 </xsl:template> |
|
621 |
|
622 <xsl:template match="overlay" mode="id">Pattern<xsl:choose> |
|
623 <xsl:when test="@type"><xsl:value-of select="@type"/></xsl:when> |
|
624 <xsl:otherwise>Overlay<xsl:value-of select="count(preceding::overlay)"/></xsl:otherwise> |
|
625 </xsl:choose> |
|
626 </xsl:template> |
|
627 |
|
628 <xsl:template match="border" mode="id">Border<xsl:choose> |
|
629 <xsl:when test="@type"><xsl:value-of select="@type"/></xsl:when> |
|
630 <xsl:otherwise>Shape<xsl:value-of select="count(preceding::border)"/></xsl:otherwise> |
|
631 </xsl:choose> |
|
632 </xsl:template> |
|
633 |
|
634 <!-- can explictly reference self-defined pattern or border: chop off starting # --> |
|
635 <xsl:template match="*[starts-with(@type,'#')]" mode="id" priority="1"><xsl:value-of select="substring(@type,2)"/></xsl:template> |
|
636 |
|
637 |
|
638 <xsl:template match="border[@value] | color[@value] | overlay[@value] | style[@value]" mode="when-test"> |
|
639 <xsl:if test="not(../@use)">.</xsl:if> |
|
640 <xsl:value-of select="../@use"/>='<xsl:value-of select="@value"/>'</xsl:template> |
|
641 |
|
642 <xsl:template match="border[@rule] |color[@rule] | overlay [@rule] | style[@rule]" mode="when-test"> |
|
643 <xsl:variable name="rule"><xsl:apply-templates select="@rule"/></xsl:variable> |
|
644 <xsl:choose> |
|
645 <xsl:when test="../@use">(<xsl:value-of select="../@use"/>)[<xsl:value-of select="$rule"/>]</xsl:when> |
|
646 <xsl:otherwise><xsl:value-of select="$rule"/></xsl:otherwise> |
|
647 </xsl:choose> |
|
648 </xsl:template> |
|
649 |
|
650 |
|
651 <xsl:template match="borders" mode="defines"> |
|
652 <!-- make symbols for all the (unique) borders --> |
|
653 <xsl:for-each select="border"> |
|
654 <xsl:if test="not(@type)"> |
|
655 <symbol> |
|
656 <xsl:attribute name="id"><xsl:apply-templates select="." mode="id"/></xsl:attribute> |
|
657 <xsl:apply-templates select="." mode="model"/> |
|
658 </symbol> |
|
659 </xsl:if> |
|
660 </xsl:for-each> |
|
661 |
|
662 <xsl:if test="$Verbose"> |
|
663 <xsl:if test="not(border[not(@value|@rule)])"><xsl:message>
warning: no default border</xsl:message></xsl:if> |
|
664 <xsl:if test="count(border[not(@value|@rule)]) > 1 "><xsl:message>
error: more than one default border</xsl:message></xsl:if> |
|
665 </xsl:if> |
|
666 </xsl:template> |
|
667 |
|
668 |
|
669 <xsl:template match="patterns" mode="defines"> |
|
670 <!-- make symbols for all the (unique) overlays --> |
|
671 <xsl:for-each select="*"> |
|
672 <xsl:if test="count(self::overlay/*) > 1 "><xsl:message>
error: more than one pattern in overlay</xsl:message></xsl:if> |
|
673 <xsl:for-each select="self::*[not(@type)]/*[1]"> <!-- should only be one --> |
|
674 <xsl:copy><xsl:copy-of select="@*"/> |
|
675 <xsl:attribute name="id"><xsl:apply-templates select=".." mode="id"/></xsl:attribute> |
|
676 <xsl:copy-of select="*"/> |
|
677 </xsl:copy> |
|
678 </xsl:for-each> |
|
679 </xsl:for-each> |
|
680 |
|
681 |
|
682 <xsl:if test="count(*[not(@value|@rule)]) > 1 "><xsl:message>
error: more than one default <xsl:value-of select="name(*)"/></xsl:message></xsl:if> |
|
683 |
|
684 </xsl:template> |
|
685 |
|
686 |
|
687 <xsl:template match="border" mode="model"> |
|
688 <xsl:copy-of select="@viewBox|*"/> |
|
689 </xsl:template> |
|
690 |
|
691 <!-- Borders --> |
|
692 <xsl:template match="borders"> |
|
693 <!-- add attributes to s:use element --> |
|
694 <a:template mode="shape" match="component"> |
|
695 <!-- <xsl:call-template name="match-syntax"/> only applies to components --> |
|
696 <xsl:call-template name="declare-vars"/> |
|
697 <xsl:variable name="id"><xsl:apply-templates select="." mode="style-id"/></xsl:variable> |
|
698 <xsl:choose> |
|
699 <xsl:when test="@use and not(border[@rule])"> |
|
700 <!-- no borders with rules, should all be default or value --> |
|
701 <a:variable name="c" select="key('{name()}-{$id}',{@use})/@value"/> |
|
702 <a:value-of select="$c"/> |
|
703 <a:if test="not($c)">#<xsl:apply-templates select="border[not(@value)][1]" mode="id"/></a:if> |
|
704 </xsl:when> |
|
705 <xsl:when test="border[@rule]"> |
|
706 <!-- at least one border has a rule --> |
|
707 <a:choose> |
|
708 <xsl:for-each select="border[@rule]"> |
|
709 <a:when> |
|
710 <xsl:attribute name="test"><xsl:apply-templates select="." mode="when-test"/></xsl:attribute> |
|
711 <xsl:text>#</xsl:text> |
|
712 <xsl:apply-templates select="." mode="id"/> |
|
713 </a:when> |
|
714 </xsl:for-each> |
|
715 <a:otherwise> |
|
716 <xsl:choose> |
|
717 <xsl:when test="@use"> |
|
718 <a:variable name="c" select="key('{name()}-{$id}',{@use})/@value"/> |
|
719 <a:value-of select="$c"/> |
|
720 <a:if test="not($c)">#<xsl:apply-templates select="border[not(@value)][1]" mode="id"/></a:if> |
|
721 </xsl:when> |
|
722 <xsl:when test="border[not(@value)]">#<xsl:apply-templates select="border[not(@value)][1]" mode="id"/></xsl:when> |
|
723 </xsl:choose> |
|
724 </a:otherwise> |
|
725 </a:choose> |
|
726 </xsl:when> |
|
727 <!-- no rules and no @use, must just have a single default --> |
|
728 <xsl:when test="border[not(@value)]">#<xsl:apply-templates select="border[not(@value)][1]" mode="id"/></xsl:when> |
|
729 </xsl:choose> |
|
730 </a:template> |
|
731 <xsl:if test="border[not(@value)]"> |
|
732 <a:template match="cmp" mode="shape"> |
|
733 <xsl:text>#</xsl:text><xsl:apply-templates select="border[not(@value)][1]" mode="id"/> |
|
734 </a:template> |
|
735 </xsl:if> |
|
736 </xsl:template> |
|
737 |
|
738 |
|
739 <!-- Colours --> |
|
740 |
|
741 |
|
742 <xsl:template match="colors[@type='highlight']" mode="defines"> |
|
743 <xsl:for-each select="color"> |
|
744 <xsl:variable name="id"><xsl:apply-templates select="." mode="id"/></xsl:variable> |
|
745 <filter id="{$id}" filterUnits="userSpaceOnUse"> |
|
746 <feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/> |
|
747 <feFlood flood-color="{@color}" flood-opacity="1" result="flood"/> |
|
748 <feComposite in2="blur" in="flood" operator="atop" result="comp" /> |
|
749 <feMerge> |
|
750 <feMergeNode in="comp"/><feMergeNode in="SourceGraphic"/> |
|
751 </feMerge> |
|
752 </filter> |
|
753 </xsl:for-each> |
|
754 </xsl:template> |
|
755 |
|
756 <xsl:template match="colors[@type='text-highlight']" mode="defines"> |
|
757 <xsl:for-each select="color"> |
|
758 <xsl:variable name="id"><xsl:apply-templates select="." mode="id"/></xsl:variable> |
|
759 <filter id="{$id}" filterUnits="userSpaceOnUse"> |
|
760 <feMorphology operator="dilate" in="SourceAlpha" radius="0.2" result="blur"/> |
|
761 <!-- <feGaussianBlur in="SourceAlpha" stdDeviation="0.8" result="blur"/> --> |
|
762 <feFlood flood-color="{@color}" flood-opacity="1" result="flood"/> |
|
763 <feComposite in2="blur" in="flood" operator="atop" result="comp" /> |
|
764 <feMerge><feMergeNode in="comp"/><feMergeNode in="SourceGraphic"/></feMerge> |
|
765 </filter> |
|
766 </xsl:for-each> |
|
767 </xsl:template> |
|
768 |
|
769 |
|
770 <xsl:template match="colors"> |
|
771 <a:template mode="{substring-before(@type,'highlight')}filter"> |
|
772 <xsl:call-template name="match-syntax"/> |
|
773 <xsl:call-template name="declare-vars"/> |
|
774 <a:choose> |
|
775 <xsl:for-each select="color[@value|@rule]"> |
|
776 <a:when> |
|
777 <xsl:attribute name="test"><xsl:apply-templates select="." mode="when-test"/></xsl:attribute> |
|
778 <a:attribute name="filter">url(#<xsl:apply-templates select="." mode="id"/>)</a:attribute> |
|
779 </a:when> |
|
780 </xsl:for-each> |
|
781 <xsl:for-each select="color[not(@value|@rule)]"> |
|
782 <a:otherwise><a:attribute name="filter">url(#<xsl:apply-templates select="." mode="id"/>)</a:attribute></a:otherwise> |
|
783 </xsl:for-each> |
|
784 </a:choose> |
|
785 </a:template> |
|
786 </xsl:template> |
|
787 |
|
788 <xsl:template name="color-select"> |
|
789 <xsl:param name="default"/> |
|
790 <xsl:variable name="id"><xsl:apply-templates select="." mode="style-id"/></xsl:variable> |
|
791 <a:variable name="c" select="key('{name()}-{$id}',{@use})/@value"/> |
|
792 <a:choose> |
|
793 <a:when test="not($c)"><xsl:value-of select="$default"/></a:when> |
|
794 <a:when test="count($c)=1"><a:value-of select="$c"/></a:when> |
|
795 <a:otherwise>url(#bg<a:apply-templates select="." mode="id"/>)</a:otherwise> |
|
796 </a:choose> |
|
797 </xsl:template> |
|
798 |
|
799 <xsl:template match="colors[@type='background' or not(@type)]" priority="1"> |
|
800 <xsl:variable name="default-color"> |
|
801 <xsl:choose> |
|
802 <xsl:when test="color[not(@value|@rule)]"><xsl:value-of select="color[not(@value|@rule)]/@color"/></xsl:when> |
|
803 <xsl:otherwise><xsl:value-of select="@default"/></xsl:otherwise> |
|
804 </xsl:choose> |
|
805 </xsl:variable> |
|
806 |
|
807 <!-- possible future enhancements: |
|
808 computed colour: expression to generate a comma-separated rgb tripple to be put inside "rgb(...)" --> |
|
809 |
|
810 <xsl:if test="@use"> |
|
811 <!-- multiple colours: if there are multiple match they'll appear as a gradient--> |
|
812 <a:template mode="multi-color"> |
|
813 <xsl:call-template name="match-syntax"/> |
|
814 <xsl:variable name="key"><xsl:value-of select="name()"/>-<xsl:apply-templates select="." mode="style-id"/></xsl:variable> |
|
815 <a:call-template name="multi-color-grad"> |
|
816 <xsl:choose> |
|
817 <xsl:when test="@spacing='proportional'"> <!-- as opposed to the default: fixed --> |
|
818 <a:with-param name="c" select="key('{$key}',{@use})/@value"/> |
|
819 </xsl:when> |
|
820 <xsl:otherwise> |
|
821 <a:with-param name="key" select="'{$key}'"/> |
|
822 <a:with-param name="c" select="{@use}"/> |
|
823 </xsl:otherwise> |
|
824 </xsl:choose> |
|
825 <a:with-param name="dir" select="'{@direction}'" /> <!-- not documented! only used for XSLT processors that can't handle sin / cos --> |
|
826 <a:with-param name="angle" select="'{@angle}'" /> |
|
827 <a:with-param name="blur"> |
|
828 <xsl:attribute name="select"> |
|
829 <xsl:choose> |
|
830 <xsl:when test="not(@blur)">0</xsl:when> |
|
831 <xsl:otherwise> |
|
832 <xsl:value-of select="0.5 * 100 * @blur"/> |
|
833 </xsl:otherwise> |
|
834 </xsl:choose> |
|
835 </xsl:attribute> |
|
836 </a:with-param> |
|
837 </a:call-template> |
|
838 </a:template> |
|
839 </xsl:if> |
|
840 |
|
841 <a:template mode="display-style-color"> |
|
842 <xsl:call-template name="match-syntax"/> |
|
843 <xsl:call-template name="declare-vars"/> |
|
844 <xsl:choose> |
|
845 <xsl:when test="@use and not(color[@rule])"> |
|
846 <xsl:call-template name="color-select"> |
|
847 <xsl:with-param name="default" select="$default-color"/> |
|
848 </xsl:call-template> |
|
849 </xsl:when> |
|
850 <xsl:otherwise> |
|
851 <a:choose> |
|
852 <xsl:for-each select="color[@rule]"> |
|
853 <a:when> |
|
854 <xsl:attribute name="test"><xsl:apply-templates select="." mode="when-test"/></xsl:attribute> |
|
855 <xsl:value-of select="@color"/> |
|
856 </a:when> |
|
857 </xsl:for-each> |
|
858 <a:otherwise> |
|
859 <xsl:choose> |
|
860 <xsl:when test="@use"> <!-- only useful if there's something to look up --> |
|
861 <xsl:call-template name="color-select"> |
|
862 <xsl:with-param name="default" select="$default-color"/> |
|
863 </xsl:call-template> |
|
864 </xsl:when> |
|
865 <xsl:otherwise> |
|
866 <xsl:value-of select="$default-color"/> |
|
867 </xsl:otherwise> |
|
868 </xsl:choose> |
|
869 </a:otherwise> |
|
870 </a:choose> |
|
871 </xsl:otherwise> |
|
872 </xsl:choose> |
|
873 </a:template> |
|
874 |
|
875 <xsl:if test="(@type='background' or not(@type)) and $default-color!=''"> |
|
876 <a:template match="cmp" mode="display-style-color"> |
|
877 <xsl:value-of select="$default-color"/> |
|
878 </a:template> |
|
879 </xsl:if> |
|
880 |
|
881 |
|
882 |
|
883 <a:template mode="animate-color"> |
|
884 <xsl:call-template name="match-syntax"/> |
|
885 <a:if test="not(ancestor::SystemDefinition/@static='true')"> |
|
886 <xsl:call-template name="declare-vars"/> |
|
887 <xsl:variable name="id"><xsl:apply-templates select="." mode="style-id"/></xsl:variable> |
|
888 <xsl:choose> |
|
889 <xsl:when test="@use and not(color[@rule])"> |
|
890 <a:for-each select="key('{name()}-{$id}',{@use})"> |
|
891 <set attributeName="opacity" attributeType="XML" to="0.5" fill="remove"> |
|
892 <xsl:attribute name="begin">{@style-id}.mouseover</xsl:attribute> |
|
893 <xsl:attribute name="end">{@style-id}.mouseout</xsl:attribute> |
|
894 </set> |
|
895 </a:for-each> |
|
896 </xsl:when> |
|
897 <xsl:when test="not(*) and @match='@ts'"> |
|
898 <a:for-each select="key('{name()}-{$id}',@ts)"> |
|
899 <set attributeName="opacity" attributeType="XML" to="0.5" fill="remove"> |
|
900 <xsl:attribute name="begin">{@style-id}.mouseover</xsl:attribute> |
|
901 <xsl:attribute name="end">{@style-id}.mouseout</xsl:attribute> |
|
902 </set> |
|
903 </a:for-each> |
|
904 </xsl:when> |
|
905 <xsl:otherwise> |
|
906 <a:choose> |
|
907 <xsl:for-each select="color[@rule]"> |
|
908 <a:when> |
|
909 <xsl:attribute name="test"><xsl:apply-templates select="." mode="when-test"/></xsl:attribute> |
|
910 <set attributeName="opacity" attributeType="XML" to="0.5" fill="remove"> |
|
911 <xsl:attribute name="begin"><xsl:apply-templates select="." mode="style-id"/>.mouseover</xsl:attribute> |
|
912 <xsl:attribute name="end"><xsl:apply-templates select="." mode="style-id"/>.mouseout</xsl:attribute> |
|
913 </set> |
|
914 </a:when> |
|
915 </xsl:for-each> |
|
916 <xsl:if test="@use"> <!-- only useful if there's something to look up --> |
|
917 <a:otherwise> |
|
918 <a:for-each select="key('{name()}-{$id}',{@use})"> |
|
919 <set attributeName="opacity" attributeType="XML" to="0.5" fill="remove"> |
|
920 <xsl:attribute name="begin">{@style-id}.mouseover</xsl:attribute> |
|
921 <xsl:attribute name="end">{@style-id}.mouseout</xsl:attribute> |
|
922 </set> |
|
923 </a:for-each> |
|
924 </a:otherwise> |
|
925 </xsl:if> |
|
926 </a:choose> |
|
927 </xsl:otherwise> |
|
928 </xsl:choose> |
|
929 </a:if> |
|
930 </a:template> |
|
931 |
|
932 |
|
933 </xsl:template> |
|
934 |
|
935 |
|
936 <xsl:template match="patterns"> |
|
937 <a:template mode="overlay-{1 + count(preceding::patterns)}"> |
|
938 <xsl:call-template name="match-syntax"/> |
|
939 <xsl:call-template name="declare-vars"/> |
|
940 <a:choose> |
|
941 <xsl:for-each select="overlay"> |
|
942 <a:when> |
|
943 <xsl:attribute name="test"> |
|
944 <xsl:apply-templates select="." mode="when-test"/> |
|
945 </xsl:attribute><o>#<xsl:apply-templates mode="id" select="."/></o></a:when> |
|
946 </xsl:for-each> |
|
947 </a:choose> |
|
948 </a:template> |
|
949 </xsl:template> |
|
950 |
|
951 <xsl:template name="declare-vars"> |
|
952 <xsl:for-each select="*[@variable]"> |
|
953 <a:variable> |
|
954 <xsl:attribute name="name"><xsl:apply-templates select="." mode="varname"/></xsl:attribute> |
|
955 <xsl:attribute name="select"><xsl:value-of select="@variable"/></xsl:attribute> |
|
956 </a:variable> |
|
957 </xsl:for-each> |
|
958 </xsl:template> |
|
959 |
|
960 <xsl:template match="styles"> |
|
961 <a:template mode="display-style-{position()}"> |
|
962 <xsl:call-template name="match-syntax"/> |
|
963 <!-- set any necessary variables --> |
|
964 <xsl:call-template name="declare-vars"/> |
|
965 <a:choose> |
|
966 <xsl:for-each select="style[@rule]"> |
|
967 <a:when> |
|
968 <xsl:attribute name="test"><xsl:apply-templates select="." mode="when-test"/></xsl:attribute> |
|
969 <xsl:value-of select="."/> |
|
970 </a:when> |
|
971 </xsl:for-each> |
|
972 <xsl:for-each select="style[not(@rule|@value)]"> <!-- the default is last (if it exists)--> |
|
973 <a:otherwise><xsl:value-of select="."/></a:otherwise> |
|
974 </xsl:for-each> |
|
975 </a:choose> |
|
976 <a:text>; </a:text> |
|
977 </a:template> |
|
978 |
|
979 </xsl:template> |
|
980 |
|
981 <xsl:template name="match-syntax"> |
|
982 <xsl:choose> |
|
983 <xsl:when test="not(@match)"><xsl:attribute name="match">component</xsl:attribute></xsl:when> |
|
984 <xsl:when test="@match='module'"><xsl:attribute name="match">collection</xsl:attribute></xsl:when> |
|
985 <xsl:when test="@match='logicalset' or @match='block'"><xsl:attribute name="match">package</xsl:attribute></xsl:when> |
|
986 <xsl:when test="@match='logicalsubset' or @match='subblock'"><xsl:attribute name="match">package/package</xsl:attribute></xsl:when> |
|
987 <xsl:otherwise><xsl:copy-of select="@match"/></xsl:otherwise> |
|
988 </xsl:choose> |
|
989 </xsl:template> |
|
990 |
|
991 |
|
992 <!-- from model.xsl: --> |
|
993 |
|
994 <xsl:template match="*" mode="style-id"> |
|
995 <xsl:message>not found</xsl:message> |
|
996 </xsl:template> |
|
997 |
|
998 <xsl:template match="item" mode="style-id"> |
|
999 <xsl:message>Generated Text not supported in values files</xsl:message> |
|
1000 </xsl:template> |
|
1001 |
|
1002 |
|
1003 <xsl:template match="info" mode="style-id"> |
|
1004 <xsl:value-of select="concat('i',count(preceding-sibling::info))"/> |
|
1005 </xsl:template> |
|
1006 |
|
1007 <xsl:template match="legend" mode="style-id"> |
|
1008 <xsl:value-of select="concat('L',count(preceding::legend))"/> |
|
1009 </xsl:template> |
|
1010 |
|
1011 <xsl:template match="note" mode="style-id"> |
|
1012 <xsl:value-of select="concat('n',count(preceding::note))"/> |
|
1013 </xsl:template> |
|
1014 |
|
1015 <!-- what about values and items? --> |
|
1016 |
|
1017 <xsl:template match="colors|borders|patterns|styles|examples" mode="style-id"> |
|
1018 <xsl:value-of select="concat('s',count(preceding-sibling::*))"/> |
|
1019 </xsl:template> |
|
1020 |
|
1021 <xsl:template match="colors/color|borders/border|patterns/overlay|styles/style" mode="style-id"> |
|
1022 <xsl:apply-templates select=".." mode="style-id"/>-<xsl:value-of select="name()"/> |
|
1023 <xsl:value-of select="count(preceding-sibling::*)"/> |
|
1024 </xsl:template> |
|
1025 |
|
1026 <xsl:template match="examples/cmp" mode="style-id"> |
|
1027 <xsl:value-of select="concat('e',count(preceding::cmp[parent::examples]))"/> |
|
1028 </xsl:template> |
|
1029 |
|
1030 |
|
1031 </xsl:stylesheet> |