47 |
47 |
48 copy "$content"; |
48 copy "$content"; |
49 apply "following-sibling::*[1]", mode="index" { |
49 apply "following-sibling::*[1]", mode="index" { |
50 with "index", "$index + count(exsl:node-set($content)/*)"; |
50 with "index", "$index + count(exsl:node-set($content)/*)"; |
51 with "parentpath" > «$parentpath» |
51 with "parentpath" > «$parentpath» |
52 } |
|
53 } |
|
54 |
|
55 def "func:get_hmi_tree_elt" { |
|
56 param "path"; |
|
57 param "root", "$hmitree"; |
|
58 message > get_hmi_tree_elt «$path» |
|
59 if "not(starts-with($path, '/'))" error > Given path "«$path»" should start with a "/" |
|
60 const "stripped", "substring($path, 2)"; |
|
61 const "token" choose { |
|
62 when "contains($stripped, '/')" value "substring-before($stripped, '/')"; |
|
63 otherwise value "$stripped"; |
|
64 } |
|
65 |
|
66 choose { |
|
67 when "string-length($token) = 0"{ |
|
68 result "$root"; |
|
69 } |
|
70 otherwise{ |
|
71 const "rest", "substring-after($stripped, $token)"; |
|
72 const "match", "$root/*[@name = $token]"; |
|
73 choose { |
|
74 when "string-length($rest) > 0"{ |
|
75 result "func:get_hmi_tree_el($rest, $match)"; |
|
76 } |
|
77 otherwise{ |
|
78 result "$match"; |
|
79 } |
|
80 } |
|
81 } |
|
82 } |
52 } |
83 } |
53 } |
84 |
54 |
85 // Parses: |
55 // Parses: |
86 // "HMI:WidgetType:param1:param2@path1@path2" |
56 // "HMI:WidgetType:param1:param2@path1@path2" |
137 param "id"; |
107 param "id"; |
138 result "$parsed_widgets/widget[@id = $id]"; |
108 result "$parsed_widgets/widget[@id = $id]"; |
139 } |
109 } |
140 |
110 |
141 |
111 |
|
112 def "func:is_descendant_path" { |
|
113 param "descend"; |
|
114 param "ancest"; |
|
115 // TODO : use HMI tree to answer more accurately |
|
116 result "string-length($ancest) > 0 and starts-with($descend,$ancest)"; |
|
117 } |
|
118 |
|
119 |
142 // Debug data |
120 // Debug data |
143 template "*", mode="testtree"{ |
121 template "*", mode="testtree"{ |
144 param "indent", "''"; |
122 param "indent", "''"; |
145 > «$indent» «local-name()» |
123 > «$indent» «local-name()» |
146 foreach "@*" > «local-name()»="«.»" |
124 foreach "@*" > «local-name()»="«.»" |