svghmi/gen_index_xhtml.ysl2
author Edouard Tisserant
Fri, 11 Oct 2019 12:03:14 +0200
branchsvghmi
changeset 2797 c5ba1e77f054
parent 2796 c7a22ce8c156
child 2798 ddb2c4668a6b
permissions -rw-r--r--
SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
2753
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
     1
include yslt_noindent.yml2
2779
75c6a31caca6 SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents: 2763
diff changeset
     2
75c6a31caca6 SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents: 2763
diff changeset
     3
// overrides yslt's output function to set CDATA
75c6a31caca6 SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents: 2763
diff changeset
     4
decl output(method, cdata-section-elements="script");
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
     5
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
     6
istylesheet
2753
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
     7
            /* From Inkscape */
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
     8
            xmlns:dc="http://purl.org/dc/elements/1.1/"
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
     9
            xmlns:cc="http://creativecommons.org/ns#"
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
    10
            xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
    11
            xmlns:svg="http://www.w3.org/2000/svg"
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
    12
            xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
    13
            xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
    14
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
    15
            /* Our namespace to invoke python code */
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
    16
            xmlns:ns="beremiz"
2793
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
    17
            extension-element-prefixes="ns func"
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
    18
            exclude-result-prefixes="ns str regexp exsl func" {
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    19
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    20
    /* This retrieves geometry obtained through "inkscape -S"
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    21
     * already parsed by python and presented as a list of
2753
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
    22
     * <bbox x="0" y="0" w="42" h="42">
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
    23
     */
2791
d022523cb621 SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents: 2790
diff changeset
    24
    const "geometry", "ns:GetSVGGeometry()";
d022523cb621 SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents: 2790
diff changeset
    25
    const "hmitree", "ns:GetHMITree()";
2790
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    26
2797
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
    27
    const "hmi_elements", "//svg:*[starts-with(@inkscape:label, 'HMI:')]";
2794
c10069a02ed0 SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents: 2793
diff changeset
    28
    const "hmi_geometry", "$geometry[@Id = $hmi_elements/@id]";
c10069a02ed0 SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents: 2793
diff changeset
    29
c10069a02ed0 SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents: 2793
diff changeset
    30
    const "hmi_pages", "$hmi_elements[func:parselabel(@inkscape:label)/widget/@type = 'Page']";
c10069a02ed0 SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents: 2793
diff changeset
    31
2795
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
    32
    const "default_page" choose {
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
    33
        when "count($hmi_pages) > 1" {
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
    34
            const "Home_page", 
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
    35
                "$hmi_pages[func:parselabel(@inkscape:label)/widget/arg[1]/@value = 'Home']";
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
    36
            choose {
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
    37
                when "$Home_page" > Home
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
    38
                otherwise {
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
    39
                    error "No Home page defined!";
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
    40
                }
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
    41
            }
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
    42
        }
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
    43
        when "count($hmi_pages) = 0" {
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
    44
            error "No page defined!";
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
    45
        }
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
    46
        otherwise > «func:parselabel($hmi_pages/@inkscape:label)/widget/arg[1]/@value»
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
    47
    }
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
    48
2791
d022523cb621 SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents: 2790
diff changeset
    49
    const "_categories" {
2790
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    50
        noindex > HMI_ROOT
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    51
        noindex > HMI_LABEL
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    52
        noindex > HMI_CLASS
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    53
        noindex > HMI_PLC_STATUS
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    54
        noindex > HMI_CURRENT_PAGE
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    55
    }
2791
d022523cb621 SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents: 2790
diff changeset
    56
    const "categories", "exsl:node-set($_categories)";
d022523cb621 SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents: 2790
diff changeset
    57
    const "_indexed_hmitree" apply "$hmitree", mode="index";
d022523cb621 SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents: 2790
diff changeset
    58
    const "indexed_hmitree", "exsl:node-set($_indexed_hmitree)";
2790
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    59
2794
c10069a02ed0 SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents: 2793
diff changeset
    60
    template "*", mode="index" {
2790
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    61
        param "index", "0";
2791
d022523cb621 SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents: 2790
diff changeset
    62
        param "parentpath", "''";
d022523cb621 SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents: 2790
diff changeset
    63
        const "content" {
d022523cb621 SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents: 2790
diff changeset
    64
            const "path"
d022523cb621 SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents: 2790
diff changeset
    65
                choose {
d022523cb621 SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents: 2790
diff changeset
    66
                    when "local-name() = 'HMI_ROOT'" > «$parentpath»
d022523cb621 SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents: 2790
diff changeset
    67
                    otherwise > «$parentpath»/«@name»
d022523cb621 SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents: 2790
diff changeset
    68
                }
2790
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    69
            choose {
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    70
                when "not(local-name() = $categories/noindex)" {
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    71
                    xsl:copy {
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    72
                        attrib "index" > «$index»
2791
d022523cb621 SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents: 2790
diff changeset
    73
                        attrib "hmipath" > «$path»
2790
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    74
                        foreach "@*" xsl:copy;
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    75
                    }
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    76
                    /* no node expected below value nodes */
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    77
                }
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    78
                otherwise {
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    79
                    apply "*[1]", mode="index"{
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    80
                        with "index", "$index";
2791
d022523cb621 SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents: 2790
diff changeset
    81
                        with "parentpath" > «$path»
2790
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    82
                    }
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    83
                }
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    84
            }
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    85
        }
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    86
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    87
        copy "$content";
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    88
        apply "following-sibling::*[1]", mode="index" {
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    89
            with "index", "$index + count(exsl:node-set($content)/*)";
2791
d022523cb621 SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents: 2790
diff changeset
    90
            with "parentpath" > «$parentpath»
2790
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    91
        }
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    92
    }
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    93
2753
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
    94
    /* Identity template :
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
    95
     *  - copy every attributes 
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
    96
     *  - copy every sub-elements
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
    97
     */
2791
d022523cb621 SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents: 2790
diff changeset
    98
    template "@* | node()", mode="identity_svg" {
2753
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
    99
      /* use real xsl:copy instead copy-of alias from yslt.yml2 */
2791
d022523cb621 SVGHMI: now generating JS object describing widgets and pointing to SVG elements
Edouard Tisserant
parents: 2790
diff changeset
   100
      xsl:copy apply "@* | node()", mode="identity_svg";
2753
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
   101
    }
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
   102
2794
c10069a02ed0 SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents: 2793
diff changeset
   103
    /*const "mark" > =HMI=\n*/
2782
723e420dfe72 SVGHMI: added transformation of code given in inkscape's description fields into javascript functions
Edouard Tisserant
parents: 2780
diff changeset
   104
2753
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
   105
    /* copy root node and add geometry as comment for a test */
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   106
    template "/" { 
2793
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   107
        comment > Made with SVGHMI. https://beremiz.org
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   108
        html xmlns="http://www.w3.org/1999/xhtml" {
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   109
            head;
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   110
            body style="margin:0;" {
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   111
                xsl:copy {
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   112
                    comment {
2794
c10069a02ed0 SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents: 2793
diff changeset
   113
                        apply "$hmi_geometry", mode="testgeo";
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   114
                    }
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   115
                    comment {
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   116
                        apply "$hmitree", mode="testtree";
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   117
                    }
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   118
                    comment {
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   119
                        apply "$indexed_hmitree", mode="testtree";
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   120
                    }
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   121
                    apply "@* | node()", mode="identity_svg";
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   122
                }
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   123
                script{
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   124
                    call "scripts";
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   125
                }
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   126
            }
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   127
        }
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   128
    }
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   129
2793
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   130
    func:function name="func:parselabel" {
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   131
        param "label";
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   132
        const "description", "substring-after($label,'HMI:')";
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   133
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   134
        const "_args", "substring-before($description,'@')";
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   135
        const "args" choose {
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   136
            when "$_args" value "$_args";
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   137
            otherwise value "$description";
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   138
        }
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   139
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   140
        const "_type", "substring-before($args,':')";
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   141
        const "type" choose {
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   142
            when "$_type" value "$_type";
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   143
            otherwise value "$args";
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   144
        }
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   145
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   146
        const "ast" if "$type" widget {
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   147
            attrib "type" > «$type»
2794
c10069a02ed0 SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents: 2793
diff changeset
   148
            foreach "str:split(substring-after($args, ':'), ':')" {
2793
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   149
                arg {
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   150
                    attrib "value" > «.»
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   151
                }
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   152
            }
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   153
            const "paths", "substring-after($description,'@')";
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   154
            foreach "str:split($paths, '@')" {
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   155
                path {
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   156
                    attrib "value" > «.»
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   157
                }
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   158
            }
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   159
        }
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   160
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   161
        func:result select="exsl:node-set($ast)"
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   162
    }
2a97688c94c5 SVGHMI: use func:function for parsing labels so that it can be used in predicates
Edouard Tisserant
parents: 2792
diff changeset
   163
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   164
    function "scripts"
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   165
    {
2797
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   166
        /* paste hmitree hash stored in hmi tree root node */
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   167
        | var hmi_hash = [«$hmitree/@hash»]; 
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   168
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   169
        /* TODO re-enable
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   170
        ||
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   171
        function evaluate_js_from_descriptions() {
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   172
            var Page;
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   173
            var Input;
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   174
            var Display;
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   175
            var res = [];
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   176
        ||
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   177
        const "midmark" > \n«$mark»
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   178
        apply """//*[contains(child::svg:desc, $midmark) or \
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   179
                     starts-with(child::svg:desc, $mark)]""",2 
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   180
              mode="code_from_descs";
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   181
        ||
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   182
            return res;
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   183
        }
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   184
        ||
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   185
        */
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   186
2797
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   187
        | var hmi_widgets = {
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   188
        foreach "$hmi_elements" {
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   189
            const "widget", "func:parselabel(@inkscape:label)/widget";
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   190
            | «@id»: {
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   191
            |     type: "«$widget/@type»",
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   192
            |     frequency: `apply "$widget", mode="refresh_frequency"`,
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   193
            |     args: [
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   194
            foreach "$widget/arg"
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   195
            |         "«@value»"`if "position()!=last()" > ,`
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   196
            |     ],
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   197
            |     paths: [
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   198
            foreach "$widget/path" {
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   199
                const "hmipath","@value";
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   200
                const "hmitree_match","$indexed_hmitree/*[@hmipath = $hmipath]";
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   201
                if "count($hmitree_match) = 0"
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   202
                    error > No match for HMI «$hmipath»;
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   203
            |         «$hmitree_match/@index»`if "position()!=last()" > ,`
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   204
            }
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   205
            |     ]
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   206
            | }`if "position()!=last()" > ,`
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   207
        }
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   208
        | }
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   209
        |
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   210
        | var hmi_index = [
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   211
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   212
        const "svg","/"; /* foreach loses document root */
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   213
        foreach "$indexed_hmitree/*" {
2797
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   214
            | {   /* «@index»  «@hmipath» */
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   215
            |     type: "«local-name()»",
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   216
            |     ids: [
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   217
            const "hmipath","@hmipath";
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   218
            foreach "$svg//*[substring-after(@inkscape:label,'@') = $hmipath]" {
2797
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   219
            |         hmi_widgets["«@id»"]`if "position()!=last()" > ,`
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   220
            }
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   221
            |     ]
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   222
            | }`if "position()!=last()" > ,`
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   223
        }
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   224
2797
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   225
        | ]
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   226
        |
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   227
        | var page_desc = {
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   228
2794
c10069a02ed0 SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents: 2793
diff changeset
   229
        foreach "$hmi_pages" {
c10069a02ed0 SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents: 2793
diff changeset
   230
            const "desc", "func:parselabel(@inkscape:label)/widget";
2797
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   231
            const "page", "."; 
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   232
            const "p", "$hmi_geometry[@Id = $page/@id]"; 
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   233
            const "page_ids","""$hmi_geometry[@Id != $page/@id and 
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   234
                                @x >= $p/@x and @y >= $p/@y and 
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   235
                                @x+@w <= $p/@x+$p/@w and @y+@h <= $p/@y+$p/@h]/@Id""";
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   236
            const "page_elements", "$hmi_elements[@id = $page_ids]";
2794
c10069a02ed0 SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents: 2793
diff changeset
   237
            |     "«$desc/arg[1]/@value»": {
2795
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
   238
            |         id: "«@id»",
2794
c10069a02ed0 SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents: 2793
diff changeset
   239
            |         widgets: [
2797
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   240
            foreach "$page_ids" {
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   241
            |             "«.»"`if "position()!=last()" > ,`
2794
c10069a02ed0 SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents: 2793
diff changeset
   242
            }
c10069a02ed0 SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents: 2793
diff changeset
   243
            |         ]
2797
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   244
            |         subscriptions: [
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   245
            foreach "$page_elements" {
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   246
                const "hmipaths", "func:parselabel(@inkscape:label)/widget/path/@value";
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   247
                const "notlast", "position()!=last()";
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   248
                foreach "$hmipaths" {
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   249
                    const "hmipath",".";
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   250
            |             «$indexed_hmitree/*[@hmipath = $hmipath]/@index»`if "$notlast or position()!=last()" > ,`
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   251
                }
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   252
            }
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   253
            |         ]
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   254
            |     }`if "position()!=last()" > ,`
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   255
        }
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   256
        | }
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   257
2795
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
   258
        |
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
   259
        | var default_page = "«$default_page»";
c0cf62bb9aa7 SVGHMI compute default page
Edouard Tisserant
parents: 2794
diff changeset
   260
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   261
        include text svghmi.js
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   262
    }
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   263
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   264
    /*
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   265
        Parses:
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   266
        "HMI:WidgetType:param1:param2@path1@path2"
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   267
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   268
        Into:
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   269
        widget type="WidgetType" {
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   270
            arg value="param1";
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   271
            arg value="param2";
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   272
            path value="path1";
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   273
            path value="path2";
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   274
        }
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   275
    */
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   276
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
   277
    template "*", mode="page_desc" {
2753
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
   278
    }
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
   279
2782
723e420dfe72 SVGHMI: added transformation of code given in inkscape's description fields into javascript functions
Edouard Tisserant
parents: 2780
diff changeset
   280
    template "*", mode="code_from_descs" {
2783
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   281
        ||
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   282
        {
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   283
            var path, role, name, priv;
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   284
            var id = "«@id»";
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   285
        ||
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   286
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   287
        /* if label is used, use it as default name */
2789
ba0dd2ec6dc4 SVGHMI: now built.
Edouard Tisserant
parents: 2788
diff changeset
   288
        if "@inkscape:label"
2783
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   289
            |> name = "«@inkscape:label»";
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   290
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   291
        | /* -------------- */
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   292
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   293
        // this breaks indent, but fixing indent could break string literals
2782
723e420dfe72 SVGHMI: added transformation of code given in inkscape's description fields into javascript functions
Edouard Tisserant
parents: 2780
diff changeset
   294
        value "substring-after(svg:desc, $mark)";
2783
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   295
        // nobody reads generated code anyhow...
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   296
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   297
        ||
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   298
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   299
            /* -------------- */
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   300
            res.push({
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   301
                path:path,
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   302
                role:role,
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   303
                name:name,
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   304
                priv:priv
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   305
            })
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   306
        }
5ee6967f721d SVGHMI: Starting to define JS side more in details.
Edouard Tisserant
parents: 2782
diff changeset
   307
        ||
2782
723e420dfe72 SVGHMI: added transformation of code given in inkscape's description fields into javascript functions
Edouard Tisserant
parents: 2780
diff changeset
   308
    }
723e420dfe72 SVGHMI: added transformation of code given in inkscape's description fields into javascript functions
Edouard Tisserant
parents: 2780
diff changeset
   309
723e420dfe72 SVGHMI: added transformation of code given in inkscape's description fields into javascript functions
Edouard Tisserant
parents: 2780
diff changeset
   310
2753
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
   311
    template "bbox", mode="testgeo"{
2763
ce04d79b8e57 Pass HMITree to SVG transform. It seems it could really help to reduce JS tree binding logic in the end.
Edouard Tisserant
parents: 2756
diff changeset
   312
        | ID: «@Id» x: «@x» y: «@y» w: «@w» h: «@h»
ce04d79b8e57 Pass HMITree to SVG transform. It seems it could really help to reduce JS tree binding logic in the end.
Edouard Tisserant
parents: 2756
diff changeset
   313
    }
ce04d79b8e57 Pass HMITree to SVG transform. It seems it could really help to reduce JS tree binding logic in the end.
Edouard Tisserant
parents: 2756
diff changeset
   314
ce04d79b8e57 Pass HMITree to SVG transform. It seems it could really help to reduce JS tree binding logic in the end.
Edouard Tisserant
parents: 2756
diff changeset
   315
    template "*", mode="testtree"{
ce04d79b8e57 Pass HMITree to SVG transform. It seems it could really help to reduce JS tree binding logic in the end.
Edouard Tisserant
parents: 2756
diff changeset
   316
        param "indent", "''";
2790
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
   317
        > «$indent» «local-name()» 
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
   318
        foreach "@*" > «local-name()»=«.» 
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
   319
        > \n
2763
ce04d79b8e57 Pass HMITree to SVG transform. It seems it could really help to reduce JS tree binding logic in the end.
Edouard Tisserant
parents: 2756
diff changeset
   320
        apply "*", mode="testtree" {
ce04d79b8e57 Pass HMITree to SVG transform. It seems it could really help to reduce JS tree binding logic in the end.
Edouard Tisserant
parents: 2756
diff changeset
   321
            with "indent" value "concat($indent,'>')"
ce04d79b8e57 Pass HMITree to SVG transform. It seems it could really help to reduce JS tree binding logic in the end.
Edouard Tisserant
parents: 2756
diff changeset
   322
        };
2753
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
   323
    }
2797
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   324
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   325
    template "widget", mode="refresh_frequency" > 10
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   326
    template "widget[@type='Meter']", mode="refresh_frequency" > 10
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   327
    template "widget[@type='Display']", mode="refresh_frequency" > 5
c5ba1e77f054 SVGHMI: added a widgets description object, accessed by id. Added frequency to widgets, as separate template to allow future customization. Excluded non svg elements (i.e inkscape Sets) with HMI: labels from widgets.
Edouard Tisserant
parents: 2796
diff changeset
   328
    template "widget[@type='Input']", mode="refresh_frequency" > 5
2753
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
   329
}