<commit_before><?xml version="1.0"?>
<!--
  Copyright 1999-2004 The Apache Software Foundation

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                xmlns:st="http://chaperon.sourceforge.net/schema/syntaxtree/2.0"
                exclude-result-prefixes="st">

 <xsl:output indent="yes" 
             method="html"
             doctype-public="-//APACHE//DTD Documentation V1.1//EN"
             doctype-system="document-v11.dtd"
             cdata-section-elements="source"/>

 <xsl:param name="name" select="''"/>
 <xsl:param name="spaceless-filenames" select="''"/>

 <xsl:template name="splitString">
    <xsl:param name="restOfString"/>
    
    <xsl:variable name="uppercase">(ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
    <xsl:variable name="currentLetter" select="substring($restOfString,1,1)"/>
    
    <xsl:choose>
        <xsl:when test="contains($restOfString, '(') or contains($restOfString,' ')">
            <xsl:value-of select="$restOfString"/>
        </xsl:when>
        <xsl:when test="string-length($restOfString) &gt;= 2">
        <!-- there's a possibility it needs to be split -->
        <xsl:choose>
            <xsl:when test="contains($uppercase,$currentLetter)">
                <xsl:variable name="followingLetter" select="substring($restOfString,2,1)"/>
                <xsl:if test="not(contains($uppercase,$followingLetter))">
                    <xsl:text> </xsl:text>
                </xsl:if>
                <xsl:value-of select="$currentLetter"/>
                
                <xsl:call-template name="splitString">
                    <xsl:with-param name="restOfString" select="substring($restOfString,2)"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <!-- current letter is lower-case - just spit it out -->
                <xsl:value-of select="$currentLetter"/>
                <xsl:call-template name="splitString">
                    <xsl:with-param name="restOfString" select="substring($restOfString,2)"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
        </xsl:when>
        <xsl:otherwise>
        <!-- end of string - just write the remainder -->
        <xsl:value-of select="$restOfString"/>
        </xsl:otherwise>
    </xsl:choose>
 </xsl:template>



 <xsl:template match="st:output">
   <document>  
    <header>  
     <title>
      <xsl:variable name="title" select="st:document/st:sections/st:section/st:title/st:textsequence"/>
      <xsl:choose>
       <xsl:when test="$title">
        <xsl:value-of select="$title"/>
       </xsl:when>
       <xsl:otherwise>
        <xsl:call-template name="splitString">
         <xsl:with-param name="restOfString" select="$name"/>
        </xsl:call-template>
       </xsl:otherwise>
      </xsl:choose>
     </title>  
     </header>  
    <body>
  <xsl:apply-templates select="st:document/st:paragraphs/st:paragraph/*" mode="paragraph"/>  <commit_msg>Go back to the old behaviour of getting the page title from the filename until we make it configurable to use first level-3 heading. Issue: FOR-270<commit_after><?xml version="1.0"?>
<!--
  Copyright 1999-2004 The Apache Software Foundation

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                xmlns:st="http://chaperon.sourceforge.net/schema/syntaxtree/2.0"
                exclude-result-prefixes="st">

 <xsl:output indent="yes" 
             method="html"
             doctype-public="-//APACHE//DTD Documentation V1.1//EN"
             doctype-system="document-v11.dtd"
             cdata-section-elements="source"/>

 <xsl:param name="name" select="''"/>
 <xsl:param name="spaceless-filenames" select="''"/>

 <xsl:template name="splitString">
    <xsl:param name="restOfString"/>
    
    <xsl:variable name="uppercase">(ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
    <xsl:variable name="currentLetter" select="substring($restOfString,1,1)"/>
    
    <xsl:choose>
        <xsl:when test="contains($restOfString, '(') or contains($restOfString,' ')">
            <xsl:value-of select="$restOfString"/>
        </xsl:when>
        <xsl:when test="string-length($restOfString) &gt;= 2">
        <!-- there's a possibility it needs to be split -->
        <xsl:choose>
            <xsl:when test="contains($uppercase,$currentLetter)">
                <xsl:variable name="followingLetter" select="substring($restOfString,2,1)"/>
                <xsl:if test="not(contains($uppercase,$followingLetter))">
                    <xsl:text> </xsl:text>
                </xsl:if>
                <xsl:value-of select="$currentLetter"/>
                
                <xsl:call-template name="splitString">
                    <xsl:with-param name="restOfString" select="substring($restOfString,2)"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <!-- current letter is lower-case - just spit it out -->
                <xsl:value-of select="$currentLetter"/>
                <xsl:call-template name="splitString">
                    <xsl:with-param name="restOfString" select="substring($restOfString,2)"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
        </xsl:when>
        <xsl:otherwise>
        <!-- end of string - just write the remainder -->
        <xsl:value-of select="$restOfString"/>
        </xsl:otherwise>
    </xsl:choose>
 </xsl:template>



 <xsl:template match="st:output">
   <document>  
    <header>  
     <title>
      <xsl:variable name="title" select="st:document/st:sections/st:section/st:title/st:textsequence"/>
      <xsl:choose>
       <!-- make this configurable: FOR-270
       <xsl:when test="$title">
        <xsl:value-of select="$title"/>
       </xsl:when>
       -->
       <xsl:when test="$name">
        <xsl:call-template name="splitString">
         <xsl:with-param name="restOfString" select="$name"/>
        </xsl:call-template>
       </xsl:when>
       <xsl:otherwise>
        <xsl:value-of select="$title"/>
       </xsl:otherwise>
      </xsl:choose>
     </title>  
     </header>  
    <body>
  <xsl:apply-templates select="st:document/st:paragraphs/st:paragraph/*" mode="paragraph"/>  
{'fraction_non_alphanumeric': 0.14840274969672462, 'fraction_numerical': 0.010109179134654266, 'mean_word_length': 2.480300187617261, 'pattern_counts': {'":': 0, '<': 133, '<?xml version=': 2, '>': 133, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '373034', 'n_tokens_mistral': 2339, 'n_tokens_neox': 2093, 'n_words': 466}