SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability. svghmi
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Sat, 18 Apr 2020 11:49:02 +0200
branchsvghmi
changeset 2937 9226a830fbc3
parent 2936 53fb11263ff1
child 2938 1379cd5c69dd
SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
svghmi/gen_index_xhtml.ysl2
svghmi/inline_svg.ysl2
svghmi/widgets_common.ysl2
--- a/svghmi/gen_index_xhtml.ysl2	Thu Apr 16 10:21:25 2020 +0200
+++ b/svghmi/gen_index_xhtml.ysl2	Sat Apr 18 11:49:02 2020 +0200
@@ -3,20 +3,6 @@
 // overrides yslt's output function to set CDATA
 decl output(method, cdata-section-elements="xhtml:script");
 
-in xsl decl labels(*ptr, name="defs_by_labels") alias call-template {
-    with "hmi_element", "$hmi_element";
-    with "labels"{text *ptr};
-};
-
-in xsl decl optional_labels(*ptr, name="defs_by_labels") alias call-template {
-    with "hmi_element", "$hmi_element";
-    with "labels"{text *ptr};
-    with "mandatory","'no'";
-};
-
-in xsl decl svgtmpl(match, xmlns="http://www.w3.org/2000/svg") alias template;
-in xsl decl svgfunc(name, xmlns="http://www.w3.org/2000/svg") alias template;
-
 istylesheet
             /* From Inkscape */
             xmlns:dc="http://purl.org/dc/elements/1.1/"
--- a/svghmi/inline_svg.ysl2	Thu Apr 16 10:21:25 2020 +0200
+++ b/svghmi/inline_svg.ysl2	Sat Apr 18 11:49:02 2020 +0200
@@ -2,6 +2,11 @@
 //
 // Produce Inline SVG element of resulting XHTML page.
 
+// Since stylesheet output namespace is xhtml, templates that output svg have to be explicitely declared as such 
+in xsl decl svgtmpl(match, xmlns="http://www.w3.org/2000/svg") alias template;
+in xsl decl svgfunc(name, xmlns="http://www.w3.org/2000/svg") alias template;
+
+
 // Identity template :
 //  - copy every attributes 
 //  - copy every sub-elements
--- a/svghmi/widgets_common.ysl2	Thu Apr 16 10:21:25 2020 +0200
+++ b/svghmi/widgets_common.ysl2	Sat Apr 18 11:49:02 2020 +0200
@@ -3,19 +3,22 @@
 in xsl decl labels(*ptr, name="defs_by_labels") alias call-template {
     with "hmi_element", "$hmi_element";
     with "labels"{text *ptr};
+    content;
 };
 
-in xsl decl optional_labels(*ptr, name="defs_by_labels") alias call-template {
-    with "hmi_element", "$hmi_element";
-    with "labels"{text *ptr};
-    with "mandatory","'no'";
+decl optional_labels(*ptr) alias - {
+    /* TODO add some per label xslt variable to check if exist */
+    labels(*ptr){
+        with "mandatory","'no'";
+        content;
+    }
 };
 
-in xsl decl activable_labels(*ptr, name="defs_by_labels") alias call-template {
-    with "hmi_element", "$hmi_element";
-    with "labels"{text *ptr};
-    with "mandatory","'no'";
-    with "subelements","'active inactive'";
+decl activable_labels(*ptr) alias - {
+    optional_labels(*ptr) {
+        with "subelements","'active inactive'";
+        content;
+    }
 };
 
 template "svg:*", mode="hmi_elements" {