in xsl decl labels(*ptr, name="defs_by_labels") alias call-template {
with "hmi_element", "$hmi_element";
with "labels"{text *ptr};
in xsl decl optional_labels(*ptr, name="defs_by_labels") alias call-template {
with "hmi_element", "$hmi_element";
with "labels"{text *ptr};
template "svg:*", mode="hmi_elements" {
const "widget", "func:widget(@id)";
| type: "«$widget/@type»",
| "«@value»"`if "position()!=last()" > ,`
warning > Widget «$widget/@type» id="«$eltid»" : No match for path "«@value»" in HMI tree
| «@index» /* «@value» */ `if "position()!=last()" > ,`
apply "$widget", mode="widget_defs" with "hmi_element",".";
apply "$widget", mode="widget_subscribe" with "hmi_element",".";
| }`if "position()!=last()" > ,`
// default : normal subscribing
template "widget", mode="widget_subscribe" {
| apply_cache: widget_apply_cache,
// page aren't subscribers
template "widget[@type='Page']", mode="widget_subscribe";
function "defs_by_labels" {
param "mandatory","'yes'";
const "widget_type","@type";
foreach "str:split($labels)" {
const "elt_id","$result_svg_ns//*[@id = $hmi_element/@id]//*[@inkscape:label=$name][1]/@id";
// TODO FIXME error > «$widget_type» widget must have a «$name» element
warning > «$widget_type» widget must have a «$name» element
// otherwise produce nothing
| «$name»_elt: id("«$elt_id»"),
def "func:escape_quotes" {
// have to use a python string to enter escaped quote
const "frst", !"substring-before($txt,'\"')"!;
const "frstln", "string-length($frst)";
when "$frstln > 0 and string-length($txt) > $frstln" {
result !"concat($frst,'\\\"',func:escape_quotes(substring-after($txt,'\"')))"!;