svghmi/gen_index_xhtml.ysl2
author Edouard Tisserant
Thu, 04 Jun 2020 11:14:21 +0200
branchsvghmi
changeset 2980 2a21d6060d64
parent 2947 25f593573579
child 3077 82312473d153
permissions -rw-r--r--
SVGHMI: add "unsubscribable" property to widgets in order to generalize what already happens for jump buttons.
In most cases jump buttons do not really subscribe to pointed HMI variable, path is given as a relative page jump path. When widget.unsubscribable is set to true, no subscription is made on page switch, but still offset is updated.
This fixes bug happening on relative jump buttons without "disabled" element where offset did not change on relative page switch.
include yslt_noindent.yml2

// overrides yslt's output function to set CDATA
decl output(method, cdata-section-elements="xhtml:script");

// helper to emit some content to internal namespaces
decl emit(*name) alias - {
    *name;
    template *name {
        |
        | /* «local-name()» */
        |
        content;
        |
    }
};

istylesheet
            /* From Inkscape */
            xmlns:dc="http://purl.org/dc/elements/1.1/"
            xmlns:cc="http://creativecommons.org/ns#"
            xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
            xmlns:svg="http://www.w3.org/2000/svg"
            xmlns:xlink="http://www.w3.org/1999/xlink"
            xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
            xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
            xmlns:xhtml="http://www.w3.org/1999/xhtml"

            /* Internal namespaces to allow emit code/content from anywhere */
            xmlns:debug="debug"
            xmlns:preamble="preamble"
            xmlns:declarations="declarations"
            xmlns:definitions="definitions"
            xmlns:epilogue="epilogue"

            /* Namespace to invoke python code */
            xmlns:ns="beremiz"

            extension-element-prefixes="ns func exsl regexp str dyn"
            exclude-result-prefixes="ns func exsl regexp str dyn debug preamble epilogue declarations definitions" {

    const "svg", "/svg:svg";
    const "hmi_elements", "//svg:*[starts-with(@inkscape:label, 'HMI:')]";


    include hmi_tree.ysl2

    include geometry.ysl2

    include detachable_pages.ysl2

    include inline_svg.ysl2

    include widgets_common.ysl2

    include widget_*.ysl2


    template "/" {
        comment > Made with SVGHMI. https://beremiz.org

        // all debug output from included definitions, as comments
        comment apply "document('')/*/debug:*";

        html xmlns="http://www.w3.org/1999/xhtml"
             xmlns:svg="http://www.w3.org/2000/svg"
             xmlns:xlink="http://www.w3.org/1999/xlink" {
            head;
            body style="margin:0;overflow:hidden;" {
                // Inline SVG
                copy "$result_svg";
                script{
                    | \n//\n//\n// Early independent declarations \n//\n//
                    apply "document('')/*/preamble:*";

                    | \n//\n//\n// Declarations depending on preamble \n//\n//
                    apply "document('')/*/declarations:*";

                    | \n//\n//\n// Order independent declaration and code \n//\n//
                    apply "document('')/*/definitions:*";

                    | \n//\n//\n// Statements that needs to be at the end \n//\n//
                    apply "document('')/*/epilogue:*";

                    include text svghmi.js

                }
            }
        }
    }
}