68 // take last available expression (i.e can have more suffixes than expressions) |
68 // take last available expression (i.e can have more suffixes than expressions) |
69 const "expr","$expressions[position() <= $pos][last()]/expression"; |
69 const "expr","$expressions[position() <= $pos][last()]/expression"; |
70 choose { |
70 choose { |
71 when "contains($suffix,'=')" { |
71 when "contains($suffix,'=')" { |
72 const "name", "substring-before($suffix,'=')"; |
72 const "name", "substring-before($suffix,'=')"; |
73 if "$expr/@name[. != $name]" |
73 if "$expr/@name[. != $name]" |
74 error > JsonTable : missplaced '=' or inconsistent names in Json data expressions. |
74 error > JsonTable : missplaced '=' or inconsistent names in Json data expressions. |
75 attrib "name" value "$name"; |
75 attrib "name" value "$name"; |
76 attrib "content" > «$expr/@content»«substring-after($suffix,'=')» |
76 attrib "content" > «$expr/@content»«substring-after($suffix,'=')» |
77 } |
77 } |
78 otherwise { |
78 otherwise { |
142 otherwise value "$elt/@id"; |
142 otherwise value "$elt/@id"; |
143 } |
143 } |
144 result "$widget_elts[@id=$eltid]/@inkscape:label"; |
144 result "$widget_elts[@id=$eltid]/@inkscape:label"; |
145 } |
145 } |
146 |
146 |
|
147 template "svg:*", mode="json_table_render_except_comments"{ |
|
148 param "expressions"; |
|
149 param "widget_elts"; |
|
150 |
|
151 const "label", "func:filter_non_widget_label(., $widget_elts)"; |
|
152 // filter out "# commented" elements |
|
153 if "not(starts-with($label,'#'))" |
|
154 apply ".", mode="json_table_render"{ |
|
155 with "expressions", "$expressions"; |
|
156 with "widget_elts", "$widget_elts"; |
|
157 with "label", "$label"; |
|
158 } |
|
159 } |
|
160 |
147 template "svg:*", mode="json_table_render" { |
161 template "svg:*", mode="json_table_render" { |
148 param "expressions"; |
162 param "expressions"; |
149 param "widget_elts"; |
163 param "widget_elts"; |
150 const "label", "func:filter_non_widget_label(., $widget_elts)"; |
164 param "label"; |
151 apply ".", mode="json_table_elt_render" { |
165 apply ".", mode="json_table_elt_render" |
152 with "expressions", "func:json_expressions($expressions, $label)"; |
166 with "expressions", "func:json_expressions($expressions, $label)"; |
153 } |
|
154 } |
167 } |
155 |
168 |
156 template "svg:g", mode="json_table_render" { |
169 template "svg:g", mode="json_table_render" { |
157 param "expressions"; |
170 param "expressions"; |
158 param "widget_elts"; |
171 param "widget_elts"; |
|
172 param "label"; |
159 const "gid", "@id"; |
173 const "gid", "@id"; |
160 |
174 |
161 // use intermediate variables for optimization |
175 // use intermediate variables for optimization |
162 const "varprefix" > obj_«$gid»_ |
176 const "varprefix" > obj_«$gid»_ |
163 | try { |
177 | try { |
177 } |
191 } |
178 |
192 |
179 // revert hiding in case it did happen before |
193 // revert hiding in case it did happen before |
180 | id("«@id»").setAttribute("style", "«@style»"); |
194 | id("«@id»").setAttribute("style", "«@style»"); |
181 |
195 |
182 const "label", "func:filter_non_widget_label(., $widget_elts)"; |
196 apply "*", mode="json_table_render_except_comments" { |
183 apply "*", mode="json_table_render" { |
|
184 with "expressions", "func:json_expressions(exsl:node-set($new_expressions), $label)"; |
197 with "expressions", "func:json_expressions(exsl:node-set($new_expressions), $label)"; |
185 with "widget_elts", "$widget_elts"; |
198 with "widget_elts", "$widget_elts"; |
186 } |
199 } |
187 | } catch(err) { |
200 | } catch(err) { |
188 | id("«$gid»").setAttribute("style", "display:none"); |
201 | id("«$gid»").setAttribute("style", "display:none"); |
198 | spread_json_data: function(janswer) { |
211 | spread_json_data: function(janswer) { |
199 | let [range,position,jdata] = janswer; |
212 | let [range,position,jdata] = janswer; |
200 | this.apply_hmi_value(1, range); |
213 | this.apply_hmi_value(1, range); |
201 | this.apply_hmi_value(2, position); |
214 | this.apply_hmi_value(2, position); |
202 | console.log(range,position,jdata); |
215 | console.log(range,position,jdata); |
203 apply "$data_elt/*", mode="json_table_render" { |
216 apply "$data_elt", mode="json_table_render_except_comments" { |
204 with "expressions","$initexpr_ns"; |
217 with "expressions","$initexpr_ns"; |
205 with "widget_elts","$hmi_element/*[@inkscape:label = 'data']/descendant::svg:*"; |
218 with "widget_elts","$hmi_element/*[@inkscape:label = 'data']/descendant::svg:*"; |
206 } |
219 } |
207 | } |
220 | } |
208 } |
221 } |