diff -r 27dd409fba1d -r d57a12b8f5db svghmi/hmi_tree.ysl2 --- a/svghmi/hmi_tree.ysl2 Mon Mar 23 10:16:38 2020 +0100 +++ b/svghmi/hmi_tree.ysl2 Mon Mar 23 15:13:36 2020 +0100 @@ -52,14 +52,44 @@ } } +def "func:get_hmi_tree_elt" { + param "path"; + param "root", "$hmitree"; + message > get_hmi_tree_elt «$path» + if "not(starts-with($path, '/'))" error > Given path "«$path»" should start with a "/" + const "stripped", "substring($path, 2)"; + const "token" choose { + when "contains($stripped, '/')" value "substring-before($stripped, '/')"; + otherwise value "$stripped"; + } + + choose { + when "string-length($token) = 0"{ + result "$root"; + } + otherwise{ + const "rest", "substring-after($stripped, $token)"; + const "match", "$root/*[@name = $token]"; + choose { + when "string-length($rest) > 0"{ + result "func:get_hmi_tree_el($rest, $match)"; + } + otherwise{ + result "$match"; + } + } + } + } +} + // Parses: // "HMI:WidgetType:param1:param2@path1@path2" // // Into: -// widget type="WidgetType" { +// widget type="WidgetType" id="blah456" { // arg value="param1"; // arg value="param2"; -// path value="path1"; +// path value="path1" index="345"; // path value="path2"; // } //