--- a/svghmi/detachable_elements.ysl2 Tue Mar 17 10:34:26 2020 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-// detachable_elements.ysl2
-// compute what elements are required by pages
-// and decide where to cut when removing/attaching
-// pages elements on page switch
-// returns all directly or indirectly refered elements
-def "func:refered_elements" {
- const "descend", "$elems/descendant-or-self::svg:*";
- const "clones", "$descend[self::svg:use]";
- const "originals", "//svg:*[concat('#',@id) = $clones/@xlink:href]";
- result "$descend | func:refered_elements($originals)";
-def "func:all_related_elements" {
- const "page_overlapping_geometry", "func:overlapping_geometry($page)";
- const "page_overlapping_elements", "//svg:*[@id = $page_overlapping_geometry/@Id]";
- const "page_sub_elements", "func:refered_elements($page | $page_overlapping_elements)";
- 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" {
- result """func:sumarized_elements(func:all_related_elements($pages[1]))
- | func:detachable_elements($pages[position()!=1])""";
-// Avoid nested detachables
-const "_detachable_elements", "func:detachable_elements($hmi_pages)";
-const "detachable_elements", "$_detachable_elements[not(ancestor::*/@id = $_detachable_elements/@id)]";
-function "debug_detachables" {
- foreach "$detachable_elements"{
-!debug_output_calls.append("debug_detachables")
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/svghmi/detachable_pages.ysl2 Tue Mar 17 11:24:07 2020 +0100
@@ -0,0 +1,150 @@
+// detachable_elements.ysl2 +// compute what elements are required by pages +// and decide where to cut when removing/attaching +// pages elements on page switch +const "hmi_pages", "$hmi_elements[func:parselabel(@inkscape:label)/widget/@type = 'Page']"; +const "default_page" choose { + when "count($hmi_pages) > 1" { + "$hmi_pages[func:parselabel(@inkscape:label)/widget/arg[1]/@value = 'Home']"; + when "$Home_page" > Home + error "No Home page defined!"; + when "count($hmi_pages) = 0" { + error "No page defined!"; + otherwise > «func:parselabel($hmi_pages/@inkscape:label)/widget/arg[1]/@value» +// returns all directly or indirectly refered elements +def "func:refered_elements" { + const "descend", "$elems/descendant-or-self::svg:*"; + const "clones", "$descend[self::svg:use]"; + const "originals", "//svg:*[concat('#',@id) = $clones/@xlink:href]"; + result "$descend | func:refered_elements($originals)"; +def "func:all_related_elements" { + const "page_overlapping_geometry", "func:overlapping_geometry($page)"; + const "page_overlapping_elements", "//svg:*[@id = $page_overlapping_geometry/@Id]"; + const "page_sub_elements", "func:refered_elements($page | $page_overlapping_elements)"; + 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" { + result """func:sumarized_elements(func:all_related_elements($pages[1])) + | func:detachable_elements($pages[position()!=1])"""; +// Avoid nested detachables +const "_detachable_elements", "func:detachable_elements($hmi_pages)"; +const "detachable_elements", "$_detachable_elements[not(ancestor::*/@id = $_detachable_elements/@id)]"; +def "func:is_descendant_path" { + result "string-length($ancest) > 0 and starts-with($descend,$ancest)"; +template "svg:*", mode="page_desc" { + const "desc", "func:parselabel(@inkscape:label)/widget"; + const "p", "$geometry[@Id = $page/@id]"; + const "page_all_elements", "func:all_related_elements($page)"; + const "all_page_widgets","$hmi_elements[@id = $page_all_elements/@id and @id != $page/@id]"; + const "page_relative_widgets", + "$all_page_widgets[func:is_descendant_path(func:parselabel(@inkscape:label)/widget/path/@value, $desc/path/@value)]"; + // Take closest ancestor in detachable_elements + // since nested detachable elements are filtered out + const "required_detachables", + """func:sumarized_elements($page_all_elements)/ + ancestor-or-self::*[@id = $detachable_elements/@id]"""; + | "«$desc/arg[1]/@value»": { + | widget: hmi_widgets["«@id»"], + | bbox: [«$p/@x», «$p/@y», «$p/@w», «$p/@h»], + if "$desc/path/@value" { + if "count($desc/path/@index)=0" + warning > Page id="«$page/@id»" : No match for path "«$desc/path/@value»" in HMI tree + | page_index: «$desc/path/@index», + foreach "$page_relative_widgets" { + | hmi_widgets["«@id»"]`if "position()!=last()" > ,` + foreach "$all_page_widgets[not(@id = $page_relative_widgets/@id)]" { + | hmi_widgets["«@id»"]`if "position()!=last()" > ,` + | required_detachables: { + foreach "$required_detachables" { + | "«@id»": detachable_elements["«@id»"]`if "position()!=last()" > ,` + | }`if "position()!=last()" > ,` +function "debug_detachables" { + foreach "$detachable_elements"{ +!debug_output_calls.append("debug_detachables") --- a/svghmi/gen_index_xhtml.xslt Tue Mar 17 10:34:26 2020 +0100
+++ b/svghmi/gen_index_xhtml.xslt Tue Mar 17 11:24:07 2020 +0100
@@ -1,30 +1,7 @@
<xsl:stylesheet xmlns:func="http://exslt.org/functions" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg" xmlns:str="http://exslt.org/strings" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:exsl="http://exslt.org/common" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ns="beremiz" xmlns:cc="http://creativecommons.org/ns#" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dc="http://purl.org/dc/elements/1.1/" extension-element-prefixes="ns func exsl regexp str dyn" version="1.0" exclude-result-prefixes="ns str regexp exsl func dyn">
<xsl:output method="xml" cdata-section-elements="xhtml:script"/>
- <xsl:variable name="svg_root_id" select="/svg:svg/@id"/>
- <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/>
- <xsl:variable name="hmi_pages" select="$hmi_elements[func:parselabel(@inkscape:label)/widget/@type = 'Page']"/>
- <xsl:variable name="default_page">
- <xsl:when test="count($hmi_pages) > 1">
- <xsl:variable name="Home_page" select="$hmi_pages[func:parselabel(@inkscape:label)/widget/arg[1]/@value = 'Home']"/>
- <xsl:when test="$Home_page">
- <xsl:text>Home</xsl:text>
- <xsl:message terminate="yes">No Home page defined!</xsl:message>
- <xsl:when test="count($hmi_pages) = 0">
- <xsl:message terminate="yes">No page defined!</xsl:message>
- <xsl:value-of select="func:parselabel($hmi_pages/@inkscape:label)/widget/arg[1]/@value"/>
+ <xsl:variable name="hmitree" select="ns:GetHMITree()"/> <xsl:variable name="_categories">
<xsl:text>HMI_ROOT</xsl:text>
@@ -37,6 +14,154 @@
<xsl:variable name="categories" select="exsl:node-set($_categories)"/>
+ <xsl:variable name="_indexed_hmitree"> + <xsl:apply-templates mode="index" select="$hmitree"/> + <xsl:variable name="indexed_hmitree" select="exsl:node-set($_indexed_hmitree)"/> + <xsl:template mode="index" match="*"> + <xsl:param name="index" select="0"/> + <xsl:param name="parentpath" select="''"/> + <xsl:variable name="content"> + <xsl:variable name="path"> + <xsl:when test="local-name() = 'HMI_ROOT'"> + <xsl:value-of select="$parentpath"/> + <xsl:value-of select="$parentpath"/> + <xsl:value-of select="@name"/> + <xsl:when test="not(local-name() = $categories/noindex)"> + <xsl:attribute name="index"> + <xsl:value-of select="$index"/> + <xsl:attribute name="hmipath"> + <xsl:value-of select="$path"/> + <xsl:for-each select="@*"> + <xsl:apply-templates mode="index" select="*[1]"> + <xsl:with-param name="index" select="$index + 1"/> + <xsl:with-param name="parentpath"> + <xsl:value-of select="$path"/> + <xsl:apply-templates mode="index" select="*[1]"> + <xsl:with-param name="index" select="$index"/> + <xsl:with-param name="parentpath"> + <xsl:value-of select="$path"/> + <xsl:copy-of select="$content"/> + <xsl:apply-templates mode="index" select="following-sibling::*[1]"> + <xsl:with-param name="index" select="$index + count(exsl:node-set($content)/*)"/> + <xsl:with-param name="parentpath"> + <xsl:value-of select="$parentpath"/> + <func:function name="func:parselabel"> + <xsl:param name="label"/> + <xsl:variable name="description" select="substring-after($label,'HMI:')"/> + <xsl:variable name="_args" select="substring-before($description,'@')"/> + <xsl:variable name="args"> + <xsl:when test="$_args"> + <xsl:value-of select="$_args"/> + <xsl:value-of select="$description"/> + <xsl:variable name="_type" select="substring-before($args,':')"/> + <xsl:variable name="type"> + <xsl:when test="$_type"> + <xsl:value-of select="$_type"/> + <xsl:value-of select="$args"/> + <xsl:variable name="ast"> + <xsl:attribute name="type"> + <xsl:value-of select="$type"/> + <xsl:for-each select="str:split(substring-after($args, ':'), ':')"> + <xsl:attribute name="value"> + <xsl:value-of select="."/> + <xsl:variable name="paths" select="substring-after($description,'@')"/> + <xsl:for-each select="str:split($paths, '@')"> + <xsl:if test="string-length(.) > 0"> + <xsl:attribute name="value"> + <xsl:value-of select="."/> + <xsl:variable name="path" select="."/> + <xsl:variable name="item" select="$indexed_hmitree/*[@hmipath = $path]"/> + <xsl:if test="count($item) = 1"> + <xsl:attribute name="index"> + <xsl:value-of select="$item/@index"/> + <func:result select="exsl:node-set($ast)"/> + <xsl:template mode="testtree" match="*"> + <xsl:param name="indent" select="''"/> + <xsl:value-of select="$indent"/> + <xsl:value-of select="local-name()"/> + <xsl:for-each select="@*"> + <xsl:value-of select="local-name()"/> + <xsl:text>="</xsl:text> + <xsl:value-of select="."/> + <xsl:text>" </xsl:text> + <xsl:apply-templates mode="testtree" select="*"> + <xsl:with-param name="indent"> + <xsl:value-of select="concat($indent,'>')"/> + <xsl:template name="debug_hmitree"> + <xsl:apply-templates mode="testtree" select="$hmitree"/> + <xsl:text>Indexed HMI tree + <xsl:apply-templates mode="testtree" select="$indexed_hmitree"/> <xsl:variable name="geometry" select="ns:GetSVGGeometry()"/>
<xsl:template name="debug_geometry">
@@ -102,6 +227,30 @@
<xsl:variable name="candidates" select="$geometry[@Id != $elt/@id]"/>
<func:result select="$candidates[(@Id = $groups/@id and (func:intersect($g, .) = 9)) or (not(@Id = $groups/@id) and (func:intersect($g, .) > 0 ))]"/>
+ <xsl:variable name="svg_root_id" select="/svg:svg/@id"/> + <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/> + <xsl:variable name="hmi_pages" select="$hmi_elements[func:parselabel(@inkscape:label)/widget/@type = 'Page']"/> + <xsl:variable name="default_page"> + <xsl:when test="count($hmi_pages) > 1"> + <xsl:variable name="Home_page" select="$hmi_pages[func:parselabel(@inkscape:label)/widget/arg[1]/@value = 'Home']"/> + <xsl:when test="$Home_page"> + <xsl:text>Home</xsl:text> + <xsl:message terminate="yes">No Home page defined!</xsl:message> + <xsl:when test="count($hmi_pages) = 0"> + <xsl:message terminate="yes">No page defined!</xsl:message> + <xsl:value-of select="func:parselabel($hmi_pages/@inkscape:label)/widget/arg[1]/@value"/> <func:function name="func:refered_elements">
<xsl:param name="elems"/>
<xsl:variable name="descend" select="$elems/descendant-or-self::svg:*"/>
@@ -156,6 +305,103 @@
<xsl:variable name="_detachable_elements" select="func:detachable_elements($hmi_pages)"/>
<xsl:variable name="detachable_elements" select="$_detachable_elements[not(ancestor::*/@id = $_detachable_elements/@id)]"/>
+ <func:function name="func:is_descendant_path"> + <xsl:param name="descend"/> + <xsl:param name="ancest"/> + <func:result select="string-length($ancest) > 0 and starts-with($descend,$ancest)"/> + <xsl:template mode="page_desc" match="svg:*"> + <xsl:variable name="desc" select="func:parselabel(@inkscape:label)/widget"/> + <xsl:variable name="page" select="."/> + <xsl:variable name="p" select="$geometry[@Id = $page/@id]"/> + <xsl:variable name="page_all_elements" select="func:all_related_elements($page)"/> + <xsl:variable name="all_page_widgets" select="$hmi_elements[@id = $page_all_elements/@id and @id != $page/@id]"/> + <xsl:variable name="page_relative_widgets" select="$all_page_widgets[func:is_descendant_path(func:parselabel(@inkscape:label)/widget/path/@value, $desc/path/@value)]"/> + <xsl:variable name="required_detachables" select="func:sumarized_elements($page_all_elements)/ ancestor-or-self::*[@id = $detachable_elements/@id]"/> + <xsl:text> "</xsl:text> + <xsl:value-of select="$desc/arg[1]/@value"/> + <xsl:text> widget: hmi_widgets["</xsl:text> + <xsl:value-of select="@id"/> + <xsl:text> bbox: [</xsl:text> + <xsl:value-of select="$p/@x"/> + <xsl:text>, </xsl:text> + <xsl:value-of select="$p/@y"/> + <xsl:text>, </xsl:text> + <xsl:value-of select="$p/@w"/> + <xsl:text>, </xsl:text> + <xsl:value-of select="$p/@h"/> + <xsl:if test="$desc/path/@value"> + <xsl:if test="count($desc/path/@index)=0"> + <xsl:message terminate="no"> + <xsl:text>Page id="</xsl:text> + <xsl:value-of select="$page/@id"/> + <xsl:text>" : No match for path "</xsl:text> + <xsl:value-of select="$desc/path/@value"/> + <xsl:text>" in HMI tree</xsl:text> + <xsl:text> page_index: </xsl:text> + <xsl:value-of select="$desc/path/@index"/> + <xsl:text> relative_widgets: [ + <xsl:for-each select="$page_relative_widgets"> + <xsl:text> hmi_widgets["</xsl:text> + <xsl:value-of select="@id"/> + <xsl:text>"]</xsl:text> + <xsl:if test="position()!=last()"> + <xsl:text> absolute_widgets: [ + <xsl:for-each select="$all_page_widgets[not(@id = $page_relative_widgets/@id)]"> + <xsl:text> hmi_widgets["</xsl:text> + <xsl:value-of select="@id"/> + <xsl:text>"]</xsl:text> + <xsl:if test="position()!=last()"> + <xsl:text> required_detachables: { + <xsl:for-each select="$required_detachables"> + <xsl:text> "</xsl:text> + <xsl:value-of select="@id"/> + <xsl:text>": detachable_elements["</xsl:text> + <xsl:value-of select="@id"/> + <xsl:text>"]</xsl:text> + <xsl:if test="position()!=last()"> + <xsl:text> }</xsl:text> + <xsl:if test="position()!=last()"> <xsl:template name="debug_detachables">
<xsl:for-each select="$detachable_elements">
@@ -164,100 +410,6 @@
- <xsl:variable name="hmitree" select="ns:GetHMITree()"/>
- <xsl:variable name="_indexed_hmitree">
- <xsl:apply-templates mode="index" select="$hmitree"/>
- <xsl:variable name="indexed_hmitree" select="exsl:node-set($_indexed_hmitree)"/>
- <xsl:template mode="index" match="*">
- <xsl:param name="index" select="0"/>
- <xsl:param name="parentpath" select="''"/>
- <xsl:variable name="content">
- <xsl:variable name="path">
- <xsl:when test="local-name() = 'HMI_ROOT'">
- <xsl:value-of select="$parentpath"/>
- <xsl:value-of select="$parentpath"/>
- <xsl:value-of select="@name"/>
- <xsl:when test="not(local-name() = $categories/noindex)">
- <xsl:attribute name="index">
- <xsl:value-of select="$index"/>
- <xsl:attribute name="hmipath">
- <xsl:value-of select="$path"/>
- <xsl:for-each select="@*">
- <xsl:apply-templates mode="index" select="*[1]">
- <xsl:with-param name="index" select="$index + 1"/>
- <xsl:with-param name="parentpath">
- <xsl:value-of select="$path"/>
- <xsl:apply-templates mode="index" select="*[1]">
- <xsl:with-param name="index" select="$index"/>
- <xsl:with-param name="parentpath">
- <xsl:value-of select="$path"/>
- <xsl:copy-of select="$content"/>
- <xsl:apply-templates mode="index" select="following-sibling::*[1]">
- <xsl:with-param name="index" select="$index + count(exsl:node-set($content)/*)"/>
- <xsl:with-param name="parentpath">
- <xsl:value-of select="$parentpath"/>
- <xsl:template mode="testtree" match="*">
- <xsl:param name="indent" select="''"/>
- <xsl:value-of select="$indent"/>
- <xsl:value-of select="local-name()"/>
- <xsl:for-each select="@*">
- <xsl:value-of select="local-name()"/>
- <xsl:text>="</xsl:text>
- <xsl:value-of select="."/>
- <xsl:text>" </xsl:text>
- <xsl:apply-templates mode="testtree" select="*">
- <xsl:with-param name="indent">
- <xsl:value-of select="concat($indent,'>')"/>
- <xsl:template name="debug_hmitree">
- <xsl:apply-templates mode="testtree" select="$hmitree"/>
- <xsl:text>Indexed HMI tree
- <xsl:apply-templates mode="testtree" select="$indexed_hmitree"/>
- <func:function name="func:is_descendant_path">
- <xsl:param name="descend"/>
- <xsl:param name="ancest"/>
- <func:result select="string-length($ancest) > 0 and starts-with($descend,$ancest)"/>
<xsl:template mode="inline_svg" match="@* | node()">
<xsl:if test="not(@id = $discardable_elements/@id)">
@@ -376,6 +528,15 @@
+ <xsl:text>debug_hmitree: + <xsl:call-template name="debug_hmitree"/> <xsl:text>debug_geometry:
<xsl:call-template name="debug_geometry"/>
@@ -392,15 +553,6 @@
- <xsl:text>debug_hmitree:
- <xsl:call-template name="debug_hmitree"/>
<xsl:for-each select="$to_unlink">
@@ -419,66 +571,6 @@
- <func:function name="func:parselabel">
- <xsl:param name="label"/>
- <xsl:variable name="description" select="substring-after($label,'HMI:')"/>
- <xsl:variable name="_args" select="substring-before($description,'@')"/>
- <xsl:variable name="args">
- <xsl:when test="$_args">
- <xsl:value-of select="$_args"/>
- <xsl:value-of select="$description"/>
- <xsl:variable name="_type" select="substring-before($args,':')"/>
- <xsl:variable name="type">
- <xsl:when test="$_type">
- <xsl:value-of select="$_type"/>
- <xsl:value-of select="$args"/>
- <xsl:variable name="ast">
- <xsl:attribute name="type">
- <xsl:value-of select="$type"/>
- <xsl:for-each select="str:split(substring-after($args, ':'), ':')">
- <xsl:attribute name="value">
- <xsl:value-of select="."/>
- <xsl:variable name="paths" select="substring-after($description,'@')"/>
- <xsl:for-each select="str:split($paths, '@')">
- <xsl:if test="string-length(.) > 0">
- <xsl:attribute name="value">
- <xsl:value-of select="."/>
- <xsl:variable name="path" select="."/>
- <xsl:variable name="item" select="$indexed_hmitree/*[@hmipath = $path]"/>
- <xsl:if test="count($item) = 1">
- <xsl:attribute name="index">
- <xsl:value-of select="$item/@index"/>
- <func:result select="exsl:node-set($ast)"/>
<xsl:template name="scripts">
@@ -613,98 +705,7 @@
<xsl:text>var page_desc = {
- <xsl:for-each select="$hmi_pages">
- <xsl:variable name="desc" select="func:parselabel(@inkscape:label)/widget"/>
- <xsl:variable name="page" select="."/>
- <xsl:variable name="p" select="$geometry[@Id = $page/@id]"/>
- <xsl:variable name="page_all_elements" select="func:all_related_elements($page)"/>
- <xsl:variable name="all_page_widgets" select="$hmi_elements[@id = $page_all_elements/@id and @id != $page/@id]"/>
- <xsl:variable name="page_relative_widgets" select="$all_page_widgets[func:is_descendant_path(func:parselabel(@inkscape:label)/widget/path/@value, $desc/path/@value)]"/>
- <xsl:variable name="required_detachables" select="func:sumarized_elements($page_all_elements)/ ancestor-or-self::*[@id = $detachable_elements/@id]"/>
- <xsl:text> "</xsl:text>
- <xsl:value-of select="$desc/arg[1]/@value"/>
- <xsl:text> widget: hmi_widgets["</xsl:text>
- <xsl:value-of select="@id"/>
- <xsl:text> bbox: [</xsl:text>
- <xsl:value-of select="$p/@x"/>
- <xsl:text>, </xsl:text>
- <xsl:value-of select="$p/@y"/>
- <xsl:text>, </xsl:text>
- <xsl:value-of select="$p/@w"/>
- <xsl:text>, </xsl:text>
- <xsl:value-of select="$p/@h"/>
- <xsl:if test="$desc/path/@value">
- <xsl:if test="count($desc/path/@index)=0">
- <xsl:message terminate="no">
- <xsl:text>Page id="</xsl:text>
- <xsl:value-of select="$page/@id"/>
- <xsl:text>" : No match for path "</xsl:text>
- <xsl:value-of select="$desc/path/@value"/>
- <xsl:text>" in HMI tree</xsl:text>
- <xsl:text> page_index: </xsl:text>
- <xsl:value-of select="$desc/path/@index"/>
- <xsl:text> relative_widgets: [
- <xsl:for-each select="$page_relative_widgets">
- <xsl:text> hmi_widgets["</xsl:text>
- <xsl:value-of select="@id"/>
- <xsl:text>"]</xsl:text>
- <xsl:if test="position()!=last()">
- <xsl:text> absolute_widgets: [
- <xsl:for-each select="$all_page_widgets[not(@id = $page_relative_widgets/@id)]">
- <xsl:text> hmi_widgets["</xsl:text>
- <xsl:value-of select="@id"/>
- <xsl:text>"]</xsl:text>
- <xsl:if test="position()!=last()">
- <xsl:text> required_detachables: {
- <xsl:for-each select="$required_detachables">
- <xsl:text> "</xsl:text>
- <xsl:value-of select="@id"/>
- <xsl:text>": detachable_elements["</xsl:text>
- <xsl:value-of select="@id"/>
- <xsl:text>"]</xsl:text>
- <xsl:if test="position()!=last()">
- <xsl:text> }</xsl:text>
- <xsl:if test="position()!=last()">
+ <xsl:apply-templates mode="page_desc" select="$hmi_pages"/> --- a/svghmi/gen_index_xhtml.ysl2 Tue Mar 17 10:34:26 2020 +0100
+++ b/svghmi/gen_index_xhtml.ysl2 Tue Mar 17 11:24:07 2020 +0100
@@ -36,47 +36,14 @@
exclude-result-prefixes="ns str regexp exsl func dyn" {
const "svg_root_id", "/svg:svg/@id";
const "hmi_elements", "//svg:*[starts-with(@inkscape:label, 'HMI:')]";
- const "hmi_pages", "$hmi_elements[func:parselabel(@inkscape:label)/widget/@type = 'Page']";
- const "default_page" choose {
- when "count($hmi_pages) > 1" {
- "$hmi_pages[func:parselabel(@inkscape:label)/widget/arg[1]/@value = 'Home']";
- when "$Home_page" > Home
- error "No Home page defined!";
- when "count($hmi_pages) = 0" {
- error "No page defined!";
- otherwise > «func:parselabel($hmi_pages/@inkscape:label)/widget/arg[1]/@value»
- noindex > HMI_PLC_STATUS
- noindex > HMI_CURRENT_PAGE
- const "categories", "exsl:node-set($_categories)";
- include detachable_elements.ysl2
- def "func:is_descendant_path" {
- result "string-length($ancest) > 0 and starts-with($descend,$ancest)";
+ include detachable_pages.ysl2 //////////////// Inline SVG
@@ -230,43 +197,6 @@
- def "func:parselabel" {
- const "description", "substring-after($label,'HMI:')";
- const "_args", "substring-before($description,'@')";
- when "$_args" value "$_args";
- otherwise value "$description";
- const "_type", "substring-before($args,':')";
- when "$_type" value "$_type";
- otherwise value "$args";
- const "ast" if "$type" widget {
- attrib "type" > «$type»
- foreach "str:split(substring-after($args, ':'), ':')" {
- const "paths", "substring-after($description,'@')";
- foreach "str:split($paths, '@')" {
- if "string-length(.) > 0" path {
- const "item", "$indexed_hmitree/*[@hmipath = $path]";
- attrib "index" > «$item/@index»
- result "exsl:node-set($ast)";
@@ -341,50 +271,7 @@
- const "desc", "func:parselabel(@inkscape:label)/widget";
- const "p", "$geometry[@Id = $page/@id]";
- const "page_all_elements", "func:all_related_elements($page)";
- const "all_page_widgets","$hmi_elements[@id = $page_all_elements/@id and @id != $page/@id]";
- const "page_relative_widgets",
- "$all_page_widgets[func:is_descendant_path(func:parselabel(@inkscape:label)/widget/path/@value, $desc/path/@value)]";
- // Take closest ancestor in detachable_elements
- // since nested detachable elements are filtered out
- const "required_detachables",
- """func:sumarized_elements($page_all_elements)/
- ancestor-or-self::*[@id = $detachable_elements/@id]""";
- | "«$desc/arg[1]/@value»": {
- | widget: hmi_widgets["«@id»"],
- | bbox: [«$p/@x», «$p/@y», «$p/@w», «$p/@h»],
- if "$desc/path/@value" {
- if "count($desc/path/@index)=0"
- warning > Page id="«$page/@id»" : No match for path "«$desc/path/@value»" in HMI tree
- | page_index: «$desc/path/@index»,
- foreach "$page_relative_widgets" {
- | hmi_widgets["«@id»"]`if "position()!=last()" > ,`
- foreach "$all_page_widgets[not(@id = $page_relative_widgets/@id)]" {
- | hmi_widgets["«@id»"]`if "position()!=last()" > ,`
- | required_detachables: {
- foreach "$required_detachables" {
- | "«@id»": detachable_elements["«@id»"]`if "position()!=last()" > ,`
- | }`if "position()!=last()" > ,`
+ apply "$hmi_pages", mode="page_desc"; --- a/svghmi/hmi_tree.ysl2 Tue Mar 17 10:34:26 2020 +0100
+++ b/svghmi/hmi_tree.ysl2 Tue Mar 17 11:24:07 2020 +0100
@@ -4,6 +4,12 @@
// HMI Tree computed from VARIABLES.CSV in svghmi.py
const "hmitree", "ns:GetHMITree()";
+ noindex > HMI_PLC_STATUS + noindex > HMI_CURRENT_PAGE +const "categories", "exsl:node-set($_categories)"; const "_indexed_hmitree" apply "$hmitree", mode="index";
@@ -46,6 +52,44 @@
+ const "description", "substring-after($label,'HMI:')"; + const "_args", "substring-before($description,'@')"; + when "$_args" value "$_args"; + otherwise value "$description"; + const "_type", "substring-before($args,':')"; + when "$_type" value "$_type"; + otherwise value "$args"; + const "ast" if "$type" widget { + attrib "type" > «$type» + foreach "str:split(substring-after($args, ':'), ':')" { + const "paths", "substring-after($description,'@')"; + foreach "str:split($paths, '@')" { + if "string-length(.) > 0" path { + const "item", "$indexed_hmitree/*[@hmipath = $path]"; + attrib "index" > «$item/@index» + result "exsl:node-set($ast)"; template "*", mode="testtree"{