svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 2846 7b1db17287b6
parent 2845 61548f7d1bef
child 2847 dffade5c83d3
equal deleted inserted replaced
2845:61548f7d1bef 2846:7b1db17287b6
    98       <xsl:otherwise>
    98       <xsl:otherwise>
    99         <func:result select="0"/>
    99         <func:result select="0"/>
   100       </xsl:otherwise>
   100       </xsl:otherwise>
   101     </xsl:choose>
   101     </xsl:choose>
   102   </func:function>
   102   </func:function>
       
   103   <xsl:variable name="groups" select="/svg:svg | //svg:g"/>
   103   <func:function name="func:overlapping_geometry">
   104   <func:function name="func:overlapping_geometry">
   104     <xsl:param name="elt"/>
   105     <xsl:param name="elt"/>
   105     <xsl:variable name="g" select="$geometry[@Id = $elt/@id]"/>
   106     <xsl:variable name="g" select="$geometry[@Id = $elt/@id]"/>
   106     <xsl:variable name="candidates" select="$geometry[@Id != $elt/@id]"/>
   107     <xsl:variable name="candidates" select="$geometry[@Id != $elt/@id]"/>
   107     <func:result select="$candidates[func:intersect($g, .) = 9]"/>
   108     <func:result select="$candidates[(@Id = $groups/@id and (func:intersect($g, .) = 9)) or &#10;                              (not(@Id = $groups/@id) and (func:intersect($g, .) &gt; 0 ))]"/>
   108   </func:function>
       
   109   <func:function name="func:sumarized_elements">
       
   110     <xsl:param name="elements"/>
       
   111     <xsl:variable name="short_list" select="$elements[not(ancestor::*/@id = $elements/@id)]"/>
       
   112     <xsl:variable name="filled_groups" select="$short_list/parent::svg:*[not(descendant::*[not(self::svg:g)][not(@id = $short_list/descendant-or-self::*[not(self::svg:g)]/@id)])]"/>
       
   113     <xsl:variable name="groups_to_add" select="$filled_groups[not(ancestor::*/@id = $filled_groups/@id)]"/>
       
   114     <func:result select="$groups_to_add | $short_list[not(ancestor::svg:g/@id = $filled_groups/@id)]"/>
       
   115   </func:function>
   109   </func:function>
   116   <func:function name="func:all_related_elements">
   110   <func:function name="func:all_related_elements">
   117     <xsl:param name="page"/>
   111     <xsl:param name="page"/>
   118     <xsl:variable name="page_overlapping_geometry" select="func:overlapping_geometry($page)"/>
   112     <xsl:variable name="page_overlapping_geometry" select="func:overlapping_geometry($page)"/>
   119     <xsl:variable name="page_overlapping_elements" select="//svg:*[@id = $page_overlapping_geometry/@Id]"/>
   113     <xsl:variable name="page_overlapping_elements" select="//svg:*[@id = $page_overlapping_geometry/@Id]"/>
   120     <xsl:variable name="page_sub_elements" select="func:refered_elements($page | $page_overlapping_elements)"/>
   114     <xsl:variable name="page_sub_elements" select="func:refered_elements($page | $page_overlapping_elements)"/>
   121     <func:result select="$page_sub_elements"/>
   115     <func:result select="$page_sub_elements"/>
       
   116   </func:function>
       
   117   <func:function name="func:required_elements">
       
   118     <xsl:param name="pages"/>
       
   119     <xsl:choose>
       
   120       <xsl:when test="$pages">
       
   121         <func:result select="func:all_related_elements($pages[1])&#10;                          | func:required_elements($pages[position()!=1])"/>
       
   122       </xsl:when>
       
   123       <xsl:otherwise>
       
   124         <func:result select="/.."/>
       
   125       </xsl:otherwise>
       
   126     </xsl:choose>
       
   127   </func:function>
       
   128   <xsl:variable name="required_elements" select="//svg:defs/descendant-or-self::svg:*&#10;           | func:required_elements($hmi_pages)/ancestor-or-self::svg:*"/>
       
   129   <xsl:variable name="discardable_elements" select="//svg:*[not(@id = $required_elements/@id)]"/>
       
   130   <func:function name="func:sumarized_elements">
       
   131     <xsl:param name="elements"/>
       
   132     <xsl:variable name="short_list" select="$elements[not(ancestor::*/@id = $elements/@id)]"/>
       
   133     <xsl:variable name="filled_groups" select="$short_list/parent::svg:*[&#10;            not(descendant::*[&#10;                not(self::svg:g) and &#10;                not(@id = $discardable_elements/@id) and&#10;                not(@id = $short_list/descendant-or-self::*[not(self::svg:g)]/@id)&#10;            ])]"/>
       
   134     <xsl:variable name="groups_to_add" select="$filled_groups[not(ancestor::*/@id = $filled_groups/@id)]"/>
       
   135     <func:result select="$groups_to_add | $short_list[not(ancestor::svg:g/@id = $filled_groups/@id)]"/>
   122   </func:function>
   136   </func:function>
   123   <func:function name="func:detachable_elements">
   137   <func:function name="func:detachable_elements">
   124     <xsl:param name="pages"/>
   138     <xsl:param name="pages"/>
   125     <xsl:choose>
   139     <xsl:choose>
   126       <xsl:when test="$pages">
   140       <xsl:when test="$pages">
   130         <func:result select="/.."/>
   144         <func:result select="/.."/>
   131       </xsl:otherwise>
   145       </xsl:otherwise>
   132     </xsl:choose>
   146     </xsl:choose>
   133   </func:function>
   147   </func:function>
   134   <xsl:variable name="detachable_elements" select="func:detachable_elements($hmi_pages)"/>
   148   <xsl:variable name="detachable_elements" select="func:detachable_elements($hmi_pages)"/>
   135   <xsl:variable name="essential_elements" select="$detachable_elements | /svg:svg/svg:defs"/>
       
   136   <xsl:variable name="required_elements" select="$essential_elements//svg:* | $essential_elements/ancestor-or-self::svg:*"/>
       
   137   <xsl:variable name="discardable_elements" select="//svg:*[not(@id = $required_elements/@id)]"/>
       
   138   <xsl:template mode="index" match="*">
   149   <xsl:template mode="index" match="*">
   139     <xsl:param name="index" select="0"/>
   150     <xsl:param name="index" select="0"/>
   140     <xsl:param name="parentpath" select="''"/>
   151     <xsl:param name="parentpath" select="''"/>
   141     <xsl:variable name="content">
   152     <xsl:variable name="content">
   142       <xsl:variable name="path">
   153       <xsl:variable name="path">
   182         <xsl:value-of select="$parentpath"/>
   193         <xsl:value-of select="$parentpath"/>
   183       </xsl:with-param>
   194       </xsl:with-param>
   184     </xsl:apply-templates>
   195     </xsl:apply-templates>
   185   </xsl:template>
   196   </xsl:template>
   186   <xsl:template mode="inline_svg" match="@* | node()">
   197   <xsl:template mode="inline_svg" match="@* | node()">
   187     <xsl:copy>
   198     <xsl:if test="not(@id = $discardable_elements/@id)">
   188       <xsl:apply-templates mode="inline_svg" select="@* | node()"/>
   199       <xsl:copy>
   189     </xsl:copy>
   200         <xsl:apply-templates mode="inline_svg" select="@* | node()"/>
       
   201       </xsl:copy>
       
   202     </xsl:if>
   190   </xsl:template>
   203   </xsl:template>
   191   <xsl:template mode="inline_svg" match="svg:svg/@width"/>
   204   <xsl:template mode="inline_svg" match="svg:svg/@width"/>
   192   <xsl:template mode="inline_svg" match="svg:svg/@height"/>
   205   <xsl:template mode="inline_svg" match="svg:svg/@height"/>
   193   <xsl:template xmlns="http://www.w3.org/2000/svg" mode="inline_svg" match="svg:svg">
   206   <xsl:template xmlns="http://www.w3.org/2000/svg" mode="inline_svg" match="svg:svg">
   194     <svg>
   207     <svg>