svghmi/widget_jsontable.ysl2
branchsvghmi
changeset 3043 d7b009e49e87
parent 3041 de4503de2f8c
child 3048 d46d545ff7b7
--- a/svghmi/widget_jsontable.ysl2	Thu Aug 27 09:59:35 2020 +0200
+++ b/svghmi/widget_jsontable.ysl2	Thu Aug 27 14:34:00 2020 +0200
@@ -70,7 +70,7 @@
                 choose {
                     when "contains($suffix,'=')" {
                         const "name", "substring-before($suffix,'=')";
-                        if "$expr/@name[. != $name]" 
+                        if "$expr/@name[. != $name]"
                             error > JsonTable : missplaced '=' or inconsistent names in Json data expressions.
                         attrib "name" value "$name";
                         attrib "content" > «$expr/@content»«substring-after($suffix,'=')»
@@ -144,18 +144,32 @@
     result "$widget_elts[@id=$eltid]/@inkscape:label";
 }
 
+template "svg:*", mode="json_table_render_except_comments"{
+    param "expressions";
+    param "widget_elts";
+
+    const "label", "func:filter_non_widget_label(., $widget_elts)";
+    // filter out "# commented" elements
+    if "not(starts-with($label,'#'))" 
+        apply ".", mode="json_table_render"{
+            with "expressions", "$expressions";
+            with "widget_elts", "$widget_elts";
+            with "label", "$label";
+        }
+}
+
 template "svg:*", mode="json_table_render" {
     param "expressions";
     param "widget_elts";
-    const "label", "func:filter_non_widget_label(., $widget_elts)";
-    apply ".", mode="json_table_elt_render" {
+    param "label";
+    apply ".", mode="json_table_elt_render"
         with "expressions", "func:json_expressions($expressions, $label)";
-    }
 }
 
 template "svg:g", mode="json_table_render" {
     param "expressions";
     param "widget_elts";
+    param "label";
     const "gid", "@id";
 
     // use intermediate variables for optimization
@@ -179,8 +193,7 @@
     // revert hiding in case it did happen before
     |           id("«@id»").setAttribute("style", "«@style»");
 
-    const "label", "func:filter_non_widget_label(., $widget_elts)";
-    apply "*", mode="json_table_render" {
+    apply "*", mode="json_table_render_except_comments" {
         with "expressions", "func:json_expressions(exsl:node-set($new_expressions), $label)";
         with "widget_elts", "$widget_elts";
     }
@@ -200,7 +213,7 @@
     |         this.apply_hmi_value(1, range);
     |         this.apply_hmi_value(2, position);
     |         console.log(range,position,jdata);
-    apply "$data_elt/*", mode="json_table_render" {
+    apply "$data_elt", mode="json_table_render_except_comments" {
         with "expressions","$initexpr_ns";
         with "widget_elts","$hmi_element/*[@inkscape:label = 'data']/descendant::svg:*";
     }