equal
deleted
inserted
replaced
1 <?xml version="1.0"?> |
1 <?xml version="1.0"?> |
2 <xsl:stylesheet xmlns:func="http://exslt.org/functions" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:svg="http://www.w3.org/2000/svg" xmlns:str="http://exslt.org/strings" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:exsl="http://exslt.org/common" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:ns="beremiz" xmlns:cc="http://creativecommons.org/ns#" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dc="http://purl.org/dc/elements/1.1/" extension-element-prefixes="ns func" version="1.0" exclude-result-prefixes="ns str regexp exsl func"> |
2 <xsl:stylesheet xmlns:func="http://exslt.org/functions" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg" xmlns:str="http://exslt.org/strings" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:exsl="http://exslt.org/common" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ns="beremiz" xmlns:cc="http://creativecommons.org/ns#" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dc="http://purl.org/dc/elements/1.1/" extension-element-prefixes="ns func" version="1.0" exclude-result-prefixes="ns str regexp exsl func"> |
3 <xsl:output method="xml" cdata-section-elements="xhtml:script"/> |
3 <xsl:output method="xml" cdata-section-elements="xhtml:script"/> |
4 <xsl:variable name="geometry" select="ns:GetSVGGeometry()"/> |
4 <xsl:variable name="geometry" select="ns:GetSVGGeometry()"/> |
5 <xsl:variable name="hmitree" select="ns:GetHMITree()"/> |
5 <xsl:variable name="hmitree" select="ns:GetHMITree()"/> |
6 <xsl:variable name="svg_root_id" select="/svg:svg/@id"/> |
6 <xsl:variable name="svg_root_id" select="/svg:svg/@id"/> |
7 <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/> |
7 <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/> |
116 <xsl:apply-templates mode="inline_svg" select="@* | node()"/> |
116 <xsl:apply-templates mode="inline_svg" select="@* | node()"/> |
117 </xsl:copy> |
117 </xsl:copy> |
118 </xsl:template> |
118 </xsl:template> |
119 <xsl:template mode="inline_svg" match="svg:svg[@viewBox!=concat('0 0 ', @width, ' ', @height)]"> |
119 <xsl:template mode="inline_svg" match="svg:svg[@viewBox!=concat('0 0 ', @width, ' ', @height)]"> |
120 <xsl:message terminate="yes"> |
120 <xsl:message terminate="yes"> |
121 <xsl:text>Scale other than 1.000 in Inkscape's document properties is not supported</xsl:text> |
121 <xsl:text>ViewBox settings other than X=0, Y=0 and Scale=1 are not supported</xsl:text> |
122 </xsl:message> |
122 </xsl:message> |
123 </xsl:template> |
123 </xsl:template> |
124 <xsl:template mode="inline_svg" match="sodipodi:namedview[@units!='px' or @inkscape:document-units!='px']"> |
124 <xsl:template mode="inline_svg" match="sodipodi:namedview[@units!='px' or @inkscape:document-units!='px']"> |
125 <xsl:message terminate="yes"> |
125 <xsl:message terminate="yes"> |
126 <xsl:text>All units must be set to "px" in Inkscape's document properties</xsl:text> |
126 <xsl:text>All units must be set to "px" in Inkscape's document properties</xsl:text> |
198 </widget> |
198 </widget> |
199 </xsl:if> |
199 </xsl:if> |
200 </xsl:variable> |
200 </xsl:variable> |
201 <func:result select="exsl:node-set($ast)"/> |
201 <func:result select="exsl:node-set($ast)"/> |
202 </func:function> |
202 </func:function> |
|
203 <func:function name="func:refered_elements"> |
|
204 <xsl:param name="elems"/> |
|
205 <xsl:variable name="descend" select="$elems/descendant-or-self::svg:*"/> |
|
206 <xsl:variable name="clones" select="$descend[self::svg:use]"/> |
|
207 <xsl:variable name="reals" select="$descend[not(self::svg:use)]"/> |
|
208 <xsl:variable name="originals" select="//svg:*[concat('#',@id) = $clones/@xlink:href]"/> |
|
209 <xsl:choose> |
|
210 <xsl:when test="$originals"> |
|
211 <func:result select="$reals | func:refered_elements($originals)"/> |
|
212 </xsl:when> |
|
213 <xsl:otherwise> |
|
214 <func:result select="$reals"/> |
|
215 </xsl:otherwise> |
|
216 </xsl:choose> |
|
217 </func:function> |
203 <xsl:template name="scripts"> |
218 <xsl:template name="scripts"> |
204 <xsl:text>//(function(){ |
219 <xsl:text>//(function(){ |
205 </xsl:text> |
220 </xsl:text> |
206 <xsl:text> |
221 <xsl:text> |
207 </xsl:text> |
222 </xsl:text> |
310 <xsl:for-each select="$hmi_pages"> |
325 <xsl:for-each select="$hmi_pages"> |
311 <xsl:variable name="desc" select="func:parselabel(@inkscape:label)/widget"/> |
326 <xsl:variable name="desc" select="func:parselabel(@inkscape:label)/widget"/> |
312 <xsl:variable name="page" select="."/> |
327 <xsl:variable name="page" select="."/> |
313 <xsl:variable name="p" select="$hmi_geometry[@Id = $page/@id]"/> |
328 <xsl:variable name="p" select="$hmi_geometry[@Id = $page/@id]"/> |
314 <xsl:variable name="page_ids" select="$hmi_geometry[@Id != $page/@id and @x >= $p/@x and @y >= $p/@y and @x+@w <= $p/@x+$p/@w and @y+@h <= $p/@y+$p/@h]/@Id"/> |
329 <xsl:variable name="page_ids" select="$hmi_geometry[@Id != $page/@id and @x >= $p/@x and @y >= $p/@y and @x+@w <= $p/@x+$p/@w and @y+@h <= $p/@y+$p/@h]/@Id"/> |
315 <xsl:variable name="page_elements" select="$hmi_elements[@id = $page_ids]"/> |
330 <xsl:variable name="page_sub_ids" select="func:refered_elements($page)[@id = $hmi_elements/@id]/@id"/> |
|
331 <xsl:variable name="all_page_ids" select="$page_ids | $page_sub_ids[not(. = $page_ids)]"/> |
316 <xsl:text> "</xsl:text> |
332 <xsl:text> "</xsl:text> |
317 <xsl:value-of select="$desc/arg[1]/@value"/> |
333 <xsl:value-of select="$desc/arg[1]/@value"/> |
318 <xsl:text>": { |
334 <xsl:text>": { |
319 </xsl:text> |
335 </xsl:text> |
320 <xsl:text> id: "</xsl:text> |
336 <xsl:text> id: "</xsl:text> |
331 <xsl:value-of select="$p/@h"/> |
347 <xsl:value-of select="$p/@h"/> |
332 <xsl:text>], |
348 <xsl:text>], |
333 </xsl:text> |
349 </xsl:text> |
334 <xsl:text> widgets: [ |
350 <xsl:text> widgets: [ |
335 </xsl:text> |
351 </xsl:text> |
336 <xsl:for-each select="$page_ids"> |
352 <xsl:for-each select="$all_page_ids"> |
337 <xsl:text> hmi_widgets["</xsl:text> |
353 <xsl:text> hmi_widgets["</xsl:text> |
338 <xsl:value-of select="."/> |
354 <xsl:value-of select="."/> |
339 <xsl:text>"]</xsl:text> |
355 <xsl:text>"]</xsl:text> |
340 <xsl:if test="position()!=last()"> |
356 <xsl:if test="position()!=last()"> |
341 <xsl:text>,</xsl:text> |
357 <xsl:text>,</xsl:text> |
1094 <xsl:template mode="widget_defs" match="widget[@type='Change']"> |
1110 <xsl:template mode="widget_defs" match="widget[@type='Change']"> |
1095 <xsl:text> frequency: 5, |
1111 <xsl:text> frequency: 5, |
1096 </xsl:text> |
1112 </xsl:text> |
1097 </xsl:template> |
1113 </xsl:template> |
1098 <xsl:template mode="widget_defs" match="widget[@type='Jump']"> |
1114 <xsl:template mode="widget_defs" match="widget[@type='Jump']"> |
|
1115 <xsl:param name="hmi_element"/> |
|
1116 <xsl:text>on_click: function() { |
|
1117 </xsl:text> |
|
1118 <xsl:text> switch_page(this.args[0]); |
|
1119 </xsl:text> |
|
1120 <xsl:text>}, |
|
1121 </xsl:text> |
1099 <xsl:text>init: function() { |
1122 <xsl:text>init: function() { |
1100 </xsl:text> |
1123 </xsl:text> |
1101 <xsl:text> this.element.addEventListener( |
1124 <xsl:text> this.element.setAttribute("onclick", "hmi_widgets['</xsl:text> |
1102 </xsl:text> |
1125 <xsl:value-of select="$hmi_element/@id"/> |
1103 <xsl:text> "click", |
1126 <xsl:text>'].on_click()"); |
1104 </xsl:text> |
|
1105 <xsl:text> evt => switch_page(this.args[0])); |
|
1106 </xsl:text> |
1127 </xsl:text> |
1107 <xsl:text>}, |
1128 <xsl:text>}, |
1108 </xsl:text> |
1129 </xsl:text> |
1109 </xsl:template> |
1130 </xsl:template> |
1110 </xsl:stylesheet> |
1131 </xsl:stylesheet> |