--- a/svghmi/gen_index_xhtml.xslt Fri Feb 28 17:52:35 2020 +0100
+++ b/svghmi/gen_index_xhtml.xslt Fri Feb 28 22:54:07 2020 +0100
@@ -100,18 +100,12 @@
+ <xsl:variable name="groups" select="/svg:svg | //svg:g"/> <func:function name="func:overlapping_geometry">
<xsl:variable name="g" select="$geometry[@Id = $elt/@id]"/>
<xsl:variable name="candidates" select="$geometry[@Id != $elt/@id]"/>
- <func:result select="$candidates[func:intersect($g, .) = 9]"/>
- <func:function name="func:sumarized_elements">
- <xsl:param name="elements"/>
- <xsl:variable name="short_list" select="$elements[not(ancestor::*/@id = $elements/@id)]"/>
- <xsl:variable name="filled_groups" select="$short_list/parent::svg:*[not(descendant::*[not(self::svg:g)][not(@id = $short_list/descendant-or-self::*[not(self::svg:g)]/@id)])]"/>
- <xsl:variable name="groups_to_add" select="$filled_groups[not(ancestor::*/@id = $filled_groups/@id)]"/>
- <func:result select="$groups_to_add | $short_list[not(ancestor::svg:g/@id = $filled_groups/@id)]"/>
+ <func:result select="$candidates[(@Id = $groups/@id and (func:intersect($g, .) = 9)) or (not(@Id = $groups/@id) and (func:intersect($g, .) > 0 ))]"/> <func:function name="func:all_related_elements">
@@ -120,6 +114,26 @@
<xsl:variable name="page_sub_elements" select="func:refered_elements($page | $page_overlapping_elements)"/>
<func:result select="$page_sub_elements"/>
+ <func:function name="func:required_elements"> + <xsl:param name="pages"/> + <xsl:when test="$pages"> + <func:result select="func:all_related_elements($pages[1]) | func:required_elements($pages[position()!=1])"/> + <func:result select="/.."/> + <xsl:variable name="required_elements" select="//svg:defs/descendant-or-self::svg:* | func:required_elements($hmi_pages)/ancestor-or-self::svg:*"/> + <xsl:variable name="discardable_elements" select="//svg:*[not(@id = $required_elements/@id)]"/> + <func:function name="func:sumarized_elements"> + <xsl:param name="elements"/> + <xsl:variable name="short_list" select="$elements[not(ancestor::*/@id = $elements/@id)]"/> + <xsl:variable name="filled_groups" select="$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) ])]"/> + <xsl:variable name="groups_to_add" select="$filled_groups[not(ancestor::*/@id = $filled_groups/@id)]"/> + <func:result select="$groups_to_add | $short_list[not(ancestor::svg:g/@id = $filled_groups/@id)]"/> <func:function name="func:detachable_elements">
<xsl:param name="pages"/>
@@ -132,9 +146,6 @@
<xsl:variable name="detachable_elements" select="func:detachable_elements($hmi_pages)"/>
- <xsl:variable name="essential_elements" select="$detachable_elements | /svg:svg/svg:defs"/>
- <xsl:variable name="required_elements" select="$essential_elements//svg:* | $essential_elements/ancestor-or-self::svg:*"/>
- <xsl:variable name="discardable_elements" select="//svg:*[not(@id = $required_elements/@id)]"/>
<xsl:template mode="index" match="*">
<xsl:param name="index" select="0"/>
<xsl:param name="parentpath" select="''"/>
@@ -184,9 +195,11 @@
<xsl:template mode="inline_svg" match="@* | node()">
- <xsl:apply-templates mode="inline_svg" select="@* | node()"/>
+ <xsl:if test="not(@id = $discardable_elements/@id)"> + <xsl:apply-templates mode="inline_svg" select="@* | node()"/> <xsl:template mode="inline_svg" match="svg:svg/@width"/>
<xsl:template mode="inline_svg" match="svg:svg/@height"/>
--- 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" {
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" {
- 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" { + result """func:all_related_elements($pages[1]) + | func:required_elements($pages[position()!=1])"""; + 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" { + const "short_list", "$elements[not(ancestor::*/@id = $elements/@id)]"; + const "filled_groups", """$short_list/parent::svg:*[ + 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" {
@@ -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" {
@@ -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 */