svghmi/gen_dnd_widget_svg.ysl2
author Edouard Tisserant
Tue, 06 Apr 2021 16:05:58 +0200
branchsvghmi
changeset 3225 cfa5690c8c15
parent 3223 061796d9855e
child 3229 c5be4fd425e7
permissions -rw-r--r--
SVGHMI: Naive implementation of widget path substitution in widget DnD: considers widget always have only one variable, and no type checking.
3221
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     1
include yslt_noindent.yml2
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     2
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     3
in xsl decl svgtmpl(match, xmlns="http://www.w3.org/2000/svg") alias template;
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     4
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     5
istylesheet
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     6
            /* From Inkscape */
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     7
            xmlns:dc="http://purl.org/dc/elements/1.1/"
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     8
            xmlns:cc="http://creativecommons.org/ns#"
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     9
            xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    10
            xmlns:svg="http://www.w3.org/2000/svg"
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    11
            xmlns:xlink="http://www.w3.org/1999/xlink"
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    12
            xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    13
            xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    14
            xmlns:xhtml="http://www.w3.org/1999/xhtml"
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    15
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    16
            /* Namespace to invoke python code */
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    17
            xmlns:ns="beremiz"
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    18
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    19
            extension-element-prefixes="ns func exsl regexp str dyn"
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    20
            exclude-result-prefixes="ns func exsl regexp str dyn" {
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    21
3223
061796d9855e SVGHMI: Widget transform before DnD now should have HMI path as a parameter, but this path isn't computed for some reason... WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3222
diff changeset
    22
    param "hmi_path";
3221
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    23
    const "svg", "/svg:svg";
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    24
    const "hmi_elements", "//svg:*[starts-with(@inkscape:label, 'HMI:')]";
3222
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    25
    const "subhmitree", "ns:GetSubHMITree()";
3221
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    26
3222
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    27
    const "indexed_hmitree", "/.."; // compatibility with parse_labels.ysl2
3221
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    28
    include parse_labels.ysl2
3222
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    29
    const "_parsed_widgets" apply "$hmi_elements", mode="parselabel";
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    30
    const "parsed_widgets","exsl:node-set($_parsed_widgets)";
3221
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    31
3223
061796d9855e SVGHMI: Widget transform before DnD now should have HMI path as a parameter, but this path isn't computed for some reason... WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3222
diff changeset
    32
    const "selected_node_type","local-name($subhmitree)";
061796d9855e SVGHMI: Widget transform before DnD now should have HMI path as a parameter, but this path isn't computed for some reason... WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3222
diff changeset
    33
    const "svg_widget", "$parsed_widgets/widget[1]";
061796d9855e SVGHMI: Widget transform before DnD now should have HMI path as a parameter, but this path isn't computed for some reason... WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3222
diff changeset
    34
    const "svg_widget_type", "$svg_widget/@type";
061796d9855e SVGHMI: Widget transform before DnD now should have HMI path as a parameter, but this path isn't computed for some reason... WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3222
diff changeset
    35
    const "svg_widget_path", "$svg_widget/@path";
061796d9855e SVGHMI: Widget transform before DnD now should have HMI path as a parameter, but this path isn't computed for some reason... WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3222
diff changeset
    36
    const "svg_widget_count", "count($parsed_widgets/widget)";
061796d9855e SVGHMI: Widget transform before DnD now should have HMI path as a parameter, but this path isn't computed for some reason... WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3222
diff changeset
    37
3221
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    38
    svgtmpl "@*", mode="inline_svg" xsl:copy;
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    39
3223
061796d9855e SVGHMI: Widget transform before DnD now should have HMI path as a parameter, but this path isn't computed for some reason... WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3222
diff changeset
    40
    svgtmpl "@inkscape:label[starts-with(., 'HMI:')]", mode="inline_svg" {
3225
cfa5690c8c15 SVGHMI: Naive implementation of widget path substitution in widget DnD: considers widget always have only one variable, and no type checking.
Edouard Tisserant
parents: 3223
diff changeset
    41
        attrib "inkscape:label" > «substring-before(., '@')»@«$hmi_path»
3223
061796d9855e SVGHMI: Widget transform before DnD now should have HMI path as a parameter, but this path isn't computed for some reason... WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3222
diff changeset
    42
    }
061796d9855e SVGHMI: Widget transform before DnD now should have HMI path as a parameter, but this path isn't computed for some reason... WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3222
diff changeset
    43
3221
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    44
    template "node()", mode="inline_svg" {
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    45
      xsl:copy apply "@* | node()", mode="inline_svg";
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    46
    }
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    47
3222
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    48
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    49
    const "NODES_TYPES","str:split('HMI_ROOT HMI_NODE')";
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    50
    const "HMI_NODES_COMPAT","str:split('Page Jump Foreach')";
3221
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    51
    template "/" {
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    52
        comment > Widget dropped in Inkscape from Beremiz
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    53
3222
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    54
        choose {
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    55
            when "$svg_widget_count < 1"
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    56
                error > No widget detected on selected SVG
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    57
            when "$svg_widget_count > 1"
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    58
                error > Multiple widget DnD not yet supported
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    59
            when """$selected_node_type = $NODES_TYPES and \
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    60
                    not($svg_widget_type = $HMI_NODES_COMPAT)"""
3223
061796d9855e SVGHMI: Widget transform before DnD now should have HMI path as a parameter, but this path isn't computed for some reason... WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3222
diff changeset
    61
                error > Widget incompatible with selected HMI tree node
3222
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    62
        }
3223
061796d9855e SVGHMI: Widget transform before DnD now should have HMI path as a parameter, but this path isn't computed for some reason... WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3222
diff changeset
    63
3222
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    64
        const "testmsg" {
3223
061796d9855e SVGHMI: Widget transform before DnD now should have HMI path as a parameter, but this path isn't computed for some reason... WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3222
diff changeset
    65
            msg value "$hmi_path";
3222
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    66
            msg value "$selected_node_type";
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    67
            msg value "$svg_widget_type";
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    68
        }
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    69
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    70
        value "ns:GiveDetails($testmsg)";
6adeeb16ac3e SVGHMI: Widget DnD to Inkscape : Added source SVG widget label parsing and pass selecte HMI subtree to XSLT tranform, so that SVG containing multiple widgets can later be matched against hmi tree fragments, in order to DnD complex groups of widgets.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3221
diff changeset
    71
3221
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    72
        apply "/", mode="inline_svg";
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    73
    }
3d307ad803ea SVGHMI: Widget Library Picker now transforms SVG widget before allowing DnD. Transform is just identity forn now, but label parsing have already been included. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    74
}