svghmi/inline_svg.ysl2
author usveticic
Wed, 16 Sep 2020 09:41:52 +0200
branchsvghmi
changeset 3056 827bf284feec
parent 3027 d660b1b6bf4f
child 3030 2d13a4379e2f
permissions -rw-r--r--
Button, ToggleButton and slider updated. Error to warning when building

Button fixed so it doesn't release until it gets feedback from plc

Toggle button changed so it makes changes instantly. There was too big delay if we waited for feedback.

Slider added new features need some changes for final version.
2878
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
     1
// inline_svg.ysl2
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
     2
//
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
     3
// Produce Inline SVG element of resulting XHTML page.
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
     4
2937
9226a830fbc3 SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2909
diff changeset
     5
// Since stylesheet output namespace is xhtml, templates that output svg have to be explicitely declared as such 
9226a830fbc3 SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2909
diff changeset
     6
in xsl decl svgtmpl(match, xmlns="http://www.w3.org/2000/svg") alias template;
9226a830fbc3 SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2909
diff changeset
     7
in xsl decl svgfunc(name, xmlns="http://www.w3.org/2000/svg") alias template;
9226a830fbc3 SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2909
diff changeset
     8
9226a830fbc3 SVGHMI: moving code wher it belongs, and reformulate some declarations for better readability.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2909
diff changeset
     9
2878
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    10
// Identity template :
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    11
//  - copy every attributes 
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    12
//  - copy every sub-elements
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    13
template "@* | node()", mode="inline_svg" {
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    14
  // use real xsl:copy instead copy-of alias from yslt.yml2
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    15
  if "not(@id = $discardable_elements/@id)"
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    16
      xsl:copy apply "@* | node()", mode="inline_svg";
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    17
}
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    18
2878
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    19
// replaces inkscape's height and width hints. forces fit
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    20
template "svg:svg/@width", mode="inline_svg";
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    21
template "svg:svg/@height", mode="inline_svg";
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    22
svgtmpl "svg:svg", mode="inline_svg" svg {
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    23
    attrib "preserveAspectRatio" > none
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    24
    attrib "height" > 100vh
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    25
    attrib "width" > 100vw
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    26
    apply "@* | node()", mode="inline_svg";
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    27
}
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    28
// ensure that coordinate in CSV file generated by inkscape are in default reference frame
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    29
template "svg:svg[@viewBox!=concat('0 0 ', @width, ' ', @height)]", mode="inline_svg" {
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    30
    error > ViewBox settings other than X=0, Y=0 and Scale=1 are not supported
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    31
}
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    32
// ensure that coordinate in CSV file generated by inkscape match svg default unit
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    33
template "sodipodi:namedview[@units!='px' or @inkscape:document-units!='px']", mode="inline_svg" {
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    34
    error > All units must be set to "px" in Inkscape's document properties
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    35
}
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    36
2941
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
    37
////// Clone unlinking
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
    38
//
2878
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    39
// svg:use (inkscape's clones) inside a widgets are
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    40
// replaced by real elements they refer in order to :
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    41
//  - allow finding "needle" element in "meter" widget,
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    42
//    even if "needle" is in a group refered by a svg use.
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    43
//  - if "needle" is visible through a svg:use for
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    44
//    each instance of the widget, then needle would show
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    45
//    the same position in all instances
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    46
//
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    47
// For now, clone unlinkink applies to descendants of all widget except HMI:Page
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    48
// TODO: narrow application of clone unlinking to active elements,
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    49
//       while keeping static decoration cloned
2995
7769e7c7f925 SVGHMI: Minimal support for HMI:List : clones pointing to elements of any HMI:List are never unlinked, widgets using HMI:List will rely on this.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2968
diff changeset
    50
const "hmi_lists_descs", "$parsed_widgets/widget[@type = 'List']";
7769e7c7f925 SVGHMI: Minimal support for HMI:List : clones pointing to elements of any HMI:List are never unlinked, widgets using HMI:List will rely on this.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2968
diff changeset
    51
const "hmi_lists", "$hmi_elements[@id = $hmi_lists_descs/@id]";
3027
d660b1b6bf4f SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2995
diff changeset
    52
const "targets_not_to_unlink", "$hmi_lists/descendant-or-self::svg:*";
2995
7769e7c7f925 SVGHMI: Minimal support for HMI:List : clones pointing to elements of any HMI:List are never unlinked, widgets using HMI:List will rely on this.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2968
diff changeset
    53
const "to_unlink", "$hmi_elements[not(@id = $hmi_pages/@id)]/descendant-or-self::svg:use";
2878
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    54
svgtmpl "svg:use", mode="inline_svg"
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    55
{
3027
d660b1b6bf4f SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2995
diff changeset
    56
    param "seed";
2995
7769e7c7f925 SVGHMI: Minimal support for HMI:List : clones pointing to elements of any HMI:List are never unlinked, widgets using HMI:List will rely on this.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2968
diff changeset
    57
    const "targetid","substring-after(@xlink:href,'#')";
2878
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    58
    choose {
2995
7769e7c7f925 SVGHMI: Minimal support for HMI:List : clones pointing to elements of any HMI:List are never unlinked, widgets using HMI:List will rely on this.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2968
diff changeset
    59
        when "@id = $to_unlink/@id and not($targetid = $targets_not_to_unlink/@id)" {
3027
d660b1b6bf4f SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2995
diff changeset
    60
            call "unlink_clone" {
d660b1b6bf4f SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2995
diff changeset
    61
                with "targetid", "$targetid";
d660b1b6bf4f SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2995
diff changeset
    62
                with "seed","$seed";
d660b1b6bf4f SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2995
diff changeset
    63
            }
2995
7769e7c7f925 SVGHMI: Minimal support for HMI:List : clones pointing to elements of any HMI:List are never unlinked, widgets using HMI:List will rely on this.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2968
diff changeset
    64
        }
2878
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    65
        otherwise
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    66
            xsl:copy apply "@* | node()", mode="inline_svg";
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    67
    }
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    68
}
2877
682bce953795 SVGHMI: detachable_elements.ysl2 becomes detachable_pages.ysl2, and includes logic to process pages elements. Other minor code moves.
Edouard Tisserant
parents: 2876
diff changeset
    69
2878
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    70
// to unlink a clone, an group containing a copy of target element is created
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    71
// that way, style and transforms can be preserved
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    72
const "_excluded_use_attrs" {
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    73
    name > href
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    74
    name > width
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    75
    name > height
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    76
    name > x
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    77
    name > y
3027
d660b1b6bf4f SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2995
diff changeset
    78
    name > id
2878
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    79
}
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    80
const "excluded_use_attrs","exsl:node-set($_excluded_use_attrs)";
2794
c10069a02ed0 SVGHMI: deduce pages content out of geometry (elements contained in page bounding box are in)
Edouard Tisserant
parents: 2793
diff changeset
    81
2968
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
    82
const "_merge_use_attrs" {
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
    83
    name > transform
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
    84
    name > style
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
    85
}
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
    86
const "merge_use_attrs","exsl:node-set($_merge_use_attrs)";
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
    87
2878
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    88
svgfunc "unlink_clone"{
2995
7769e7c7f925 SVGHMI: Minimal support for HMI:List : clones pointing to elements of any HMI:List are never unlinked, widgets using HMI:List will rely on this.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2968
diff changeset
    89
    param "targetid";
3027
d660b1b6bf4f SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2995
diff changeset
    90
    param "seed";
2968
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
    91
    const "target", "//svg:*[@id = $targetid]";
3027
d660b1b6bf4f SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2995
diff changeset
    92
    const "seeded_id","concat($seed, @id)";
2878
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
    93
    g{
3027
d660b1b6bf4f SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2995
diff changeset
    94
        attrib "id" value "$seeded_id";
2968
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
    95
        choose {
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
    96
            when "$target[self::svg:g]" {
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
    97
                foreach "@*[not(local-name() = $excluded_use_attrs/name | $merge_use_attrs)]"
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
    98
                    attrib "{name()}" > «.»
2853
6d39beb19f38 SVGHMI: whitespaces and comments
Edouard Tisserant
parents: 2852
diff changeset
    99
2968
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   100
                if "@style | $target/@style"
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   101
                    attrib "style" {
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   102
                        > «@style»
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   103
                        if "@style and $target/@style" > ;
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   104
                        > «$target/@style»
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   105
                    }
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   106
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   107
                if "@transform | $target/@transform"
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   108
                    attrib "transform" {
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   109
                        > «@transform»
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   110
                        if "@transform and $target/@transform" >  
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   111
                        > «$target/@transform»
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   112
                    }
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   113
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   114
                apply "$target/*", mode="unlink_clone"{
3027
d660b1b6bf4f SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2995
diff changeset
   115
                    with "seed","concat($seed, @id)";
2968
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   116
                }
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   117
            }
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   118
            otherwise {
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   119
                // include non excluded attributes
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   120
                foreach "@*[not(local-name() = $excluded_use_attrs/name)]"
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   121
                    attrib "{name()}" > «.»
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   122
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   123
                apply "$target", mode="unlink_clone"{
3027
d660b1b6bf4f SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2995
diff changeset
   124
                    with "seed","concat($seed, @id)";
2968
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   125
                }
556ef07a7e31 SVGHMI: When unlinking a clone of a group, do not create additional group, but merge transformation and styles, and replace label. This allows svg:use based widgets to directly access elements of svg:use targeted element.
Edouard Tisserant
parents: 2967
diff changeset
   126
            }
2854
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
   127
        }
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
   128
    }
2878
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   129
}
2854
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
   130
2878
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   131
// clone unlinking is really similar to deep-copy
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   132
// all nodes are sytematically copied
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   133
svgtmpl "@id", mode="unlink_clone" {
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   134
    param "seed";
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   135
    attrib "id" > «$seed»_«.»
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   136
}
2854
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
   137
2878
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   138
svgtmpl "@*", mode="unlink_clone" xsl:copy;
2854
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
   139
3027
d660b1b6bf4f SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2995
diff changeset
   140
svgtmpl "svg:use", mode="unlink_clone" {
d660b1b6bf4f SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2995
diff changeset
   141
    param "seed";
d660b1b6bf4f SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2995
diff changeset
   142
    apply "." mode="inline_svg" with "seed","concat($seed, '_')";
d660b1b6bf4f SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2995
diff changeset
   143
}
d660b1b6bf4f SVGHMI: Deeper clone unlinking. Was actually not recursive, and clones in clones where not unlinked. Stack successive ids to avoid collisions.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2995
diff changeset
   144
2878
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   145
// copying widgets would have unwanted effect
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   146
// instead widget is refered through a svg:use.
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   147
svgtmpl "svg:*", mode="unlink_clone" {
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   148
    param "seed";
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   149
    choose {
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   150
        // node recursive copy ends when finding a widget
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   151
        when "@id = $hmi_elements/@id" {
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   152
            // place a clone instead of copying
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   153
            use{
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   154
                attrib "xlink:href" > «concat('#',@id)»
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   155
            }
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   156
        }
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   157
        otherwise {
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   158
            xsl:copy apply "@* | node()", mode="unlink_clone" {
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   159
                with "seed","$seed";
2854
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
   160
            }
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
   161
        }
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
   162
    }
2878
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   163
}
2854
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
   164
2878
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   165
const "result_svg" apply "/", mode="inline_svg";
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   166
const "result_svg_ns", "exsl:node-set($result_svg)";
2854
c7d5f46cc306 SVGHMI: unlink clones (i.e. deep copy elements refered by svg:use) inside widget.
Edouard Tisserant
parents: 2853
diff changeset
   167
2941
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
   168
emit "preamble:inline-svg" {
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
   169
    | let id = document.getElementById.bind(document);
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
   170
    | var svg_root = id("«$svg/@id»");
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
   171
}
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
   172
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
   173
emit "debug:clone-unlinking" {
ef13a4007538 SVGHMI: spread JS code from svghmi/scripts.ysl2 in other .ysl2 files, using dedicated preamble and epilogue namespaces
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2940
diff changeset
   174
    |
2904
92d115d8828d SVGHMI: collect debug data through xslt reflectivity instead of yml2/python trick
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2878
diff changeset
   175
    | Unlinked :
2878
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   176
    foreach "$to_unlink"{
bec552270ad1 SVGHMI: added inline_svg.ysl2
Edouard Tisserant
parents: 2877
diff changeset
   177
        | «@id»
2808
dc78ffa5253d SVGHMI: SVG viewport now defined so that HMI take scales and fit to the view. Implemented page switch through viewport change, no hiding of widget for now.
Edouard Tisserant
parents: 2807
diff changeset
   178
    }
2995
7769e7c7f925 SVGHMI: Minimal support for HMI:List : clones pointing to elements of any HMI:List are never unlinked, widgets using HMI:List will rely on this.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2968
diff changeset
   179
    | Not to unlink :
7769e7c7f925 SVGHMI: Minimal support for HMI:List : clones pointing to elements of any HMI:List are never unlinked, widgets using HMI:List will rely on this.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2968
diff changeset
   180
    foreach "$targets_not_to_unlink"{
7769e7c7f925 SVGHMI: Minimal support for HMI:List : clones pointing to elements of any HMI:List are never unlinked, widgets using HMI:List will rely on this.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2968
diff changeset
   181
        | «@id»
7769e7c7f925 SVGHMI: Minimal support for HMI:List : clones pointing to elements of any HMI:List are never unlinked, widgets using HMI:List will rely on this.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2968
diff changeset
   182
    }
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
   183
}