|
1 <xsl:stylesheet version="1.0" |
|
2 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|
3 xmlns:ppx="http://www.plcopen.org/xml/tc6_0201" |
|
4 xmlns:ns="instances_ns" |
|
5 extension-element-prefixes="ns" |
|
6 exclude-result-prefixes="ns"> |
|
7 <xsl:param name="instance_type"/> |
|
8 <xsl:template match="ppx:project"> |
|
9 <instances> |
|
10 <xsl:apply-templates select="ppx:instances/ppx:configurations/ppx:configuration"/> |
|
11 </instances> |
|
12 </xsl:template> |
|
13 <xsl:template match="ppx:configuration"> |
|
14 <xsl:apply-templates select="ppx:globalVars/ppx:variable[ppx:type/ppx:derived]"> |
|
15 <xsl:with-param name="parent_path" select="@name"/> |
|
16 </xsl:apply-templates> |
|
17 <xsl:apply-templates select="ppx:resource"> |
|
18 <xsl:with-param name="parent_path" select="@name"/> |
|
19 </xsl:apply-templates> |
|
20 </xsl:template> |
|
21 <xsl:template match="ppx:resource"> |
|
22 <xsl:param name="parent_path"/> |
|
23 <xsl:variable name="resource_path"> |
|
24 <xsl:value-of select="$parent_path"/> |
|
25 <xsl:text>.</xsl:text> |
|
26 <xsl:value-of select="@name"/> |
|
27 </xsl:variable> |
|
28 <xsl:apply-templates select="ppx:globalVars/ppx:variable[ppx:type/ppx:derived]"> |
|
29 <xsl:with-param name="parent_path" select="$resource_path"/> |
|
30 </xsl:apply-templates> |
|
31 <xsl:apply-templates select="ppx:pouInstance | ppx:task/ppx:pouInstance"> |
|
32 <xsl:with-param name="parent_path" select="$resource_path"/> |
|
33 </xsl:apply-templates> |
|
34 </xsl:template> |
|
35 <xsl:template match="ppx:pouInstance"> |
|
36 <xsl:param name="parent_path"/> |
|
37 <xsl:variable name="pou_instance_path"> |
|
38 <xsl:value-of select="$parent_path"/> |
|
39 <xsl:text>.</xsl:text> |
|
40 <xsl:value-of select="@name"/> |
|
41 </xsl:variable> |
|
42 <xsl:choose> |
|
43 <xsl:when test="@typeName=$instance_type"> |
|
44 <instance> |
|
45 <xsl:attribute name="path"> |
|
46 <xsl:value-of select="$pou_instance_path"/> |
|
47 </xsl:attribute> |
|
48 </instance> |
|
49 </xsl:when> |
|
50 <xsl:otherwise> |
|
51 <ns:instance_definition> |
|
52 <xsl:attribute name="name"> |
|
53 <xsl:value-of select="@typeName"/> |
|
54 </xsl:attribute> |
|
55 <xsl:attribute name="path"> |
|
56 <xsl:value-of select="$pou_instance_path"/> |
|
57 </xsl:attribute> |
|
58 </ns:instance_definition> |
|
59 </xsl:otherwise> |
|
60 </xsl:choose> |
|
61 </xsl:template> |
|
62 <xsl:template match="ppx:pou"> |
|
63 <xsl:param name="instance_path"/> |
|
64 <xsl:apply-templates select="ppx:interface/*/ppx:variable[ppx:type/ppx:derived]"> |
|
65 <xsl:with-param name="parent_path" select="$instance_path"/> |
|
66 </xsl:apply-templates> |
|
67 </xsl:template> |
|
68 <xsl:template match="ppx:dataType"> |
|
69 <xsl:param name="instance_path"/> |
|
70 <xsl:apply-templates select="ppx:baseType/*[self::ppx:derived or self::ppx:struct or self::ppx:array]"> |
|
71 <xsl:with-param name="parent_path" select="$instance_path"/> |
|
72 </xsl:apply-templates> |
|
73 </xsl:template> |
|
74 <xsl:template match="ppx:variable"> |
|
75 <xsl:param name="parent_path"/> |
|
76 <xsl:variable name="variable_path"> |
|
77 <xsl:value-of select="$parent_path"/> |
|
78 <xsl:text>.</xsl:text> |
|
79 <xsl:value-of select="@name"/> |
|
80 </xsl:variable> |
|
81 <xsl:apply-templates select="ppx:type/ppx:derived"> |
|
82 <xsl:with-param name="variable_path" select="$variable_path"/> |
|
83 </xsl:apply-templates> |
|
84 </xsl:template> |
|
85 <xsl:template match="ppx:derived"> |
|
86 <xsl:param name="variable_path"/> |
|
87 <xsl:choose> |
|
88 <xsl:when test="@name=$instance_type"> |
|
89 <instance> |
|
90 <xsl:attribute name="path"> |
|
91 <xsl:value-of select="$variable_path"/> |
|
92 </xsl:attribute> |
|
93 </instance> |
|
94 </xsl:when> |
|
95 <xsl:otherwise> |
|
96 <ns:instance_definition> |
|
97 <xsl:attribute name="name"> |
|
98 <xsl:value-of select="@name"/> |
|
99 </xsl:attribute> |
|
100 <xsl:attribute name="path"> |
|
101 <xsl:value-of select="$variable_path"/> |
|
102 </xsl:attribute> |
|
103 </ns:instance_definition> |
|
104 </xsl:otherwise> |
|
105 </xsl:choose> |
|
106 </xsl:template> |
|
107 <xsl:template name="ppx:struct"> |
|
108 <xsl:param name="variable_path"/> |
|
109 <xsl:for-each select="ppx:variable[ppx:type/ppx:derived or ppx:type/ppx:struct or ppx:type/ppx:array]"> |
|
110 <xsl:variable name="element_path"> |
|
111 <xsl:value-of select="$variable_path"/> |
|
112 <xsl:text>.</xsl:text> |
|
113 <xsl:value-of select="@name"/> |
|
114 </xsl:variable> |
|
115 <xsl:apply-templates select="ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]"> |
|
116 <xsl:with-param name="variable_path" select="$element_path"/> |
|
117 </xsl:apply-templates> |
|
118 </xsl:for-each> |
|
119 </xsl:template> |
|
120 <xsl:template name="ppx:array"> |
|
121 <xsl:param name="variable_path"/> |
|
122 <xsl:apply-templates select="ppx:baseType/*[self::ppx:derived or self::ppx:struct or self::ppx:array]"> |
|
123 <xsl:with-param name="variable_path" select="$variable_path"/> |
|
124 </xsl:apply-templates> |
|
125 </xsl:template> |
|
126 <xsl:template match="pou_instance"> |
|
127 <xsl:apply-templates> |
|
128 <xsl:with-param name="instance_path" select="@pou_path"/> |
|
129 </xsl:apply-templates> |
|
130 </xsl:template> |
|
131 <xsl:template match="datatype_instance"> |
|
132 <xsl:apply-templates> |
|
133 <xsl:with-param name="instance_path" select="@datatype_path"/> |
|
134 </xsl:apply-templates> |
|
135 </xsl:template> |
|
136 <xsl:template match="text()"/> |
|
137 </xsl:stylesheet> |