|
1 <?xml version="1.0"?> |
|
2 <xsl:stylesheet xmlns:func="http://exslt.org/functions" xmlns:dyn="http://exslt.org/dynamic" xmlns:str="http://exslt.org/strings" xmlns:math="http://exslt.org/math" xmlns:exsl="http://exslt.org/common" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:yml="http://fdik.org/yml" xmlns:set="http://exslt.org/sets" xmlns:ppx="http://www.plcopen.org/xml/tc6_0201" xmlns:ns="var_infos_ns" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" extension-element-prefixes="ns" version="1.0" exclude-result-prefixes="ns"> |
|
3 <xsl:output method="xml"/> |
|
4 <xsl:variable name="space" select="' '"/> |
|
5 <xsl:param name="autoindent" select="4"/> |
|
6 <xsl:param name="tree"/> |
|
7 <xsl:template match="text()"> |
|
8 <xsl:param name="_indent" select="0"/> |
|
9 </xsl:template> |
|
10 <xsl:variable name="project"> |
|
11 <xsl:copy-of select="document('project')/project/*"/> |
|
12 </xsl:variable> |
|
13 <xsl:variable name="stdlib"> |
|
14 <xsl:copy-of select="document('stdlib')/stdlib/*"/> |
|
15 </xsl:variable> |
|
16 <xsl:variable name="extensions"> |
|
17 <xsl:copy-of select="document('extensions')/extensions/*"/> |
|
18 </xsl:variable> |
|
19 <xsl:template match="ppx:configuration"> |
|
20 <xsl:param name="_indent" select="0"/> |
|
21 <xsl:apply-templates select="ppx:globalVars"> |
|
22 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
23 </xsl:apply-templates> |
|
24 </xsl:template> |
|
25 <xsl:template match="ppx:resource"> |
|
26 <xsl:param name="_indent" select="0"/> |
|
27 <xsl:apply-templates select="ppx:globalVars"> |
|
28 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
29 </xsl:apply-templates> |
|
30 </xsl:template> |
|
31 <xsl:template match="ppx:pou"> |
|
32 <xsl:param name="_indent" select="0"/> |
|
33 <xsl:apply-templates select="ppx:interface/*"> |
|
34 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
35 </xsl:apply-templates> |
|
36 </xsl:template> |
|
37 <xsl:template match="ppx:returnType"> |
|
38 <xsl:param name="_indent" select="0"/> |
|
39 <xsl:value-of select="ns:AddTree()"/> |
|
40 <xsl:apply-templates mode="var_type" select="."> |
|
41 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
42 </xsl:apply-templates> |
|
43 </xsl:template> |
|
44 <xsl:template name="variables_infos"> |
|
45 <xsl:param name="_indent" select="0"/> |
|
46 <xsl:param name="var_class"/> |
|
47 <xsl:variable name="var_option"> |
|
48 <xsl:choose> |
|
49 <xsl:when test="@constant='true' or @constant='1'"> |
|
50 <xsl:text>Constant</xsl:text> |
|
51 </xsl:when> |
|
52 <xsl:when test="@retain='true' or @retain='1'"> |
|
53 <xsl:text>Retain</xsl:text> |
|
54 </xsl:when> |
|
55 <xsl:when test="@nonretain='true' or @nonretain='1'"> |
|
56 <xsl:text>Non-Retain</xsl:text> |
|
57 </xsl:when> |
|
58 </xsl:choose> |
|
59 </xsl:variable> |
|
60 <xsl:for-each select="ppx:variable"> |
|
61 <xsl:variable name="initial_value"> |
|
62 <xsl:apply-templates select="ppx:initialValue"> |
|
63 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
64 </xsl:apply-templates> |
|
65 </xsl:variable> |
|
66 <xsl:variable name="edit"> |
|
67 <xsl:choose> |
|
68 <xsl:when test="$var_class='Global' or $var_class='External'"> |
|
69 <xsl:text>true</xsl:text> |
|
70 </xsl:when> |
|
71 <xsl:otherwise> |
|
72 <xsl:apply-templates mode="var_edit" select="ppx:type"> |
|
73 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
74 </xsl:apply-templates> |
|
75 </xsl:otherwise> |
|
76 </xsl:choose> |
|
77 </xsl:variable> |
|
78 <xsl:value-of select="ns:AddTree()"/> |
|
79 <xsl:apply-templates mode="var_type" select="ppx:type"> |
|
80 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
81 </xsl:apply-templates> |
|
82 <xsl:value-of select="ns:AddVariable(@name, $var_class, $var_option, @address, $initial_value, $edit, ppx:documentation/xhtml:p/text())"/> |
|
83 </xsl:for-each> |
|
84 </xsl:template> |
|
85 <xsl:template match="ppx:localVars"> |
|
86 <xsl:param name="_indent" select="0"/> |
|
87 <xsl:call-template name="variables_infos"> |
|
88 <xsl:with-param name="var_class"> |
|
89 <xsl:text>Local</xsl:text> |
|
90 </xsl:with-param> |
|
91 </xsl:call-template> |
|
92 </xsl:template> |
|
93 <xsl:template match="ppx:globalVars"> |
|
94 <xsl:param name="_indent" select="0"/> |
|
95 <xsl:call-template name="variables_infos"> |
|
96 <xsl:with-param name="var_class"> |
|
97 <xsl:text>Global</xsl:text> |
|
98 </xsl:with-param> |
|
99 </xsl:call-template> |
|
100 </xsl:template> |
|
101 <xsl:template match="ppx:externalVars"> |
|
102 <xsl:param name="_indent" select="0"/> |
|
103 <xsl:call-template name="variables_infos"> |
|
104 <xsl:with-param name="var_class"> |
|
105 <xsl:text>External</xsl:text> |
|
106 </xsl:with-param> |
|
107 </xsl:call-template> |
|
108 </xsl:template> |
|
109 <xsl:template match="ppx:tempVars"> |
|
110 <xsl:param name="_indent" select="0"/> |
|
111 <xsl:call-template name="variables_infos"> |
|
112 <xsl:with-param name="var_class"> |
|
113 <xsl:text>Temp</xsl:text> |
|
114 </xsl:with-param> |
|
115 </xsl:call-template> |
|
116 </xsl:template> |
|
117 <xsl:template match="ppx:inputVars"> |
|
118 <xsl:param name="_indent" select="0"/> |
|
119 <xsl:call-template name="variables_infos"> |
|
120 <xsl:with-param name="var_class"> |
|
121 <xsl:text>Input</xsl:text> |
|
122 </xsl:with-param> |
|
123 </xsl:call-template> |
|
124 </xsl:template> |
|
125 <xsl:template match="ppx:outputVars"> |
|
126 <xsl:param name="_indent" select="0"/> |
|
127 <xsl:call-template name="variables_infos"> |
|
128 <xsl:with-param name="var_class"> |
|
129 <xsl:text>Output</xsl:text> |
|
130 </xsl:with-param> |
|
131 </xsl:call-template> |
|
132 </xsl:template> |
|
133 <xsl:template match="ppx:inOutVars"> |
|
134 <xsl:param name="_indent" select="0"/> |
|
135 <xsl:call-template name="variables_infos"> |
|
136 <xsl:with-param name="var_class"> |
|
137 <xsl:text>InOut</xsl:text> |
|
138 </xsl:with-param> |
|
139 </xsl:call-template> |
|
140 </xsl:template> |
|
141 <xsl:template mode="var_type" match="ppx:pou"> |
|
142 <xsl:param name="_indent" select="0"/> |
|
143 <xsl:apply-templates mode="var_type" select="ppx:interface/*[self::ppx:inputVars or self::ppx:inOutVars or self::ppx:outputVars]/ppx:variable"> |
|
144 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
145 </xsl:apply-templates> |
|
146 </xsl:template> |
|
147 <xsl:template mode="var_type" match="ppx:variable"> |
|
148 <xsl:param name="_indent" select="0"/> |
|
149 <xsl:variable name="name"> |
|
150 <xsl:value-of select="@name"/> |
|
151 </xsl:variable> |
|
152 <xsl:value-of select="ns:AddTree()"/> |
|
153 <xsl:apply-templates mode="var_type" select="ppx:type"> |
|
154 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
155 </xsl:apply-templates> |
|
156 <xsl:value-of select="ns:AddVarToTree($name)"/> |
|
157 </xsl:template> |
|
158 <xsl:template mode="var_type" match="ppx:dataType"> |
|
159 <xsl:param name="_indent" select="0"/> |
|
160 <xsl:apply-templates mode="var_type" select="ppx:baseType"> |
|
161 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
162 </xsl:apply-templates> |
|
163 </xsl:template> |
|
164 <xsl:template mode="var_type" match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:struct"> |
|
165 <xsl:param name="_indent" select="0"/> |
|
166 <xsl:apply-templates mode="var_type" select="ppx:variable"> |
|
167 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
168 </xsl:apply-templates> |
|
169 </xsl:template> |
|
170 <xsl:template mode="var_type" match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:derived"> |
|
171 <xsl:param name="_indent" select="0"/> |
|
172 <xsl:variable name="type_name"> |
|
173 <xsl:value-of select="@name"/> |
|
174 </xsl:variable> |
|
175 <xsl:choose> |
|
176 <xsl:when test="$tree='True'"> |
|
177 <xsl:apply-templates mode="var_type" select="exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | exsl:node-set($project)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] | exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] | exsl:node-set($extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | exsl:node-set($extensions)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]"> |
|
178 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
179 </xsl:apply-templates> |
|
180 </xsl:when> |
|
181 </xsl:choose> |
|
182 <xsl:value-of select="ns:SetType($type_name)"/> |
|
183 </xsl:template> |
|
184 <xsl:template mode="var_type" match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:array"> |
|
185 <xsl:param name="_indent" select="0"/> |
|
186 <xsl:apply-templates mode="var_type" select="ppx:baseType"> |
|
187 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
188 </xsl:apply-templates> |
|
189 <xsl:for-each select="ppx:dimension"> |
|
190 <xsl:variable name="lower"> |
|
191 <xsl:value-of select="@lower"/> |
|
192 </xsl:variable> |
|
193 <xsl:variable name="upper"> |
|
194 <xsl:value-of select="@upper"/> |
|
195 </xsl:variable> |
|
196 <xsl:value-of select="ns:AddDimension($lower, $upper)"/> |
|
197 </xsl:for-each> |
|
198 </xsl:template> |
|
199 <xsl:template mode="var_type" match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:string"> |
|
200 <xsl:param name="_indent" select="0"/> |
|
201 <xsl:variable name="name"> |
|
202 <xsl:text>STRING</xsl:text> |
|
203 </xsl:variable> |
|
204 <xsl:value-of select="ns:SetType($name)"/> |
|
205 </xsl:template> |
|
206 <xsl:template mode="var_type" match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:wstring"> |
|
207 <xsl:param name="_indent" select="0"/> |
|
208 <xsl:variable name="name"> |
|
209 <xsl:text>WSTRING</xsl:text> |
|
210 </xsl:variable> |
|
211 <xsl:value-of select="ns:SetType($name)"/> |
|
212 </xsl:template> |
|
213 <xsl:template mode="var_type" match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/*"> |
|
214 <xsl:param name="_indent" select="0"/> |
|
215 <xsl:variable name="name"> |
|
216 <xsl:value-of select="local-name()"/> |
|
217 </xsl:variable> |
|
218 <xsl:value-of select="ns:SetType($name)"/> |
|
219 </xsl:template> |
|
220 <xsl:template mode="var_edit" match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:derived"> |
|
221 <xsl:param name="_indent" select="0"/> |
|
222 <xsl:variable name="type_name"> |
|
223 <xsl:value-of select="@name"/> |
|
224 </xsl:variable> |
|
225 <xsl:variable name="pou_infos"> |
|
226 <xsl:copy-of select="exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | exsl:node-set($extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name]"/> |
|
227 </xsl:variable> |
|
228 <xsl:choose> |
|
229 <xsl:when test="$pou_infos != ''"> |
|
230 <xsl:text>false</xsl:text> |
|
231 </xsl:when> |
|
232 <xsl:otherwise> |
|
233 <xsl:text>true</xsl:text> |
|
234 </xsl:otherwise> |
|
235 </xsl:choose> |
|
236 </xsl:template> |
|
237 <xsl:template mode="var_edit" match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/*"> |
|
238 <xsl:param name="_indent" select="0"/> |
|
239 <xsl:text>true</xsl:text> |
|
240 </xsl:template> |
|
241 <xsl:template match="ppx:value"> |
|
242 <xsl:param name="_indent" select="0"/> |
|
243 <xsl:choose> |
|
244 <xsl:when test="@repetitionValue"> |
|
245 <xsl:value-of select="@repetitionValue"/> |
|
246 <xsl:text>(</xsl:text> |
|
247 <xsl:apply-templates> |
|
248 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
249 </xsl:apply-templates> |
|
250 <xsl:text>)</xsl:text> |
|
251 </xsl:when> |
|
252 <xsl:when test="@member"> |
|
253 <xsl:value-of select="@member"/> |
|
254 <xsl:text> := </xsl:text> |
|
255 <xsl:apply-templates> |
|
256 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
257 </xsl:apply-templates> |
|
258 </xsl:when> |
|
259 <xsl:otherwise> |
|
260 <xsl:apply-templates> |
|
261 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
262 </xsl:apply-templates> |
|
263 </xsl:otherwise> |
|
264 </xsl:choose> |
|
265 </xsl:template> |
|
266 <xsl:template match="ppx:simpleValue"> |
|
267 <xsl:param name="_indent" select="0"/> |
|
268 <xsl:value-of select="@value"/> |
|
269 </xsl:template> |
|
270 <xsl:template name="complex_type_value"> |
|
271 <xsl:param name="_indent" select="0"/> |
|
272 <xsl:param name="start_bracket"/> |
|
273 <xsl:param name="end_bracket"/> |
|
274 <xsl:value-of select="$start_bracket"/> |
|
275 <xsl:for-each select="ppx:value"> |
|
276 <xsl:apply-templates select="."> |
|
277 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
278 </xsl:apply-templates> |
|
279 <xsl:choose> |
|
280 <xsl:when test="position()!=last()"> |
|
281 <xsl:text>, </xsl:text> |
|
282 </xsl:when> |
|
283 </xsl:choose> |
|
284 </xsl:for-each> |
|
285 <xsl:value-of select="$end_bracket"/> |
|
286 </xsl:template> |
|
287 <xsl:template match="ppx:arrayValue"> |
|
288 <xsl:param name="_indent" select="0"/> |
|
289 <xsl:call-template name="complex_type_value"> |
|
290 <xsl:with-param name="start_bracket"> |
|
291 <xsl:text>[</xsl:text> |
|
292 </xsl:with-param> |
|
293 <xsl:with-param name="end_bracket"> |
|
294 <xsl:text>]</xsl:text> |
|
295 </xsl:with-param> |
|
296 </xsl:call-template> |
|
297 </xsl:template> |
|
298 <xsl:template match="ppx:structValue"> |
|
299 <xsl:param name="_indent" select="0"/> |
|
300 <xsl:call-template name="complex_type_value"> |
|
301 <xsl:with-param name="start_bracket"> |
|
302 <xsl:text>(</xsl:text> |
|
303 </xsl:with-param> |
|
304 <xsl:with-param name="end_bracket"> |
|
305 <xsl:text>)</xsl:text> |
|
306 </xsl:with-param> |
|
307 </xsl:call-template> |
|
308 </xsl:template> |
|
309 </xsl:stylesheet> |