<commit_before><?xml version="1.0"?>

<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">

 <xsl:import href="copyover.xsl"/>

  <xsl:template match="faqs">
   <document>
    <header>
     <title><xsl:value-of select="@title"/></title>
    </header>
    <body>
      <section>
       <title>Questions</title>
       <ul>
        <xsl:apply-templates select="faq|part" mode="index"/>
       </ul>
      </section>
      <section>
       <title>Answers</title>
        <xsl:apply-templates select="faq|part"/>
      </section>
    </body>
   </document>  
  </xsl:template>

  <xsl:template match="part" mode="index">
    <li>
	  <xsl:attribute name="id">
        <xsl:call-template name="generate-id"/><xsl:text>-menu</xsl:text>
	  </xsl:attribute>
      <link>
        <xsl:attribute name="href">
          <xsl:text>#</xsl:text><xsl:call-template name="generate-id"/>
        </xsl:attribute>
	  <xsl:number level="multiple" count="faq|part" format="1.1. "/>
       <xsl:apply-templates select="title"/>
      </link>
       <ul>
        <xsl:apply-templates select="faq|part" mode="index"/>
       </ul>
    </li>
  </xsl:template>

  <xsl:template match="faq" mode="index">
    <li>
	  <xsl:attribute name="id">
        <xsl:call-template name="generate-id"/><xsl:text>-menu</xsl:text>
	  </xsl:attribute>
      <link>
        <xsl:attribute name="href">
          <xsl:text>#</xsl:text><xsl:call-template name="generate-id"/>
        </xsl:attribute>
		<!--
		  IMHO adding this makes the tightly-packed menu less legible for
		  little benefit (JT)
	    <xsl:number level="multiple" count="faq|part" format="1.1. "/>
		-->
        <xsl:apply-templates select="question" mode="index"/>
      </link>
    </li>
  </xsl:template>

  <xsl:template match="part">
    <xsl:variable name="id">
      <xsl:call-template name="generate-id"/>
    </xsl:variable>
    <section id="{$id}">
      <title>
        <xsl:number level="multiple" count="faq|part" format="1.1. "/>
        <xsl:value-of select="title"/>
      </title>
      <xsl:apply-templates select="faq|part"/>
    </section>
  </xsl:template>

  <xsl:template match="faq">
    <xsl:variable name="id">
      <xsl:call-template name="generate-id"/>
    </xsl:variable>

    <section id="{$id}">
      <title>
        <xsl:number level="multiple" count="faq|part" format="1.1. "/>
        <xsl:apply-templates select="question"/>
      </title>
      <xsl:apply-templates select="answer"/>
    </section>
  </xsl:template>

  <xsl:template name="generate-id">
    <xsl:choose>
      <xsl:when test="@id">
        <xsl:value-of select="@id"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="concat(concat(local-name(.), '-'), generate-id(.))"/>
      </xsl:otherwise>
  </xsl:choose>
  </xsl:template>

  <xsl:template match="question" mode="index">
    <xsl:apply-templates select="node()[not(local-name()='elaboration')]"/>
  </xsl:template>

  <xsl:template match="question">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="answer">
    <xsl:if test="count(p)>0"> 
      <xsl:apply-templates/>
    </xsl:if>
    <xsl:if test="count(p)=0"> 
      <p>
        <xsl:apply-templates/>
      </p>
    </xsl:if>
  </xsl:template>

  <xsl:template match="title">
    <xsl:apply-templates/>
  </xsl:template>

</xsl:stylesheet>
<commit_msg>- Don't generate links for faqsection titles, as they are more useful when not   blending into link-happy blueness - Use <ol> instead of <ul> to avoid use of <xsl:number> - Add hacky <br/> to add some space between faqsections<commit_after><?xml version="1.0"?>

<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">

 <xsl:import href="copyover.xsl"/>

  <xsl:template match="faqs">
   <document>
    <header>
     <title><xsl:value-of select="@title"/></title>
    </header>
    <body>
      <section>
       <title>Questions</title>
       <ol>
        <xsl:apply-templates select="faq|part" mode="index"/>
       </ol>
      </section>
      <section>
       <title>Answers</title>
        <xsl:apply-templates select="faq|part"/>
      </section>
    </body>
   </document>  
  </xsl:template>

  <xsl:template match="part" mode="index">
    <li>
      <strong>
      <!-- Rely on <ol> numbering here -->
      <!--<xsl:number level="multiple" count="faq|part" format="1.1. "/> -->
       <xsl:apply-templates select="title"/></strong>
       <ul>
        <xsl:apply-templates select="faq|part" mode="index"/>
       </ul><br />
    </li>
  </xsl:template>

  <xsl:template match="faq" mode="index">
    <li>
	  <xsl:attribute name="id">
        <xsl:call-template name="generate-id"/><xsl:text>-menu</xsl:text>
	  </xsl:attribute>
      <link>
        <xsl:attribute name="href">
          <xsl:text>#</xsl:text><xsl:call-template name="generate-id"/>
        </xsl:attribute>
		<!--
		  IMHO adding this makes the tightly-packed menu less legible for
		  little benefit (JT)
	    <xsl:number level="multiple" count="faq|part" format="1.1. "/>
		-->
        <xsl:apply-templates select="question" mode="index"/>
      </link>
    </li>
  </xsl:template>

  <xsl:template match="part">
    <xsl:variable name="id">
      <xsl:call-template name="generate-id"/>
    </xsl:variable>
    <section id="{$id}">
      <title>
        <xsl:number level="multiple" count="faq|part" format="1.1. "/>
        <xsl:value-of select="title"/>
      </title>
      <xsl:apply-templates select="faq|part"/>
    </section>
  </xsl:template>

  <xsl:template match="faq">
    <xsl:variable name="id">
      <xsl:call-template name="generate-id"/>
    </xsl:variable>

    <section id="{$id}">
      <title>
        <xsl:number level="multiple" count="faq|part" format="1.1. "/>
        <xsl:apply-templates select="question"/>
      </title>
      <xsl:apply-templates select="answer"/>
    </section>
  </xsl:template>

  <xsl:template name="generate-id">
    <xsl:choose>
      <xsl:when test="@id">
        <xsl:value-of select="@id"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="concat(concat(local-name(.), '-'), generate-id(.))"/>
      </xsl:otherwise>
  </xsl:choose>
  </xsl:template>

  <xsl:template match="question" mode="index">
    <xsl:apply-templates select="node()[not(local-name()='elaboration')]"/>
  </xsl:template>

  <xsl:template match="question">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="answer">
    <xsl:if test="count(p)>0"> 
      <xsl:apply-templates/>
    </xsl:if>
    <xsl:if test="count(p)=0"> 
      <p>
        <xsl:apply-templates/>
      </p>
    </xsl:if>
  </xsl:template>

  <xsl:template match="title">
    <xsl:apply-templates/>
  </xsl:template>

</xsl:stylesheet>

{'fraction_non_alphanumeric': 0.20387918270654426, 'fraction_numerical': 0.005626295528575659, 'mean_word_length': 2.849002849002849, 'pattern_counts': {'":': 0, '<': 241, '<?xml version=': 2, '>': 243, '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': '5205824', 'n_tokens_mistral': 2517, 'n_tokens_neox': 2280, 'n_words': 396}