svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 2794 c10069a02ed0
parent 2793 2a97688c94c5
child 2795 c0cf62bb9aa7
equal deleted inserted replaced
2793:2a97688c94c5 2794:c10069a02ed0
     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: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: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: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="script"/>
     3   <xsl:output method="xml" cdata-section-elements="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="hmi_elements" select="//*[starts-with(@inkscape:label, 'HMI:')]"/>
       
     7   <xsl:variable name="hmi_geometry" select="$geometry[@Id = $hmi_elements/@id]"/>
       
     8   <xsl:variable name="hmi_pages" select="$hmi_elements[func:parselabel(@inkscape:label)/widget/@type = 'Page']"/>
     6   <xsl:variable name="_categories">
     9   <xsl:variable name="_categories">
     7     <noindex>
    10     <noindex>
     8       <xsl:text>HMI_ROOT</xsl:text>
    11       <xsl:text>HMI_ROOT</xsl:text>
     9     </noindex>
    12     </noindex>
    10     <noindex>
    13     <noindex>
    76   <xsl:template mode="identity_svg" match="@* | node()">
    79   <xsl:template mode="identity_svg" match="@* | node()">
    77     <xsl:copy>
    80     <xsl:copy>
    78       <xsl:apply-templates mode="identity_svg" select="@* | node()"/>
    81       <xsl:apply-templates mode="identity_svg" select="@* | node()"/>
    79     </xsl:copy>
    82     </xsl:copy>
    80   </xsl:template>
    83   </xsl:template>
    81   <xsl:variable name="mark">
       
    82     <xsl:text>=HMI=
       
    83 </xsl:text>
       
    84   </xsl:variable>
       
    85   <xsl:template match="/">
    84   <xsl:template match="/">
    86     <xsl:comment>
    85     <xsl:comment>
    87       <xsl:text>Made with SVGHMI. https://beremiz.org</xsl:text>
    86       <xsl:text>Made with SVGHMI. https://beremiz.org</xsl:text>
    88     </xsl:comment>
    87     </xsl:comment>
    89     <html xmlns="http://www.w3.org/1999/xhtml">
    88     <html xmlns="http://www.w3.org/1999/xhtml">
    90       <head/>
    89       <head/>
    91       <body style="margin:0;">
    90       <body style="margin:0;">
    92         <xsl:copy>
    91         <xsl:copy>
    93           <xsl:comment>
    92           <xsl:comment>
    94             <xsl:apply-templates mode="testgeo" select="$geometry"/>
    93             <xsl:apply-templates mode="testgeo" select="$hmi_geometry"/>
    95           </xsl:comment>
    94           </xsl:comment>
    96           <xsl:comment>
    95           <xsl:comment>
    97             <xsl:apply-templates mode="testtree" select="$hmitree"/>
    96             <xsl:apply-templates mode="testtree" select="$hmitree"/>
    98           </xsl:comment>
    97           </xsl:comment>
    99           <xsl:comment>
    98           <xsl:comment>
   136       <xsl:if test="$type">
   135       <xsl:if test="$type">
   137         <widget>
   136         <widget>
   138           <xsl:attribute name="type">
   137           <xsl:attribute name="type">
   139             <xsl:value-of select="$type"/>
   138             <xsl:value-of select="$type"/>
   140           </xsl:attribute>
   139           </xsl:attribute>
   141           <xsl:for-each select="str:split($args, ':')">
   140           <xsl:for-each select="str:split(substring-after($args, ':'), ':')">
   142             <arg>
   141             <arg>
   143               <xsl:attribute name="value">
   142               <xsl:attribute name="value">
   144                 <xsl:value-of select="."/>
   143                 <xsl:value-of select="."/>
   145               </xsl:attribute>
   144               </xsl:attribute>
   146             </arg>
   145             </arg>
   200 </xsl:text>
   199 </xsl:text>
   201     <xsl:text>
   200     <xsl:text>
   202 </xsl:text>
   201 </xsl:text>
   203     <xsl:text>var page_desc = {
   202     <xsl:text>var page_desc = {
   204 </xsl:text>
   203 </xsl:text>
   205     <xsl:for-each select="//*[func:parselabel(@inkscape:label)/widget/@type = 'Page']">
   204     <xsl:for-each select="$hmi_pages">
   206       <xsl:value-of select="@inkscape:label"/>
   205       <xsl:variable name="desc" select="func:parselabel(@inkscape:label)/widget"/>
   207       <xsl:text>
   206       <xsl:text>    "</xsl:text>
   208 </xsl:text>
   207       <xsl:value-of select="$desc/arg[1]/@value"/>
   209       <xsl:variable name="ast" select="func:parselabel(@inkscape:label)"/>
   208       <xsl:text>": {
   210       <xsl:apply-templates mode="testtree" select="$ast"/>
   209 </xsl:text>
       
   210       <xsl:text>        id: "</xsl:text>
       
   211       <xsl:value-of select="@id"/>
       
   212       <xsl:text>"
       
   213 </xsl:text>
       
   214       <xsl:text>        widgets: [
       
   215 </xsl:text>
       
   216       <xsl:variable name="page" select="."/>
       
   217       <xsl:variable name="p" select="$hmi_geometry[@Id = $page/@id]"/>
       
   218       <xsl:for-each select="$hmi_geometry[@Id != $page/@id and &#10;                       @x &gt;= $p/@x and @y &gt;= $p/@y and @w &lt;= $p/@w and @h &lt;= $p/@h]">
       
   219         <xsl:text>            "</xsl:text>
       
   220         <xsl:value-of select="@Id"/>
       
   221         <xsl:text>"</xsl:text>
       
   222         <xsl:if test="position()!=last()">
       
   223           <xsl:text>,</xsl:text>
       
   224         </xsl:if>
       
   225         <xsl:text>
       
   226 </xsl:text>
       
   227       </xsl:for-each>
       
   228       <xsl:text>        ]
       
   229 </xsl:text>
   211     </xsl:for-each>
   230     </xsl:for-each>
   212     <xsl:text>}
   231     <xsl:text>}
   213 </xsl:text>
   232 </xsl:text>
   214     <xsl:text>// svghmi.js
   233     <xsl:text>// svghmi.js
   215 </xsl:text>
   234 </xsl:text>