<commit_before><?xml version='1.0' encoding='utf-8' ?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:param name="activeTab">t01</xsl:param>

<!-- document fragment template. See structure stylesheet for more comments -->
<xsl:template match="layout_fragment">
   <layout_fragment>
    <xsl:call-template name="tabList"/>
    <content>
      <xsl:apply-templates/>
    </content>
   </layout_fragment>    
</xsl:template>

<xsl:template match="layout">
   <layout>
    <header>
      <xsl:for-each select="descendant::folder[attribute::type='header']">
	<xsl:copy-of select="./"/>
      </xsl:for-each>
    </header>
    <xsl:call-template name="tabList"/>
    <content>
     <xsl:apply-templates/>
    </content>
    <footer>
      <xsl:for-each select="descendant::folder[attribute::type='footer']">
	<xsl:copy-of select="./"/>
      </xsl:for-each>
    </footer>
   </layout>    
</xsl:template>

<xsl:template name="tabList"><navigation>
<xsl:for-each select="/layout/folder[attribute::type='regular']">
   <tab>
    <xsl:attribute name="ID"><xsl:value-of select="@ID"/></xsl:attribute>
	<xsl:choose>
	<xsl:when test="$activeTab=@ID">
	<xsl:attribute name="activeTab">true</xsl:attribute>
	</xsl:when>
	<xsl:otherwise>
	<xsl:attribute name="activeTab">false</xsl:attribute>
	</xsl:otherwise>
	</xsl:choose>
    <xsl:attribute name="priority"><xsl:value-of select="@priority"/></xsl:attribute>
    <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
   </tab>
</xsl:for-each>
</navigation>
</xsl:template>

<xsl:template match="folder[attribute::type='regular']"><xsl:if test="$activeTab=@ID">
<xsl:if test="child::folder">
<xsl:for-each select="folder">
  <column>
    <xsl:attribute name="ID"><xsl:value-of select="@ID"/></xsl:attribute>
    <xsl:attribute name="priority"><xsl:value-of select="@priority"/></xsl:attribute>
    <xsl:attribute name="width"><xsl:value-of select="@width"/></xsl:attribute>
    <xsl:apply-templates/><commit_msg>Corrected header/footer folder handling. Note that all header/footer content is flattened by this transformation (i.e. no folder structures are preserved under header and footer elements)<commit_after><?xml version='1.0' encoding='utf-8' ?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:param name="activeTab">t01</xsl:param>

<!-- document fragment template. See structure stylesheet for more comments -->
<xsl:template match="layout_fragment">
   <layout_fragment>
    <xsl:call-template name="tabList"/>
    <content>
      <xsl:apply-templates/>
    </content>
   </layout_fragment>    
</xsl:template>

<xsl:template match="layout">
   <layout>
    <header>
      <xsl:for-each select="child::folder[attribute::type='header']">
	<xsl:copy-of select=".//channel"/>
      </xsl:for-each>
    </header>
    <xsl:call-template name="tabList"/>
    <content>
     <xsl:apply-templates select="folder[attribute::type='regular']"/>
    </content>
    <footer>
      <xsl:for-each select="child::folder[attribute::type='footer']">
	<xsl:copy-of select=".//channel"/>
      </xsl:for-each>
    </footer>
   </layout>    
</xsl:template>

<xsl:template name="tabList"><navigation>
<xsl:for-each select="/layout/folder[attribute::type='regular']">
   <tab>
    <xsl:attribute name="ID"><xsl:value-of select="@ID"/></xsl:attribute>
	<xsl:choose>
	<xsl:when test="$activeTab=@ID">
	<xsl:attribute name="activeTab">true</xsl:attribute>
	</xsl:when>
	<xsl:otherwise>
	<xsl:attribute name="activeTab">false</xsl:attribute>
	</xsl:otherwise>
	</xsl:choose>
    <xsl:attribute name="priority"><xsl:value-of select="@priority"/></xsl:attribute>
    <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
   </tab>
</xsl:for-each>
</navigation>
</xsl:template>

<xsl:template match="folder">
<xsl:if test="$activeTab=@ID">
<xsl:if test="child::folder">
<xsl:for-each select="folder">
  <column>
    <xsl:attribute name="ID"><xsl:value-of select="@ID"/></xsl:attribute>
    <xsl:attribute name="priority"><xsl:value-of select="@priority"/></xsl:attribute>
    <xsl:attribute name="width"><xsl:value-of select="@width"/></xsl:attribute>
    <xsl:apply-templates/>
{'fraction_non_alphanumeric': 0.2099263832818808, 'fraction_numerical': 0.00569935882213251, 'mean_word_length': 5.157894736842105, 'pattern_counts': {'":': 0, '<': 149, '<?xml version=': 2, '>': 149, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6721319', 'n_tokens_mistral': 1519, 'n_tokens_neox': 1373, 'n_words': 221}