svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 3124 f263359d8108
parent 3118 e704b0487515
child 3128 32a4675af377
equal deleted inserted replaced
3123:f8cba959553f 3124:f263359d8108
     1 <?xml version="1.0"?>
     1 <?xml version="1.0"?>
     2 <xsl:stylesheet xmlns:ns="beremiz" xmlns:definitions="definitions" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:func="http://exslt.org/functions" xmlns:epilogue="epilogue" xmlns:preamble="preamble" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:svg="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:str="http://exslt.org/strings" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:exsl="http://exslt.org/common" xmlns:declarations="declarations" xmlns:debug="debug" exclude-result-prefixes="ns func exsl regexp str dyn debug preamble epilogue declarations definitions" extension-element-prefixes="ns func exsl regexp str dyn" version="1.0">
     2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:str="http://exslt.org/strings" xmlns:func="http://exslt.org/functions" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:debug="debug" xmlns:preamble="preamble" xmlns:declarations="declarations" xmlns:definitions="definitions" xmlns:epilogue="epilogue" xmlns:ns="beremiz" version="1.0" extension-element-prefixes="ns func exsl regexp str dyn" exclude-result-prefixes="ns func exsl regexp str dyn debug preamble epilogue declarations definitions">
     3   <xsl:output method="xml" cdata-section-elements="xhtml:script"/>
     3   <xsl:output cdata-section-elements="xhtml:script" method="xml"/>
     4   <xsl:variable name="svg" select="/svg:svg"/>
     4   <xsl:variable name="svg" select="/svg:svg"/>
     5   <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/>
     5   <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/>
     6   <xsl:variable name="hmitree" select="ns:GetHMITree()"/>
     6   <xsl:variable name="hmitree" select="ns:GetHMITree()"/>
     7   <xsl:variable name="_categories">
     7   <xsl:variable name="_categories">
     8     <noindex>
     8     <noindex>
   508 </xsl:text>
   508 </xsl:text>
   509     <xsl:text>
   509     <xsl:text>
   510 </xsl:text>
   510 </xsl:text>
   511   </xsl:template>
   511   </xsl:template>
   512   <xsl:variable name="forEach_widgets_ids" select="$parsed_widgets/widget[@type = 'ForEach']/@id"/>
   512   <xsl:variable name="forEach_widgets_ids" select="$parsed_widgets/widget[@type = 'ForEach']/@id"/>
   513   <xsl:variable name="forEach_widgets" select="$hmi_elements[@id = $forEach_widgets_ids]"/>
   513   <xsl:variable name="forEach_widgets" select="$hmi_widgets[@id = $forEach_widgets_ids]"/>
   514   <xsl:variable name="in_forEach_widget_ids" select="func:refered_elements($forEach_widgets)[not(@id = $forEach_widgets_ids)]/@id"/>
   514   <xsl:variable name="in_forEach_widget_ids" select="func:refered_elements($forEach_widgets)[not(@id = $forEach_widgets_ids)]/@id"/>
   515   <xsl:template mode="page_desc" match="svg:*">
   515   <xsl:template mode="page_desc" match="svg:*">
   516     <xsl:if test="ancestor::*[@id = $hmi_pages/@id]">
   516     <xsl:if test="ancestor::*[@id = $hmi_pages/@id]">
   517       <xsl:message terminate="yes">
   517       <xsl:message terminate="yes">
   518         <xsl:text>HMI:Page </xsl:text>
   518         <xsl:text>HMI:Page </xsl:text>
   522     </xsl:if>
   522     </xsl:if>
   523     <xsl:variable name="desc" select="func:widget(@id)"/>
   523     <xsl:variable name="desc" select="func:widget(@id)"/>
   524     <xsl:variable name="page" select="."/>
   524     <xsl:variable name="page" select="."/>
   525     <xsl:variable name="p" select="$geometry[@Id = $page/@id]"/>
   525     <xsl:variable name="p" select="$geometry[@Id = $page/@id]"/>
   526     <xsl:variable name="page_all_elements" select="func:all_related_elements($page)"/>
   526     <xsl:variable name="page_all_elements" select="func:all_related_elements($page)"/>
   527     <xsl:variable name="all_page_widgets" select="$hmi_elements[@id = $page_all_elements/@id and @id != $page/@id]"/>
   527     <xsl:variable name="all_page_widgets" select="$hmi_widgets[@id = $page_all_elements/@id and @id != $page/@id]"/>
   528     <xsl:variable name="page_managed_widgets" select="$all_page_widgets[not(@id=$in_forEach_widget_ids)]"/>
   528     <xsl:variable name="page_managed_widgets" select="$all_page_widgets[not(@id=$in_forEach_widget_ids)]"/>
   529     <xsl:variable name="page_relative_widgets" select="$page_managed_widgets[func:is_descendant_path(func:widget(@id)/path/@value, $desc/path/@value)]"/>
   529     <xsl:variable name="page_relative_widgets" select="$page_managed_widgets[func:is_descendant_path(func:widget(@id)/path/@value, $desc/path/@value)]"/>
   530     <xsl:variable name="required_detachables" select="func:sumarized_elements($page_all_elements)/&#10;           ancestor-or-self::*[@id = $detachable_elements/@id]"/>
   530     <xsl:variable name="required_detachables" select="func:sumarized_elements($page_all_elements)/&#10;           ancestor-or-self::*[@id = $detachable_elements/@id]"/>
   531     <xsl:text>  "</xsl:text>
   531     <xsl:text>  "</xsl:text>
   532     <xsl:value-of select="$desc/arg[1]/@value"/>
   532     <xsl:value-of select="$desc/arg[1]/@value"/>
  1108       <xsl:text>,</xsl:text>
  1108       <xsl:text>,</xsl:text>
  1109     </xsl:if>
  1109     </xsl:if>
  1110     <xsl:text>
  1110     <xsl:text>
  1111 </xsl:text>
  1111 </xsl:text>
  1112   </xsl:template>
  1112   </xsl:template>
  1113   <func:function name="func:unique_types">
       
  1114     <xsl:param name="elts_with_type"/>
       
  1115     <xsl:choose>
       
  1116       <xsl:when test="count($elts_with_type) &gt; 1">
       
  1117         <xsl:variable name="prior_results" select="func:unique_types($elts_with_type[position()!=last()])"/>
       
  1118         <xsl:choose>
       
  1119           <xsl:when test="$elts_with_type[last()][@type = $prior_results/@type]">
       
  1120             <func:result select="$prior_results"/>
       
  1121           </xsl:when>
       
  1122           <xsl:otherwise>
       
  1123             <func:result select="$prior_results | $elts_with_type[last()]"/>
       
  1124           </xsl:otherwise>
       
  1125         </xsl:choose>
       
  1126       </xsl:when>
       
  1127       <xsl:otherwise>
       
  1128         <func:result select="$elts_with_type"/>
       
  1129       </xsl:otherwise>
       
  1130     </xsl:choose>
       
  1131   </func:function>
       
  1132   <preamble:local-variable-indexes/>
  1113   <preamble:local-variable-indexes/>
  1133   <xsl:template match="preamble:local-variable-indexes">
  1114   <xsl:template match="preamble:local-variable-indexes">
  1134     <xsl:text>
  1115     <xsl:text>
  1135 </xsl:text>
  1116 </xsl:text>
  1136     <xsl:text>/* </xsl:text>
  1117     <xsl:text>/* </xsl:text>
  1528     <xsl:text>}
  1509     <xsl:text>}
  1529 </xsl:text>
  1510 </xsl:text>
  1530     <xsl:text>
  1511     <xsl:text>
  1531 </xsl:text>
  1512 </xsl:text>
  1532   </xsl:template>
  1513   </xsl:template>
       
  1514   <xsl:variable name="excluded_types" select="str:split('Page VarInit')"/>
       
  1515   <xsl:key name="TypesKey" match="widget" use="@type"/>
  1533   <declarations:hmi-classes/>
  1516   <declarations:hmi-classes/>
  1534   <xsl:template match="declarations:hmi-classes">
  1517   <xsl:template match="declarations:hmi-classes">
  1535     <xsl:text>
  1518     <xsl:text>
  1536 </xsl:text>
  1519 </xsl:text>
  1537     <xsl:text>/* </xsl:text>
  1520     <xsl:text>/* </xsl:text>
  1538     <xsl:value-of select="local-name()"/>
  1521     <xsl:value-of select="local-name()"/>
  1539     <xsl:text> */
  1522     <xsl:text> */
  1540 </xsl:text>
  1523 </xsl:text>
  1541     <xsl:text>
  1524     <xsl:text>
  1542 </xsl:text>
  1525 </xsl:text>
  1543     <xsl:variable name="used_widget_types" select="func:unique_types($parsed_widgets/widget)"/>
  1526     <xsl:variable name="used_widget_types" select="$parsed_widgets/widget[&#10;                                    generate-id() = generate-id(key('TypesKey', @type)) and &#10;                                    not(@type = $excluded_types)]"/>
  1544     <xsl:apply-templates mode="widget_class" select="$used_widget_types"/>
  1527     <xsl:apply-templates mode="widget_class" select="$used_widget_types"/>
  1545     <xsl:text>
  1528     <xsl:text>
  1546 </xsl:text>
  1529 </xsl:text>
  1547   </xsl:template>
  1530   </xsl:template>
  1548   <xsl:template mode="widget_class" match="widget">
  1531   <xsl:template mode="widget_class" match="widget">
  1555     <xsl:text> widget didn't provide any */
  1538     <xsl:text> widget didn't provide any */
  1556 </xsl:text>
  1539 </xsl:text>
  1557     <xsl:text>}
  1540     <xsl:text>}
  1558 </xsl:text>
  1541 </xsl:text>
  1559   </xsl:template>
  1542   </xsl:template>
  1560   <xsl:variable name="excluded_types" select="str:split('Page Lang VarInit')"/>
       
  1561   <xsl:variable name="included_ids" select="$parsed_widgets/widget[not(@type = $excluded_types) and not(@id = $discardable_elements/@id)]/@id"/>
  1543   <xsl:variable name="included_ids" select="$parsed_widgets/widget[not(@type = $excluded_types) and not(@id = $discardable_elements/@id)]/@id"/>
       
  1544   <xsl:variable name="hmi_widgets" select="$hmi_elements[@id = $included_ids]"/>
  1562   <declarations:hmi-elements/>
  1545   <declarations:hmi-elements/>
  1563   <xsl:template match="declarations:hmi-elements">
  1546   <xsl:template match="declarations:hmi-elements">
  1564     <xsl:text>
  1547     <xsl:text>
  1565 </xsl:text>
  1548 </xsl:text>
  1566     <xsl:text>/* </xsl:text>
  1549     <xsl:text>/* </xsl:text>
  1569 </xsl:text>
  1552 </xsl:text>
  1570     <xsl:text>
  1553     <xsl:text>
  1571 </xsl:text>
  1554 </xsl:text>
  1572     <xsl:text>var hmi_widgets = {
  1555     <xsl:text>var hmi_widgets = {
  1573 </xsl:text>
  1556 </xsl:text>
  1574     <xsl:apply-templates mode="hmi_widgets" select="$hmi_elements[@id = $included_ids]"/>
  1557     <xsl:apply-templates mode="hmi_widgets" select="$hmi_widgets"/>
  1575     <xsl:text>}
  1558     <xsl:text>}
  1576 </xsl:text>
  1559 </xsl:text>
  1577     <xsl:text>
  1560     <xsl:text>
  1578 </xsl:text>
  1561 </xsl:text>
  1579   </xsl:template>
  1562   </xsl:template>
  6300       <xsl:text>Made with SVGHMI. https://beremiz.org</xsl:text>
  6283       <xsl:text>Made with SVGHMI. https://beremiz.org</xsl:text>
  6301     </xsl:comment>
  6284     </xsl:comment>
  6302     <xsl:comment>
  6285     <xsl:comment>
  6303       <xsl:apply-templates select="document('')/*/debug:*"/>
  6286       <xsl:apply-templates select="document('')/*/debug:*"/>
  6304     </xsl:comment>
  6287     </xsl:comment>
  6305     <html xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/1999/xhtml">
  6288     <html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  6306       <head/>
  6289       <head/>
  6307       <body style="margin:0;overflow:hidden;user-select:none;touch-action:none;">
  6290       <body style="margin:0;overflow:hidden;user-select:none;touch-action:none;">
  6308         <xsl:copy-of select="$result_svg"/>
  6291         <xsl:copy-of select="$result_svg"/>
  6309         <script>
  6292         <script>
  6310           <xsl:text>
  6293           <xsl:text>