1 <?xml version="1.0"?> |
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="instances_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"> |
2 <xsl:stylesheet xmlns:exsl="http://exslt.org/common" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:ppx="http://www.plcopen.org/xml/tc6_0201" xmlns:ns="instances_ns" 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"/> |
3 <xsl:output method="xml"/> |
4 <xsl:variable name="space" select="' '"/> |
|
5 <xsl:param name="autoindent" select="4"/> |
|
6 <xsl:param name="instance_type"/> |
4 <xsl:param name="instance_type"/> |
7 <xsl:template match="text()"> |
5 <xsl:template match="text()"/> |
8 <xsl:param name="_indent" select="0"/> |
|
9 </xsl:template> |
|
10 <xsl:variable name="project"> |
6 <xsl:variable name="project"> |
11 <xsl:copy-of select="document('project')/project/*"/> |
7 <xsl:copy-of select="document('project')/project/*"/> |
12 </xsl:variable> |
8 </xsl:variable> |
13 <xsl:variable name="stdlib"> |
9 <xsl:variable name="stdlib"> |
14 <xsl:copy-of select="document('stdlib')/stdlib/*"/> |
10 <xsl:copy-of select="document('stdlib')/stdlib/*"/> |
15 </xsl:variable> |
11 </xsl:variable> |
16 <xsl:variable name="extensions"> |
12 <xsl:variable name="extensions"> |
17 <xsl:copy-of select="document('extensions')/extensions/*"/> |
13 <xsl:copy-of select="document('extensions')/extensions/*"/> |
18 </xsl:variable> |
14 </xsl:variable> |
19 <xsl:template match="ppx:project"> |
15 <xsl:template match="ppx:project"> |
20 <xsl:param name="_indent" select="0"/> |
|
21 <instances> |
16 <instances> |
22 <xsl:apply-templates select="ppx:instances/ppx:configurations/ppx:configuration"> |
17 <xsl:apply-templates select="ppx:instances/ppx:configurations/ppx:configuration"/> |
23 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
24 </xsl:apply-templates> |
|
25 </instances> |
18 </instances> |
26 </xsl:template> |
19 </xsl:template> |
27 <xsl:template match="ppx:configuration"> |
20 <xsl:template match="ppx:configuration"> |
28 <xsl:param name="_indent" select="0"/> |
|
29 <xsl:apply-templates select="ppx:globalVars/ppx:variable[ppx:type/ppx:derived] | ppx:resource"> |
21 <xsl:apply-templates select="ppx:globalVars/ppx:variable[ppx:type/ppx:derived] | ppx:resource"> |
30 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
31 <xsl:with-param name="parent_path"> |
22 <xsl:with-param name="parent_path"> |
32 <xsl:value-of select="@name"/> |
23 <xsl:value-of select="@name"/> |
33 </xsl:with-param> |
24 </xsl:with-param> |
34 </xsl:apply-templates> |
25 </xsl:apply-templates> |
35 </xsl:template> |
26 </xsl:template> |
36 <xsl:template match="ppx:resource"> |
27 <xsl:template match="ppx:resource"> |
37 <xsl:param name="_indent" select="0"/> |
|
38 <xsl:param name="parent_path"/> |
28 <xsl:param name="parent_path"/> |
39 <xsl:variable name="resource_path"> |
29 <xsl:variable name="resource_path"> |
40 <xsl:value-of select="$parent_path"/> |
30 <xsl:value-of select="$parent_path"/> |
41 <xsl:text>.</xsl:text> |
31 <xsl:text>.</xsl:text> |
42 <xsl:value-of select="@name"/> |
32 <xsl:value-of select="@name"/> |
43 </xsl:variable> |
33 </xsl:variable> |
44 <xsl:apply-templates select="ppx:globalVars/ppx:variable[ppx:type/ppx:derived] | ppx:pouInstance | ppx:task/ppx:pouInstance"> |
34 <xsl:apply-templates select="ppx:globalVars/ppx:variable[ppx:type/ppx:derived] | ppx:pouInstance | ppx:task/ppx:pouInstance"> |
45 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
46 <xsl:with-param name="parent_path"> |
35 <xsl:with-param name="parent_path"> |
47 <xsl:value-of select="$resource_path"/> |
36 <xsl:value-of select="$resource_path"/> |
48 </xsl:with-param> |
37 </xsl:with-param> |
49 </xsl:apply-templates> |
38 </xsl:apply-templates> |
50 </xsl:template> |
39 </xsl:template> |
51 <xsl:template match="ppx:pouInstance"> |
40 <xsl:template match="ppx:pouInstance"> |
52 <xsl:param name="_indent" select="0"/> |
|
53 <xsl:param name="parent_path"/> |
41 <xsl:param name="parent_path"/> |
54 <xsl:variable name="pou_instance_path"> |
42 <xsl:variable name="pou_instance_path"> |
55 <xsl:value-of select="$parent_path"/> |
43 <xsl:value-of select="$parent_path"/> |
56 <xsl:text>.</xsl:text> |
44 <xsl:text>.</xsl:text> |
57 <xsl:value-of select="@name"/> |
45 <xsl:value-of select="@name"/> |
63 <xsl:otherwise> |
51 <xsl:otherwise> |
64 <xsl:variable name="type_name"> |
52 <xsl:variable name="type_name"> |
65 <xsl:value-of select="@typeName"/> |
53 <xsl:value-of select="@typeName"/> |
66 </xsl:variable> |
54 </xsl:variable> |
67 <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]"> |
55 <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]"> |
68 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
69 <xsl:with-param name="instance_path"> |
56 <xsl:with-param name="instance_path"> |
70 <xsl:value-of select="$pou_instance_path"/> |
57 <xsl:value-of select="$pou_instance_path"/> |
71 </xsl:with-param> |
58 </xsl:with-param> |
72 </xsl:apply-templates> |
59 </xsl:apply-templates> |
73 </xsl:otherwise> |
60 </xsl:otherwise> |
74 </xsl:choose> |
61 </xsl:choose> |
75 </xsl:template> |
62 </xsl:template> |
76 <xsl:template match="ppx:pou"> |
63 <xsl:template match="ppx:pou"> |
77 <xsl:param name="_indent" select="0"/> |
|
78 <xsl:param name="instance_path"/> |
64 <xsl:param name="instance_path"/> |
79 <xsl:apply-templates select="ppx:interface/*/ppx:variable[ppx:type/ppx:derived]"> |
65 <xsl:apply-templates select="ppx:interface/*/ppx:variable[ppx:type/ppx:derived]"> |
80 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
81 <xsl:with-param name="parent_path"> |
66 <xsl:with-param name="parent_path"> |
82 <xsl:value-of select="$instance_path"/> |
67 <xsl:value-of select="$instance_path"/> |
83 </xsl:with-param> |
68 </xsl:with-param> |
84 </xsl:apply-templates> |
69 </xsl:apply-templates> |
85 </xsl:template> |
70 </xsl:template> |
86 <xsl:template match="ppx:dataType"> |
71 <xsl:template match="ppx:dataType"> |
87 <xsl:param name="_indent" select="0"/> |
|
88 <xsl:param name="instance_path"/> |
72 <xsl:param name="instance_path"/> |
89 <xsl:apply-templates select="ppx:baseType/*[self::ppx:derived or self::ppx:struct or self::ppx:array]"> |
73 <xsl:apply-templates select="ppx:baseType/*[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="parent_path"> |
74 <xsl:with-param name="parent_path"> |
92 <xsl:value-of select="$instance_path"/> |
75 <xsl:value-of select="$instance_path"/> |
93 </xsl:with-param> |
76 </xsl:with-param> |
94 </xsl:apply-templates> |
77 </xsl:apply-templates> |
95 </xsl:template> |
78 </xsl:template> |
96 <xsl:template match="ppx:variable"> |
79 <xsl:template match="ppx:variable"> |
97 <xsl:param name="_indent" select="0"/> |
|
98 <xsl:param name="parent_path"/> |
80 <xsl:param name="parent_path"/> |
99 <xsl:variable name="variable_path"> |
81 <xsl:variable name="variable_path"> |
100 <xsl:value-of select="$parent_path"/> |
82 <xsl:value-of select="$parent_path"/> |
101 <xsl:text>.</xsl:text> |
83 <xsl:text>.</xsl:text> |
102 <xsl:value-of select="@name"/> |
84 <xsl:value-of select="@name"/> |
103 </xsl:variable> |
85 </xsl:variable> |
104 <xsl:apply-templates select="ppx:type/ppx:derived"> |
86 <xsl:apply-templates select="ppx:type/ppx:derived"> |
105 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
106 <xsl:with-param name="variable_path"> |
87 <xsl:with-param name="variable_path"> |
107 <xsl:value-of select="$variable_path"/> |
88 <xsl:value-of select="$variable_path"/> |
108 </xsl:with-param> |
89 </xsl:with-param> |
109 </xsl:apply-templates> |
90 </xsl:apply-templates> |
110 </xsl:template> |
91 </xsl:template> |
111 <xsl:template match="ppx:derived"> |
92 <xsl:template match="ppx:derived"> |
112 <xsl:param name="_indent" select="0"/> |
|
113 <xsl:param name="variable_path"/> |
93 <xsl:param name="variable_path"/> |
114 <xsl:choose> |
94 <xsl:choose> |
115 <xsl:when test="@name=$instance_type"> |
95 <xsl:when test="@name=$instance_type"> |
116 <xsl:value-of select="ns:AddInstance($variable_path)"/> |
96 <xsl:value-of select="ns:AddInstance($variable_path)"/> |
117 </xsl:when> |
97 </xsl:when> |
118 <xsl:otherwise> |
98 <xsl:otherwise> |
119 <xsl:variable name="type_name"> |
99 <xsl:variable name="type_name"> |
120 <xsl:value-of select="@name"/> |
100 <xsl:value-of select="@name"/> |
121 </xsl:variable> |
101 </xsl:variable> |
122 <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]"> |
102 <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]"> |
123 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
124 <xsl:with-param name="instance_path"> |
103 <xsl:with-param name="instance_path"> |
125 <xsl:value-of select="$variable_path"/> |
104 <xsl:value-of select="$variable_path"/> |
126 </xsl:with-param> |
105 </xsl:with-param> |
127 </xsl:apply-templates> |
106 </xsl:apply-templates> |
128 </xsl:otherwise> |
107 </xsl:otherwise> |
129 </xsl:choose> |
108 </xsl:choose> |
130 </xsl:template> |
109 </xsl:template> |
131 <xsl:template match="ppx:struct"> |
110 <xsl:template match="ppx:struct"> |
132 <xsl:param name="_indent" select="0"/> |
|
133 <xsl:param name="variable_path"/> |
111 <xsl:param name="variable_path"/> |
134 <xsl:for-each select="ppx:variable[ppx:type/ppx:derived or ppx:type/ppx:struct or ppx:type/ppx:array]"> |
112 <xsl:for-each select="ppx:variable[ppx:type/ppx:derived or ppx:type/ppx:struct or ppx:type/ppx:array]"> |
135 <xsl:variable name="element_path"> |
113 <xsl:variable name="element_path"> |
136 <xsl:value-of select="$variable_path"/> |
114 <xsl:value-of select="$variable_path"/> |
137 <xsl:text>.</xsl:text> |
115 <xsl:text>.</xsl:text> |
138 <xsl:value-of select="@name"/> |
116 <xsl:value-of select="@name"/> |
139 </xsl:variable> |
117 </xsl:variable> |
140 </xsl:for-each> |
118 </xsl:for-each> |
141 <xsl:apply-templates select="ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]"> |
119 <xsl:apply-templates select="ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]"> |
142 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
143 <xsl:with-param name="variable_path"> |
120 <xsl:with-param name="variable_path"> |
144 <xsl:value-of select="$element_path"/> |
121 <xsl:value-of select="$element_path"/> |
145 </xsl:with-param> |
122 </xsl:with-param> |
146 </xsl:apply-templates> |
123 </xsl:apply-templates> |
147 </xsl:template> |
124 </xsl:template> |
148 <xsl:template match="ppx:array"> |
125 <xsl:template match="ppx:array"> |
149 <xsl:param name="_indent" select="0"/> |
|
150 <xsl:param name="variable_path"/> |
126 <xsl:param name="variable_path"/> |
151 <xsl:apply-templates select="ppx:baseType/*[self::ppx:derived or self::ppx:struct or self::ppx:array]"> |
127 <xsl:apply-templates select="ppx:baseType/*[self::ppx:derived or self::ppx:struct or self::ppx:array]"> |
152 <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/> |
|
153 <xsl:with-param name="variable_path"> |
128 <xsl:with-param name="variable_path"> |
154 <xsl:value-of select="$variable_path"/> |
129 <xsl:value-of select="$variable_path"/> |
155 </xsl:with-param> |
130 </xsl:with-param> |
156 </xsl:apply-templates> |
131 </xsl:apply-templates> |
157 </xsl:template> |
132 </xsl:template> |