blob: 7933c690672fdd6ed4f8720b929a8a0eb0fb011b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet
version ="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<!--
::
:: Any callback must be equipped with a 'context' attribute
:: indicating where the rewriting triggered by the event will
:: occur
::
::::> 'here' computes context value at execution point.
::
::::> 'context' is used as an attribute of a callback:
::
:: <{event-callback} {action}="{path}">
:: <xsl:call-template name="context"/>
:: [...]
:: </{event-callback}>
::
::::> org.scilab.modules.gui.utils.XCommonManager.getElementByContext
::
-->
<xsl:template name="here">
<xsl:for-each select="ancestor-or-self::*">
<xsl:if test="not(.=/)">
<xsl:value-of select="count(preceding-sibling::*)+1"/>
<xsl:text>/</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="context">
<xsl:attribute name="context">
<xsl:call-template name="here"/>
</xsl:attribute>
</xsl:template>
<!--
::
:: Select template allow to define values of combobox within the XSL.
::
:: <xsl:call-template name="Select">
:: <xsl:with-param name="among">
:: <option <<attr>>="<<value 1>>"/>
:: <option <<attr>>="<<value 2>>"/>
:: <option <<attr>>="<<value 3>>"/>
:: ...
:: </xsl:with-param>
:: </xsl:call-template>
::
-->
<xsl:template name="Select">
<xsl:param name="among"/>
<xsl:param name="enable" select="'true'"/>
<xsl:variable name="list" select="nodeset($among)/*"/>
<xsl:variable name="attr-name">
<xsl:for-each select="$list[1]/@*[1]">
<xsl:value-of select="local-name()"/>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="attr-value" select="@*[local-name()=$attr-name]"/>
<Select listener="ActionListener" enable="{$enable}">
<actionPerformed choose="{$attr-name}">
<xsl:call-template name="context"/>
</actionPerformed>
<xsl:for-each select="$list">
<option value="{@*}">
<xsl:if test="@*=$attr-value">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
</option>
</xsl:for-each>
</Select>
</xsl:template>
<xsl:template name="Slider">
<xsl:param name="among"/>
<xsl:variable name="list" select="nodeset($among)/*"/>
<xsl:variable name="attr-name">
<xsl:for-each select="$list[1]/@*[1]">
<xsl:value-of select="local-name()"/>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="attr-value" select="@*[local-name()=$attr-name]"/>
<Slider listener="ActionListener">
<actionPerformed choose="{$attr-name}">
<xsl:call-template name="context"/>
</actionPerformed>
<xsl:for-each select="$list">
<option value="{@*}">
<xsl:if test="@*=$attr-value">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
</option>
</xsl:for-each>
</Slider>
</xsl:template>
<!--
::
:: BooleanCheckBox template (@attr-name in {true, false})
::
:: <xsl:call-template name="SimpleCheckBox">
:: <xsl:with-param name="attr-name">...</xsl:with-param>
:: </xsl:call-template>
::
-->
<xsl:template name="BooleanCheckBox">
<xsl:param name="attr-name"/>
<xsl:param name="text" select="''"/>
<xsl:choose>
<xsl:when test="@*[local-name()=$attr-name]='true'">
<Checkbox checked="checked" listener="ActionListener" text="{$text}">
<actionPerformed set="{$attr-name}" value="false">
<xsl:call-template name="context"/>
</actionPerformed>
</Checkbox>
</xsl:when>
<xsl:otherwise>
<Checkbox checked="unchecked" listener="ActionListener" text="{$text}">
<actionPerformed set="{$attr-name}" value="true">
<xsl:call-template name="context"/>
</actionPerformed>
</Checkbox>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="InvertedCheckBox">
<xsl:param name="attr-name"/>
<xsl:param name="text" select="''"/>
<xsl:choose>
<xsl:when test="@*[local-name()=$attr-name]='false'">
<Checkbox checked="checked" listener="ActionListener" text="{$text}">
<actionPerformed set="{$attr-name}" value="true">
<xsl:call-template name="context"/>
</actionPerformed>
</Checkbox>
</xsl:when>
<xsl:otherwise>
<Checkbox checked="unchecked" listener="ActionListener" text="{$text}">
<actionPerformed set="{$attr-name}" value="false">
<xsl:call-template name="context"/>
</actionPerformed>
</Checkbox>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="BooleanRadio">
<xsl:param name="attr-name"/>
<xsl:param name="text" select="''"/>
<xsl:choose>
<xsl:when test="@*[local-name()=$attr-name]='true'">
<Radiobutton checked="checked" listener="ActionListener" text="{$text}">
<actionPerformed set="{$attr-name}" value="false">
<xsl:call-template name="context"/>
</actionPerformed>
</Radiobutton>
</xsl:when>
<xsl:otherwise>
<Radiobutton checked="unchecked" listener="ActionListener" text="{$text}">
<actionPerformed set="{$attr-name}" value="true">
<xsl:call-template name="context"/>
</actionPerformed>
</Radiobutton>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="InvertedRadio">
<xsl:param name="attr-name"/>
<xsl:param name="text" select="''"/>
<xsl:choose>
<xsl:when test="@*[local-name()=$attr-name]='false'">
<Radiobutton checked="checked" listener="ActionListener" text="{$text}">
<actionPerformed set="{$attr-name}" value="true">
<xsl:call-template name="context"/>
</actionPerformed>
</Radiobutton>
</xsl:when>
<xsl:otherwise>
<Radiobutton checked="unchecked" listener="ActionListener" text="{$text}">
<actionPerformed set="{$attr-name}" value="false">
<xsl:call-template name="context"/>
</actionPerformed>
</Radiobutton>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--
::
:: Common vocabulary
::
-->
<xsl:template match="TBD">
<Glue/>
<HBox>
<Glue/>
Implemented soon...
<Glue/>
</HBox>
<Glue/>
</xsl:template>
</xsl:stylesheet>
|