<commit_before><xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"
	xmlns:sch="http://purl.oclc.org/dsdl/schematron"
	xmlns:loc="http://www.thaiopensource.com/ns/location"
	xmlns:err="http://www.thaiopensource.com/ns/error"
	xmlns:xsltc="http://www.thaiopensource.com/ns/xsltc"
	xmlns:osaxon="http://icl.com/saxon"
	xmlns:nsaxon="http://saxon.sf.net/"
	xmlns:xalan-node-info="http://xml.apache.org/xalan/java/org.apache.xalan.lib.NodeInfo">
  <!-- <EMAIL>: 
    Use the iso namespace xmlns:sch="http://purl.oclc.org/dsdl/schematron" -->
  
  <xsl:param name="phase" select="'#DEFAULT'"/>
  <xsl:param name="diagnose" select="false()"/>
  
  <xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>
  
  <xsl:output indent="yes"/>
  
  <xsl:key name="phase"
    match="/sch:schema/sch:phase[@id]"
    use="normalize-space(@id)"/>
  
  <xsl:key name="active"
    match="/sch:schema/sch:phase[@id]/sch:active"
    use="normalize-space(@pattern)"/>
  
  <xsl:key name="rule"
    match="/sch:schema/sch:pattern/sch:rule[@id]"
    use="normalize-space(@id)"/>
  
  <xsl:key name="pattern"
    match="/sch:schema/sch:pattern[@id]"
    use="normalize-space(@id)"/>
  
  <xsl:key name="diagnostic"
    match="/sch:schema/sch:diagnostics/sch:diagnostic[@id]"
    use="normalize-space(@id)"/>
  
  <xsl:template match="sch:schema">
    <axsl:stylesheet version="1.0">
      <xsl:for-each select="sch:ns">
        <xsl:attribute name="{concat(@prefix,':dummy-for-xmlns')}" namespace="{@uri}"/>
      </xsl:for-each>
      <xsl:apply-templates select="." mode="check"/>
      <axsl:template match="/">
        <result>
          <axsl:apply-templates select="/" mode="all"/>
        </result>
      </axsl:template>
      <!-- <EMAIL>: add sch:let -->
      <xsl:apply-templates select="sch:let"/>
      <!-- <EMAIL>: use xsl:key instead of sch:key -->
      <xsl:apply-templates select="xsl:key|sch:diagnostics/sch:diagnostic"/>
      <xsl:choose>
        <xsl:when test="normalize-space($phase)='#DEFAULT' and @defaultPhase">
          <xsl:call-template name="process-phase">
            <xsl:with-param name="p" select="normalize-space(@defaultPhase)"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:when test="normalize-space($phase)='#DEFAULT'">
          <xsl:call-template name="process-phase">
            <xsl:with-param name="p" select="'#ALL'"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:call-template name="process-phase">
            <xsl:with-param name="p" select="normalize-space($phase)"/>
          </xsl:call-template>
        </xsl:otherwise>
      </xsl:choose>
      <axsl:template match="*|/" mode="all">
        <axsl:apply-templates select="*" mode="all"/>
      </axsl:template>
      <xsl:call-template name="define-location"/>
    </axsl:stylesheet>
  </xsl:template>
  
  <xsl:template name="process-phase">
    <xsl:param name="p"/>
    <xsl:choose>
      <xsl:when test="$p='#ALL'">
        <!-- TODO: <EMAIL> check skeleton impl to see what happens with
          let instructions under phase in this case -->
        <xsl:call-template name="process-patterns">
          <xsl:with-param name="patterns" select="sch:pattern"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <!-- <EMAIL>: handle let -->
        <xsl:apply-templates select="key('phase',$p)/sch:let"/>
              
        <xsl:variable name="active-patterns" select="key('phase',$p)/sch:active/@pattern"/>
        <xsl:call-template name="process-patterns">
          <xsl:with-param name="patterns" select="<commit_msg>Work on issue 63 - covert all let instructions inside phase to global variables if the phase is '#ALL'.<commit_after><xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"
	xmlns:sch="http://purl.oclc.org/dsdl/schematron"
	xmlns:loc="http://www.thaiopensource.com/ns/location"
	xmlns:err="http://www.thaiopensource.com/ns/error"
	xmlns:xsltc="http://www.thaiopensource.com/ns/xsltc"
	xmlns:osaxon="http://icl.com/saxon"
	xmlns:nsaxon="http://saxon.sf.net/"
	xmlns:xalan-node-info="http://xml.apache.org/xalan/java/org.apache.xalan.lib.NodeInfo">
  <!-- <EMAIL>: 
    Use the iso namespace xmlns:sch="http://purl.oclc.org/dsdl/schematron" -->
  
  <xsl:param name="phase" select="'#DEFAULT'"/>
  <xsl:param name="diagnose" select="false()"/>
  
  <xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>
  
  <xsl:output indent="yes"/>
  
  <xsl:key name="phase"
    match="/sch:schema/sch:phase[@id]"
    use="normalize-space(@id)"/>
  
  <xsl:key name="active"
    match="/sch:schema/sch:phase[@id]/sch:active"
    use="normalize-space(@pattern)"/>
  
  <xsl:key name="rule"
    match="/sch:schema/sch:pattern/sch:rule[@id]"
    use="normalize-space(@id)"/>
  
  <xsl:key name="pattern"
    match="/sch:schema/sch:pattern[@id]"
    use="normalize-space(@id)"/>
  
  <xsl:key name="diagnostic"
    match="/sch:schema/sch:diagnostics/sch:diagnostic[@id]"
    use="normalize-space(@id)"/>
  
  <xsl:template match="sch:schema">
    <axsl:stylesheet version="1.0">
      <xsl:for-each select="sch:ns">
        <xsl:attribute name="{concat(@prefix,':dummy-for-xmlns')}" namespace="{@uri}"/>
      </xsl:for-each>
      <xsl:apply-templates select="." mode="check"/>
      <axsl:template match="/">
        <result>
          <axsl:apply-templates select="/" mode="all"/>
        </result>
      </axsl:template>
      <!-- <EMAIL>: add sch:let -->
      <xsl:apply-templates select="sch:let"/>
      <!-- <EMAIL>: use xsl:key instead of sch:key -->
      <xsl:apply-templates select="xsl:key|sch:diagnostics/sch:diagnostic"/>
      <xsl:choose>
        <xsl:when test="normalize-space($phase)='#DEFAULT' and @defaultPhase">
          <xsl:call-template name="process-phase">
            <xsl:with-param name="p" select="normalize-space(@defaultPhase)"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:when test="normalize-space($phase)='#DEFAULT'">
          <xsl:call-template name="process-phase">
            <xsl:with-param name="p" select="'#ALL'"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:call-template name="process-phase">
            <xsl:with-param name="p" select="normalize-space($phase)"/>
          </xsl:call-template>
        </xsl:otherwise>
      </xsl:choose>
      <axsl:template match="*|/" mode="all">
        <axsl:apply-templates select="*" mode="all"/>
      </axsl:template>
      <xsl:call-template name="define-location"/>
    </axsl:stylesheet>
  </xsl:template>
  
  <xsl:template name="process-phase">
    <xsl:param name="p"/>
    <xsl:choose>
      <xsl:when test="$p='#ALL'">
        <!-- <EMAIL>: hanle let inside phase -->
        <xsl:apply-templates select="sch:phase/sch:let"/>
        <xsl:call-template name="process-patterns">
          <xsl:with-param name="patterns" select="sch:pattern"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <!-- <EMAIL>: handle let -->
        <xsl:apply-templates select="key('phase',$p)/sch:let"/>
              
        <xsl:variable name="active-patterns" select="key('phase',$p)/sch:active/@pattern"/>
        <xsl:call-template name="process-patterns">
          <xsl:with-param name="patterns" select="
{'fraction_non_alphanumeric': 0.2043658765233695, 'fraction_numerical': 0.004017677782241864, 'mean_word_length': 3.195505617977528, 'pattern_counts': {'":': 0, '<': 142, '<?xml version=': 0, '>': 140, 'https://': 0, 'lorem ipsum': 0, 'www.': 10, 'xml': 24}, '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': '6444776', 'n_tokens_mistral': 2700, 'n_tokens_neox': 2522, 'n_words': 342}