<commit_before><?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:exist="http://exist.sourceforge.net/NS/exist" 
  exclude-result-prefixes="exist" 
  version="1.0">

  <xsl:import href="toc.xsl"/> 
  <xsl:import href="summary.xsl"/> 
  
  <xsl:param name="mode"/>
  <!-- any parameters to be added to urls within the site (e.g., for passing keywords) -->
  <xsl:param name="url_suffix"/>

  <!-- strings for translating case -->
  <xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'"/>
  <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
  
  <xsl:template match="/">
    <xsl:choose>
      <xsl:when test="$mode = 'full'">
        <xsl:apply-templates/>
      </xsl:when>
      <xsl:otherwise>

        <div id="toc">	
          <h1>Table of Contents</h1>
          <hr/>
          <xsl:apply-templates select="//toc/ead/archdesc" mode="toc"/>


        </div>

        <!--start content-->
        <div id="content">
          <!--          <xsl:apply-templates select="//results/ead/eadheader/filedesc/titlestmt"/>-->
          <xsl:apply-templates select="//results/ead"/>		
        </div>
        
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="titlestmt">
    <div id="title">
      <xsl:if test="$mode != 'full'">
        <!-- print link 
             (kind of a hack: inside title div to float above title bar lined up at the right)
             -->
        <div id="printable">
          <a>
            <xsl:attribute name="onclick">javascript:pdfnotify('pdf.php?id=<xsl:value-of select="//ead/@id"/>')</xsl:attribute>
            <xsl:attribute name="href">pdf.php?id=<xsl:value-of select="//ead/@id"/></xsl:attribute>
            Print finding aid (PDF)
          </a>
        </div>
      </xsl:if>

      <xsl:apply-templates select="titleproper | subtitle"/>
    </div>
  </xsl:template>

  <!-- unused in our documents? -->
  <xsl:template match="titlestmt/subtitle">
    <xsl:element name="span">
      <xsl:attribute name="class">content_subtitle</xsl:attribute>
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>


  <xsl:template match="publicationstmt">
    <div id="publicationstmt">
      <xsl:apply-templates/>
    </div>
  </xsl:template>

  <xsl:template match="publicationstmt/publisher">
    <h3><xsl:apply-templates/></h3>
  </xsl:template>

  <xsl:template match="publicationstmt/address">
    <h4><xsl:apply-templates/></h4>
  </xsl:template>

 <xsl:template match="addressline">
   <p class="tight"><xsl:apply-templates/></p>
 </xsl:template> 

 <!-- templates to ignore for now -->
 <xsl:template match="eadid|author|publicationstmt/date|profiledesc"/>

  <!-- date document was encoded; currently not displayed -->
  <xsl:template match="publicationstmt/date"/>

  <!-- archive description -->
  <xsl:template match="ead/archdesc">
   <div class="content">
     <xsl:apply-templates select="did" />

     <hr/>
     
     <xsl:element name="h2">
       <a>
         <xsl:attribute name="name">adminInfo</xsl:attribute>
         Administrative Information
       </a> 
     </xsl:element>
     
     <!-- display the following fields, in this specific order -->
     <xsl:apply-templates select="accessrestrict"/>
     <xsl:apply-templates select="userestrict"/>
     <xsl:apply-templates select="altformavail"/>
     <xsl:apply-templates select="originalsloc"/>
     <xsl:apply-templates select="bibliography"/>
     <xsl:apply-templates select="relatedmaterial"/>
     <xsl:apply-templates select="separatedmaterial"/>
     <xsl:apply-templates select="acqinfo"/>
     <xsl:apply-templates select="custodhist"/>
     <xsl:apply-templates select="prefercite"/>
     
     <hr/>
     
     <xsl:element name="h2">
       <a>
         <xsl:attribute name="name">collectionDesc</xsl:attribute>
         Collection Description
       </a>
     </xsl:element>
     <!-- display the following fields, in this specific order -->
     <xsl:apply-templates select="bioghist"/>
     <xsl:apply-templates select="scopecontent"/>
     <xsl:apply-templates select="arrangement"/>
     <xsl:apply-templates select="otherfindaid"/>
     
     
     <!-- don't display search terms in full/printable (pdf) version -->
     <xsl:if test="$mode != 'full'">
       <hr/>
       <xsl:apply-templates select="controlaccess"/>     
     </xsl:if>

     <hr/>
     
     <xsl:apply-templates select="dsc"/>     
     
   </div>
 </xsl:template>

 <xsl:template match="archdesc/did">
   <hr/>
    <xsl:element name="h2">

      <a>
        <xsl:attribute name="name">descriptiveSummary</xsl:attribute>	
        Descriptive Summary
      </a>
    </xsl:element>

    <table id="descriptivesummary">
      <col width="20%" align="left" valign="top"/>
      <col width="80%" align="left" valign="top"/>
      <xsl:apply-templates/>
    </table>

 </xsl:template>

 <!-- don't display repository; redundant information -->
 <xsl:template match="archdesc/did/repository"/>

 <xsl:template match="archdesc/did/*">
   <xsl:variable name="name"><xsl:value-of select="local-name()"/></xsl:variable>
   
   <xsl:variable name="label">
     <xsl:choose>
       <xsl:when test="$name = 'unittitle'">Title:</xsl:when>
       <xsl:when test="$name = 'unitid'">Call Number:</xsl:when>
       <!-- only display extent label once even if there are multiple physdesc elements -->
       <xsl:when test="$name = 'physdesc' and preceding-sibling::physdesc"></xsl:when>
       <xsl:when test="$name = 'physdesc'">Extent:</xsl:when>
       <xsl:when test="$name = 'origination'">Creator:</xsl:when>
       <xsl:when test="$name = 'langmaterial'">Language:</xsl:when>
       <xsl:otherwise>
         <!-- use element name for label; capitalize the first letter -->
         <xsl:value-of select="concat(translate(substring($name,1,1),$lowercase, $uppercase),substring($name, 2, (string-length($name) - 1)))"/>: 
       </xsl:otherwise>
     </xsl:choose>
   </xsl:variable>
   
   <tr>
     <th>
       <xsl:value-of select="$label"/>
     </th><commit_msg>fixed display problem for content view with keyword highlighting<commit_after><?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:exist="http://exist.sourceforge.net/NS/exist" 
  exclude-result-prefixes="exist" 
  version="1.0">

  <xsl:import href="toc.xsl"/> 
  <xsl:import href="summary.xsl"/> 
  
  <xsl:param name="mode"/>
  <!-- any parameters to be added to urls within the site (e.g., for passing keywords) -->
  <xsl:param name="url_suffix"/>

  <!-- strings for translating case -->
  <xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'"/>
  <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
  
  <xsl:template match="/">
    <xsl:choose>
      <xsl:when test="$mode = 'full'">
        <xsl:apply-templates/>
      </xsl:when>
      <xsl:otherwise>

        <div id="toc">	
          <h1>Table of Contents</h1>
          <hr/>
          <xsl:apply-templates select="//toc/ead/archdesc" mode="toc"/>


        </div>

        <!--start content-->
        <div id="content">
          <!--          <xsl:apply-templates select="//results/ead/eadheader/filedesc/titlestmt"/>-->
          <xsl:apply-templates select="//results/ead"/>		
        </div>
        
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="titlestmt">
    <div id="title">
      <xsl:if test="$mode != 'full'">
        <!-- print link 
             (kind of a hack: inside title div to float above title bar lined up at the right)
             -->
        <div id="printable">
          <a>
            <xsl:attribute name="onclick">javascript:pdfnotify('pdf.php?id=<xsl:value-of select="//ead/@id"/>')</xsl:attribute>
            <xsl:attribute name="href">pdf.php?id=<xsl:value-of select="//ead/@id"/></xsl:attribute>
            Print finding aid (PDF)
          </a>
        </div>
      </xsl:if>

      <xsl:apply-templates select="titleproper | subtitle"/>
    </div>
  </xsl:template>

  <!-- unused in our documents? -->
  <xsl:template match="titlestmt/subtitle">
    <xsl:element name="span">
      <xsl:attribute name="class">content_subtitle</xsl:attribute>
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>


  <xsl:template match="publicationstmt">
    <div id="publicationstmt">
      <xsl:apply-templates/>
    </div>
  </xsl:template>

  <xsl:template match="publicationstmt/publisher">
    <h3><xsl:apply-templates/></h3>
  </xsl:template>

  <xsl:template match="publicationstmt/address">
    <h4><xsl:apply-templates/></h4>
  </xsl:template>

 <xsl:template match="addressline">
   <p class="tight"><xsl:apply-templates/></p>
 </xsl:template> 

 <!-- templates to ignore for now -->
 <xsl:template match="eadid|author|publicationstmt/date|profiledesc"/>

  <!-- date document was encoded; currently not displayed -->
  <xsl:template match="publicationstmt/date"/>

  <!-- archive description -->
  <xsl:template match="ead/archdesc">
   <div class="content">
     <xsl:apply-templates select="did" />

     <hr/>
     
     <xsl:element name="h2">
       <a>
         <xsl:attribute name="name">adminInfo</xsl:attribute>
         Administrative Information
       </a> 
     </xsl:element>
     
     <!-- display the following fields, in this specific order -->
     <xsl:apply-templates select="accessrestrict"/>
     <xsl:apply-templates select="userestrict"/>
     <xsl:apply-templates select="altformavail"/>
     <xsl:apply-templates select="originalsloc"/>
     <xsl:apply-templates select="bibliography"/>
     <xsl:apply-templates select="relatedmaterial"/>
     <xsl:apply-templates select="separatedmaterial"/>
     <xsl:apply-templates select="acqinfo"/>
     <xsl:apply-templates select="custodhist"/>
     <xsl:apply-templates select="prefercite"/>
     
     <hr/>
     
     <xsl:element name="h2">
       <a>
         <xsl:attribute name="name">collectionDesc</xsl:attribute>
         Collection Description
       </a>
     </xsl:element>
     <!-- display the following fields, in this specific order -->
     <xsl:apply-templates select="bioghist"/>
     <xsl:apply-templates select="scopecontent"/>
     <xsl:apply-templates select="arrangement"/>
     <xsl:apply-templates select="otherfindaid"/>
     
     
     <!-- don't display search terms in full/printable (pdf) version -->
     <xsl:if test="$mode != 'full'">
       <hr/>
       <xsl:apply-templates select="controlaccess"/>     
     </xsl:if>

     <hr/>
     
     <xsl:apply-templates select="dsc"/>     
     
   </div>
 </xsl:template>

 <xsl:template match="archdesc/did">
   <hr/>
    <xsl:element name="h2">

      <a>
        <xsl:attribute name="name">descriptiveSummary</xsl:attribute>	
        Descriptive Summary
      </a>
    </xsl:element>

    <table id="descriptivesummary">
      <col width="20%" align="left" valign="top"/>
      <col width="80%" align="left" valign="top"/>
      <xsl:apply-templates/>
    </table>

 </xsl:template>

 <!-- don't display repository; redundant information -->
 <xsl:template match="archdesc/did/repository"/>

 <xsl:template match="archdesc/did/*[not(self::hits)]">
   <xsl:variable name="name"><xsl:value-of select="local-name()"/></xsl:variable>
   
   <xsl:variable name="label">
     <xsl:choose>
       <xsl:when test="$name = 'unittitle'">Title:</xsl:when>
       <xsl:when test="$name = 'unitid'">Call Number:</xsl:when>
       <!-- only display extent label once even if there are multiple physdesc elements -->
       <xsl:when test="$name = 'physdesc' and preceding-sibling::physdesc"></xsl:when>
       <xsl:when test="$name = 'physdesc'">Extent:</xsl:when>
       <xsl:when test="$name = 'origination'">Creator:</xsl:when>
       <xsl:when test="$name = 'langmaterial'">Language:</xsl:when>
       <xsl:otherwise>
         <!-- use element name for label; capitalize the first letter -->
         <xsl:value-of select="concat(translate(substring($name,1,1),$lowercase, $uppercase),substring($name, 2, (string-length($name) - 1)))"/>: 
       </xsl:otherwise>
     </xsl:choose>
   </xsl:variable>
   
   <tr>
     <th>
       <xsl:value-of select="$label"/>
     </th>
{'fraction_non_alphanumeric': 0.18098510882016036, 'fraction_numerical': 0.004254622811323842, 'mean_word_length': 2.918884257774928, 'pattern_counts': {'":': 0, '<': 341, '<?xml version=': 2, '>': 341, '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': '3914617', 'n_tokens_mistral': 4143, 'n_tokens_neox': 3721, 'n_words': 717}