198 } |
198 } |
199 |
199 |
200 // return overlapping geometry for a given element |
200 // return overlapping geometry for a given element |
201 // all intersercting element are returned |
201 // all intersercting element are returned |
202 // except groups, that must be contained to be counted in |
202 // except groups, that must be contained to be counted in |
|
203 const "groups", "/svg:svg | //svg:g"; |
|
204 |
203 def "func:overlapping_geometry" { |
205 def "func:overlapping_geometry" { |
204 param "elt"; |
206 param "elt"; |
205 const "g", "$geometry[@Id = $elt/@id]"; |
207 const "g", "$geometry[@Id = $elt/@id]"; |
206 const "candidates", "$geometry[@Id != $elt/@id]"; |
208 const "candidates", "$geometry[@Id != $elt/@id]"; |
207 result "$candidates[func:intersect($g, .) = 9]"; |
209 result """$candidates[(@Id = $groups/@id and (func:intersect($g, .) = 9)) or |
208 /* |
210 (not(@Id = $groups/@id) and (func:intersect($g, .) > 0 ))]"""; |
209 const "groups", "$candidates[@Id = //svg:g/@id]"; |
|
210 const "graphic", "$candidates[@Id != $groups/@Id]"; |
|
211 result "$groups[func:intersect($g, .) = 9] | $graphic[func:intersect($g, .) > 0]"; |
|
212 */ |
|
213 } |
|
214 |
|
215 def "func:sumarized_elements" { |
|
216 param "elements"; |
|
217 const "short_list", "$elements[not(ancestor::*/@id = $elements/@id)]"; |
|
218 /* TODO exclude globally discardable elements from group fulfillment check */ |
|
219 const "filled_groups", "$short_list/parent::svg:*[not(descendant::*[not(self::svg:g)][not(@id = $short_list/descendant-or-self::*[not(self::svg:g)]/@id)])]"; |
|
220 const "groups_to_add", "$filled_groups[not(ancestor::*/@id = $filled_groups/@id)]"; |
|
221 result "$groups_to_add | $short_list[not(ancestor::svg:g/@id = $filled_groups/@id)]"; |
|
222 } |
211 } |
223 |
212 |
224 def "func:all_related_elements" { |
213 def "func:all_related_elements" { |
225 param "page"; |
214 param "page"; |
226 const "page_overlapping_geometry", "func:overlapping_geometry($page)"; |
215 const "page_overlapping_geometry", "func:overlapping_geometry($page)"; |
227 const "page_overlapping_elements", "//svg:*[@id = $page_overlapping_geometry/@Id]"; |
216 const "page_overlapping_elements", "//svg:*[@id = $page_overlapping_geometry/@Id]"; |
228 const "page_sub_elements", "func:refered_elements($page | $page_overlapping_elements)"; |
217 const "page_sub_elements", "func:refered_elements($page | $page_overlapping_elements)"; |
229 result "$page_sub_elements"; |
218 result "$page_sub_elements"; |
|
219 } |
|
220 |
|
221 def "func:required_elements" { |
|
222 param "pages"; |
|
223 choose{ |
|
224 when "$pages"{ |
|
225 result """func:all_related_elements($pages[1]) |
|
226 | func:required_elements($pages[position()!=1])"""; |
|
227 }otherwise{ |
|
228 result "/.."; |
|
229 } |
|
230 } |
|
231 } |
|
232 |
|
233 const "required_elements", |
|
234 """//svg:defs/descendant-or-self::svg:* |
|
235 | func:required_elements($hmi_pages)/ancestor-or-self::svg:*"""; |
|
236 |
|
237 const "discardable_elements", "//svg:*[not(@id = $required_elements/@id)]"; |
|
238 |
|
239 def "func:sumarized_elements" { |
|
240 param "elements"; |
|
241 const "short_list", "$elements[not(ancestor::*/@id = $elements/@id)]"; |
|
242 const "filled_groups", """$short_list/parent::svg:*[ |
|
243 not(descendant::*[ |
|
244 not(self::svg:g) and |
|
245 not(@id = $discardable_elements/@id) and |
|
246 not(@id = $short_list/descendant-or-self::*[not(self::svg:g)]/@id) |
|
247 ])]"""; |
|
248 const "groups_to_add", "$filled_groups[not(ancestor::*/@id = $filled_groups/@id)]"; |
|
249 result "$groups_to_add | $short_list[not(ancestor::svg:g/@id = $filled_groups/@id)]"; |
230 } |
250 } |
231 |
251 |
232 def "func:detachable_elements" { |
252 def "func:detachable_elements" { |
233 param "pages"; |
253 param "pages"; |
234 choose{ |
254 choose{ |
240 } |
260 } |
241 } |
261 } |
242 } |
262 } |
243 |
263 |
244 const "detachable_elements", "func:detachable_elements($hmi_pages)"; |
264 const "detachable_elements", "func:detachable_elements($hmi_pages)"; |
245 const "essential_elements", "$detachable_elements | /svg:svg/svg:defs"; |
265 // const "essential_elements", "$detachable_elements | /svg:svg/svg:defs"; |
246 const "required_elements", "$essential_elements//svg:* | $essential_elements/ancestor-or-self::svg:*"; |
266 // const "required_elements", "$essential_elements//svg:* | $essential_elements/ancestor-or-self::svg:*"; |
247 const "discardable_elements", "//svg:*[not(@id = $required_elements/@id)]"; |
|
248 |
267 |
249 template "*", mode="index" { |
268 template "*", mode="index" { |
250 param "index", "0"; |
269 param "index", "0"; |
251 param "parentpath", "''"; |
270 param "parentpath", "''"; |
252 const "content" { |
271 const "content" { |
284 * - copy every attributes |
303 * - copy every attributes |
285 * - copy every sub-elements |
304 * - copy every sub-elements |
286 */ |
305 */ |
287 template "@* | node()", mode="inline_svg" { |
306 template "@* | node()", mode="inline_svg" { |
288 /* use real xsl:copy instead copy-of alias from yslt.yml2 */ |
307 /* use real xsl:copy instead copy-of alias from yslt.yml2 */ |
289 xsl:copy apply "@* | node()", mode="inline_svg"; |
308 if "not(@id = $discardable_elements/@id)" |
290 /* TODO filter out globally discardable elements */ |
309 xsl:copy apply "@* | node()", mode="inline_svg"; |
291 } |
310 } |
292 |
311 |
293 /* replaces inkscape's height and width hints. forces fit */ |
312 /* replaces inkscape's height and width hints. forces fit */ |
294 template "svg:svg/@width", mode="inline_svg"; |
313 template "svg:svg/@width", mode="inline_svg"; |
295 template "svg:svg/@height", mode="inline_svg"; |
314 template "svg:svg/@height", mode="inline_svg"; |