svghmi/gen_dnd_widget_svg.ysl2
branchsvghmi
changeset 3229 c5be4fd425e7
parent 3225 cfa5690c8c15
child 3234 f2bfb047d0e6
equal deleted inserted replaced
3228:80f96db773bd 3229:c5be4fd425e7
    28     include parse_labels.ysl2
    28     include parse_labels.ysl2
    29     const "_parsed_widgets" apply "$hmi_elements", mode="parselabel";
    29     const "_parsed_widgets" apply "$hmi_elements", mode="parselabel";
    30     const "parsed_widgets","exsl:node-set($_parsed_widgets)";
    30     const "parsed_widgets","exsl:node-set($_parsed_widgets)";
    31 
    31 
    32     const "selected_node_type","local-name($subhmitree)";
    32     const "selected_node_type","local-name($subhmitree)";
    33     const "svg_widget", "$parsed_widgets/widget[1]";
    33     const "svg_widget", "$parsed_widgets/widget[1]"; // TODO take all widgets
    34     const "svg_widget_type", "$svg_widget/@type";
    34     const "svg_widget_type", "$svg_widget/@type";
    35     const "svg_widget_path", "$svg_widget/@path";
    35     const "svg_widget_path", "$svg_widget/@path";
    36     const "svg_widget_count", "count($parsed_widgets/widget)";
    36     const "svg_widget_count", "count($parsed_widgets/widget)";
    37 
    37 
       
    38     // Templates to change label paths(s)
       
    39     template "@* | node()", mode="replace_path" {
       
    40         xsl:copy apply "@* | node()", mode="replace_path";
       
    41     }
       
    42 
       
    43     template "path/@value", mode="replace_path" {
       
    44         attrib "value" > «$hmi_path»
       
    45     }
       
    46 
       
    47     // all attribs are usually copied
    38     svgtmpl "@*", mode="inline_svg" xsl:copy;
    48     svgtmpl "@*", mode="inline_svg" xsl:copy;
    39 
    49 
    40     svgtmpl "@inkscape:label[starts-with(., 'HMI:')]", mode="inline_svg" {
    50     // except labels, ignored
    41         attrib "inkscape:label" > «substring-before(., '@')»@«$hmi_path»
    51     svgtmpl "@inkscape:label[starts-with(., 'HMI:')]", mode="inline_svg";
       
    52 
       
    53     template "node()", mode="inline_svg" xsl:copy {
       
    54 
       
    55       // in case this node widget's main element inject label
       
    56       if "@id = $svg_widget/@id" {
       
    57           const "substituted_widget" apply "$svg_widget", mode="replace_path";
       
    58           const "substituted_widget_ns", "exsl:node-set($substituted_widget)";
       
    59           const "new_label" apply "$substituted_widget_ns", mode="genlabel";
       
    60           attrib "inkscape:label" > «$new_label»
       
    61       }
       
    62       // all nodes are copied as well
       
    63       apply "@* | node()", mode="inline_svg";
    42     }
    64     }
    43 
       
    44     template "node()", mode="inline_svg" {
       
    45       xsl:copy apply "@* | node()", mode="inline_svg";
       
    46     }
       
    47 
       
    48 
    65 
    49     const "NODES_TYPES","str:split('HMI_ROOT HMI_NODE')";
    66     const "NODES_TYPES","str:split('HMI_ROOT HMI_NODE')";
    50     const "HMI_NODES_COMPAT","str:split('Page Jump Foreach')";
    67     const "HMI_NODES_COMPAT","str:split('Page Jump Foreach')";
    51     template "/" {
    68     template "/" {
    52         comment > Widget dropped in Inkscape from Beremiz
    69         comment > Widget dropped in Inkscape from Beremiz