71 const "categories", "exsl:node-set($_categories)"; |
71 const "categories", "exsl:node-set($_categories)"; |
72 const "_indexed_hmitree" apply "$hmitree", mode="index"; |
72 const "_indexed_hmitree" apply "$hmitree", mode="index"; |
73 const "indexed_hmitree", "exsl:node-set($_indexed_hmitree)"; |
73 const "indexed_hmitree", "exsl:node-set($_indexed_hmitree)"; |
74 |
74 |
75 |
75 |
76 // TODO globally discardable elements, not (used by | ancestor of) any page |
76 // returns all directly or indirectly refered elements |
77 |
77 def "func:refered_elements" { |
|
78 param "elems"; |
|
79 const "descend", "$elems/descendant-or-self::svg:*"; |
|
80 const "clones", "$descend[self::svg:use]"; |
|
81 const "originals", "//svg:*[concat('#',@id) = $clones/@xlink:href]"; |
|
82 choose { |
|
83 when "$originals" |
|
84 result "$descend | func:refered_elements($originals)"; |
|
85 otherwise |
|
86 result "$descend"; |
|
87 } |
|
88 } |
|
89 |
|
90 def "func:intersect_1d" { |
|
91 /* it is assumed that a1 > a0 and b1 > b0 */ |
|
92 param "a0"; |
|
93 param "a1"; |
|
94 param "b0"; |
|
95 param "b1"; |
|
96 |
|
97 const "d0", "$a0 >= $b0"; |
|
98 const "d1", "$a1 >= $b1"; |
|
99 choose { |
|
100 when "not($d0) and $d1" |
|
101 result "3"; /* a included in b */ |
|
102 when "$d0 and not($d1)" |
|
103 result "2"; /* b included in a */ |
|
104 when "$d0 = $d1 and $b0 < $a1" |
|
105 result "1"; /* a and b are overlapped */ |
|
106 otherwise |
|
107 result "0"; /* no intersection*/ |
|
108 } |
|
109 } |
|
110 |
|
111 def "func:intersect" { |
|
112 param "a"; |
|
113 param "b"; |
|
114 |
|
115 const "x_intersect", "func:intersect_1d($a/@x, $a/@x+$a/@w, $b/@x, $b/@x+$b/@w)"; |
|
116 |
|
117 choose{ |
|
118 when "$x_intersect != 0"{ |
|
119 const "y_intersect", "func:intersect_1d($a/@y, $a/@y+$a/@w, $b/@y, $b/@y+$b/@w)"; |
|
120 result "$x_intersect * $y_intersect"; |
|
121 } |
|
122 otherwise result "0"; |
|
123 } |
|
124 } |
|
125 |
|
126 // return overlapping geometry a given element |
|
127 def "func:overlapping_geometry" { |
|
128 param "elt"; |
|
129 /* only included groups are returned */ |
|
130 /* all other elemenst are returne when overlapping*/ |
|
131 const "g", "$geometry[@Id = $elt/@id]"; |
|
132 result """$geometry[@Id != $elt/@id and func:intersect(., $g) = 4]"""; |
|
133 } |
|
134 |
|
135 def "func:sumarized_elements" { |
|
136 param "elements"; |
|
137 const "short_list", "$elements[not(ancestor::*/@id = $elements/@id)]"; |
|
138 /* TODO exclude globally discardable elements from group fulfillment check */ |
|
139 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)])]"; |
|
140 const "groups_to_add", "$filled_groups[not(ancestor::*/@id = $filled_groups/@id)]"; |
|
141 result "$groups_to_add | $short_list[not(ancestor::svg:g/@id = $filled_groups/@id)]"; |
|
142 } |
|
143 |
|
144 def "func:all_related_elements" { |
|
145 param "page"; |
|
146 const "page_overlapping_geometry", "func:overlapping_geometry($page)"; |
|
147 const "page_overlapping_elements", "//svg:*[@id = $page_overlapping_geometry/@Id]"; |
|
148 const "page_sub_elements", "func:refered_elements($page | $page_overlapping_elements)"; |
|
149 result "$page_sub_elements"; |
|
150 } |
|
151 |
|
152 def "func:detachable_elements" { |
|
153 param "pages"; |
|
154 choose{ |
|
155 when "$pages"{ |
|
156 result """func:sumarized_elements(func:all_related_elements($pages[1])) |
|
157 | func:detachable_elements($pages[position()!=1])"""; |
|
158 }otherwise{ |
|
159 result "/.."; |
|
160 } |
|
161 } |
|
162 } |
|
163 |
|
164 const "detachable_elements", "func:detachable_elements($hmi_pages)"; |
|
165 const "essential_elements", "$detachable_elements | /svg:svg/svg:defs"; |
|
166 const "required_elements", "$essential_elements//svg:* | $essential_elements/ancestor-or-self::svg:*"; |
|
167 const "discardable_elements", "//svg:*[not(@id = $required_elements/@id)]"; |
78 |
168 |
79 template "*", mode="index" { |
169 template "*", mode="index" { |
80 param "index", "0"; |
170 param "index", "0"; |
81 param "parentpath", "''"; |
171 param "parentpath", "''"; |
82 const "content" { |
172 const "content" { |
250 } |
352 } |
251 } |
353 } |
252 } |
354 } |
253 |
355 |
254 result "exsl:node-set($ast)"; |
356 result "exsl:node-set($ast)"; |
255 } |
|
256 |
|
257 // returns all directly or indirectly refered elements |
|
258 def "func:refered_elements" { |
|
259 param "elems"; |
|
260 const "descend", "$elems/descendant-or-self::svg:*"; |
|
261 const "clones", "$descend[self::svg:use]"; |
|
262 const "originals", "//svg:*[concat('#',@id) = $clones/@xlink:href]"; |
|
263 choose { |
|
264 when "$originals" |
|
265 result "$descend | func:refered_elements($originals)"; |
|
266 otherwise |
|
267 result "$descend"; |
|
268 } |
|
269 } |
|
270 |
|
271 // return included geometry a given element |
|
272 def "func:included_geometry" { |
|
273 param "elt"; |
|
274 const "g", "$geometry[@Id = $elt/@id]"; |
|
275 result """$geometry[@Id != $elt/@id and |
|
276 @x >= $g/@x and @y >= $g/@y and |
|
277 @x+@w <= $g/@x+$g/@w and @y+@h <= $g/@y+$g/@h]"""; |
|
278 |
|
279 } |
|
280 |
|
281 def "func:sumarized_elements" { |
|
282 param "elements"; |
|
283 const "short_list", "$elements[not(ancestor::*/@id = $elements/@id)]"; |
|
284 /* TODO exclude globally discardable elements from group fulfillment check */ |
|
285 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)])]"; |
|
286 const "groups_to_add", "$filled_groups[not(ancestor::*/@id = $filled_groups/@id)]"; |
|
287 result "$groups_to_add | $short_list[not(ancestor::svg:g/@id = $filled_groups/@id)]"; |
|
288 } |
|
289 |
|
290 def "func:all_related_elements" { |
|
291 param "page"; |
|
292 const "page_included_geometry", "func:included_geometry($page)"; |
|
293 const "page_sub_elements", "func:refered_elements($page)"; |
|
294 |
|
295 const "page_included_elements", "//svg:*[@id = $page_included_geometry/@Id]"; |
|
296 result "$page_sub_elements | $page_included_elements"; |
|
297 } |
357 } |
298 |
358 |
299 function "scripts" |
359 function "scripts" |
300 { |
360 { |
301 | //(function(){ |
361 | //(function(){ |