svghmi/gen_index_xhtml.ysl2
branchsvghmi
changeset 2836 ce6cecdb7320
parent 2834 6ac6a9dff594
child 2837 53d9eb6a7498
--- a/svghmi/gen_index_xhtml.ysl2	Thu Feb 13 09:41:43 2020 +0100
+++ b/svghmi/gen_index_xhtml.ysl2	Thu Feb 13 09:43:35 2020 +0100
@@ -8,6 +8,12 @@
     with "labels"{text *ptr};
 };
 
+in xsl decl optional_labels(*ptr, name="defs_by_labels") alias call-template {
+    with "hmi_element", "$hmi_element";
+    with "labels"{text *ptr};
+    with "mandatory","'no'";
+};
+
 istylesheet
             /* From Inkscape */
             xmlns:dc="http://purl.org/dc/elements/1.1/"
@@ -337,9 +343,18 @@
         foreach "str:split($labels)" {
             const "name",".";
             const "elt_id","$hmi_element//*[@inkscape:label=$name][1]/@id";
-            if "$mandatory='yes' and not($elt_id)"
-                warning > «$widget_type» widget must have a «$name» element
-            | «$name»_elt: document.getElementById("«$elt_id»"),
+            choose {
+                when "not($elt_id)" {
+                    if "$mandatory='yes'" {
+                        // TODO FIXME error > «$widget_type» widget must have a «$name» element
+                        warning > «$widget_type» widget must have a «$name» element
+                    }
+                    // otherwise produce nothing 
+                }
+                otherwise {
+                    | «$name»_elt: document.getElementById("«$elt_id»"),
+                }
+            }
         }
     }
 
@@ -397,9 +412,14 @@
 
     template "widget[@type='Input']", mode="widget_defs" {
         param "hmi_element";
-        | frequency: 5,
-        labels("value");
+        const "value_elt" {
+            optional_labels("value");
+        }
+        value "$value_elt";
+        if "$value_elt"
+            | frequency: 5,
         | dispatch: function(value) {
+        if "$value_elt"
         |     this.value_elt.textContent = String(value);
         | },
         const "edit_elt_id","$hmi_element/*[@inkscape:label='edit'][1]/@id";