SVGHMI: allow designating widget's sub-elements as main element child rather than descendant. Names staring with "/" in yslt call to labels() only match direct widget childs.
authorEdouard Tisserant
Thu, 05 May 2022 10:31:16 +0200
changeset 3452 a0bd2c4cb8f7
parent 3451 302efcf746e0
child 3453 e5967a2ae2bb
SVGHMI: allow designating widget's sub-elements as main element child rather than descendant. Names staring with "/" in yslt call to labels() only match direct widget childs.
svghmi/widgets_common.ysl2
--- a/svghmi/widgets_common.ysl2	Thu May 05 10:24:56 2022 +0200
+++ b/svghmi/widgets_common.ysl2	Thu May 05 10:31:16 2022 +0200
@@ -395,8 +395,10 @@
     param "hmi_element";
     const "widget_type","@type";
     foreach "str:split($labels)" {
-        const "name",".";
-        const "elt","$result_widgets[@id = $hmi_element/@id]//*[@inkscape:label=$name][1]";
+        const "absolute", "starts-with(., '/')";
+        const "name","substring(.,number($absolute)+1)";
+        const "widget","$result_widgets[@id = $hmi_element/@id]";
+        const "elt","($widget//*[not($absolute) and @inkscape:label=$name] | $widget/*[$absolute and @inkscape:label=$name])[1]";
         choose {
             when "not($elt/@id)" {
                 if "$mandatory='yes'" {