|
1 include yslt.yml2 |
|
2 estylesheet xmlns:ppx="http://www.plcopen.org/xml/tc6_0201" |
|
3 xmlns:xhtml="http://www.w3.org/1999/xhtml" |
|
4 xmlns:ns="pou_vars_ns" |
|
5 extension-element-prefixes="ns" |
|
6 exclude-result-prefixes="ns" { |
|
7 |
|
8 template "text()"; |
|
9 template "text()", mode="var_class"; |
|
10 template "text()", mode="var_type"; |
|
11 template "text()", mode="var_edit"; |
|
12 template "text()", mode="var_debug"; |
|
13 |
|
14 variable "project" { |
|
15 copy "document('project')/project/*"; |
|
16 } |
|
17 |
|
18 variable "stdlib" { |
|
19 copy "document('stdlib')/stdlib/*"; |
|
20 } |
|
21 variable "extensions" { |
|
22 copy "document('extensions')/extensions/*"; |
|
23 } |
|
24 |
|
25 function "add_root" { |
|
26 param "class"; |
|
27 param "type"; |
|
28 param "edit" > true |
|
29 param "debug" > true |
|
30 value "ns:SetRoot($class, $type, $edit, $debug)"; |
|
31 } |
|
32 |
|
33 template "ppx:pou" { |
|
34 call "add_root" { |
|
35 with "class" > «@pouType» |
|
36 with "type" > «@name» |
|
37 } |
|
38 apply "ppx:interface"; |
|
39 apply "ppx:actions/ppx:action | ppx:transitions/ppx:transition", mode="variable_list"; |
|
40 } |
|
41 |
|
42 template "ppx:action" { |
|
43 call "add_root" { |
|
44 with "class" > action |
|
45 } |
|
46 apply "ancestor::ppx:pou/child::ppx:interface"; |
|
47 } |
|
48 |
|
49 template "ppx:transition" { |
|
50 call "add_root" { |
|
51 with "class" > transition |
|
52 } |
|
53 apply "ancestor::ppx:pou/child::ppx:interface"; |
|
54 } |
|
55 |
|
56 template "ppx:configuration" { |
|
57 call "add_root" { |
|
58 with "class" > configuration |
|
59 with "debug" > false |
|
60 } |
|
61 apply "ppx:resource", mode="variable_list"; |
|
62 apply "ppx:globalVars"; |
|
63 } |
|
64 |
|
65 template "ppx:resource" { |
|
66 call "add_root" { |
|
67 with "class" > resource |
|
68 with "debug" > false |
|
69 } |
|
70 apply "ppx:pouInstance | ppx:task/ppx:pouInstance", mode="variable_list"; |
|
71 apply "ppx:globalVars"; |
|
72 } |
|
73 |
|
74 function "variables_infos" { |
|
75 param "var_class"; |
|
76 foreach "ppx:variable" { |
|
77 variable "class" { |
|
78 apply "ppx:type", mode="var_class" { |
|
79 with "default_class" > «$var_class» |
|
80 } |
|
81 } |
|
82 variable "type" { |
|
83 apply"ppx:type", mode="var_type"; |
|
84 } |
|
85 variable "edit" { |
|
86 apply "ppx:type", mode="var_edit"; |
|
87 } |
|
88 variable "debug" { |
|
89 apply "ppx:type", mode="var_debug"; |
|
90 } |
|
91 value "ns:AddVariable(@name, $class, $type, $edit, $debug)"; |
|
92 } |
|
93 } |
|
94 |
|
95 template "ppx:localVars" { |
|
96 call "variables_infos" { |
|
97 with "var_class" > Local |
|
98 } |
|
99 } |
|
100 |
|
101 template "ppx:globalVars" { |
|
102 call "variables_infos" { |
|
103 with "var_class" > Global |
|
104 } |
|
105 } |
|
106 |
|
107 template "ppx:externalVars" { |
|
108 call "variables_infos" { |
|
109 with "var_class" > External |
|
110 } |
|
111 } |
|
112 |
|
113 template "ppx:tempVars" { |
|
114 call "variables_infos" { |
|
115 with "var_class" > Temp |
|
116 } |
|
117 } |
|
118 |
|
119 template "ppx:inputVars" { |
|
120 call "variables_infos" { |
|
121 with "var_class" > Input |
|
122 } |
|
123 } |
|
124 |
|
125 template "ppx:outputVars" { |
|
126 call "variables_infos" { |
|
127 with "var_class" > Output |
|
128 } |
|
129 } |
|
130 |
|
131 template "ppx:inOutVars" { |
|
132 call "variables_infos" { |
|
133 with "var_class" > InOut |
|
134 } |
|
135 } |
|
136 |
|
137 function "add_variable" { |
|
138 param "name"; |
|
139 param "class"; |
|
140 param "type"; |
|
141 param "edit" > true |
|
142 param "debug" > true |
|
143 value "ns:AddVariable($name, $class, $type, $edit, $debug)"; |
|
144 } |
|
145 |
|
146 template "ppx:action", mode="variable_list" { |
|
147 call "add_variable" { |
|
148 with "name" > «@name» |
|
149 with "class" > action |
|
150 } |
|
151 } |
|
152 |
|
153 template "ppx:transition", mode="variable_list" { |
|
154 call "add_variable" { |
|
155 with "name" > «@name» |
|
156 with "class" > transition |
|
157 } |
|
158 } |
|
159 |
|
160 template "ppx:resource", mode="variable_list" { |
|
161 call "add_variable" { |
|
162 with "name" > «@name» |
|
163 with "class" > resource |
|
164 with "debug" > false |
|
165 } |
|
166 } |
|
167 |
|
168 template "ppx:pouInstance", mode="variable_list" { |
|
169 call "add_variable" { |
|
170 with "name" > «@name» |
|
171 with "class" > program |
|
172 with "type" > «@typeName» |
|
173 } |
|
174 } |
|
175 |
|
176 template "*[self::ppx:type or self::ppx:baseType]/ppx:derived", mode="var_class" { |
|
177 param "default_class"; |
|
178 variable "type_name", "@name"; |
|
179 variable "pou_infos" { |
|
180 copy """exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | |
|
181 exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | |
|
182 exsl:node-set($extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name]"""; |
|
183 } |
|
184 choose { |
|
185 when "$pou_infos != ''" { |
|
186 apply "exsl:node-set($pou_infos)", mode="var_class"; |
|
187 } |
|
188 otherwise { |
|
189 value "$default_class" |
|
190 } |
|
191 } |
|
192 } |
|
193 |
|
194 template "ppx:pou", mode="var_class" { |
|
195 value "@pouType"; |
|
196 } |
|
197 |
|
198 template "*[self::ppx:type or self::ppx:baseType]/*" mode="var_class" { |
|
199 param "default_class"; |
|
200 value "$default_class"; |
|
201 } |
|
202 |
|
203 template "*[self::ppx:type or self::ppx:baseType]/ppx:derived", mode="var_type" { |
|
204 > «@name» |
|
205 } |
|
206 |
|
207 template "*[self::ppx:type or self::ppx:baseType]/ppx:array", mode="var_type" { |
|
208 > ARRAY [ |
|
209 foreach "ppx:dimension" { |
|
210 > «@lower»..«@upper» |
|
211 } |
|
212 > ] OF |
|
213 apply "ppx:baseType", mode="var_type"; |
|
214 } |
|
215 |
|
216 template "*[self::ppx:type or self::ppx:baseType]/ppx:string", mode="var_type" { |
|
217 > STRING |
|
218 } |
|
219 |
|
220 template "*[self::ppx:type or self::ppx:baseType]/ppx:wstring", mode="var_type" { |
|
221 > WSTRING |
|
222 } |
|
223 |
|
224 template "*[self::ppx:type or self::ppx:baseType]/*", mode="var_type" { |
|
225 > «local-name()» |
|
226 } |
|
227 |
|
228 template "*[self::ppx:type or self::ppx:baseType]/ppx:derived", mode="var_edit" { |
|
229 variable "type_name", "@name"; |
|
230 variable "pou_infos" { |
|
231 copy "exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name]"; |
|
232 } |
|
233 choose { |
|
234 when "$pou_infos != ''" > true |
|
235 otherwise > false |
|
236 } |
|
237 } |
|
238 |
|
239 template "*[self::ppx:type or self::ppx:baseType]/ppx:array", mode="var_edit" { |
|
240 apply "ppx:baseType", mode="var_edit"; |
|
241 } |
|
242 |
|
243 template "*[self::ppx:type or self::ppx:baseType]/*", mode="var_edit" { |
|
244 > false |
|
245 } |
|
246 |
|
247 template "*[self::ppx:type or self::ppx:baseType]/ppx:derived", mode="var_debug" { |
|
248 variable "type_name", "@name"; |
|
249 variable "datatype_infos" { |
|
250 copy """exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | |
|
251 exsl:node-set($project)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] | |
|
252 exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] | |
|
253 exsl:node-set($extensions)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]"""; |
|
254 } |
|
255 choose { |
|
256 when "$datatype_infos != ''" { |
|
257 apply "exsl:node-set($datatype_infos)", mode="var_debug"; |
|
258 } |
|
259 otherwise > false |
|
260 } |
|
261 } |
|
262 |
|
263 template "ppx:pou", mode="var_debug" { |
|
264 > true |
|
265 } |
|
266 |
|
267 template "*[self::ppx:type or self::ppx:baseType]/ppx:array", mode="var_debug" { |
|
268 > false |
|
269 } |
|
270 |
|
271 template "*[self::ppx:type or self::ppx:baseType]/ppx:struct", mode="var_debug" { |
|
272 > false |
|
273 } |
|
274 |
|
275 template "*[self::ppx:type or self::ppx:baseType]/*", mode="var_debug" { |
|
276 > true |
|
277 } |
|
278 |
|
279 } |