svghmi/gen_index_xhtml.ysl2
branchsvghmi
changeset 2791 d022523cb621
parent 2790 8fab1886ebec
child 2792 0c0d3895b036
equal deleted inserted replaced
2790:8fab1886ebec 2791:d022523cb621
    19     
    19     
    20     /* This retrieves geometry obtained through "inkscape -S" 
    20     /* This retrieves geometry obtained through "inkscape -S" 
    21      * already parsed by python and presented as a list of 
    21      * already parsed by python and presented as a list of 
    22      * <bbox x="0" y="0" w="42" h="42">
    22      * <bbox x="0" y="0" w="42" h="42">
    23      */
    23      */
    24     variable "geometry", "ns:GetSVGGeometry()";
    24     const "geometry", "ns:GetSVGGeometry()";
    25     variable "hmitree", "ns:GetHMITree()";
    25     const "hmitree", "ns:GetHMITree()";
    26 
    26 
    27     variable "_categories" {
    27     const "_categories" {
    28         noindex > HMI_ROOT
    28         noindex > HMI_ROOT
    29         noindex > HMI_LABEL
    29         noindex > HMI_LABEL
    30         noindex > HMI_CLASS
    30         noindex > HMI_CLASS
    31         noindex > HMI_PLC_STATUS
    31         noindex > HMI_PLC_STATUS
    32         noindex > HMI_CURRENT_PAGE
    32         noindex > HMI_CURRENT_PAGE
    33     }
    33     }
    34     variable "categories", "exsl:node-set($_categories)";
    34     const "categories", "exsl:node-set($_categories)";
    35     //variable "indexed_hmitree", "$hmitree[not(local-name() = $categories/noindex/text())]";
    35     //const "indexed_hmitree", "$hmitree[not(local-name() = $categories/noindex/text())]";
    36     variable "indexed_hmitree" apply "$hmitree", mode="index";
    36     const "_indexed_hmitree" apply "$hmitree", mode="index";
       
    37     const "indexed_hmitree", "exsl:node-set($_indexed_hmitree)";
    37 
    38 
    38     template "node()", mode="index"{
    39     template "*", mode="index"{
    39         param "index", "0";
    40         param "index", "0";
    40         variable "content" {
    41         param "parentpath", "''";
       
    42         const "content" {
       
    43             const "path"
       
    44                 choose {
       
    45                     when "local-name() = 'HMI_ROOT'" > «$parentpath»
       
    46                     otherwise > «$parentpath»/«@name»
       
    47                 }
    41             choose {
    48             choose {
    42                 when "not(local-name() = $categories/noindex)" {
    49                 when "not(local-name() = $categories/noindex)" {
    43                     xsl:copy {
    50                     xsl:copy {
    44                         attrib "index" > «$index»
    51                         attrib "index" > «$index»
       
    52                         attrib "hmipath" > «$path»
    45                         foreach "@*" xsl:copy;
    53                         foreach "@*" xsl:copy;
    46                     }
    54                     }
    47                     /* no node expected below value nodes */
    55                     /* no node expected below value nodes */
    48                 }
    56                 }
    49                 otherwise {
    57                 otherwise {
    50                     apply "*[1]", mode="index"{
    58                     apply "*[1]", mode="index"{
    51                         with "index", "$index";
    59                         with "index", "$index";
       
    60                         with "parentpath" > «$path»
    52                     }
    61                     }
    53                 }
    62                 }
    54             }
    63             }
    55         }
    64         }
    56 
    65 
    57         copy "$content";
    66         copy "$content";
    58         apply "following-sibling::*[1]", mode="index" {
    67         apply "following-sibling::*[1]", mode="index" {
    59             with "index", "$index + count(exsl:node-set($content)/*)";
    68             with "index", "$index + count(exsl:node-set($content)/*)";
       
    69             with "parentpath" > «$parentpath»
    60         }
    70         }
    61     }
    71     }
    62 
    72 
    63     /* Identity template :
    73     /* Identity template :
    64      *  - copy every attributes 
    74      *  - copy every attributes 
    65      *  - copy every sub-elements
    75      *  - copy every sub-elements
    66      */
    76      */
    67     template "@* | node()" {
    77     template "@* | node()", mode="identity_svg" {
    68       /* use real xsl:copy instead copy-of alias from yslt.yml2 */
    78       /* use real xsl:copy instead copy-of alias from yslt.yml2 */
    69       xsl:copy apply "@* | node()";
    79       xsl:copy apply "@* | node()", mode="identity_svg";
    70     }
    80     }
    71 
    81 
    72     variable "mark" > =HMI=\n
    82     const "mark" > =HMI=\n
    73 
    83 
    74     /* copy root node and add geometry as comment for a test */
    84     /* copy root node and add geometry as comment for a test */
    75     template "/" 
    85     template "/" 
    76       html xmlns="http://www.w3.org/1999/xhtml" {
    86       html xmlns="http://www.w3.org/1999/xhtml" {
    77           head;
    87           head;
    82                   }
    92                   }
    83                   comment {
    93                   comment {
    84                       apply "$hmitree", mode="testtree";
    94                       apply "$hmitree", mode="testtree";
    85                   }
    95                   }
    86                   comment {
    96                   comment {
    87                       apply "exsl:node-set($indexed_hmitree)", mode="testtree";
    97                       apply "$indexed_hmitree", mode="testtree";
    88                   }
    98                   }
    89                   apply "@* | node()";
    99                   apply "@* | node()", mode="identity_svg";
    90               }
   100               }
    91               script{
   101               script{
    92                   /* TODO : paste hmitree hash stored in hmi tree root node */
   102                   /* TODO : paste hmitree hash stored in hmi tree root node */
    93 
   103 
    94                   /* TODO re-enable
   104                   /* TODO re-enable
    97                       var Page;
   107                       var Page;
    98                       var Input;
   108                       var Input;
    99                       var Display;
   109                       var Display;
   100                       var res = [];
   110                       var res = [];
   101                   ||
   111                   ||
   102                   variable "midmark" > \n«$mark»
   112                   const "midmark" > \n«$mark»
   103                   apply """//*[contains(child::svg:desc, $midmark) or \
   113                   apply """//*[contains(child::svg:desc, $midmark) or \
   104                                starts-with(child::svg:desc, $mark)]""",2 
   114                                starts-with(child::svg:desc, $mark)]""",2 
   105                         mode="code_from_descs";
   115                         mode="code_from_descs";
   106                   ||
   116                   ||
   107                       return res;
   117                       return res;
   113                     - pages content
   123                     - pages content
   114                       + with ref to elt ?
   124                       + with ref to elt ?
   115                     - widgets parameters
   125                     - widgets parameters
   116                   */
   126                   */
   117 
   127 
   118                   ||
   128                   | var subscriptions = {
   119                   var subscriptions = {
   129 
   120                   ||
   130                   const "svg","/"; /* foreach loses document root */
   121                   //    apply "$hmitree", mode="subscription_";
   131                   foreach "$indexed_hmitree/*" {
   122                   ||
   132                       | «@index»: {
   123                       return res;
   133                       |     name: "«@name»",
       
   134                       |     hmipath: "«@hmipath»"
       
   135                       |     ids: [
       
   136                       const "hmipath","@hmipath";
       
   137                       foreach "$svg//*[substring-after(@inkscape:label,'@') = $hmipath]" {
       
   138                       |         "«@id»"`if "position()!=last()" > ,`
       
   139                       }
       
   140                       |     ]
       
   141                       | }`if "position()!=last()" > ,`
   124                   }
   142                   }
   125                   ||
   143 
       
   144                   | }
       
   145 
   126                   include text svghmi.js
   146                   include text svghmi.js
   127               }
   147               }
   128           }
   148           }
   129     }
   149     }
   130 
   150