svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 2791 d022523cb621
parent 2790 8fab1886ebec
child 2792 0c0d3895b036
equal deleted inserted replaced
2790:8fab1886ebec 2791:d022523cb621
    19     <noindex>
    19     <noindex>
    20       <xsl:text>HMI_CURRENT_PAGE</xsl:text>
    20       <xsl:text>HMI_CURRENT_PAGE</xsl:text>
    21     </noindex>
    21     </noindex>
    22   </xsl:variable>
    22   </xsl:variable>
    23   <xsl:variable name="categories" select="exsl:node-set($_categories)"/>
    23   <xsl:variable name="categories" select="exsl:node-set($_categories)"/>
    24   <xsl:variable name="indexed_hmitree">
    24   <xsl:variable name="_indexed_hmitree">
    25     <xsl:apply-templates mode="index" select="$hmitree"/>
    25     <xsl:apply-templates mode="index" select="$hmitree"/>
    26   </xsl:variable>
    26   </xsl:variable>
    27   <xsl:template mode="index" match="node()">
    27   <xsl:variable name="indexed_hmitree" select="exsl:node-set($_indexed_hmitree)"/>
       
    28   <xsl:template mode="index" match="*">
    28     <xsl:param name="index" select="0"/>
    29     <xsl:param name="index" select="0"/>
       
    30     <xsl:param name="parentpath" select="''"/>
    29     <xsl:variable name="content">
    31     <xsl:variable name="content">
       
    32       <xsl:variable name="path">
       
    33         <xsl:choose>
       
    34           <xsl:when test="local-name() = 'HMI_ROOT'">
       
    35             <xsl:value-of select="$parentpath"/>
       
    36           </xsl:when>
       
    37           <xsl:otherwise>
       
    38             <xsl:value-of select="$parentpath"/>
       
    39             <xsl:text>/</xsl:text>
       
    40             <xsl:value-of select="@name"/>
       
    41           </xsl:otherwise>
       
    42         </xsl:choose>
       
    43       </xsl:variable>
    30       <xsl:choose>
    44       <xsl:choose>
    31         <xsl:when test="not(local-name() = $categories/noindex)">
    45         <xsl:when test="not(local-name() = $categories/noindex)">
    32           <xsl:copy>
    46           <xsl:copy>
    33             <xsl:attribute name="index">
    47             <xsl:attribute name="index">
    34               <xsl:value-of select="$index"/>
    48               <xsl:value-of select="$index"/>
       
    49             </xsl:attribute>
       
    50             <xsl:attribute name="hmipath">
       
    51               <xsl:value-of select="$path"/>
    35             </xsl:attribute>
    52             </xsl:attribute>
    36             <xsl:for-each select="@*">
    53             <xsl:for-each select="@*">
    37               <xsl:copy/>
    54               <xsl:copy/>
    38             </xsl:for-each>
    55             </xsl:for-each>
    39           </xsl:copy>
    56           </xsl:copy>
    40         </xsl:when>
    57         </xsl:when>
    41         <xsl:otherwise>
    58         <xsl:otherwise>
    42           <xsl:apply-templates mode="index" select="*[1]">
    59           <xsl:apply-templates mode="index" select="*[1]">
    43             <xsl:with-param name="index" select="$index"/>
    60             <xsl:with-param name="index" select="$index"/>
       
    61             <xsl:with-param name="parentpath">
       
    62               <xsl:value-of select="$path"/>
       
    63             </xsl:with-param>
    44           </xsl:apply-templates>
    64           </xsl:apply-templates>
    45         </xsl:otherwise>
    65         </xsl:otherwise>
    46       </xsl:choose>
    66       </xsl:choose>
    47     </xsl:variable>
    67     </xsl:variable>
    48     <xsl:copy-of select="$content"/>
    68     <xsl:copy-of select="$content"/>
    49     <xsl:apply-templates mode="index" select="following-sibling::*[1]">
    69     <xsl:apply-templates mode="index" select="following-sibling::*[1]">
    50       <xsl:with-param name="index" select="$index + count(exsl:node-set($content)/*)"/>
    70       <xsl:with-param name="index" select="$index + count(exsl:node-set($content)/*)"/>
       
    71       <xsl:with-param name="parentpath">
       
    72         <xsl:value-of select="$parentpath"/>
       
    73       </xsl:with-param>
    51     </xsl:apply-templates>
    74     </xsl:apply-templates>
    52   </xsl:template>
    75   </xsl:template>
    53   <xsl:template match="@* | node()">
    76   <xsl:template mode="identity_svg" match="@* | node()">
    54     <xsl:copy>
    77     <xsl:copy>
    55       <xsl:apply-templates select="@* | node()"/>
    78       <xsl:apply-templates mode="identity_svg" select="@* | node()"/>
    56     </xsl:copy>
    79     </xsl:copy>
    57   </xsl:template>
    80   </xsl:template>
    58   <xsl:variable name="mark">
    81   <xsl:variable name="mark">
    59     <xsl:text>=HMI=
    82     <xsl:text>=HMI=
    60 </xsl:text>
    83 </xsl:text>
    69           </xsl:comment>
    92           </xsl:comment>
    70           <xsl:comment>
    93           <xsl:comment>
    71             <xsl:apply-templates mode="testtree" select="$hmitree"/>
    94             <xsl:apply-templates mode="testtree" select="$hmitree"/>
    72           </xsl:comment>
    95           </xsl:comment>
    73           <xsl:comment>
    96           <xsl:comment>
    74             <xsl:apply-templates mode="testtree" select="exsl:node-set($indexed_hmitree)"/>
    97             <xsl:apply-templates mode="testtree" select="$indexed_hmitree"/>
    75           </xsl:comment>
    98           </xsl:comment>
    76           <xsl:apply-templates select="@* | node()"/>
    99           <xsl:apply-templates mode="identity_svg" select="@* | node()"/>
    77         </xsl:copy>
   100         </xsl:copy>
    78         <script>
   101         <script>
    79           <xsl:text>var subscriptions = {
   102           <xsl:text>var subscriptions = {
    80 </xsl:text>
   103 </xsl:text>
    81           <xsl:text>    return res;
   104           <xsl:variable name="svg" select="/"/>
    82 </xsl:text>
   105           <xsl:for-each select="$indexed_hmitree/*">
       
   106             <xsl:value-of select="@index"/>
       
   107             <xsl:text>: {
       
   108 </xsl:text>
       
   109             <xsl:text>    name: "</xsl:text>
       
   110             <xsl:value-of select="@name"/>
       
   111             <xsl:text>",
       
   112 </xsl:text>
       
   113             <xsl:text>    hmipath: "</xsl:text>
       
   114             <xsl:value-of select="@hmipath"/>
       
   115             <xsl:text>"
       
   116 </xsl:text>
       
   117             <xsl:text>    ids: [
       
   118 </xsl:text>
       
   119             <xsl:variable name="hmipath" select="@hmipath"/>
       
   120             <xsl:for-each select="$svg//*[substring-after(@inkscape:label,'@') = $hmipath]">
       
   121               <xsl:text>        "</xsl:text>
       
   122               <xsl:value-of select="@id"/>
       
   123               <xsl:text>"</xsl:text>
       
   124               <xsl:if test="position()!=last()">
       
   125                 <xsl:text>,</xsl:text>
       
   126               </xsl:if>
       
   127               <xsl:text>
       
   128 </xsl:text>
       
   129             </xsl:for-each>
       
   130             <xsl:text>    ]
       
   131 </xsl:text>
       
   132             <xsl:text>}</xsl:text>
       
   133             <xsl:if test="position()!=last()">
       
   134               <xsl:text>,</xsl:text>
       
   135             </xsl:if>
       
   136             <xsl:text>
       
   137 </xsl:text>
       
   138           </xsl:for-each>
    83           <xsl:text>}
   139           <xsl:text>}
    84 </xsl:text>
   140 </xsl:text>
    85           <xsl:text>// svghmi.js
   141           <xsl:text>// svghmi.js
    86 </xsl:text>
   142 </xsl:text>
    87           <xsl:text>
   143           <xsl:text>