|
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="instance_tagname_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="instance_path"/> |
|
7 <xsl:variable name="project"> |
|
8 <xsl:copy-of select="document('project')/project/*"/> |
|
9 </xsl:variable> |
|
10 <xsl:variable name="stdlib"> |
|
11 <xsl:copy-of select="document('stdlib')/stdlib/*"/> |
|
12 </xsl:variable> |
|
13 <xsl:variable name="extensions"> |
|
14 <xsl:copy-of select="document('extensions')/extensions/*"/> |
|
15 </xsl:variable> |
|
16 <xsl:template name="element_name"> |
|
17 <xsl:param name="_indent" select="0"/> |
|
18 <xsl:param name="path"/> |
|
19 <xsl:choose> |
|
20 <xsl:when test="contains($path,'.')"> |
|
21 <xsl:value-of select="substring-before($path,'.')"/> |
|
22 </xsl:when> |
|
23 <xsl:otherwise> |
|
24 <xsl:value-of select="$path"/> |
|
25 </xsl:otherwise> |
|
26 </xsl:choose> |
|
27 </xsl:template> |
|
28 <xsl:template name="next_path"> |
|
29 <xsl:param name="_indent" select="0"/> |
|
30 <xsl:param name="path"/> |
|
31 <xsl:choose> |
|
32 <xsl:when test="contains($path,'.')"> |
|
33 <xsl:value-of select="substring-after($path,'.')"/> |
|
34 </xsl:when> |
|
35 </xsl:choose> |
|
36 </xsl:template> |
|
37 <xsl:template match="ppx:project"> |
|
38 <xsl:param name="_indent" select="0"/> |
|
39 <xsl:variable name="config_name"> |
|
40 <xsl:call-template name="element_name"> |
|
41 <xsl:with-param name="path" select="$instance_path"/> |
|
42 </xsl:call-template> |
|
43 </xsl:variable> |
|
44 <xsl:apply-templates select="ppx:instances/ppx:configurations/ppx:configuration[@name=$config_name]"> |
|
45 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
46 <xsl:with-param name="element_path"> |
|
47 <xsl:call-template name="next_path"> |
|
48 <xsl:with-param name="path" select="$instance_path"/> |
|
49 </xsl:call-template> |
|
50 </xsl:with-param> |
|
51 </xsl:apply-templates> |
|
52 </xsl:template> |
|
53 <xsl:template match="ppx:configuration"> |
|
54 <xsl:param name="_indent" select="0"/> |
|
55 <xsl:param name="element_path"/> |
|
56 <xsl:choose> |
|
57 <xsl:when test="$element_path!=''"> |
|
58 <xsl:variable name="child_name"> |
|
59 <xsl:call-template name="element_name"> |
|
60 <xsl:with-param name="path" select="$element_path"/> |
|
61 </xsl:call-template> |
|
62 </xsl:variable> |
|
63 <xsl:apply-templates select="ppx:resource[@name=$child_name] | ppx:globalVars/ppx:variable[@name=$child_name]/ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]"> |
|
64 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
65 <xsl:with-param name="element_path"> |
|
66 <xsl:call-template name="next_path"> |
|
67 <xsl:with-param name="path" select="$element_path"/> |
|
68 </xsl:call-template> |
|
69 </xsl:with-param> |
|
70 </xsl:apply-templates> |
|
71 </xsl:when> |
|
72 <xsl:otherwise> |
|
73 <xsl:value-of select="ns:ConfigTagName(@name)"/> |
|
74 </xsl:otherwise> |
|
75 </xsl:choose> |
|
76 </xsl:template> |
|
77 <xsl:template match="ppx:resource"> |
|
78 <xsl:param name="_indent" select="0"/> |
|
79 <xsl:param name="element_path"/> |
|
80 <xsl:choose> |
|
81 <xsl:when test="$element_path!=''"> |
|
82 <xsl:variable name="child_name"> |
|
83 <xsl:call-template name="element_name"> |
|
84 <xsl:with-param name="path"> |
|
85 <xsl:value-of select="$element_path"/> |
|
86 </xsl:with-param> |
|
87 </xsl:call-template> |
|
88 </xsl:variable> |
|
89 <xsl:apply-templates select="ppx:pouInstance[@name=$child_name] | ppx:task/ppx:pouInstance[@name=$child_name] | ppx:globalVars/ppx:variable[@name=$child_name]/ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]"> |
|
90 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
91 <xsl:with-param name="element_path"> |
|
92 <xsl:call-template name="next_path"> |
|
93 <xsl:with-param name="path" select="$element_path"/> |
|
94 </xsl:call-template> |
|
95 </xsl:with-param> |
|
96 </xsl:apply-templates> |
|
97 </xsl:when> |
|
98 <xsl:otherwise> |
|
99 <xsl:value-of select="ns:ResourceTagName(ancestor::ppx:configuration/@name, @name)"/> |
|
100 </xsl:otherwise> |
|
101 </xsl:choose> |
|
102 </xsl:template> |
|
103 <xsl:template match="ppx:pouInstance"> |
|
104 <xsl:param name="_indent" select="0"/> |
|
105 <xsl:param name="element_path"/> |
|
106 <xsl:variable name="type_name"> |
|
107 <xsl:value-of select="@typeName"/> |
|
108 </xsl:variable> |
|
109 <xsl:apply-templates 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]"> |
|
110 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
111 <xsl:with-param name="element_path" select="$element_path"/> |
|
112 </xsl:apply-templates> |
|
113 </xsl:template> |
|
114 <xsl:template match="ppx:pou"> |
|
115 <xsl:param name="_indent" select="0"/> |
|
116 <xsl:param name="element_path"/> |
|
117 <xsl:choose> |
|
118 <xsl:when test="$element_path!=''"> |
|
119 <xsl:variable name="child_name"> |
|
120 <xsl:call-template name="element_name"> |
|
121 <xsl:with-param name="path" select="$element_path"/> |
|
122 </xsl:call-template> |
|
123 </xsl:variable> |
|
124 <xsl:apply-templates select="ppx:interface/*/ppx:variable[@name=$child_name]/ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]"> |
|
125 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
126 <xsl:with-param name="element_path"> |
|
127 <xsl:call-template name="next_path"> |
|
128 <xsl:with-param name="path" select="$element_path"/> |
|
129 </xsl:call-template> |
|
130 </xsl:with-param> |
|
131 </xsl:apply-templates> |
|
132 <xsl:apply-templates select="ppx:actions/ppx:action[@name=$child_name] | ppx:transitions/ppx:transition[@name=$child_name]"> |
|
133 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
134 </xsl:apply-templates> |
|
135 </xsl:when> |
|
136 <xsl:otherwise> |
|
137 <xsl:variable name="name"> |
|
138 <xsl:value-of select="@name"/> |
|
139 </xsl:variable> |
|
140 <xsl:value-of select="ns:PouTagName($name)"/> |
|
141 </xsl:otherwise> |
|
142 </xsl:choose> |
|
143 </xsl:template> |
|
144 <xsl:template match="ppx:action"> |
|
145 <xsl:param name="_indent" select="0"/> |
|
146 <xsl:value-of select="ns:ActionTagName(ancestor::ppx:pou/@name, @name)"/> |
|
147 </xsl:template> |
|
148 <xsl:template match="ppx:transition"> |
|
149 <xsl:param name="_indent" select="0"/> |
|
150 <xsl:value-of select="ns:TransitionTagName(ancestor::ppx:pou/@name, @name)"/> |
|
151 </xsl:template> |
|
152 <xsl:template match="ppx:dataType"> |
|
153 <xsl:param name="_indent" select="0"/> |
|
154 <xsl:param name="element_path"/> |
|
155 <xsl:apply-templates select="ppx:baseType/*[self::ppx:derived or self::ppx:struct or self::ppx:array]"> |
|
156 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
157 <xsl:with-param name="element_path" select="$element_path"/> |
|
158 </xsl:apply-templates> |
|
159 </xsl:template> |
|
160 <xsl:template match="ppx:derived"> |
|
161 <xsl:param name="_indent" select="0"/> |
|
162 <xsl:param name="element_path"/> |
|
163 <xsl:variable name="type_name"> |
|
164 <xsl:value-of select="@name"/> |
|
165 </xsl:variable> |
|
166 <xsl:apply-templates 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]"> |
|
167 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
168 <xsl:with-param name="element_path" select="$element_path"/> |
|
169 </xsl:apply-templates> |
|
170 </xsl:template> |
|
171 <xsl:template match="ppx:array"> |
|
172 <xsl:param name="_indent" select="0"/> |
|
173 <xsl:param name="element_path"/> |
|
174 <xsl:apply-templates select="ppx:baseType/*[self::ppx:derived or self::ppx:struct or self::ppx:array]"> |
|
175 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
176 <xsl:with-param name="element_path" select="$element_path"/> |
|
177 </xsl:apply-templates> |
|
178 </xsl:template> |
|
179 <xsl:template match="ppx:struct"> |
|
180 <xsl:param name="_indent" select="0"/> |
|
181 <xsl:param name="element_path"/> |
|
182 <xsl:variable name="child_name"> |
|
183 <xsl:call-template name="element_name"> |
|
184 <xsl:with-param name="path" select="$element_path"/> |
|
185 </xsl:call-template> |
|
186 </xsl:variable> |
|
187 <xsl:apply-templates select="ppx:variable[@name=$child_name]/ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]"> |
|
188 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
189 <xsl:with-param name="element_path"> |
|
190 <xsl:call-template name="next_path"> |
|
191 <xsl:with-param name="path" select="$element_path"/> |
|
192 </xsl:call-template> |
|
193 </xsl:with-param> |
|
194 </xsl:apply-templates> |
|
195 </xsl:template> |
|
196 </xsl:stylesheet> |