|
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 choose { |
|
14 when "$tree='True'" { |
|
15 copy "document('project')/project/*"; |
|
16 } |
|
17 } |
|
18 } |
|
19 |
|
20 variable "stdlib" { |
|
21 choose { |
|
22 when "$tree='True'" { |
|
23 copy "document('stdlib')/stdlib/*"; |
|
24 } |
|
25 } |
|
26 } |
|
27 variable "extensions" { |
|
28 choose { |
|
29 when "$tree='True'" { |
|
30 copy "document('extensions')/extensions/*"; |
|
31 } |
|
32 } |
|
33 } |
|
34 |
|
35 template "ppx:returnType" { |
|
36 value "ns:AddTree()"; |
|
37 apply; |
|
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"; |
|
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" { |
|
110 apply "ppx:interface/*[self::ppx:inputVars or self::ppx:inOutVars or self::ppx:outputVars]/ppx:variable"; |
|
111 } |
|
112 |
|
113 template "ppx:variable" { |
|
114 variable "name" > «@name» |
|
115 value "ns:AddTree($name)"; |
|
116 apply "ppx:type"; |
|
117 value "ns:AddVarToTree($name)"; |
|
118 } |
|
119 |
|
120 template "ppx:dataType" { |
|
121 apply "ppx:baseType"; |
|
122 } |
|
123 |
|
124 template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:struct" { |
|
125 apply "ppx:variable"; |
|
126 } |
|
127 |
|
128 template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:derived" { |
|
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]"""; |
|
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" { |
|
144 apply "ppx:baseType"; |
|
145 foreach "ppx:dimension" { |
|
146 value "ns:AddDimension(@lower, @upper)"; |
|
147 } |
|
148 } |
|
149 |
|
150 template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:string" { |
|
151 variable "name" > STRING |
|
152 value "ns:SetType($name)"; |
|
153 } |
|
154 |
|
155 template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:wstring" { |
|
156 variable "name" > WSTRING |
|
157 value "ns:SetType($name)"; |
|
158 } |
|
159 |
|
160 template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/*" { |
|
161 variable "name" > «local-name()» |
|
162 value "ns:SetType($name)"; |
|
163 } |
|
164 |
|
165 template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:derived", mode="var_edit" { |
|
166 variable "type_name", "@name"; |
|
167 variable "pou_infos" { |
|
168 copy """exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | |
|
169 exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | |
|
170 exsl:node-set($extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name]"""; |
|
171 } |
|
172 choose { |
|
173 when "$pou_infos != ''" > false |
|
174 otherwise > true |
|
175 } |
|
176 } |
|
177 |
|
178 template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/*", mode="var_edit" { |
|
179 > true |
|
180 } |
|
181 |
|
182 template "ppx:value" { |
|
183 choose { |
|
184 when "@repetitionValue" { |
|
185 > «@repetitionValue»( |
|
186 apply; |
|
187 > ) |
|
188 } |
|
189 when "@member" { |
|
190 > «@member» := |
|
191 apply; |
|
192 } |
|
193 otherwise { |
|
194 apply; |
|
195 } |
|
196 } |
|
197 } |
|
198 |
|
199 template "ppx:simpleValue" { |
|
200 > «@value» |
|
201 } |
|
202 |
|
203 function "complex_type_value" { |
|
204 param "start_bracket"; |
|
205 param "end_bracket"; |
|
206 > «@start_bracket» |
|
207 foreach "ppx:value" { |
|
208 apply "."; |
|
209 choose { |
|
210 when "position()!=last()" > , |
|
211 } |
|
212 } |
|
213 > «@end_bracket» |
|
214 } |
|
215 |
|
216 template "ppx:arrayValue" { |
|
217 call "complex_type_value" { |
|
218 with "start_bracket" > [ |
|
219 with "end_bracket" > ] |
|
220 } |
|
221 } |
|
222 |
|
223 template "ppx:structValue" { |
|
224 call "complex_type_value" { |
|
225 with "start_bracket" > ( |
|
226 with "end_bracket" > ) |
|
227 } |
|
228 } |
|
229 |
|
230 } |
|
231 |
|
232 |
|
233 |