svghmi/widget_switch.ysl2
changeset 3518 c663d1f9f03b
parent 3516 d3cf85a3c282
equal deleted inserted replaced
3517:dacf329abdd9 3518:c663d1f9f03b
    41                         choice.parent = choice.elt.parentElement;
    41                         choice.parent = choice.elt.parentElement;
    42                         choice.parent.removeChild(choice.elt);
    42                         choice.parent.removeChild(choice.elt);
    43                     }
    43                     }
    44                 } else {
    44                 } else {
    45                     if(choice.parent != undefined){
    45                     if(choice.parent != undefined){
    46                         choice.parent.appendChild(choice.elt);
    46                         choice.parent.insertBefore(choice.elt,choice.sibling);
    47                         choice.parent = undefined;
    47                         choice.parent = undefined;
    48                     }
    48                     }
    49                 }
    49                 }
    50             }
    50             }
    51         }
    51         }
    58     // this prevents matching element in sub-widgets
    58     // this prevents matching element in sub-widgets
    59     const "subelts", "$result_widgets[@id = $hmi_element/@id]//*";
    59     const "subelts", "$result_widgets[@id = $hmi_element/@id]//*";
    60     const "subwidgets", "$subelts//*[@id = $hmi_widgets/@id]";
    60     const "subwidgets", "$subelts//*[@id = $hmi_widgets/@id]";
    61     const "accepted", "$subelts[not(ancestor-or-self::*/@id = $subwidgets/@id)]";
    61     const "accepted", "$subelts[not(ancestor-or-self::*/@id = $subwidgets/@id)]";
    62 
    62 
    63     foreach "$accepted[regexp:test(@inkscape:label,$regex)]" {
    63     const "choices", "$accepted[regexp:test(@inkscape:label,$regex)]";
       
    64     foreach "$choices" {
    64         const "literal", "regexp:match(@inkscape:label,$regex)[2]";
    65         const "literal", "regexp:match(@inkscape:label,$regex)[2]";
       
    66         const "sibling", "following-sibling::*[not(@id = $choices/@id)][position()=1]";
    65     |         {
    67     |         {
    66     |             elt:id("«@id»"),
    68     |             elt:id("«@id»"),
    67     |             parent:undefined,
    69     |             parent:undefined,
       
    70     choose {
       
    71         when "count($sibling)=0" {
       
    72     |             sibling:null,
       
    73         }
       
    74         otherwise {
       
    75     |             sibling:id("«$sibling/@id»"),
       
    76         }
       
    77     }
    68     |             value:«$literal»
    78     |             value:«$literal»
    69     |         }`if "position()!=last()" > ,`
    79     |         }`if "position()!=last()" > ,`
    70     }
    80     }
    71     |     ],
    81     |     ],
    72 }
    82 }