<commit_before><?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:ext="http://exslt.org/common"
  xmlns:math="http://exslt.org/math"
  xmlns:set="http://exslt.org/sets"
  extension-element-prefixes="ext math set">


<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Common components
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

     This file is part of XML-to-bootstrap.
     https://github.com/acch/XML-to-bootstrap

     Copyright 2016 <NAME>
     Released under the MIT license
     (https://github.com/acch/scrollpos-styler/blob/master/LICENSE)

     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->


<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Constants
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  <xsl:variable name="style.maincolumn">col-xs-12</xsl:variable>
  <xsl:variable name="style.sidebar.maincolumn">col-md-8</xsl:variable>
  <xsl:variable name="style.sidebar.sidecolumn">hidden-sm-down [ col-md-4 col-lg-3 col-lg-offset-1 ]</xsl:variable>
  <xsl:variable name="style.cardcolumn">col-xs-12 col-md-6 col-lg-4</xsl:variable>


<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Date format
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

  <!-- will turn 2001-12-31 into 31.12.2001 -->
  <xsl:template name="format.date">
    <xsl:param name="date" /><!-- string (format 'YYYY-MM-DD') -->

    <xsl:variable name="year" select="substring-before($date, '-')" />
    <xsl:variable name="month" select="format-number(substring-before(substring-after($date, '-'), '-'), '00')" />
    <xsl:variable name="day" select="format-number(substring-after(substring-after($date, '-'), '-'), '0')" />

    <xsl:value-of select="concat($day, '.', $month, '.', $year)" />

  </xsl:template>


<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Filename format
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

  <!-- make string lowercase and mask special characters -->
  <xsl:template name="format.filename">
    <xsl:param name="string" /><!-- string -->

    <xsl:value-of select="translate($string, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ äöüÄÖÜ', 'abcdefghijklmnopqrstuvwxyz-aouaou')" />

  </xsl:template>


<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Copy contents
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

  <!-- helper for copying child element nodes and attributes (but no namespaces)
       from XML. also, adds anchor CSS class to elements with id attribute -->
  <xsl:template name="copy.content">
    <xsl:param name="content" /><!-- node-set -->
    <xsl:param name="exclude" /><!-- string -->

    <!-- find all child elements excluding specific names -->
    <xsl:for-each select="$content/*[not(name() = $exclude)]">

      <!-- generate element without namespace -->
      <xsl:element name="{name()}">

        <!-- add anchor class to elements with id attribute -->
        <xsl:if test="@id">
          <xsl:attribute name="class">x2b-anchr</xsl:attribute>
        </xsl:if>

        <!-- copy attributes and child nodes -->
        <xsl:apply-templates select="node()|@*" />

      </xsl:element>

    </xsl:for-each>

  </xsl:template>

  <xsl:template match="node()|@*" priority="-1">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*" />
    </xsl:copy>
  </xsl:template>


<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Distinct years
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

  <!-- find distinct years of elements with a date -->
  <xsl:template name="date.years">
    <xsl:param name="elements" /><!-- node-set (with 'date' child) -->

    <!-- find all years -->
    <xsl:variable name="years">
      <xsl:for-each select="$elements/date">
        <year><xsl:value-of select="substring-before(text(), '-')" /></year>
      </xsl:for-each>
    </xsl:variable>

    <!-- find distinct years -->
    <xsl:for-each select="set:distinct(ext:node-set($years)/year)">
      <year><xsl:value-of select="text()" /></year>
    </xsl:for-each>

  </xsl:template>


<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Previous element
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

  <!-- find title of element with a date closest before the specified date -->
  <xsl:template name="date.prev.title">
    <xsl:param name="date" /><!-- string (format 'YYYY-MM-DD') -->
    <xsl:param name="elements" /><!-- node-set (with 'title' and 'date' children) -->

    <xsl:variable name="date.raw" select="translate($date, '-', '')" />

    <!-- find all elements with a date before the specified date -->
    <xsl:variable name="elements.before">
      <xsl:for-each select="ext:node-set($elements)[translate(date, '-', '') &lt; $date.raw]">
        <element title="{title}">
          <xsl:value-of select="translate(date, '-', '')" />
        </element>
      </xsl:for-each>
    </xsl:variable>

    <!-- find title of latest element -->
    <xsl:value-of select="math:highest(ext:node-set($elements.before)/element)/@title" />

  </xsl:template>


<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Next element
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

  <!-- find title of element with a date closest after the specified date -->
  <xsl:template name="date.next.title">
    <xsl:param name="date" /><!-- string (format 'YYYY-MM-DD') -->
    <xsl:param name="elements" /><!-- node-set (with 'title' and 'date' children) -->

    <xsl:variable name="date.raw" select="translate($date, '-', '')" />

    <!-- find all elements with a date after the specified date -->
    <xsl:variable name="elements.after">
      <xsl:for-each select="ext:node-set($elements)[translate(date, '-', '') &gt; $date.raw]">
        <element title="{title}">
          <xsl:value-of select="translate(date, '-', '')" />
        </element>
      </xsl:for-each>
    </xsl:variable>

    <!-- find title of earliest element -->
    <xsl:value-of select="math:lowest(ext:node-set($elements.after)/element)/@title" />

  </xsl:template>

</xsl:stylesheet>
<commit_msg>Added comment to style defs<commit_after><?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:ext="http://exslt.org/common"
  xmlns:math="http://exslt.org/math"
  xmlns:set="http://exslt.org/sets"
  extension-element-prefixes="ext math set">


<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Common components
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

     This file is part of XML-to-bootstrap.
     https://github.com/acch/XML-to-bootstrap

     Copyright 2016 <NAME>
     Released under the MIT license
     (https://github.com/acch/scrollpos-styler/blob/master/LICENSE)

     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->


<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Constants
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

  <!-- define some styles which are used all over the place -->
  <xsl:variable name="style.maincolumn">col-xs-12</xsl:variable>
  <xsl:variable name="style.sidebar.maincolumn">col-md-8</xsl:variable>
  <xsl:variable name="style.sidebar.sidecolumn">hidden-sm-down [ col-md-4 col-lg-3 col-lg-offset-1 ]</xsl:variable>
  <xsl:variable name="style.cardcolumn">col-xs-12 col-md-6 col-lg-4</xsl:variable>


<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Date format
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

  <!-- will turn 2001-12-31 into 31.12.2001 -->
  <xsl:template name="format.date">
    <xsl:param name="date" /><!-- string (format 'YYYY-MM-DD') -->

    <xsl:variable name="year" select="substring-before($date, '-')" />
    <xsl:variable name="month" select="format-number(substring-before(substring-after($date, '-'), '-'), '00')" />
    <xsl:variable name="day" select="format-number(substring-after(substring-after($date, '-'), '-'), '0')" />

    <xsl:value-of select="concat($day, '.', $month, '.', $year)" />

  </xsl:template>


<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Filename format
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

  <!-- make string lowercase and mask special characters -->
  <xsl:template name="format.filename">
    <xsl:param name="string" /><!-- string -->

    <xsl:value-of select="translate($string, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ äöüÄÖÜ', 'abcdefghijklmnopqrstuvwxyz-aouaou')" />

  </xsl:template>


<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Copy contents
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

  <!-- helper for copying child element nodes and attributes (but no namespaces)
       from XML. also, adds anchor CSS class to elements with id attribute -->
  <xsl:template name="copy.content">
    <xsl:param name="content" /><!-- node-set -->
    <xsl:param name="exclude" /><!-- string -->

    <!-- find all child elements excluding specific names -->
    <xsl:for-each select="$content/*[not(name() = $exclude)]">

      <!-- generate element without namespace -->
      <xsl:element name="{name()}">

        <!-- add anchor class to elements with id attribute -->
        <xsl:if test="@id">
          <xsl:attribute name="class">x2b-anchr</xsl:attribute>
        </xsl:if>

        <!-- copy attributes and child nodes -->
        <xsl:apply-templates select="node()|@*" />

      </xsl:element>

    </xsl:for-each>

  </xsl:template>

  <xsl:template match="node()|@*" priority="-1">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*" />
    </xsl:copy>
  </xsl:template>


<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Distinct years
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

  <!-- find distinct years of elements with a date -->
  <xsl:template name="date.years">
    <xsl:param name="elements" /><!-- node-set (with 'date' child) -->

    <!-- find all years -->
    <xsl:variable name="years">
      <xsl:for-each select="$elements/date">
        <year><xsl:value-of select="substring-before(text(), '-')" /></year>
      </xsl:for-each>
    </xsl:variable>

    <!-- find distinct years -->
    <xsl:for-each select="set:distinct(ext:node-set($years)/year)">
      <year><xsl:value-of select="text()" /></year>
    </xsl:for-each>

  </xsl:template>


<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Previous element
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

  <!-- find title of element with a date closest before the specified date -->
  <xsl:template name="date.prev.title">
    <xsl:param name="date" /><!-- string (format 'YYYY-MM-DD') -->
    <xsl:param name="elements" /><!-- node-set (with 'title' and 'date' children) -->

    <xsl:variable name="date.raw" select="translate($date, '-', '')" />

    <!-- find all elements with a date before the specified date -->
    <xsl:variable name="elements.before">
      <xsl:for-each select="ext:node-set($elements)[translate(date, '-', '') &lt; $date.raw]">
        <element title="{title}">
          <xsl:value-of select="translate(date, '-', '')" />
        </element>
      </xsl:for-each>
    </xsl:variable>

    <!-- find title of latest element -->
    <xsl:value-of select="math:highest(ext:node-set($elements.before)/element)/@title" />

  </xsl:template>


<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     Next element
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

  <!-- find title of element with a date closest after the specified date -->
  <xsl:template name="date.next.title">
    <xsl:param name="date" /><!-- string (format 'YYYY-MM-DD') -->
    <xsl:param name="elements" /><!-- node-set (with 'title' and 'date' children) -->

    <xsl:variable name="date.raw" select="translate($date, '-', '')" />

    <!-- find all elements with a date after the specified date -->
    <xsl:variable name="elements.after">
      <xsl:for-each select="ext:node-set($elements)[translate(date, '-', '') &gt; $date.raw]">
        <element title="{title}">
          <xsl:value-of select="translate(date, '-', '')" />
        </element>
      </xsl:for-each>
    </xsl:variable>

    <!-- find title of earliest element -->
    <xsl:value-of select="math:lowest(ext:node-set($elements.after)/element)/@title" />

  </xsl:template>

</xsl:stylesheet>

{'fraction_non_alphanumeric': 0.35309808703604906, 'fraction_numerical': 0.006859233290145568, 'mean_word_length': 3.810117302052786, 'pattern_counts': {'":': 0, '<': 234, '<?xml version=': 2, '>': 234, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 10}, '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': '3169707', 'n_tokens_mistral': 4081, 'n_tokens_neox': 3577, 'n_words': 698}