SVGHMI: Cosmetic changes svghmi
authorEdouard Tisserant
Tue, 17 Mar 2020 13:34:07 +0100
branchsvghmi
changeset 2879 58e6a91dc37f
parent 2878 bec552270ad1
child 2880 9da4ac0c9add
SVGHMI: Cosmetic changes
svghmi/gen_index_xhtml.xslt
svghmi/gen_index_xhtml.ysl2
svghmi/geometry.ysl2
--- a/svghmi/gen_index_xhtml.xslt	Tue Mar 17 13:16:01 2020 +0100
+++ b/svghmi/gen_index_xhtml.xslt	Tue Mar 17 13:34:07 2020 +0100
@@ -1,6 +1,7 @@
 <?xml version="1.0"?>
 <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="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/>
   <xsl:variable name="hmitree" select="ns:GetHMITree()"/>
   <xsl:variable name="_categories">
     <noindex>
@@ -166,7 +167,7 @@
   <xsl:template name="debug_geometry">
     <xsl:text>ID, x, y, w, h
 </xsl:text>
-    <xsl:for-each select="$geometry[@Id = $hmi_elements/@id]">
+    <xsl:for-each select="$geometry">
       <xsl:text> </xsl:text>
       <xsl:value-of select="@Id"/>
       <xsl:text> </xsl:text>
@@ -227,8 +228,6 @@
     <xsl:variable name="candidates" select="$geometry[@Id != $elt/@id]"/>
     <func:result select="$candidates[(@Id = $groups/@id and (func:intersect($g, .) = 9)) or &#10;                          (not(@Id = $groups/@id) and (func:intersect($g, .) &gt; 0 ))]"/>
   </func:function>
-  <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:choose>
@@ -568,15 +567,6 @@
       <xsl:text>
 </xsl:text>
     </xsl:comment>
-    <xsl:comment>
-      <xsl:text>Unlinked :
-</xsl:text>
-      <xsl:for-each select="$to_unlink">
-        <xsl:value-of select="@id"/>
-        <xsl:text>
-</xsl:text>
-      </xsl:for-each>
-    </xsl:comment>
     <html xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/1999/xhtml">
       <head/>
       <body style="margin:0;overflow:hidden;">
@@ -731,7 +721,7 @@
     <xsl:text>";
 </xsl:text>
     <xsl:text>var svg_root = id("</xsl:text>
-    <xsl:value-of select="$svg_root_id"/>
+    <xsl:value-of select="/svg:svg/@id"/>
     <xsl:text>");
 </xsl:text>
     <xsl:text>// svghmi.js
--- a/svghmi/gen_index_xhtml.ysl2	Tue Mar 17 13:16:01 2020 +0100
+++ b/svghmi/gen_index_xhtml.ysl2	Tue Mar 17 13:34:07 2020 +0100
@@ -36,13 +36,12 @@
             exclude-result-prefixes="ns str regexp exsl func dyn" {
 
 
+    const "hmi_elements", "//svg:*[starts-with(@inkscape:label, 'HMI:')]";
+
     include hmi_tree.ysl2
 
     include geometry.ysl2
 
-    const "svg_root_id", "/svg:svg/@id";
-    const "hmi_elements", "//svg:*[starts-with(@inkscape:label, 'HMI:')]";
-
     include detachable_pages.ysl2
 
     include inline_svg.ysl2
@@ -159,7 +158,7 @@
 
         |
         | var default_page = "«$default_page»";
-        | var svg_root = id("«$svg_root_id»");
+        | var svg_root = id("«/svg:svg/@id»");
         include text svghmi.js
         | //})();
     }
--- a/svghmi/geometry.ysl2	Tue Mar 17 13:16:01 2020 +0100
+++ b/svghmi/geometry.ysl2	Tue Mar 17 13:34:07 2020 +0100
@@ -10,7 +10,7 @@
 // Debug data
 function "debug_geometry" {
     | ID, x, y, w, h
-    foreach "$geometry[@Id = $hmi_elements/@id]"
+    foreach "$geometry"
         |  «@Id» «@x» «@y» «@w» «@h»
 }
 !debug_output_calls.append("debug_geometry")