1 <?xml version="1.0"?> |
1 <?xml version="1.0"?> |
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:str="http://exslt.org/strings" xmlns:func="http://exslt.org/functions" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:ns="beremiz" version="1.0" extension-element-prefixes="ns func exsl regexp str dyn" exclude-result-prefixes="ns func exsl regexp str dyn"> |
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:str="http://exslt.org/strings" xmlns:func="http://exslt.org/functions" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:ns="beremiz" version="1.0" extension-element-prefixes="ns func exsl regexp str dyn" exclude-result-prefixes="ns func exsl regexp str dyn"> |
3 <xsl:output method="xml"/> |
3 <xsl:output method="xml"/> |
4 <xsl:param name="hmi_path"/> |
|
5 <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/> |
4 <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/> |
6 <xsl:variable name="subhmitree" select="ns:GetSubHMITree()"/> |
5 <xsl:variable name="widgetparams" select="ns:GetWidgetParams()"/> |
7 <xsl:variable name="indexed_hmitree" select="/.."/> |
6 <xsl:variable name="indexed_hmitree" select="/.."/> |
8 <xsl:variable name="pathregex" select="'^([^\[,]+)(\[[^\]]+\])?([\d,]*)$'"/> |
7 <xsl:variable name="pathregex" select="'^([^\[,]+)(\[[^\]]+\])?([\d,]*)$'"/> |
9 <xsl:template mode="parselabel" match="*"> |
8 <xsl:template mode="parselabel" match="*"> |
10 <xsl:variable name="label" select="@inkscape:label"/> |
9 <xsl:variable name="label" select="@inkscape:label"/> |
11 <xsl:variable name="id" select="@id"/> |
10 <xsl:variable name="id" select="@id"/> |
149 </xsl:template> |
153 </xsl:template> |
150 <xsl:variable name="_parsed_widgets"> |
154 <xsl:variable name="_parsed_widgets"> |
151 <xsl:apply-templates mode="parselabel" select="$hmi_elements"/> |
155 <xsl:apply-templates mode="parselabel" select="$hmi_elements"/> |
152 </xsl:variable> |
156 </xsl:variable> |
153 <xsl:variable name="parsed_widgets" select="exsl:node-set($_parsed_widgets)"/> |
157 <xsl:variable name="parsed_widgets" select="exsl:node-set($_parsed_widgets)"/> |
154 <xsl:variable name="selected_node_type" select="local-name($subhmitree)"/> |
|
155 <xsl:variable name="svg_widget" select="$parsed_widgets/widget[1]"/> |
158 <xsl:variable name="svg_widget" select="$parsed_widgets/widget[1]"/> |
156 <xsl:variable name="svg_widget_type" select="$svg_widget/@type"/> |
159 <xsl:variable name="svg_widget_type" select="$svg_widget/@type"/> |
157 <xsl:variable name="svg_widget_path" select="$svg_widget/@path"/> |
160 <xsl:variable name="svg_widget_path" select="$svg_widget/@path"/> |
158 <xsl:variable name="svg_widget_count" select="count($parsed_widgets/widget)"/> |
161 <xsl:variable name="svg_widget_count" select="count($parsed_widgets/widget)"/> |
159 <xsl:template mode="replace_path" match="@* | node()"> |
162 <xsl:template mode="replace_params" match="@* | node()"> |
160 <xsl:copy> |
163 <xsl:copy> |
161 <xsl:apply-templates mode="replace_path" select="@* | node()"/> |
164 <xsl:apply-templates mode="replace_params" select="@* | node()"/> |
162 </xsl:copy> |
165 </xsl:copy> |
163 </xsl:template> |
166 </xsl:template> |
164 <xsl:template mode="replace_path" match="path/@value"> |
167 <xsl:template mode="replace_params" match="arg"/> |
165 <xsl:attribute name="value"> |
168 <xsl:template mode="replace_params" match="path"/> |
166 <xsl:value-of select="$hmi_path"/> |
169 <xsl:template mode="replace_params" match="widget"> |
167 </xsl:attribute> |
170 <xsl:copy> |
|
171 <xsl:apply-templates mode="replace_params" select="@* | node()"/> |
|
172 <xsl:copy-of select="$widgetparams/*"/> |
|
173 </xsl:copy> |
168 </xsl:template> |
174 </xsl:template> |
169 <xsl:template xmlns="http://www.w3.org/2000/svg" mode="inline_svg" match="@*"> |
175 <xsl:template xmlns="http://www.w3.org/2000/svg" mode="inline_svg" match="@*"> |
170 <xsl:copy/> |
176 <xsl:copy/> |
171 </xsl:template> |
177 </xsl:template> |
172 <xsl:template xmlns="http://www.w3.org/2000/svg" mode="inline_svg" match="@inkscape:label[starts-with(., 'HMI:')]"/> |
178 <xsl:template xmlns="http://www.w3.org/2000/svg" mode="inline_svg" match="@inkscape:label[starts-with(., 'HMI:')]"/> |
173 <xsl:template mode="inline_svg" match="node()"> |
179 <xsl:template mode="inline_svg" match="node()"> |
174 <xsl:copy> |
180 <xsl:copy> |
175 <xsl:if test="@id = $svg_widget/@id"> |
181 <xsl:if test="@id = $svg_widget/@id"> |
176 <xsl:variable name="substituted_widget"> |
182 <xsl:variable name="substituted_widget"> |
177 <xsl:apply-templates mode="replace_path" select="$svg_widget"/> |
183 <xsl:apply-templates mode="replace_params" select="$svg_widget"/> |
178 </xsl:variable> |
184 </xsl:variable> |
179 <xsl:variable name="substituted_widget_ns" select="exsl:node-set($substituted_widget)"/> |
185 <xsl:variable name="substituted_widget_ns" select="exsl:node-set($substituted_widget)"/> |
180 <xsl:variable name="new_label"> |
186 <xsl:variable name="new_label"> |
181 <xsl:apply-templates mode="genlabel" select="$substituted_widget_ns"/> |
187 <xsl:apply-templates mode="genlabel" select="$substituted_widget_ns"/> |
182 </xsl:variable> |
188 </xsl:variable> |
202 <xsl:when test="$svg_widget_count > 1"> |
206 <xsl:when test="$svg_widget_count > 1"> |
203 <xsl:message terminate="yes"> |
207 <xsl:message terminate="yes"> |
204 <xsl:text>Multiple widget DnD not yet supported</xsl:text> |
208 <xsl:text>Multiple widget DnD not yet supported</xsl:text> |
205 </xsl:message> |
209 </xsl:message> |
206 </xsl:when> |
210 </xsl:when> |
207 <xsl:when test="$selected_node_type = $NODES_TYPES and not($svg_widget_type = $HMI_NODES_COMPAT)"> |
|
208 <xsl:message terminate="yes"> |
|
209 <xsl:text>Widget incompatible with selected HMI tree node</xsl:text> |
|
210 </xsl:message> |
|
211 </xsl:when> |
|
212 </xsl:choose> |
211 </xsl:choose> |
213 <xsl:variable name="testmsg"> |
|
214 <msg> |
|
215 <xsl:value-of select="$hmi_path"/> |
|
216 </msg> |
|
217 <msg> |
|
218 <xsl:value-of select="$selected_node_type"/> |
|
219 </msg> |
|
220 <msg> |
|
221 <xsl:value-of select="$svg_widget_type"/> |
|
222 </msg> |
|
223 </xsl:variable> |
|
224 <xsl:value-of select="ns:PassMessage($testmsg)"/> |
|
225 <xsl:apply-templates mode="inline_svg" select="/"/> |
212 <xsl:apply-templates mode="inline_svg" select="/"/> |
226 </xsl:template> |
213 </xsl:template> |
227 </xsl:stylesheet> |
214 </xsl:stylesheet> |