svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 2940 034b6ce4f885
parent 2939 4296ab974d4d
child 2941 ef13a4007538
equal deleted inserted replaced
2939:4296ab974d4d 2940:034b6ce4f885
     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: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:debug="debug" xmlns:dc="http://purl.org/dc/elements/1.1/" extension-element-prefixes="ns func exsl regexp str dyn" version="1.0" exclude-result-prefixes="ns str regexp exsl func dyn debug">
     2 <xsl:stylesheet xmlns:func="http://exslt.org/functions" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:epilogue="epilogue" 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:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:preamble="preamble" 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:debug="debug" xmlns:dc="http://purl.org/dc/elements/1.1/" extension-element-prefixes="ns func exsl regexp str dyn" version="1.0" exclude-result-prefixes="ns func exsl regexp str dyn debug preamble epilogue">
     3   <xsl:output method="xml" cdata-section-elements="xhtml:script"/>
     3   <xsl:output method="xml" cdata-section-elements="xhtml:script"/>
     4   <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/>
     4   <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/>
     5   <xsl:variable name="hmitree" select="ns:GetHMITree()"/>
     5   <xsl:variable name="hmitree" select="ns:GetHMITree()"/>
     6   <xsl:variable name="_categories">
     6   <xsl:variable name="_categories">
     7     <noindex>
     7     <noindex>
   155     <xsl:param name="b"/>
   155     <xsl:param name="b"/>
   156     <xsl:variable name="class_a" select="$indexed_hmitree/*[@hmipath = $a]/@class"/>
   156     <xsl:variable name="class_a" select="$indexed_hmitree/*[@hmipath = $a]/@class"/>
   157     <xsl:variable name="class_b" select="$indexed_hmitree/*[@hmipath = $b]/@class"/>
   157     <xsl:variable name="class_b" select="$indexed_hmitree/*[@hmipath = $b]/@class"/>
   158     <func:result select="$class_a and $class_b and $class_a = $class_b"/>
   158     <func:result select="$class_a and $class_b and $class_a = $class_b"/>
   159   </func:function>
   159   </func:function>
   160   <debug:hmi-tree/>
       
   161   <xsl:template mode="testtree" match="*">
   160   <xsl:template mode="testtree" match="*">
   162     <xsl:param name="indent" select="''"/>
   161     <xsl:param name="indent" select="''"/>
   163     <xsl:value-of select="$indent"/>
   162     <xsl:value-of select="$indent"/>
   164     <xsl:text> </xsl:text>
   163     <xsl:text> </xsl:text>
   165     <xsl:value-of select="local-name()"/>
   164     <xsl:value-of select="local-name()"/>
   176       <xsl:with-param name="indent">
   175       <xsl:with-param name="indent">
   177         <xsl:value-of select="concat($indent,'&gt;')"/>
   176         <xsl:value-of select="concat($indent,'&gt;')"/>
   178       </xsl:with-param>
   177       </xsl:with-param>
   179     </xsl:apply-templates>
   178     </xsl:apply-templates>
   180   </xsl:template>
   179   </xsl:template>
   181   <xsl:template mode="debug" match="debug:hmi-tree">
   180   <debug:hmi-tree/>
       
   181   <xsl:template match="debug:hmi-tree">
   182     <xsl:text>Raw HMI tree
   182     <xsl:text>Raw HMI tree
   183 </xsl:text>
   183 </xsl:text>
   184     <xsl:apply-templates mode="testtree" select="$hmitree"/>
   184     <xsl:apply-templates mode="testtree" select="$hmitree"/>
   185     <xsl:text>
   185     <xsl:text>
   186 </xsl:text>
   186 </xsl:text>
   194     <xsl:copy-of select="_parsed_widgets"/>
   194     <xsl:copy-of select="_parsed_widgets"/>
   195     <xsl:apply-templates mode="testtree" select="$parsed_widgets"/>
   195     <xsl:apply-templates mode="testtree" select="$parsed_widgets"/>
   196   </xsl:template>
   196   </xsl:template>
   197   <xsl:variable name="geometry" select="ns:GetSVGGeometry()"/>
   197   <xsl:variable name="geometry" select="ns:GetSVGGeometry()"/>
   198   <debug:geometry/>
   198   <debug:geometry/>
   199   <xsl:template mode="debug" match="debug:geometry">
   199   <xsl:template match="debug:geometry">
   200     <xsl:text>ID, x, y, w, h
   200     <xsl:text>ID, x, y, w, h
   201 </xsl:text>
   201 </xsl:text>
   202     <xsl:for-each select="$geometry">
   202     <xsl:for-each select="$geometry">
   203       <xsl:text> </xsl:text>
   203       <xsl:text> </xsl:text>
   204       <xsl:value-of select="@Id"/>
   204       <xsl:value-of select="@Id"/>
   459     <xsl:text>
   459     <xsl:text>
   460 </xsl:text>
   460 </xsl:text>
   461   </xsl:template>
   461   </xsl:template>
   462   <xsl:template mode="per_page_widget_template" match="*"/>
   462   <xsl:template mode="per_page_widget_template" match="*"/>
   463   <debug:detachable-pages/>
   463   <debug:detachable-pages/>
   464   <xsl:template mode="debug" match="debug:detachable-pages">
   464   <xsl:template match="debug:detachable-pages">
   465     <xsl:text>DETACHABLES:
   465     <xsl:text>DETACHABLES:
   466 </xsl:text>
   466 </xsl:text>
   467     <xsl:for-each select="$detachable_elements">
   467     <xsl:for-each select="$detachable_elements">
   468       <xsl:text> </xsl:text>
   468       <xsl:text> </xsl:text>
   469       <xsl:value-of select="@id"/>
   469       <xsl:value-of select="@id"/>
   589   <xsl:variable name="result_svg">
   589   <xsl:variable name="result_svg">
   590     <xsl:apply-templates mode="inline_svg" select="/"/>
   590     <xsl:apply-templates mode="inline_svg" select="/"/>
   591   </xsl:variable>
   591   </xsl:variable>
   592   <xsl:variable name="result_svg_ns" select="exsl:node-set($result_svg)"/>
   592   <xsl:variable name="result_svg_ns" select="exsl:node-set($result_svg)"/>
   593   <debug:inline-svg/>
   593   <debug:inline-svg/>
   594   <xsl:template mode="debug" match="debug:inline-svg">
   594   <xsl:template match="debug:inline-svg">
   595     <xsl:text>Unlinked :
   595     <xsl:text>Unlinked :
   596 </xsl:text>
   596 </xsl:text>
   597     <xsl:for-each select="$to_unlink">
   597     <xsl:for-each select="$to_unlink">
   598       <xsl:value-of select="@id"/>
   598       <xsl:value-of select="@id"/>
   599       <xsl:text>
   599       <xsl:text>
   600 </xsl:text>
   600 </xsl:text>
   601     </xsl:for-each>
   601     </xsl:for-each>
       
   602   </xsl:template>
       
   603   <preamble:hmi-widget/>
       
   604   <xsl:template match="preamble:hmi-widget">
       
   605     <xsl:text>var hmi_widgets = {
       
   606 </xsl:text>
       
   607     <xsl:apply-templates mode="hmi_elements" select="$hmi_elements"/>
       
   608     <xsl:text>}
       
   609 </xsl:text>
   602   </xsl:template>
   610   </xsl:template>
   603   <xsl:template mode="hmi_elements" match="svg:*">
   611   <xsl:template mode="hmi_elements" match="svg:*">
   604     <xsl:variable name="widget" select="func:widget(@id)"/>
   612     <xsl:variable name="widget" select="func:widget(@id)"/>
   605     <xsl:variable name="eltid" select="@id"/>
   613     <xsl:variable name="eltid" select="@id"/>
   606     <xsl:text>  "</xsl:text>
   614     <xsl:text>  "</xsl:text>
  2077 </xsl:text>
  2085 </xsl:text>
  2078     <xsl:text>id = idstr =&gt; document.getElementById(idstr);
  2086     <xsl:text>id = idstr =&gt; document.getElementById(idstr);
  2079 </xsl:text>
  2087 </xsl:text>
  2080     <xsl:text>
  2088     <xsl:text>
  2081 </xsl:text>
  2089 </xsl:text>
  2082     <xsl:apply-templates select="document('')/*/jspreamble"/>
  2090     <xsl:apply-templates select="document('')/*/preamble:*"/>
  2083     <xsl:text>var hmi_hash = [</xsl:text>
  2091     <xsl:text>var hmi_hash = [</xsl:text>
  2084     <xsl:value-of select="$hmitree/@hash"/>
  2092     <xsl:value-of select="$hmitree/@hash"/>
  2085     <xsl:text>];
  2093     <xsl:text>];
  2086 </xsl:text>
       
  2087     <xsl:text>var hmi_widgets = {
       
  2088 </xsl:text>
       
  2089     <xsl:apply-templates mode="hmi_elements" select="$hmi_elements"/>
       
  2090     <xsl:text>}
       
  2091 </xsl:text>
  2094 </xsl:text>
  2092     <xsl:text>
  2095     <xsl:text>
  2093 </xsl:text>
  2096 </xsl:text>
  2094     <xsl:text>var heartbeat_index = </xsl:text>
  2097     <xsl:text>var heartbeat_index = </xsl:text>
  2095     <xsl:value-of select="$indexed_hmitree/*[@hmipath = '/HEARTBEAT']/@index"/>
  2098     <xsl:value-of select="$indexed_hmitree/*[@hmipath = '/HEARTBEAT']/@index"/>
  3220 </xsl:text>
  3223 </xsl:text>
  3221     <xsl:text>    console.log("inactive", eltsub);
  3224     <xsl:text>    console.log("inactive", eltsub);
  3222 </xsl:text>
  3225 </xsl:text>
  3223     <xsl:text>};
  3226     <xsl:text>};
  3224 </xsl:text>
  3227 </xsl:text>
  3225   </xsl:template>
  3228     <xsl:apply-templates select="document('')/*/epilogue:*"/>
  3226   <xsl:template mode="debug_as_comment" match="*[namespace-uri()='debug']">
       
  3227     <xsl:comment>
       
  3228       <xsl:value-of select="local-name()"/>
       
  3229       <xsl:text> :
       
  3230 </xsl:text>
       
  3231       <xsl:apply-templates mode="debug" select="."/>
       
  3232     </xsl:comment>
       
  3233   </xsl:template>
  3229   </xsl:template>
  3234   <xsl:template match="/">
  3230   <xsl:template match="/">
  3235     <xsl:comment>
  3231     <xsl:comment>
  3236       <xsl:text>Made with SVGHMI. https://beremiz.org</xsl:text>
  3232       <xsl:text>Made with SVGHMI. https://beremiz.org</xsl:text>
  3237     </xsl:comment>
  3233     </xsl:comment>
  3238     <xsl:apply-templates mode="debug_as_comment" select="document('')/*/debug:*"/>
  3234     <xsl:for-each select="document('')/*/debug:*">
       
  3235       <xsl:comment>
       
  3236         <xsl:value-of select="local-name()"/>
       
  3237         <xsl:text> :
       
  3238 </xsl:text>
       
  3239         <xsl:apply-templates select="."/>
       
  3240       </xsl:comment>
       
  3241     </xsl:for-each>
  3239     <html xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/1999/xhtml">
  3242     <html xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/1999/xhtml">
  3240       <head/>
  3243       <head/>
  3241       <body style="margin:0;overflow:hidden;">
  3244       <body style="margin:0;overflow:hidden;">
  3242         <xsl:copy-of select="$result_svg"/>
  3245         <xsl:copy-of select="$result_svg"/>
  3243         <script>
  3246         <script>