16 xmlns:ns="beremiz" |
16 xmlns:ns="beremiz" |
17 |
17 |
18 extension-element-prefixes="ns func exsl regexp str dyn" |
18 extension-element-prefixes="ns func exsl regexp str dyn" |
19 exclude-result-prefixes="ns func exsl regexp str dyn" { |
19 exclude-result-prefixes="ns func exsl regexp str dyn" { |
20 |
20 |
21 param "hmi_path"; |
|
22 const "hmi_elements", "//svg:*[starts-with(@inkscape:label, 'HMI:')]"; |
21 const "hmi_elements", "//svg:*[starts-with(@inkscape:label, 'HMI:')]"; |
23 const "subhmitree", "ns:GetSubHMITree()"; |
22 const "widgetparams", "ns:GetWidgetParams()"; |
24 |
23 |
25 const "indexed_hmitree", "/.."; // compatibility with parse_labels.ysl2 |
24 const "indexed_hmitree", "/.."; // compatibility with parse_labels.ysl2 |
26 include parse_labels.ysl2 |
25 include parse_labels.ysl2 |
27 const "_parsed_widgets" apply "$hmi_elements", mode="parselabel"; |
26 const "_parsed_widgets" apply "$hmi_elements", mode="parselabel"; |
28 const "parsed_widgets","exsl:node-set($_parsed_widgets)"; |
27 const "parsed_widgets","exsl:node-set($_parsed_widgets)"; |
29 |
28 |
30 const "selected_node_type","local-name($subhmitree)"; |
29 const "svg_widget", "$parsed_widgets/widget[1]"; |
31 const "svg_widget", "$parsed_widgets/widget[1]"; // TODO take all widgets |
|
32 const "svg_widget_type", "$svg_widget/@type"; |
30 const "svg_widget_type", "$svg_widget/@type"; |
33 const "svg_widget_path", "$svg_widget/@path"; |
31 const "svg_widget_path", "$svg_widget/@path"; |
34 const "svg_widget_count", "count($parsed_widgets/widget)"; |
32 const "svg_widget_count", "count($parsed_widgets/widget)"; |
35 |
33 |
36 // Templates to change label paths(s) |
34 // Templates to change label paths(s) |
37 template "@* | node()", mode="replace_path" { |
35 template "@* | node()", mode="replace_params" { |
38 xsl:copy apply "@* | node()", mode="replace_path"; |
36 xsl:copy apply "@* | node()", mode="replace_params"; |
39 } |
37 } |
40 |
38 |
41 template "path/@value", mode="replace_path" { |
39 template "arg", mode="replace_params"; |
42 attrib "value" > «$hmi_path» |
40 template "path", mode="replace_params"; |
|
41 template "widget", mode="replace_params" { |
|
42 xsl:copy { |
|
43 copy "$widgetparams/*" |
|
44 }; |
43 } |
45 } |
44 |
46 |
45 // all attribs are usually copied |
47 // all attribs are usually copied |
46 svgtmpl "@*", mode="inline_svg" xsl:copy; |
48 svgtmpl "@*", mode="inline_svg" xsl:copy; |
47 |
49 |
50 |
52 |
51 template "node()", mode="inline_svg" xsl:copy { |
53 template "node()", mode="inline_svg" xsl:copy { |
52 |
54 |
53 // in case this node widget's main element inject label |
55 // in case this node widget's main element inject label |
54 if "@id = $svg_widget/@id" { |
56 if "@id = $svg_widget/@id" { |
55 const "substituted_widget" apply "$svg_widget", mode="replace_path"; |
57 const "substituted_widget" apply "$svg_widget", mode="replace_params"; |
56 const "substituted_widget_ns", "exsl:node-set($substituted_widget)"; |
58 const "substituted_widget_ns", "exsl:node-set($substituted_widget)"; |
57 const "new_label" apply "$substituted_widget_ns", mode="genlabel"; |
59 const "new_label" apply "$substituted_widget_ns", mode="genlabel"; |
58 attrib "inkscape:label" > «$new_label» |
60 attrib "inkscape:label" > «$new_label» |
59 } |
61 } |
60 // all nodes are copied as well |
62 // all nodes are copied as well |
61 apply "@* | node()", mode="inline_svg"; |
63 apply "@* | node()", mode="inline_svg"; |
62 } |
64 } |
63 |
65 |
64 const "NODES_TYPES","str:split('HMI_ROOT HMI_NODE')"; |
|
65 const "HMI_NODES_COMPAT","str:split('Page Jump Foreach')"; |
|
66 template "/" { |
66 template "/" { |
67 comment > Widget dropped in Inkscape from Beremiz |
67 comment > Widget dropped in Inkscape from Beremiz |
68 |
68 |
69 choose { |
69 choose { |
70 when "$svg_widget_count < 1" |
70 when "$svg_widget_count < 1" |
71 error > No widget detected on selected SVG |
71 error > No widget detected on selected SVG |
72 when "$svg_widget_count > 1" |
72 when "$svg_widget_count > 1" |
73 error > Multiple widget DnD not yet supported |
73 error > Multiple widget DnD not yet supported |
74 when """$selected_node_type = $NODES_TYPES and \ |
|
75 not($svg_widget_type = $HMI_NODES_COMPAT)""" |
|
76 error > Widget incompatible with selected HMI tree node |
|
77 } |
74 } |
78 |
75 |
79 const "testmsg" { |
76 const "testmsg" { |
80 msg value "$hmi_path"; |
|
81 msg value "$selected_node_type"; |
|
82 msg value "$svg_widget_type"; |
77 msg value "$svg_widget_type"; |
83 } |
78 } |
84 |
79 |
85 value "ns:PassMessage($testmsg)"; |
80 value "ns:PassMessage($testmsg)"; |
86 |
81 |