diff -r 61548f7d1bef -r 7b1db17287b6 svghmi/gen_index_xhtml.ysl2 --- a/svghmi/gen_index_xhtml.ysl2 Fri Feb 28 17:52:35 2020 +0100 +++ b/svghmi/gen_index_xhtml.ysl2 Fri Feb 28 22:54:07 2020 +0100 @@ -200,25 +200,14 @@ // return overlapping geometry for a given element // all intersercting element are returned // except groups, that must be contained to be counted in + const "groups", "/svg:svg | //svg:g"; + def "func:overlapping_geometry" { param "elt"; const "g", "$geometry[@Id = $elt/@id]"; const "candidates", "$geometry[@Id != $elt/@id]"; - result "$candidates[func:intersect($g, .) = 9]"; -/* - const "groups", "$candidates[@Id = //svg:g/@id]"; - const "graphic", "$candidates[@Id != $groups/@Id]"; - result "$groups[func:intersect($g, .) = 9] | $graphic[func:intersect($g, .) > 0]"; - */ - } - - def "func:sumarized_elements" { - param "elements"; - const "short_list", "$elements[not(ancestor::*/@id = $elements/@id)]"; - /* TODO exclude globally discardable elements from group fulfillment check */ - 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)])]"; - const "groups_to_add", "$filled_groups[not(ancestor::*/@id = $filled_groups/@id)]"; - result "$groups_to_add | $short_list[not(ancestor::svg:g/@id = $filled_groups/@id)]"; + result """$candidates[(@Id = $groups/@id and (func:intersect($g, .) = 9)) or + (not(@Id = $groups/@id) and (func:intersect($g, .) > 0 ))]"""; } def "func:all_related_elements" { @@ -229,6 +218,37 @@ result "$page_sub_elements"; } + def "func:required_elements" { + param "pages"; + choose{ + when "$pages"{ + result """func:all_related_elements($pages[1]) + | func:required_elements($pages[position()!=1])"""; + }otherwise{ + result "/.."; + } + } + } + + const "required_elements", + """//svg:defs/descendant-or-self::svg:* + | func:required_elements($hmi_pages)/ancestor-or-self::svg:*"""; + + const "discardable_elements", "//svg:*[not(@id = $required_elements/@id)]"; + + def "func:sumarized_elements" { + param "elements"; + const "short_list", "$elements[not(ancestor::*/@id = $elements/@id)]"; + const "filled_groups", """$short_list/parent::svg:*[ + not(descendant::*[ + not(self::svg:g) and + not(@id = $discardable_elements/@id) and + not(@id = $short_list/descendant-or-self::*[not(self::svg:g)]/@id) + ])]"""; + const "groups_to_add", "$filled_groups[not(ancestor::*/@id = $filled_groups/@id)]"; + result "$groups_to_add | $short_list[not(ancestor::svg:g/@id = $filled_groups/@id)]"; + } + def "func:detachable_elements" { param "pages"; choose{ @@ -242,9 +262,8 @@ } const "detachable_elements", "func:detachable_elements($hmi_pages)"; - const "essential_elements", "$detachable_elements | /svg:svg/svg:defs"; - const "required_elements", "$essential_elements//svg:* | $essential_elements/ancestor-or-self::svg:*"; - const "discardable_elements", "//svg:*[not(@id = $required_elements/@id)]"; + // const "essential_elements", "$detachable_elements | /svg:svg/svg:defs"; + // const "required_elements", "$essential_elements//svg:* | $essential_elements/ancestor-or-self::svg:*"; template "*", mode="index" { param "index", "0"; @@ -286,8 +305,8 @@ */ template "@* | node()", mode="inline_svg" { /* use real xsl:copy instead copy-of alias from yslt.yml2 */ - xsl:copy apply "@* | node()", mode="inline_svg"; - /* TODO filter out globally discardable elements */ + if "not(@id = $discardable_elements/@id)" + xsl:copy apply "@* | node()", mode="inline_svg"; } /* replaces inkscape's height and width hints. forces fit */