svghmi/gen_index_xhtml.ysl2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Sun, 19 Apr 2020 10:48:34 +0200
branchsvghmi
changeset 2940 034b6ce4f885
parent 2939 4296ab974d4d
child 2941 ef13a4007538
permissions -rw-r--r--
SVGHMI: Introduced "emit" to simplify producing per-topic code and content from anywhere in code. Applied to debug output, next to JS.
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 {
        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: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" {

    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

    include scripts.ysl2

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

        // all debug output from included definitions, as comments
        foreach "document('')/*/debug:*" {
            comment {
                | «local-name()» :
                apply ".";
            }
        }

        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{
                    call "scripts";
                }
            }
        }
    }
}