72 <xsl:with-param name="parentpath"> |
72 <xsl:with-param name="parentpath"> |
73 <xsl:value-of select="$parentpath"/> |
73 <xsl:value-of select="$parentpath"/> |
74 </xsl:with-param> |
74 </xsl:with-param> |
75 </xsl:apply-templates> |
75 </xsl:apply-templates> |
76 </xsl:template> |
76 </xsl:template> |
77 <func:function name="func:get_hmi_tree_elt"> |
|
78 <xsl:param name="path"/> |
|
79 <xsl:param name="root" select="$hmitree"/> |
|
80 <xsl:message> |
|
81 <xsl:text>get_hmi_tree_elt </xsl:text> |
|
82 <xsl:value-of select="$path"/> |
|
83 </xsl:message> |
|
84 <xsl:if test="not(starts-with($path, '/'))"> |
|
85 <xsl:message terminate="yes"> |
|
86 <xsl:text>Given path "</xsl:text> |
|
87 <xsl:value-of select="$path"/> |
|
88 <xsl:text>" should start with a "/"</xsl:text> |
|
89 </xsl:message> |
|
90 </xsl:if> |
|
91 <xsl:variable name="stripped" select="substring($path, 2)"/> |
|
92 <xsl:variable name="token"> |
|
93 <xsl:choose> |
|
94 <xsl:when test="contains($stripped, '/')"> |
|
95 <xsl:value-of select="substring-before($stripped, '/')"/> |
|
96 </xsl:when> |
|
97 <xsl:otherwise> |
|
98 <xsl:value-of select="$stripped"/> |
|
99 </xsl:otherwise> |
|
100 </xsl:choose> |
|
101 </xsl:variable> |
|
102 <xsl:choose> |
|
103 <xsl:when test="string-length($token) = 0"> |
|
104 <func:result select="$root"/> |
|
105 </xsl:when> |
|
106 <xsl:otherwise> |
|
107 <xsl:variable name="rest" select="substring-after($stripped, $token)"/> |
|
108 <xsl:variable name="match" select="$root/*[@name = $token]"/> |
|
109 <xsl:choose> |
|
110 <xsl:when test="string-length($rest) > 0"> |
|
111 <func:result select="func:get_hmi_tree_el($rest, $match)"/> |
|
112 </xsl:when> |
|
113 <xsl:otherwise> |
|
114 <func:result select="$match"/> |
|
115 </xsl:otherwise> |
|
116 </xsl:choose> |
|
117 </xsl:otherwise> |
|
118 </xsl:choose> |
|
119 </func:function> |
|
120 <xsl:template mode="parselabel" match="*"> |
77 <xsl:template mode="parselabel" match="*"> |
121 <xsl:variable name="label" select="@inkscape:label"/> |
78 <xsl:variable name="label" select="@inkscape:label"/> |
122 <xsl:variable name="description" select="substring-after($label,'HMI:')"/> |
79 <xsl:variable name="description" select="substring-after($label,'HMI:')"/> |
123 <xsl:variable name="_args" select="substring-before($description,'@')"/> |
80 <xsl:variable name="_args" select="substring-before($description,'@')"/> |
124 <xsl:variable name="args"> |
81 <xsl:variable name="args"> |
182 </xsl:variable> |
139 </xsl:variable> |
183 <xsl:variable name="parsed_widgets" select="exsl:node-set($_parsed_widgets)"/> |
140 <xsl:variable name="parsed_widgets" select="exsl:node-set($_parsed_widgets)"/> |
184 <func:function name="func:widget"> |
141 <func:function name="func:widget"> |
185 <xsl:param name="id"/> |
142 <xsl:param name="id"/> |
186 <func:result select="$parsed_widgets/widget[@id = $id]"/> |
143 <func:result select="$parsed_widgets/widget[@id = $id]"/> |
|
144 </func:function> |
|
145 <func:function name="func:is_descendant_path"> |
|
146 <xsl:param name="descend"/> |
|
147 <xsl:param name="ancest"/> |
|
148 <func:result select="string-length($ancest) > 0 and starts-with($descend,$ancest)"/> |
187 </func:function> |
149 </func:function> |
188 <xsl:template mode="testtree" match="*"> |
150 <xsl:template mode="testtree" match="*"> |
189 <xsl:param name="indent" select="''"/> |
151 <xsl:param name="indent" select="''"/> |
190 <xsl:value-of select="$indent"/> |
152 <xsl:value-of select="$indent"/> |
191 <xsl:text> </xsl:text> |
153 <xsl:text> </xsl:text> |
360 </xsl:otherwise> |
322 </xsl:otherwise> |
361 </xsl:choose> |
323 </xsl:choose> |
362 </func:function> |
324 </func:function> |
363 <xsl:variable name="_detachable_elements" select="func:detachable_elements($hmi_pages)"/> |
325 <xsl:variable name="_detachable_elements" select="func:detachable_elements($hmi_pages)"/> |
364 <xsl:variable name="detachable_elements" select="$_detachable_elements[not(ancestor::*/@id = $_detachable_elements/@id)]"/> |
326 <xsl:variable name="detachable_elements" select="$_detachable_elements[not(ancestor::*/@id = $_detachable_elements/@id)]"/> |
365 <func:function name="func:is_descendant_path"> |
|
366 <xsl:param name="descend"/> |
|
367 <xsl:param name="ancest"/> |
|
368 <func:result select="string-length($ancest) > 0 and starts-with($descend,$ancest)"/> |
|
369 </func:function> |
|
370 <xsl:variable name="forEach_widgets_ids" select="$parsed_widgets/widget[@type = 'ForEach']/@id"/> |
327 <xsl:variable name="forEach_widgets_ids" select="$parsed_widgets/widget[@type = 'ForEach']/@id"/> |
371 <xsl:variable name="forEach_widgets" select="$hmi_elements[@id = $forEach_widgets_ids]"/> |
328 <xsl:variable name="forEach_widgets" select="$hmi_elements[@id = $forEach_widgets_ids]"/> |
372 <xsl:variable name="in_forEach_widget_ids" select="func:refered_elements($forEach_widgets)[not(@id = $forEach_widgets_ids)]/@id"/> |
329 <xsl:variable name="in_forEach_widget_ids" select="func:refered_elements($forEach_widgets)[not(@id = $forEach_widgets_ids)]/@id"/> |
373 <xsl:template mode="page_desc" match="svg:*"> |
330 <xsl:template mode="page_desc" match="svg:*"> |
374 <xsl:variable name="desc" select="func:widget(@id)"/> |
331 <xsl:variable name="desc" select="func:widget(@id)"/> |
744 </xsl:text> |
701 </xsl:text> |
745 </xsl:template> |
702 </xsl:template> |
746 <xsl:template mode="widget_defs" match="widget[@type='ForEach']"> |
703 <xsl:template mode="widget_defs" match="widget[@type='ForEach']"> |
747 <xsl:param name="hmi_element"/> |
704 <xsl:param name="hmi_element"/> |
748 <xsl:variable name="widgets" select="func:refered_elements($forEach_widgets)[not(@id = $forEach_widgets_ids)]"/> |
705 <xsl:variable name="widgets" select="func:refered_elements($forEach_widgets)[not(@id = $forEach_widgets_ids)]"/> |
749 <xsl:text> frequency: 2, |
706 <xsl:variable name="class" select="arg[1]/@value"/> |
750 </xsl:text> |
707 <xsl:variable name="base_path" select="path/@value"/> |
751 <xsl:text> dispatch: function(value) { |
708 <xsl:variable name="hmi_index_base" select="$indexed_hmitree/*[@hmipath = $base_path]"/> |
752 </xsl:text> |
709 <xsl:variable name="hmi_tree_base" select="$hmitree/descendant-or-self::*[@path = $hmi_index_base/@path]"/> |
753 <xsl:text> // do something |
710 <xsl:variable name="hmi_tree_items" select="$hmi_tree_base/*[@class = $class]"/> |
754 </xsl:text> |
711 <xsl:variable name="hmi_index_items" select="$indexed_hmitree/*[@path = $hmi_tree_items/@path]"/> |
755 <xsl:text> }, |
712 <xsl:variable name="items_paths" select="$hmi_index_items/@hmipath"/> |
756 </xsl:text> |
|
757 <xsl:text> index_pool: [ |
713 <xsl:text> index_pool: [ |
758 </xsl:text> |
714 </xsl:text> |
|
715 <xsl:for-each select="$hmi_index_items"> |
|
716 <xsl:text> </xsl:text> |
|
717 <xsl:value-of select="@index"/> |
|
718 <xsl:if test="position()!=last()"> |
|
719 <xsl:text>,</xsl:text> |
|
720 </xsl:if> |
|
721 <xsl:text> |
|
722 </xsl:text> |
|
723 </xsl:for-each> |
759 <xsl:text> ], |
724 <xsl:text> ], |
760 </xsl:text> |
725 </xsl:text> |
761 <xsl:text> buttons: [ |
726 <xsl:text> buttons: [ |
762 </xsl:text> |
727 </xsl:text> |
763 <xsl:variable name="class" select="arg[1]/@value"/> |
|
764 <xsl:variable name="prefix" select="concat($class,':')"/> |
728 <xsl:variable name="prefix" select="concat($class,':')"/> |
765 <xsl:variable name="buttons_regex" select="concat('^',$prefix,'[+\-][0-9]+')"/> |
729 <xsl:variable name="buttons_regex" select="concat('^',$prefix,'[+\-][0-9]+')"/> |
766 <xsl:for-each select="$hmi_element/*[regexp:test(@inkscape:label, $buttons_regex)]"> |
730 <xsl:for-each select="$hmi_element/*[regexp:test(@inkscape:label, $buttons_regex)]"> |
767 <xsl:text> ["</xsl:text> |
731 <xsl:text> ["</xsl:text> |
768 <xsl:value-of select="substring-after(@inkscape:label, concat(arg[1]/@value, ':'))"/> |
732 <xsl:value-of select="substring-after(@inkscape:label, concat(arg[1]/@value, ':'))"/> |
785 </xsl:text> |
749 </xsl:text> |
786 <xsl:text> }, |
750 <xsl:text> }, |
787 </xsl:text> |
751 </xsl:text> |
788 <xsl:text> items: [ |
752 <xsl:text> items: [ |
789 </xsl:text> |
753 </xsl:text> |
790 <xsl:variable name="base_path" select="path/@value"/> |
|
791 <xsl:variable name="items_regex" select="concat('^',$prefix,'[0-9]+')"/> |
754 <xsl:variable name="items_regex" select="concat('^',$prefix,'[0-9]+')"/> |
792 <xsl:variable name="unordered_items" select="$hmi_element//*[regexp:test(@inkscape:label, $items_regex)]"/> |
755 <xsl:variable name="unordered_items" select="$hmi_element//*[regexp:test(@inkscape:label, $items_regex)]"/> |
793 <xsl:for-each select="$unordered_items"> |
756 <xsl:for-each select="$unordered_items"> |
794 <xsl:variable name="elt_label" select="concat($prefix, string(position()))"/> |
757 <xsl:variable name="elt_label" select="concat($prefix, string(position()))"/> |
795 <xsl:variable name="elt" select="$unordered_items[@inkscape:label = $elt_label]"/> |
758 <xsl:variable name="elt" select="$unordered_items[@inkscape:label = $elt_label]"/> |
796 <xsl:text> /* </xsl:text> |
759 <xsl:variable name="pos" select="position()"/> |
797 <xsl:apply-templates mode="testtree" select="func:get_hmi_tree_elt($base_path)"/> |
760 <xsl:variable name="item_path" select="$items_paths[$pos]"/> |
798 <xsl:text> */ |
761 <xsl:text> [ /* item="</xsl:text> |
799 </xsl:text> |
|
800 <xsl:text> [ /* </xsl:text> |
|
801 <xsl:value-of select="$elt_label"/> |
762 <xsl:value-of select="$elt_label"/> |
802 <xsl:text> */ |
763 <xsl:text>" path="</xsl:text> |
|
764 <xsl:value-of select="$item_path"/> |
|
765 <xsl:text>" */ |
803 </xsl:text> |
766 </xsl:text> |
804 <xsl:if test="count($elt)=0"> |
767 <xsl:if test="count($elt)=0"> |
805 <xsl:message terminate="yes"> |
768 <xsl:message terminate="yes"> |
806 <xsl:text>Missing item labeled </xsl:text> |
769 <xsl:text>Missing item labeled </xsl:text> |
807 <xsl:value-of select="$elt_label"/> |
770 <xsl:value-of select="$elt_label"/> |
808 <xsl:text> in ForEach widget </xsl:text> |
771 <xsl:text> in ForEach widget </xsl:text> |
809 <xsl:value-of select="$hmi_element/@id"/> |
772 <xsl:value-of select="$hmi_element/@id"/> |
810 </xsl:message> |
773 </xsl:message> |
811 </xsl:if> |
774 </xsl:if> |
812 <xsl:for-each select="func:refered_elements($elt)[@id = $hmi_elements/@id][not(@id = $elt/@id)]"> |
775 <xsl:for-each select="func:refered_elements($elt)[@id = $hmi_elements/@id][not(@id = $elt/@id)]"> |
|
776 <xsl:if test="not(func:is_descendant_path(func:widget(@id)/path/@value, $item_path))"> |
|
777 <xsl:message terminate="yes"> |
|
778 <xsl:text>Widget id="</xsl:text> |
|
779 <xsl:value-of select="@id"/> |
|
780 <xsl:text>" label="</xsl:text> |
|
781 <xsl:value-of select="@inkscape:label"/> |
|
782 <xsl:text>" is having wrong path. Accroding to ForEach widget ancestor id="</xsl:text> |
|
783 <xsl:value-of select="$hmi_element/@id"/> |
|
784 <xsl:text>", path should be descendant of </xsl:text> |
|
785 <xsl:value-of select="$item_path"/> |
|
786 <xsl:text>.</xsl:text> |
|
787 </xsl:message> |
|
788 </xsl:if> |
813 <xsl:text> hmi_widgets["</xsl:text> |
789 <xsl:text> hmi_widgets["</xsl:text> |
814 <xsl:value-of select="@id"/> |
790 <xsl:value-of select="@id"/> |
815 <xsl:text>"]</xsl:text> |
791 <xsl:text>"]</xsl:text> |
816 <xsl:if test="position()!=last()"> |
792 <xsl:if test="position()!=last()"> |
817 <xsl:text>,</xsl:text> |
793 <xsl:text>,</xsl:text> |
830 </xsl:text> |
806 </xsl:text> |
831 </xsl:template> |
807 </xsl:template> |
832 <xsl:template mode="widget_subscribe" match="widget[@type='ForEach']"> |
808 <xsl:template mode="widget_subscribe" match="widget[@type='ForEach']"> |
833 <xsl:text> sub: function(off){ |
809 <xsl:text> sub: function(off){ |
834 </xsl:text> |
810 </xsl:text> |
835 <xsl:text> subscribe.call(this,off); |
811 <xsl:text> /*subscribe.call(this,off);*/ |
836 </xsl:text> |
812 </xsl:text> |
837 <xsl:text> }, |
813 <xsl:text> }, |
838 </xsl:text> |
814 </xsl:text> |
839 <xsl:text> unsub: function(){ |
815 <xsl:text> unsub: function(){ |
840 </xsl:text> |
816 </xsl:text> |
841 <xsl:text> unsubscribe.call(this); |
817 <xsl:text> /*unsubscribe.call(this);*/ |
842 </xsl:text> |
818 </xsl:text> |
843 <xsl:text> }, |
819 <xsl:text> }, |
844 </xsl:text> |
820 </xsl:text> |
845 </xsl:template> |
821 </xsl:template> |
846 <xsl:template mode="widget_defs" match="widget[@type='Input']"> |
822 <xsl:template mode="widget_defs" match="widget[@type='Input']"> |