|
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="var_infos_ns" |
|
5 extension-element-prefixes="ns" |
|
6 exclude-result-prefixes="ns" { |
|
7 |
|
8 param "tree"; |
|
9 |
|
10 template "text()"; |
|
11 |
|
12 variable "project" { |
|
13 copy "document('project')/project/*"; |
|
14 } |
|
15 |
|
16 variable "stdlib" { |
|
17 copy "document('stdlib')/stdlib/*"; |
|
18 } |
|
19 variable "extensions" { |
|
20 copy "document('extensions')/extensions/*"; |
|
21 } |
|
22 |
|
23 template "ppx:configuration" { |
|
24 apply "ppx:globalVars"; |
|
25 } |
|
26 |
|
27 template "ppx:resource" { |
|
28 apply "ppx:globalVars"; |
|
29 } |
|
30 |
|
31 template "ppx:pou" { |
|
32 apply "ppx:interface/*"; |
|
33 } |
|
34 |
|
35 template "ppx:returnType" { |
|
36 value "ns:AddTree()"; |
|
37 apply ".", mode="var_type"; |
|
38 } |
|
39 |
|
40 function "variables_infos" { |
|
41 param "var_class"; |
|
42 variable "var_option" { |
|
43 choose { |
|
44 when "@constant='true' or @constant='1'" > Constant |
|
45 when "@retain='true' or @retain='1'" > Retain |
|
46 when "@nonretain='true' or @nonretain='1'" > Non-Retain |
|
47 } |
|
48 } |
|
49 foreach "ppx:variable" { |
|
50 variable "initial_value" { |
|
51 apply "ppx:initialValue"; |
|
52 } |
|
53 variable "edit" { |
|
54 choose { |
|
55 when "$var_class='Global' or $var_class='External'" > true |
|
56 otherwise { |
|
57 apply "ppx:type", mode="var_edit"; |
|
58 } |
|
59 } |
|
60 } |
|
61 value "ns:AddTree()"; |
|
62 apply "ppx:type", mode="var_type"; |
|
63 value "ns:AddVariable(@name, $var_class, $var_option, @address, $initial_value, $edit, ppx:documentation/xhtml:p/text())"; |
|
64 } |
|
65 } |
|
66 |
|
67 template "ppx:localVars" { |
|
68 call "variables_infos" { |
|
69 with "var_class" > Local |
|
70 } |
|
71 } |
|
72 |
|
73 template "ppx:globalVars" { |
|
74 call "variables_infos" { |
|
75 with "var_class" > Global |
|
76 } |
|
77 } |
|
78 |
|
79 template "ppx:externalVars" { |
|
80 call "variables_infos" { |
|
81 with "var_class" > External |
|
82 } |
|
83 } |
|
84 |
|
85 template "ppx:tempVars" { |
|
86 call "variables_infos" { |
|
87 with "var_class" > Temp |
|
88 } |
|
89 } |
|
90 |
|
91 template "ppx:inputVars" { |
|
92 call "variables_infos" { |
|
93 with "var_class" > Input |
|
94 } |
|
95 } |
|
96 |
|
97 template "ppx:outputVars" { |
|
98 call "variables_infos" { |
|
99 with "var_class" > Output |
|
100 } |
|
101 } |
|
102 |
|
103 template "ppx:inOutVars" { |
|
104 call "variables_infos" { |
|
105 with "var_class" > InOut |
|
106 } |
|
107 } |
|
108 |
|
109 template "ppx:pou", mode="var_type" { |
|
110 apply "ppx:interface/*[self::ppx:inputVars or self::ppx:inOutVars or self::ppx:outputVars]/ppx:variable", mode="var_type"; |
|
111 } |
|
112 |
|
113 template "ppx:variable", mode="var_type" { |
|
114 variable "name" > «@name» |
|
115 value "ns:AddTree()"; |
|
116 apply "ppx:type", mode="var_type"; |
|
117 value "ns:AddVarToTree($name)"; |
|
118 } |
|
119 |
|
120 template "ppx:dataType", mode="var_type" { |
|
121 apply "ppx:baseType", mode="var_type"; |
|
122 } |
|
123 |
|
124 template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:struct", mode="var_type" { |
|
125 apply "ppx:variable", mode="var_type"; |
|
126 } |
|
127 |
|
128 template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:derived", mode="var_type" { |
|
129 variable "type_name" > «@name» |
|
130 choose { |
|
131 when "$tree='True'" { |
|
132 apply """exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | |
|
133 exsl:node-set($project)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] | |
|
134 exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | |
|
135 exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] | |
|
136 exsl:node-set($extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | |
|
137 exsl:node-set($extensions)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]""", mode="var_type"; |
|
138 } |
|
139 } |
|
140 value "ns:SetType($type_name)"; |
|
141 } |
|
142 |
|
143 template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:array", mode="var_type" { |
|
144 apply "ppx:baseType", mode="var_type"; |
|
145 foreach "ppx:dimension" { |
|
146 variable "lower" > «@lower» |
|
147 variable "upper" > «@upper» |
|
148 value "ns:AddDimension($lower, $upper)"; |
|
149 } |
|
150 } |
|
151 |
|
152 template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:string", mode="var_type" { |
|
153 variable "name" > STRING |
|
154 value "ns:SetType($name)"; |
|
155 } |
|
156 |
|
157 template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:wstring", mode="var_type" { |
|
158 variable "name" > WSTRING |
|
159 value "ns:SetType($name)"; |
|
160 } |
|
161 |
|
162 template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/*", mode="var_type" { |
|
163 variable "name" > «local-name()» |
|
164 value "ns:SetType($name)"; |
|
165 } |
|
166 |
|
167 template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:derived", mode="var_edit" { |
|
168 variable "type_name" > «@name» |
|
169 variable "pou_infos" { |
|
170 copy """exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | |
|
171 exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | |
|
172 exsl:node-set($extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name]"""; |
|
173 } |
|
174 choose { |
|
175 when "$pou_infos != ''" > false |
|
176 otherwise > true |
|
177 } |
|
178 } |
|
179 |
|
180 template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/*", mode="var_edit" { |
|
181 > true |
|
182 } |
|
183 |
|
184 template "ppx:value" { |
|
185 choose { |
|
186 when "@repetitionValue" { |
|
187 > «@repetitionValue»( |
|
188 apply; |
|
189 > ) |
|
190 } |
|
191 when "@member" { |
|
192 > «@member» := |
|
193 apply; |
|
194 } |
|
195 otherwise { |
|
196 apply; |
|
197 } |
|
198 } |
|
199 } |
|
200 |
|
201 template "ppx:simpleValue" { |
|
202 > «@value» |
|
203 } |
|
204 |
|
205 function "complex_type_value" { |
|
206 param "start_bracket"; |
|
207 param "end_bracket"; |
|
208 > «$start_bracket» |
|
209 foreach "ppx:value" { |
|
210 apply "."; |
|
211 choose { |
|
212 when "position()!=last()" > , |
|
213 } |
|
214 } |
|
215 > «$end_bracket» |
|
216 } |
|
217 |
|
218 template "ppx:arrayValue" { |
|
219 call "complex_type_value" { |
|
220 with "start_bracket" > [ |
|
221 with "end_bracket" > ] |
|
222 } |
|
223 } |
|
224 |
|
225 template "ppx:structValue" { |
|
226 call "complex_type_value" { |
|
227 with "start_bracket" > ( |
|
228 with "end_bracket" > ) |
|
229 } |
|
230 } |
|
231 |
|
232 } |
|
233 |
|
234 |
|
235 |