svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 2875 6a12e1084deb
parent 2874 b67af0b8dc72
child 2876 d2adbc273125
equal deleted inserted replaced
2874:b67af0b8dc72 2875:6a12e1084deb
    35     <noindex>
    35     <noindex>
    36       <xsl:text>HMI_CURRENT_PAGE</xsl:text>
    36       <xsl:text>HMI_CURRENT_PAGE</xsl:text>
    37     </noindex>
    37     </noindex>
    38   </xsl:variable>
    38   </xsl:variable>
    39   <xsl:variable name="categories" select="exsl:node-set($_categories)"/>
    39   <xsl:variable name="categories" select="exsl:node-set($_categories)"/>
    40   <func:function name="func:refered_elements">
       
    41     <xsl:param name="elems"/>
       
    42     <xsl:variable name="descend" select="$elems/descendant-or-self::svg:*"/>
       
    43     <xsl:variable name="clones" select="$descend[self::svg:use]"/>
       
    44     <xsl:variable name="originals" select="//svg:*[concat('#',@id) = $clones/@xlink:href]"/>
       
    45     <xsl:choose>
       
    46       <xsl:when test="$originals">
       
    47         <func:result select="$descend | func:refered_elements($originals)"/>
       
    48       </xsl:when>
       
    49       <xsl:otherwise>
       
    50         <func:result select="$descend"/>
       
    51       </xsl:otherwise>
       
    52     </xsl:choose>
       
    53   </func:function>
       
    54   <xsl:variable name="geometry" select="ns:GetSVGGeometry()"/>
    40   <xsl:variable name="geometry" select="ns:GetSVGGeometry()"/>
    55   <xsl:template name="debug_geometry">
    41   <xsl:template name="debug_geometry">
    56     <xsl:text>GEOMETRY : ID, x, y, w, h
    42     <xsl:text>ID, x, y, w, h
    57 </xsl:text>
    43 </xsl:text>
    58     <xsl:for-each select="$geometry[@Id = $hmi_elements/@id]">
    44     <xsl:for-each select="$geometry[@Id = $hmi_elements/@id]">
    59       <xsl:text> </xsl:text>
    45       <xsl:text> </xsl:text>
    60       <xsl:value-of select="@Id"/>
    46       <xsl:value-of select="@Id"/>
    61       <xsl:text> </xsl:text>
    47       <xsl:text> </xsl:text>
   114     <xsl:variable name="groups" select="/svg:svg | //svg:g"/>
   100     <xsl:variable name="groups" select="/svg:svg | //svg:g"/>
   115     <xsl:variable name="g" select="$geometry[@Id = $elt/@id]"/>
   101     <xsl:variable name="g" select="$geometry[@Id = $elt/@id]"/>
   116     <xsl:variable name="candidates" select="$geometry[@Id != $elt/@id]"/>
   102     <xsl:variable name="candidates" select="$geometry[@Id != $elt/@id]"/>
   117     <func:result select="$candidates[(@Id = $groups/@id and (func:intersect($g, .) = 9)) or &#10;                          (not(@Id = $groups/@id) and (func:intersect($g, .) &gt; 0 ))]"/>
   103     <func:result select="$candidates[(@Id = $groups/@id and (func:intersect($g, .) = 9)) or &#10;                          (not(@Id = $groups/@id) and (func:intersect($g, .) &gt; 0 ))]"/>
   118   </func:function>
   104   </func:function>
       
   105   <func:function name="func:refered_elements">
       
   106     <xsl:param name="elems"/>
       
   107     <xsl:variable name="descend" select="$elems/descendant-or-self::svg:*"/>
       
   108     <xsl:variable name="clones" select="$descend[self::svg:use]"/>
       
   109     <xsl:variable name="originals" select="//svg:*[concat('#',@id) = $clones/@xlink:href]"/>
       
   110     <xsl:choose>
       
   111       <xsl:when test="$originals">
       
   112         <func:result select="$descend | func:refered_elements($originals)"/>
       
   113       </xsl:when>
       
   114       <xsl:otherwise>
       
   115         <func:result select="$descend"/>
       
   116       </xsl:otherwise>
       
   117     </xsl:choose>
       
   118   </func:function>
   119   <func:function name="func:all_related_elements">
   119   <func:function name="func:all_related_elements">
   120     <xsl:param name="page"/>
   120     <xsl:param name="page"/>
   121     <xsl:variable name="page_overlapping_geometry" select="func:overlapping_geometry($page)"/>
   121     <xsl:variable name="page_overlapping_geometry" select="func:overlapping_geometry($page)"/>
   122     <xsl:variable name="page_overlapping_elements" select="//svg:*[@id = $page_overlapping_geometry/@Id]"/>
   122     <xsl:variable name="page_overlapping_elements" select="//svg:*[@id = $page_overlapping_geometry/@Id]"/>
   123     <xsl:variable name="page_sub_elements" select="func:refered_elements($page | $page_overlapping_elements)"/>
   123     <xsl:variable name="page_sub_elements" select="func:refered_elements($page | $page_overlapping_elements)"/>
   125   </func:function>
   125   </func:function>
   126   <func:function name="func:required_elements">
   126   <func:function name="func:required_elements">
   127     <xsl:param name="pages"/>
   127     <xsl:param name="pages"/>
   128     <xsl:choose>
   128     <xsl:choose>
   129       <xsl:when test="$pages">
   129       <xsl:when test="$pages">
   130         <func:result select="func:all_related_elements($pages[1])&#10;                          | func:required_elements($pages[position()!=1])"/>
   130         <func:result select="func:all_related_elements($pages[1])&#10;                      | func:required_elements($pages[position()!=1])"/>
   131       </xsl:when>
   131       </xsl:when>
   132       <xsl:otherwise>
   132       <xsl:otherwise>
   133         <func:result select="/.."/>
   133         <func:result select="/.."/>
   134       </xsl:otherwise>
   134       </xsl:otherwise>
   135     </xsl:choose>
   135     </xsl:choose>
   136   </func:function>
   136   </func:function>
   137   <xsl:variable name="required_elements" select="//svg:defs/descendant-or-self::svg:*&#10;           | func:required_elements($hmi_pages)/ancestor-or-self::svg:*"/>
   137   <xsl:variable name="required_elements" select="//svg:defs/descendant-or-self::svg:*&#10;       | func:required_elements($hmi_pages)/ancestor-or-self::svg:*"/>
   138   <xsl:variable name="discardable_elements" select="//svg:*[not(@id = $required_elements/@id)]"/>
   138   <xsl:variable name="discardable_elements" select="//svg:*[not(@id = $required_elements/@id)]"/>
   139   <func:function name="func:sumarized_elements">
   139   <func:function name="func:sumarized_elements">
   140     <xsl:param name="elements"/>
   140     <xsl:param name="elements"/>
   141     <xsl:variable name="short_list" select="$elements[not(ancestor::*/@id = $elements/@id)]"/>
   141     <xsl:variable name="short_list" select="$elements[not(ancestor::*/@id = $elements/@id)]"/>
   142     <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;            ])]"/>
   142     <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;        ])]"/>
   143     <xsl:variable name="groups_to_add" select="$filled_groups[not(ancestor::*/@id = $filled_groups/@id)]"/>
   143     <xsl:variable name="groups_to_add" select="$filled_groups[not(ancestor::*/@id = $filled_groups/@id)]"/>
   144     <func:result select="$groups_to_add | $short_list[not(ancestor::svg:g/@id = $filled_groups/@id)]"/>
   144     <func:result select="$groups_to_add | $short_list[not(ancestor::svg:g/@id = $filled_groups/@id)]"/>
   145   </func:function>
   145   </func:function>
   146   <func:function name="func:detachable_elements">
   146   <func:function name="func:detachable_elements">
   147     <xsl:param name="pages"/>
   147     <xsl:param name="pages"/>
   148     <xsl:choose>
   148     <xsl:choose>
   149       <xsl:when test="$pages">
   149       <xsl:when test="$pages">
   150         <func:result select="func:sumarized_elements(func:all_related_elements($pages[1]))&#10;                          | func:detachable_elements($pages[position()!=1])"/>
   150         <func:result select="func:sumarized_elements(func:all_related_elements($pages[1]))&#10;                      | func:detachable_elements($pages[position()!=1])"/>
   151       </xsl:when>
   151       </xsl:when>
   152       <xsl:otherwise>
   152       <xsl:otherwise>
   153         <func:result select="/.."/>
   153         <func:result select="/.."/>
   154       </xsl:otherwise>
   154       </xsl:otherwise>
   155     </xsl:choose>
   155     </xsl:choose>