<commit_before><xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:c="http://cnx.rice.edu/cnxml"
  exclude-result-prefixes="c"
  version="1.0">

<!-- Figures cannot have para tags in them and images are converted into figures as well (so it'll be a nested figure/para/figure ) -->
<xsl:template match="c:figure[c:para]">
  <xsl:copy>
    <xsl:apply-templates select="@*"/>
    <!-- Images are also converted to figures -->
    <xsl:apply-templates select="c:para/c:figure/node()"/>
    <!-- Captions and such -->
    <xsl:apply-templates select="c:para/*[not(self::c:figure)]|c:*[not(self::c:para)]"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="c:figure//c:figure">
  <xsl:processing-instruction name="cnx.warning">Stripping out nested figure (word import)</xsl:processing-instruction>
  <xsl:apply-templates select="node()"/>
</xsl:template>

<!-- Any time there are multiple images in a c:figure wrap them in a c:subfigure -->
<xsl:template match="c:media[not(parent::c:subfigure) and count(ancestor::c:figure//c:media) &gt; 1]">
  <c:subfigure>
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </c:subfigure>
</xsl:template>

<xsl:template match="c:glossary/c:para">
  <c:definition>
    <xsl:apply-templates select="*[1]"/><!-- should be a term -->
    <c:meaning>
      <xsl:apply-templates select="node()[position() != 1]"/>
    </c:meaning>
  </c:definition>
</xsl:template>

<xsl:template match="c:term/text()">
  <xsl:value-of select="normalize-space(.)"/>
</xsl:template>

<xsl:template match="c:problem[not(ancestor::c:exercise)]">
  <c:exercise>
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </c:exercise>
</xsl:template>

<!-- SHORTCUT: allow authors to just enter "<exercise>a</exercise>" (without problem) -->
<xsl:template match="c:exercise[not(c:problem)]">
  <!-- Assume everything except for c:solution is part of the problem -->
  <c:exercise>
    <xsl:apply-templates select="@*"/>
    <c:problem>
      <xsl:apply-templates select="node()[not(self::c:solution)]"/>
    </c:problem>
    <xsl:apply-templates select="c:solution"/>
  </c:exercise>
</xsl:template>

<!-- SHORTCUT: allow authors to just enter "<solution>a</solution>" (without para)-->
<xsl:template match="c:solution/text()">
  <c:para>
    <xsl:value-of select="."/>
  </c:para>
</xsl:template>

<xsl:template match="c:title//c:figure">
  <xsl:processing-instruction name="cnx.error">Figures in a heading is NOT allowed! Make sure the image is in a normal paragraph</xsl:processing-instruction>
</xsl:template>

<xsl:template match="c:section[count(*) &lt;= 1]">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
    <c:para>
      <xsl:processing-instruction name="cnx.warning">All headings must be followed by some content. Inserting an empty paragraph.</xsl:processing-instruction>
    </c:para>
  </xsl:copy>
</xsl:template>


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

</xsl:stylesheet><commit_msg>Remove debugging messages<commit_after><xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:c="http://cnx.rice.edu/cnxml"
  exclude-result-prefixes="c"
  version="1.0">

<!-- Remove all debug processing instructions -->
<xsl:template match="processing-instruction('cnx.debug')"/>

<!-- Figures cannot have para tags in them and images are converted into figures as well (so it'll be a nested figure/para/figure ) -->
<xsl:template match="c:figure[c:para]">
  <xsl:copy>
    <xsl:apply-templates select="@*"/>
    <!-- Images are also converted to figures -->
    <xsl:apply-templates select="c:para/c:figure/node()"/>
    <!-- Captions and such -->
    <xsl:apply-templates select="c:para/*[not(self::c:figure)]|c:*[not(self::c:para)]"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="c:figure//c:figure">
  <xsl:processing-instruction name="cnx.warning">Stripping out nested figure (word import)</xsl:processing-instruction>
  <xsl:apply-templates select="node()"/>
</xsl:template>

<!-- Any time there are multiple images in a c:figure wrap them in a c:subfigure -->
<xsl:template match="c:media[not(parent::c:subfigure) and count(ancestor::c:figure//c:media) &gt; 1]">
  <c:subfigure>
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </c:subfigure>
</xsl:template>

<xsl:template match="c:glossary/c:para">
  <c:definition>
    <xsl:apply-templates select="*[1]"/><!-- should be a term -->
    <c:meaning>
      <xsl:apply-templates select="node()[position() != 1]"/>
    </c:meaning>
  </c:definition>
</xsl:template>

<xsl:template match="c:term/text()">
  <xsl:value-of select="normalize-space(.)"/>
</xsl:template>

<xsl:template match="c:problem[not(ancestor::c:exercise)]">
  <c:exercise>
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </c:exercise>
</xsl:template>

<!-- SHORTCUT: allow authors to just enter "<exercise>a</exercise>" (without problem) -->
<xsl:template match="c:exercise[not(c:problem)]">
  <!-- Assume everything except for c:solution is part of the problem -->
  <c:exercise>
    <xsl:apply-templates select="@*"/>
    <c:problem>
      <xsl:apply-templates select="node()[not(self::c:solution)]"/>
    </c:problem>
    <xsl:apply-templates select="c:solution"/>
  </c:exercise>
</xsl:template>

<!-- SHORTCUT: allow authors to just enter "<solution>a</solution>" (without para)-->
<xsl:template match="c:solution/text()">
  <c:para>
    <xsl:value-of select="."/>
  </c:para>
</xsl:template>

<xsl:template match="c:title//c:figure">
  <xsl:processing-instruction name="cnx.error">Figures in a heading is NOT allowed! Make sure the image is in a normal paragraph</xsl:processing-instruction>
</xsl:template>

<xsl:template match="c:section[count(*) &lt;= 1]">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
    <c:para>
      <xsl:processing-instruction name="cnx.warning">All headings must be followed by some content. Inserting an empty paragraph.</xsl:processing-instruction>
    </c:para>
  </xsl:copy>
</xsl:template>


<xsl:template match="c:equation/c:para">
  <xsl:apply-templates select="node()"/>
</xsl:template>

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

</xsl:stylesheet>
{'fraction_non_alphanumeric': 0.20655583437892094, 'fraction_numerical': 0.003450439146800502, 'mean_word_length': 4.71415770609319, 'pattern_counts': {'":': 0, '<': 174, '<?xml version=': 0, '>': 174, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 6}, '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': '814068', 'n_tokens_mistral': 2347, 'n_tokens_neox': 2146, 'n_words': 445}