svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 2939 4296ab974d4d
parent 2938 1379cd5c69dd
child 2940 034b6ce4f885
equal deleted inserted replaced
2938:1379cd5c69dd 2939:4296ab974d4d
     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:reflect="reflect" 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 exsl regexp str dyn" version="1.0" exclude-result-prefixes="ns str regexp exsl func dyn reflect">
     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">
     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   <reflect:hmi-tree/>
   160   <debug:hmi-tree/>
   161   <xsl:template mode="testtree" match="*">
   161   <xsl:template mode="testtree" match="*">
   162     <xsl:param name="indent" select="''"/>
   162     <xsl:param name="indent" select="''"/>
   163     <xsl:value-of select="$indent"/>
   163     <xsl:value-of select="$indent"/>
   164     <xsl:text> </xsl:text>
   164     <xsl:text> </xsl:text>
   165     <xsl:value-of select="local-name()"/>
   165     <xsl:value-of select="local-name()"/>
   176       <xsl:with-param name="indent">
   176       <xsl:with-param name="indent">
   177         <xsl:value-of select="concat($indent,'&gt;')"/>
   177         <xsl:value-of select="concat($indent,'&gt;')"/>
   178       </xsl:with-param>
   178       </xsl:with-param>
   179     </xsl:apply-templates>
   179     </xsl:apply-templates>
   180   </xsl:template>
   180   </xsl:template>
   181   <xsl:template mode="debug" match="reflect:hmi-tree">
   181   <xsl:template mode="debug" 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>
   193 </xsl:text>
   193 </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   <reflect:geometry/>
   198   <debug:geometry/>
   199   <xsl:template mode="debug" match="reflect:geometry">
   199   <xsl:template mode="debug" 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"/>
   458     </xsl:if>
   458     </xsl:if>
   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   <reflect:detachable-pages/>
   463   <debug:detachable-pages/>
   464   <xsl:template mode="debug" match="reflect:detachable-pages">
   464   <xsl:template mode="debug" 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"/>
   588   </xsl:template>
   588   </xsl:template>
   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   <reflect:inline-svg/>
   593   <debug:inline-svg/>
   594   <xsl:template mode="debug" match="reflect:inline-svg">
   594   <xsl:template mode="debug" 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>
  2077 </xsl:text>
  2077 </xsl:text>
  2078     <xsl:text>id = idstr =&gt; document.getElementById(idstr);
  2078     <xsl:text>id = idstr =&gt; document.getElementById(idstr);
  2079 </xsl:text>
  2079 </xsl:text>
  2080     <xsl:text>
  2080     <xsl:text>
  2081 </xsl:text>
  2081 </xsl:text>
       
  2082     <xsl:apply-templates select="document('')/*/jspreamble"/>
  2082     <xsl:text>var hmi_hash = [</xsl:text>
  2083     <xsl:text>var hmi_hash = [</xsl:text>
  2083     <xsl:value-of select="$hmitree/@hash"/>
  2084     <xsl:value-of select="$hmitree/@hash"/>
  2084     <xsl:text>];
  2085     <xsl:text>];
  2085 </xsl:text>
  2086 </xsl:text>
  2086     <xsl:text>var hmi_widgets = {
  2087     <xsl:text>var hmi_widgets = {
  3220     <xsl:text>    console.log("inactive", eltsub);
  3221     <xsl:text>    console.log("inactive", eltsub);
  3221 </xsl:text>
  3222 </xsl:text>
  3222     <xsl:text>};
  3223     <xsl:text>};
  3223 </xsl:text>
  3224 </xsl:text>
  3224   </xsl:template>
  3225   </xsl:template>
  3225   <xsl:template mode="debug_as_comment" match="*[namespace-uri()='reflect']">
  3226   <xsl:template mode="debug_as_comment" match="*[namespace-uri()='debug']">
  3226     <xsl:comment>
  3227     <xsl:comment>
  3227       <xsl:value-of select="local-name()"/>
  3228       <xsl:value-of select="local-name()"/>
  3228       <xsl:text> :
  3229       <xsl:text> :
  3229 </xsl:text>
  3230 </xsl:text>
  3230       <xsl:apply-templates mode="debug" select="."/>
  3231       <xsl:apply-templates mode="debug" select="."/>
  3232   </xsl:template>
  3233   </xsl:template>
  3233   <xsl:template match="/">
  3234   <xsl:template match="/">
  3234     <xsl:comment>
  3235     <xsl:comment>
  3235       <xsl:text>Made with SVGHMI. https://beremiz.org</xsl:text>
  3236       <xsl:text>Made with SVGHMI. https://beremiz.org</xsl:text>
  3236     </xsl:comment>
  3237     </xsl:comment>
       
  3238     <xsl:apply-templates mode="debug_as_comment" select="document('')/*/debug:*"/>
  3237     <html xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/1999/xhtml">
  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">
  3238       <head/>
  3240       <head/>
  3239       <body style="margin:0;overflow:hidden;">
  3241       <body style="margin:0;overflow:hidden;">
  3240         <xsl:copy-of select="$result_svg"/>
  3242         <xsl:copy-of select="$result_svg"/>
  3241         <script>
  3243         <script>