svghmi/gen_index_xhtml.ysl2
branchsvghmi
changeset 2794 c10069a02ed0
parent 2793 2a97688c94c5
child 2795 c0cf62bb9aa7
equal deleted inserted replaced
2793:2a97688c94c5 2794:c10069a02ed0
    22      * <bbox x="0" y="0" w="42" h="42">
    22      * <bbox x="0" y="0" w="42" h="42">
    23      */
    23      */
    24     const "geometry", "ns:GetSVGGeometry()";
    24     const "geometry", "ns:GetSVGGeometry()";
    25     const "hmitree", "ns:GetHMITree()";
    25     const "hmitree", "ns:GetHMITree()";
    26 
    26 
       
    27     const "hmi_elements", "//*[starts-with(@inkscape:label, 'HMI:')]";
       
    28     const "hmi_geometry", "$geometry[@Id = $hmi_elements/@id]";
       
    29 
       
    30     const "hmi_pages", "$hmi_elements[func:parselabel(@inkscape:label)/widget/@type = 'Page']";
       
    31 
    27     const "_categories" {
    32     const "_categories" {
    28         noindex > HMI_ROOT
    33         noindex > HMI_ROOT
    29         noindex > HMI_LABEL
    34         noindex > HMI_LABEL
    30         noindex > HMI_CLASS
    35         noindex > HMI_CLASS
    31         noindex > HMI_PLC_STATUS
    36         noindex > HMI_PLC_STATUS
    34     const "categories", "exsl:node-set($_categories)";
    39     const "categories", "exsl:node-set($_categories)";
    35     //const "indexed_hmitree", "$hmitree[not(local-name() = $categories/noindex/text())]";
    40     //const "indexed_hmitree", "$hmitree[not(local-name() = $categories/noindex/text())]";
    36     const "_indexed_hmitree" apply "$hmitree", mode="index";
    41     const "_indexed_hmitree" apply "$hmitree", mode="index";
    37     const "indexed_hmitree", "exsl:node-set($_indexed_hmitree)";
    42     const "indexed_hmitree", "exsl:node-set($_indexed_hmitree)";
    38 
    43 
    39     template "*", mode="index"{
    44     template "*", mode="index" {
    40         param "index", "0";
    45         param "index", "0";
    41         param "parentpath", "''";
    46         param "parentpath", "''";
    42         const "content" {
    47         const "content" {
    43             const "path"
    48             const "path"
    44                 choose {
    49                 choose {
    77     template "@* | node()", mode="identity_svg" {
    82     template "@* | node()", mode="identity_svg" {
    78       /* use real xsl:copy instead copy-of alias from yslt.yml2 */
    83       /* use real xsl:copy instead copy-of alias from yslt.yml2 */
    79       xsl:copy apply "@* | node()", mode="identity_svg";
    84       xsl:copy apply "@* | node()", mode="identity_svg";
    80     }
    85     }
    81 
    86 
    82     const "mark" > =HMI=\n
    87     /*const "mark" > =HMI=\n*/
    83 
    88 
    84     /* copy root node and add geometry as comment for a test */
    89     /* copy root node and add geometry as comment for a test */
    85     template "/" { 
    90     template "/" { 
    86         comment > Made with SVGHMI. https://beremiz.org
    91         comment > Made with SVGHMI. https://beremiz.org
    87         html xmlns="http://www.w3.org/1999/xhtml" {
    92         html xmlns="http://www.w3.org/1999/xhtml" {
    88             head;
    93             head;
    89             body style="margin:0;" {
    94             body style="margin:0;" {
    90                 xsl:copy {
    95                 xsl:copy {
    91                     comment {
    96                     comment {
    92                         apply "$geometry", mode="testgeo";
    97                         apply "$hmi_geometry", mode="testgeo";
    93                     }
    98                     }
    94                     comment {
    99                     comment {
    95                         apply "$hmitree", mode="testtree";
   100                         apply "$hmitree", mode="testtree";
    96                     }
   101                     }
    97                     comment {
   102                     comment {
   122             otherwise value "$args";
   127             otherwise value "$args";
   123         }
   128         }
   124 
   129 
   125         const "ast" if "$type" widget {
   130         const "ast" if "$type" widget {
   126             attrib "type" > «$type»
   131             attrib "type" > «$type»
   127             foreach "str:split($args, ':')" {
   132             foreach "str:split(substring-after($args, ':'), ':')" {
   128                 arg {
   133                 arg {
   129                     attrib "value" > «.»
   134                     attrib "value" > «.»
   130                 }
   135                 }
   131             }
   136             }
   132             const "paths", "substring-after($description,'@')";
   137             const "paths", "substring-after($description,'@')";
   186 
   191 
   187         | }
   192         | }
   188         |
   193         |
   189         | var page_desc = {
   194         | var page_desc = {
   190 
   195 
   191         // apply "//*[substring-after(substring-before(@inkscape:label, '@'), 'HMI'
   196         foreach "$hmi_pages" {
   192         foreach "//*[func:parselabel(@inkscape:label)/widget/@type = 'Page']" {
   197             const "desc", "func:parselabel(@inkscape:label)/widget";
   193             | «@inkscape:label»
   198             |     "«$desc/arg[1]/@value»": {
   194             const "ast", "func:parselabel(@inkscape:label)";
   199             |         id: "«@id»"
   195             apply "$ast", mode="testtree";
   200             |         widgets: [
       
   201             const "page", "."; 
       
   202             const "p", "$hmi_geometry[@Id = $page/@id]"; 
       
   203             foreach """$hmi_geometry[@Id != $page/@id and 
       
   204                        @x >= $p/@x and @y >= $p/@y and 
       
   205                        @w <= $p/@w and @h <= $p/@h]""" {
       
   206                 |             "«@Id»"`if "position()!=last()" > ,`
       
   207             }
       
   208             |         ]
   196         }
   209         }
   197         | }
   210         | }
   198 
   211 
   199         include text svghmi.js
   212         include text svghmi.js
   200     }
   213     }