--- a/svghmi/gen_index_xhtml.xslt Wed Oct 09 09:04:35 2019 +0200
+++ b/svghmi/gen_index_xhtml.xslt Wed Oct 09 11:15:14 2019 +0200
@@ -3,6 +3,9 @@
<xsl:output method="xml" cdata-section-elements="script"/>
<xsl:variable name="geometry" select="ns:GetSVGGeometry()"/>
<xsl:variable name="hmitree" select="ns:GetHMITree()"/>
+ <xsl:variable name="hmi_elements" select="//*[starts-with(@inkscape:label, 'HMI:')]"/> + <xsl:variable name="hmi_geometry" select="$geometry[@Id = $hmi_elements/@id]"/> + <xsl:variable name="hmi_pages" select="$hmi_elements[func:parselabel(@inkscape:label)/widget/@type = 'Page']"/> <xsl:variable name="_categories">
<xsl:text>HMI_ROOT</xsl:text>
@@ -78,10 +81,6 @@
<xsl:apply-templates mode="identity_svg" select="@* | node()"/>
- <xsl:variable name="mark">
<xsl:text>Made with SVGHMI. https://beremiz.org</xsl:text>
@@ -91,7 +90,7 @@
- <xsl:apply-templates mode="testgeo" select="$geometry"/>
+ <xsl:apply-templates mode="testgeo" select="$hmi_geometry"/> <xsl:apply-templates mode="testtree" select="$hmitree"/>
@@ -138,7 +137,7 @@
<xsl:attribute name="type">
<xsl:value-of select="$type"/>
- <xsl:for-each select="str:split($args, ':')">
+ <xsl:for-each select="str:split(substring-after($args, ':'), ':')"> <xsl:attribute name="value">
<xsl:value-of select="."/>
@@ -202,12 +201,32 @@
<xsl:text>var page_desc = {
- <xsl:for-each select="//*[func:parselabel(@inkscape:label)/widget/@type = 'Page']">
- <xsl:value-of select="@inkscape:label"/>
+ <xsl:for-each select="$hmi_pages"> + <xsl:variable name="desc" select="func:parselabel(@inkscape:label)/widget"/> + <xsl:text> "</xsl:text> + <xsl:value-of select="$desc/arg[1]/@value"/> + <xsl:text> id: "</xsl:text> + <xsl:value-of select="@id"/> - <xsl:variable name="ast" select="func:parselabel(@inkscape:label)"/>
- <xsl:apply-templates mode="testtree" select="$ast"/>
+ <xsl:variable name="page" select="."/> + <xsl:variable name="p" select="$hmi_geometry[@Id = $page/@id]"/> + <xsl:for-each select="$hmi_geometry[@Id != $page/@id and @x >= $p/@x and @y >= $p/@y and @w <= $p/@w and @h <= $p/@h]"> + <xsl:text> "</xsl:text> + <xsl:value-of select="@Id"/> + <xsl:if test="position()!=last()"> --- a/svghmi/gen_index_xhtml.ysl2 Wed Oct 09 09:04:35 2019 +0200
+++ b/svghmi/gen_index_xhtml.ysl2 Wed Oct 09 11:15:14 2019 +0200
@@ -24,6 +24,11 @@
const "geometry", "ns:GetSVGGeometry()";
const "hmitree", "ns:GetHMITree()";
+ const "hmi_elements", "//*[starts-with(@inkscape:label, 'HMI:')]"; + const "hmi_geometry", "$geometry[@Id = $hmi_elements/@id]"; + const "hmi_pages", "$hmi_elements[func:parselabel(@inkscape:label)/widget/@type = 'Page']"; @@ -36,7 +41,7 @@
const "_indexed_hmitree" apply "$hmitree", mode="index";
const "indexed_hmitree", "exsl:node-set($_indexed_hmitree)";
- template "*", mode="index"{
+ template "*", mode="index" { param "parentpath", "''";
@@ -79,7 +84,7 @@
xsl:copy apply "@* | node()", mode="identity_svg";
+ /*const "mark" > =HMI=\n*/ /* copy root node and add geometry as comment for a test */
@@ -89,7 +94,7 @@
- apply "$geometry", mode="testgeo";
+ apply "$hmi_geometry", mode="testgeo"; apply "$hmitree", mode="testtree";
@@ -124,7 +129,7 @@
const "ast" if "$type" widget {
- foreach "str:split($args, ':')" {
+ foreach "str:split(substring-after($args, ':'), ':')" { @@ -188,11 +193,19 @@
- // apply "//*[substring-after(substring-before(@inkscape:label, '@'), 'HMI'
- foreach "//*[func:parselabel(@inkscape:label)/widget/@type = 'Page']" {
- const "ast", "func:parselabel(@inkscape:label)";
- apply "$ast", mode="testtree";
+ const "desc", "func:parselabel(@inkscape:label)/widget"; + | "«$desc/arg[1]/@value»": { + const "p", "$hmi_geometry[@Id = $page/@id]"; + foreach """$hmi_geometry[@Id != $page/@id and + @x >= $p/@x and @y >= $p/@y and + @w <= $p/@w and @h <= $p/@h]""" { + | "«@Id»"`if "position()!=last()" > ,`