svghmi/hmi_tree.ysl2
branchsvghmi
changeset 2886 6c82fad8be65
parent 2885 f398896b7ebf
child 2890 ae8063127e95
equal deleted inserted replaced
2885:f398896b7ebf 2886:6c82fad8be65
    61 //      arg value="param2";
    61 //      arg value="param2";
    62 //      path value="path1";
    62 //      path value="path1";
    63 //      path value="path2";
    63 //      path value="path2";
    64 //  }
    64 //  }
    65 //
    65 //
    66 def "func:parselabel" {
    66 template "*", mode="parselabel" {
    67     param "label";
    67     const "label","@inkscape:label";
    68     const "description", "substring-after($label,'HMI:')";
    68     const "description", "substring-after($label,'HMI:')";
    69 
    69 
    70     const "_args", "substring-before($description,'@')";
    70     const "_args", "substring-before($description,'@')";
    71     const "args" choose {
    71     const "args" choose {
    72         when "$_args" value "$_args";
    72         when "$_args" value "$_args";
    77     const "type" choose {
    77     const "type" choose {
    78         when "$_type" value "$_type";
    78         when "$_type" value "$_type";
    79         otherwise value "$args";
    79         otherwise value "$args";
    80     }
    80     }
    81 
    81 
    82     const "ast" if "$type" widget {
    82     if "$type" widget {
       
    83         attrib "id" > «@id»
    83         attrib "type" > «$type»
    84         attrib "type" > «$type»
    84         foreach "str:split(substring-after($args, ':'), ':')" {
    85         foreach "str:split(substring-after($args, ':'), ':')" {
    85             arg {
    86             arg {
    86                 attrib "value" > «.»
    87                 attrib "value" > «.»
    87             }
    88             }
    95                 if "count($item) = 1"
    96                 if "count($item) = 1"
    96                     attrib "index" > «$item/@index»
    97                     attrib "index" > «$item/@index»
    97             }
    98             }
    98         }
    99         }
    99     }
   100     }
   100 
       
   101     result "exsl:node-set($ast)";
       
   102 }
   101 }
   103 
   102 
   104 def "func:parselabels" {
   103 const "_parsed_widgets" apply "$hmi_elements", mode="parselabel";
   105     param "nodes"; 
   104 const "parsed_widgets","exsl:node-set($_parsed_widgets)";
   106     choose{
   105 
   107         when "$nodes"{
   106 def "func:widget" {
   108             result """func:parselabel($nodes[1]/@inkscape:label)
   107     param "id";
   109                       | func:parselabels($nodes[position()!=1])""";
   108     result "$parsed_widgets/widget[@id = $id]";
   110         }otherwise{
       
   111             result "/..";
       
   112         }
       
   113     }
       
   114 }
   109 }
       
   110 
   115 
   111 
   116 // Debug data
   112 // Debug data
   117 template "*", mode="testtree"{
   113 template "*", mode="testtree"{
   118     param "indent", "''";
   114     param "indent", "''";
   119     > «$indent» «local-name()» 
   115     > «$indent» «local-name()» 
   127     | Raw HMI tree
   123     | Raw HMI tree
   128     apply "$hmitree", mode="testtree";
   124     apply "$hmitree", mode="testtree";
   129     |
   125     |
   130     | Indexed HMI tree
   126     | Indexed HMI tree
   131     apply "$indexed_hmitree", mode="testtree";
   127     apply "$indexed_hmitree", mode="testtree";
       
   128     |
       
   129     | Parsed Widgets
       
   130     copy "_parsed_widgets";
       
   131     apply "$parsed_widgets", mode="testtree";
   132 }
   132 }
   133 !debug_output_calls.append("debug_hmitree")
   133 !debug_output_calls.append("debug_hmitree")