edouard@3221: include yslt_noindent.yml2 edouard@3221: edouard@3221: in xsl decl svgtmpl(match, xmlns="http://www.w3.org/2000/svg") alias template; edouard@3221: edouard@3221: istylesheet edouard@3221: /* From Inkscape */ edouard@3221: xmlns:dc="http://purl.org/dc/elements/1.1/" edouard@3221: xmlns:cc="http://creativecommons.org/ns#" edouard@3221: xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" edouard@3221: xmlns:svg="http://www.w3.org/2000/svg" edouard@3221: xmlns:xlink="http://www.w3.org/1999/xlink" edouard@3221: xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" edouard@3221: xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" edouard@3221: xmlns:xhtml="http://www.w3.org/1999/xhtml" edouard@3221: edouard@3221: /* Namespace to invoke python code */ edouard@3221: xmlns:ns="beremiz" edouard@3221: edouard@3221: extension-element-prefixes="ns func exsl regexp str dyn" edouard@3221: exclude-result-prefixes="ns func exsl regexp str dyn" { edouard@3221: edouard@3223: param "hmi_path"; edouard@3221: const "svg", "/svg:svg"; edouard@3221: const "hmi_elements", "//svg:*[starts-with(@inkscape:label, 'HMI:')]"; edouard@3222: const "subhmitree", "ns:GetSubHMITree()"; edouard@3221: edouard@3222: const "indexed_hmitree", "/.."; // compatibility with parse_labels.ysl2 edouard@3221: include parse_labels.ysl2 edouard@3222: const "_parsed_widgets" apply "$hmi_elements", mode="parselabel"; edouard@3222: const "parsed_widgets","exsl:node-set($_parsed_widgets)"; edouard@3221: edouard@3223: const "selected_node_type","local-name($subhmitree)"; edouard@3223: const "svg_widget", "$parsed_widgets/widget[1]"; edouard@3223: const "svg_widget_type", "$svg_widget/@type"; edouard@3223: const "svg_widget_path", "$svg_widget/@path"; edouard@3223: const "svg_widget_count", "count($parsed_widgets/widget)"; edouard@3223: edouard@3221: svgtmpl "@*", mode="inline_svg" xsl:copy; edouard@3221: edouard@3223: svgtmpl "@inkscape:label[starts-with(., 'HMI:')]", mode="inline_svg" { Edouard@3225: attrib "inkscape:label" > «substring-before(., '@')»@«$hmi_path» edouard@3223: } edouard@3223: edouard@3221: template "node()", mode="inline_svg" { edouard@3221: xsl:copy apply "@* | node()", mode="inline_svg"; edouard@3221: } edouard@3221: edouard@3222: edouard@3222: const "NODES_TYPES","str:split('HMI_ROOT HMI_NODE')"; edouard@3222: const "HMI_NODES_COMPAT","str:split('Page Jump Foreach')"; edouard@3221: template "/" { edouard@3221: comment > Widget dropped in Inkscape from Beremiz edouard@3221: edouard@3222: choose { edouard@3222: when "$svg_widget_count < 1" edouard@3222: error > No widget detected on selected SVG edouard@3222: when "$svg_widget_count > 1" edouard@3222: error > Multiple widget DnD not yet supported edouard@3222: when """$selected_node_type = $NODES_TYPES and \ edouard@3222: not($svg_widget_type = $HMI_NODES_COMPAT)""" edouard@3223: error > Widget incompatible with selected HMI tree node edouard@3222: } edouard@3223: edouard@3222: const "testmsg" { edouard@3223: msg value "$hmi_path"; edouard@3222: msg value "$selected_node_type"; edouard@3222: msg value "$svg_widget_type"; edouard@3222: } edouard@3222: edouard@3222: value "ns:GiveDetails($testmsg)"; edouard@3222: edouard@3221: apply "/", mode="inline_svg"; edouard@3221: } edouard@3221: }