svghmi/gen_index_xhtml.ysl2
branchsvghmi
changeset 2836 ce6cecdb7320
parent 2834 6ac6a9dff594
child 2837 53d9eb6a7498
equal deleted inserted replaced
2835:bc666f020ab3 2836:ce6cecdb7320
     4 decl output(method, cdata-section-elements="xhtml:script");
     4 decl output(method, cdata-section-elements="xhtml:script");
     5 
     5 
     6 in xsl decl labels(*ptr, name="defs_by_labels") alias call-template {
     6 in xsl decl labels(*ptr, name="defs_by_labels") alias call-template {
     7     with "hmi_element", "$hmi_element";
     7     with "hmi_element", "$hmi_element";
     8     with "labels"{text *ptr};
     8     with "labels"{text *ptr};
       
     9 };
       
    10 
       
    11 in xsl decl optional_labels(*ptr, name="defs_by_labels") alias call-template {
       
    12     with "hmi_element", "$hmi_element";
       
    13     with "labels"{text *ptr};
       
    14     with "mandatory","'no'";
     9 };
    15 };
    10 
    16 
    11 istylesheet
    17 istylesheet
    12             /* From Inkscape */
    18             /* From Inkscape */
    13             xmlns:dc="http://purl.org/dc/elements/1.1/"
    19             xmlns:dc="http://purl.org/dc/elements/1.1/"
   335         param "hmi_element";
   341         param "hmi_element";
   336         const "widget_type","@type";
   342         const "widget_type","@type";
   337         foreach "str:split($labels)" {
   343         foreach "str:split($labels)" {
   338             const "name",".";
   344             const "name",".";
   339             const "elt_id","$hmi_element//*[@inkscape:label=$name][1]/@id";
   345             const "elt_id","$hmi_element//*[@inkscape:label=$name][1]/@id";
   340             if "$mandatory='yes' and not($elt_id)"
   346             choose {
   341                 warning > «$widget_type» widget must have a «$name» element
   347                 when "not($elt_id)" {
   342             | «$name»_elt: document.getElementById("«$elt_id»"),
   348                     if "$mandatory='yes'" {
       
   349                         // TODO FIXME error > «$widget_type» widget must have a «$name» element
       
   350                         warning > «$widget_type» widget must have a «$name» element
       
   351                     }
       
   352                     // otherwise produce nothing 
       
   353                 }
       
   354                 otherwise {
       
   355                     | «$name»_elt: document.getElementById("«$elt_id»"),
       
   356                 }
       
   357             }
   343         }
   358         }
   344     }
   359     }
   345 
   360 
   346 
   361 
   347     template "widget[@type='Display']", mode="widget_defs" {
   362     template "widget[@type='Display']", mode="widget_defs" {
   395         }
   410         }
   396     }
   411     }
   397 
   412 
   398     template "widget[@type='Input']", mode="widget_defs" {
   413     template "widget[@type='Input']", mode="widget_defs" {
   399         param "hmi_element";
   414         param "hmi_element";
   400         | frequency: 5,
   415         const "value_elt" {
   401         labels("value");
   416             optional_labels("value");
       
   417         }
       
   418         value "$value_elt";
       
   419         if "$value_elt"
       
   420             | frequency: 5,
   402         | dispatch: function(value) {
   421         | dispatch: function(value) {
       
   422         if "$value_elt"
   403         |     this.value_elt.textContent = String(value);
   423         |     this.value_elt.textContent = String(value);
   404         | },
   424         | },
   405         const "edit_elt_id","$hmi_element/*[@inkscape:label='edit'][1]/@id";
   425         const "edit_elt_id","$hmi_element/*[@inkscape:label='edit'][1]/@id";
   406         | init: function() {
   426         | init: function() {
   407         if "$edit_elt_id" {
   427         if "$edit_elt_id" {