svghmi/gen_dnd_widget_svg.ysl2
branchsvghmi
changeset 3223 061796d9855e
parent 3222 6adeeb16ac3e
child 3225 cfa5690c8c15
--- a/svghmi/gen_dnd_widget_svg.ysl2	Mon Apr 05 18:22:30 2021 +0200
+++ b/svghmi/gen_dnd_widget_svg.ysl2	Tue Apr 06 11:47:07 2021 +0200
@@ -19,6 +19,7 @@
             extension-element-prefixes="ns func exsl regexp str dyn"
             exclude-result-prefixes="ns func exsl regexp str dyn" {
 
+    param "hmi_path";
     const "svg", "/svg:svg";
     const "hmi_elements", "//svg:*[starts-with(@inkscape:label, 'HMI:')]";
     const "subhmitree", "ns:GetSubHMITree()";
@@ -28,8 +29,18 @@
     const "_parsed_widgets" apply "$hmi_elements", mode="parselabel";
     const "parsed_widgets","exsl:node-set($_parsed_widgets)";
 
+    const "selected_node_type","local-name($subhmitree)";
+    const "svg_widget", "$parsed_widgets/widget[1]";
+    const "svg_widget_type", "$svg_widget/@type";
+    const "svg_widget_path", "$svg_widget/@path";
+    const "svg_widget_count", "count($parsed_widgets/widget)";
+
     svgtmpl "@*", mode="inline_svg" xsl:copy;
 
+    svgtmpl "@inkscape:label[starts-with(., 'HMI:')]", mode="inline_svg" {
+        xsl:copy;
+    }
+
     template "node()", mode="inline_svg" {
       xsl:copy apply "@* | node()", mode="inline_svg";
     }
@@ -40,10 +51,6 @@
     template "/" {
         comment > Widget dropped in Inkscape from Beremiz
 
-        const "selected_node_type","local-name($subhmitree)";
-        const "svg_widget_type", "$parsed_widgets/widget[1]/@type";
-        const "svg_widget_count", "count($parsed_widgets/widget)";
-
         choose {
             when "$svg_widget_count < 1"
                 error > No widget detected on selected SVG
@@ -51,9 +58,11 @@
                 error > Multiple widget DnD not yet supported
             when """$selected_node_type = $NODES_TYPES and \
                     not($svg_widget_type = $HMI_NODES_COMPAT)"""
-                error > Widget incopatible with selected HMI tree node
+                error > Widget incompatible with selected HMI tree node
         }
+
         const "testmsg" {
+            msg value "$hmi_path";
             msg value "$selected_node_type";
             msg value "$svg_widget_type";
         }