71 <xsl:with-param name="parentpath"> |
71 <xsl:with-param name="parentpath"> |
72 <xsl:value-of select="$parentpath"/> |
72 <xsl:value-of select="$parentpath"/> |
73 </xsl:with-param> |
73 </xsl:with-param> |
74 </xsl:apply-templates> |
74 </xsl:apply-templates> |
75 </xsl:template> |
75 </xsl:template> |
76 <func:function name="func:parselabel"> |
76 <xsl:template mode="parselabel" match="*"> |
77 <xsl:param name="label"/> |
77 <xsl:variable name="label" select="@inkscape:label"/> |
78 <xsl:variable name="description" select="substring-after($label,'HMI:')"/> |
78 <xsl:variable name="description" select="substring-after($label,'HMI:')"/> |
79 <xsl:variable name="_args" select="substring-before($description,'@')"/> |
79 <xsl:variable name="_args" select="substring-before($description,'@')"/> |
80 <xsl:variable name="args"> |
80 <xsl:variable name="args"> |
81 <xsl:choose> |
81 <xsl:choose> |
82 <xsl:when test="$_args"> |
82 <xsl:when test="$_args"> |
96 <xsl:otherwise> |
96 <xsl:otherwise> |
97 <xsl:value-of select="$args"/> |
97 <xsl:value-of select="$args"/> |
98 </xsl:otherwise> |
98 </xsl:otherwise> |
99 </xsl:choose> |
99 </xsl:choose> |
100 </xsl:variable> |
100 </xsl:variable> |
101 <xsl:variable name="ast"> |
101 <xsl:if test="$type"> |
102 <xsl:if test="$type"> |
102 <widget> |
103 <widget> |
103 <xsl:attribute name="id"> |
104 <xsl:attribute name="type"> |
104 <xsl:value-of select="@id"/> |
105 <xsl:value-of select="$type"/> |
105 </xsl:attribute> |
106 </xsl:attribute> |
106 <xsl:attribute name="type"> |
107 <xsl:for-each select="str:split(substring-after($args, ':'), ':')"> |
107 <xsl:value-of select="$type"/> |
108 <arg> |
108 </xsl:attribute> |
|
109 <xsl:for-each select="str:split(substring-after($args, ':'), ':')"> |
|
110 <arg> |
|
111 <xsl:attribute name="value"> |
|
112 <xsl:value-of select="."/> |
|
113 </xsl:attribute> |
|
114 </arg> |
|
115 </xsl:for-each> |
|
116 <xsl:variable name="paths" select="substring-after($description,'@')"/> |
|
117 <xsl:for-each select="str:split($paths, '@')"> |
|
118 <xsl:if test="string-length(.) > 0"> |
|
119 <path> |
109 <xsl:attribute name="value"> |
120 <xsl:attribute name="value"> |
110 <xsl:value-of select="."/> |
121 <xsl:value-of select="."/> |
111 </xsl:attribute> |
122 </xsl:attribute> |
112 </arg> |
123 <xsl:variable name="path" select="."/> |
113 </xsl:for-each> |
124 <xsl:variable name="item" select="$indexed_hmitree/*[@hmipath = $path]"/> |
114 <xsl:variable name="paths" select="substring-after($description,'@')"/> |
125 <xsl:if test="count($item) = 1"> |
115 <xsl:for-each select="str:split($paths, '@')"> |
126 <xsl:attribute name="index"> |
116 <xsl:if test="string-length(.) > 0"> |
127 <xsl:value-of select="$item/@index"/> |
117 <path> |
|
118 <xsl:attribute name="value"> |
|
119 <xsl:value-of select="."/> |
|
120 </xsl:attribute> |
128 </xsl:attribute> |
121 <xsl:variable name="path" select="."/> |
129 </xsl:if> |
122 <xsl:variable name="item" select="$indexed_hmitree/*[@hmipath = $path]"/> |
130 </path> |
123 <xsl:if test="count($item) = 1"> |
131 </xsl:if> |
124 <xsl:attribute name="index"> |
132 </xsl:for-each> |
125 <xsl:value-of select="$item/@index"/> |
133 </widget> |
126 </xsl:attribute> |
134 </xsl:if> |
127 </xsl:if> |
135 </xsl:template> |
128 </path> |
136 <xsl:variable name="_parsed_widgets"> |
129 </xsl:if> |
137 <xsl:apply-templates mode="parselabel" select="$hmi_elements"/> |
130 </xsl:for-each> |
138 </xsl:variable> |
131 </widget> |
139 <xsl:variable name="parsed_widgets" select="exsl:node-set($_parsed_widgets)"/> |
132 </xsl:if> |
140 <func:function name="func:widget"> |
133 </xsl:variable> |
141 <xsl:param name="id"/> |
134 <func:result select="exsl:node-set($ast)"/> |
142 <func:result select="$parsed_widgets/widget[@id = $id]"/> |
135 </func:function> |
|
136 <func:function name="func:parselabels"> |
|
137 <xsl:param name="nodes"/> |
|
138 <xsl:choose> |
|
139 <xsl:when test="$nodes"> |
|
140 <func:result select="func:parselabel($nodes[1]/@inkscape:label) | func:parselabels($nodes[position()!=1])"/> |
|
141 </xsl:when> |
|
142 <xsl:otherwise> |
|
143 <func:result select="/.."/> |
|
144 </xsl:otherwise> |
|
145 </xsl:choose> |
|
146 </func:function> |
143 </func:function> |
147 <xsl:template mode="testtree" match="*"> |
144 <xsl:template mode="testtree" match="*"> |
148 <xsl:param name="indent" select="''"/> |
145 <xsl:param name="indent" select="''"/> |
149 <xsl:value-of select="$indent"/> |
146 <xsl:value-of select="$indent"/> |
150 <xsl:text> </xsl:text> |
147 <xsl:text> </xsl:text> |
171 <xsl:text> |
168 <xsl:text> |
172 </xsl:text> |
169 </xsl:text> |
173 <xsl:text>Indexed HMI tree |
170 <xsl:text>Indexed HMI tree |
174 </xsl:text> |
171 </xsl:text> |
175 <xsl:apply-templates mode="testtree" select="$indexed_hmitree"/> |
172 <xsl:apply-templates mode="testtree" select="$indexed_hmitree"/> |
|
173 <xsl:text> |
|
174 </xsl:text> |
|
175 <xsl:text>Parsed Widgets |
|
176 </xsl:text> |
|
177 <xsl:copy-of select="_parsed_widgets"/> |
|
178 <xsl:apply-templates mode="testtree" select="$parsed_widgets"/> |
176 </xsl:template> |
179 </xsl:template> |
177 <xsl:variable name="geometry" select="ns:GetSVGGeometry()"/> |
180 <xsl:variable name="geometry" select="ns:GetSVGGeometry()"/> |
178 <xsl:template name="debug_geometry"> |
181 <xsl:template name="debug_geometry"> |
179 <xsl:text>ID, x, y, w, h |
182 <xsl:text>ID, x, y, w, h |
180 </xsl:text> |
183 </xsl:text> |
237 <xsl:variable name="groups" select="/svg:svg | //svg:g"/> |
240 <xsl:variable name="groups" select="/svg:svg | //svg:g"/> |
238 <xsl:variable name="g" select="$geometry[@Id = $elt/@id]"/> |
241 <xsl:variable name="g" select="$geometry[@Id = $elt/@id]"/> |
239 <xsl:variable name="candidates" select="$geometry[@Id != $elt/@id]"/> |
242 <xsl:variable name="candidates" select="$geometry[@Id != $elt/@id]"/> |
240 <func:result select="$candidates[(@Id = $groups/@id and (func:intersect($g, .) = 9)) or (not(@Id = $groups/@id) and (func:intersect($g, .) > 0 ))]"/> |
243 <func:result select="$candidates[(@Id = $groups/@id and (func:intersect($g, .) = 9)) or (not(@Id = $groups/@id) and (func:intersect($g, .) > 0 ))]"/> |
241 </func:function> |
244 </func:function> |
242 <xsl:variable name="hmi_pages" select="$hmi_elements[func:parselabel(@inkscape:label)/widget/@type = 'Page']"/> |
245 <xsl:variable name="hmi_pages_ids" select="$parsed_widgets/widget[@type = 'Page']/@id"/> |
|
246 <xsl:variable name="hmi_pages" select="$hmi_elements[@id = $hmi_pages_ids]"/> |
243 <xsl:variable name="default_page"> |
247 <xsl:variable name="default_page"> |
244 <xsl:choose> |
248 <xsl:choose> |
245 <xsl:when test="count($hmi_pages) > 1"> |
249 <xsl:when test="count($hmi_pages) > 1"> |
246 <xsl:variable name="Home_page" select="$hmi_pages[func:parselabel(@inkscape:label)/widget/arg[1]/@value = 'Home']"/> |
250 <xsl:variable name="Home_page" select="$hmi_pages[func:widget(@id)/arg[1]/@value = 'Home']"/> |
247 <xsl:choose> |
251 <xsl:choose> |
248 <xsl:when test="$Home_page"> |
252 <xsl:when test="$Home_page"> |
249 <xsl:text>Home</xsl:text> |
253 <xsl:text>Home</xsl:text> |
250 </xsl:when> |
254 </xsl:when> |
251 <xsl:otherwise> |
255 <xsl:otherwise> |
319 <xsl:param name="descend"/> |
323 <xsl:param name="descend"/> |
320 <xsl:param name="ancest"/> |
324 <xsl:param name="ancest"/> |
321 <func:result select="string-length($ancest) > 0 and starts-with($descend,$ancest)"/> |
325 <func:result select="string-length($ancest) > 0 and starts-with($descend,$ancest)"/> |
322 </func:function> |
326 </func:function> |
323 <xsl:template mode="page_desc" match="svg:*"> |
327 <xsl:template mode="page_desc" match="svg:*"> |
324 <xsl:variable name="desc" select="func:parselabel(@inkscape:label)/widget"/> |
328 <xsl:variable name="desc" select="func:widget(@id)"/> |
325 <xsl:variable name="page" select="."/> |
329 <xsl:variable name="page" select="."/> |
326 <xsl:variable name="p" select="$geometry[@Id = $page/@id]"/> |
330 <xsl:variable name="p" select="$geometry[@Id = $page/@id]"/> |
327 <xsl:variable name="page_all_elements" select="func:all_related_elements($page)"/> |
331 <xsl:variable name="page_all_elements" select="func:all_related_elements($page)"/> |
328 <xsl:variable name="all_page_widgets" select="$hmi_elements[@id = $page_all_elements/@id and @id != $page/@id][not(func:parselabels(ancestor::svg:*)/widget/@type = 'ForEach')]"/> |
332 <xsl:variable name="all_page_widgets" select="$hmi_elements[@id = $page_all_elements/@id and @id != $page/@id]"/> |
329 <xsl:variable name="page_relative_widgets" select="$all_page_widgets[func:is_descendant_path(func:parselabel(@inkscape:label)/widget/path/@value, $desc/path/@value)]"/> |
333 <xsl:variable name="page_relative_widgets" select="$all_page_widgets[func:is_descendant_path(func:widget(@id)/path/@value, $desc/path/@value)]"/> |
330 <xsl:variable name="required_detachables" select="func:sumarized_elements($page_all_elements)/ ancestor-or-self::*[@id = $detachable_elements/@id]"/> |
334 <xsl:variable name="required_detachables" select="func:sumarized_elements($page_all_elements)/ ancestor-or-self::*[@id = $detachable_elements/@id]"/> |
331 <xsl:text> "</xsl:text> |
335 <xsl:text> "</xsl:text> |
332 <xsl:value-of select="$desc/arg[1]/@value"/> |
336 <xsl:value-of select="$desc/arg[1]/@value"/> |
333 <xsl:text>": { |
337 <xsl:text>": { |
334 </xsl:text> |
338 </xsl:text> |