<!---

transcription.cfm

  This file:

  1) looks in the directory specified by "transcriptDir"
  2) finds the XML file(s) specified by "transcription"
  3) transforms the XML into HTML [using the stylesheet specified by "mode"]
  4) clips the HTML to the <div> specified by "transcriptDiv" [optional]
  5) outputs the HTML

  PARAMETERS:
    transcriptDir = the abbreviated name of the directory containing the transcription
    transcript    = the filename of the XML transcription
    transcriptDiv = [optional] the id of a specific <div> to display
                    (suppressing other divs in the file)
    mode          = [optional] the viewing mode, which corresponds to an XSL stylesheet

--->

<!--- SETUP PAGE LAYOUT --->



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>
<HEAD>
	<title>Massachusetts Historical Society | On View</title>

<link rel="stylesheet" type="text/css" href="http://www.thomasjeffersonpapers.org/xsl/transcription.css" />

<LINK rel="stylesheet" href="../styles/style_no_conflicts.css" type="text/css" />

<SCRIPT language="JavaScript" src="../scripts/script_global.js" type="text/JavaScript"></SCRIPT>
</HEAD>



<cfinclude template="../incl/header_alt.cfm">


<span class="sectionTitle">&nbsp;&nbsp;<i>Transcription Viewer</i></span><br>
<br>

<table width="80%" align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>

<cfquery name=itemQuery datasource="mhs_mssql" username="bshl" password="bshl2001">
SELECT * FROM on_view WHERE ID=#queryID#
</cfquery>  

<cfoutput query=itemQuery>

<!--- display caption with short description --->

<span class="pageTitleSm">

<cfif isdefined("realTitle") AND (realTitle is not "")>
<i>#realTitle#</i>
<cfelse>
#createdTitle#
</cfif>
</span><BR>

<SPAN class="text1sm">
<cfif isdefined("media") AND (media is not "")>
#media# 
</cfif>
<cfif isdefined("makerPrep") AND (makerPrep is not "")>
	<cfif isdefined("makerVisible") AND (makerVisible is not "false")>
	#makerPrep# 
	</cfif>
</cfif>
<cfif isdefined("maker") AND (maker is not "")>
	<cfif isdefined("makerVisible") AND (makerVisible is not "false")>
	#maker#, 
	</cfif>
</cfif>
<cfif isdefined("creationDate") AND (creationDate is not "")>
	<cfif isdefined("dateVisible") AND (dateVisible is not "false")>
	#creationDate#
	</cfif>
</cfif><br>
<cfif isdefined("dimensions") AND (dimensions is not "")>
#dimensions#<br>
</cfif>
<cfif isdefined("additional") AND (additional is not "")>
	<cfif isdefined("additionalVisible") AND (additionalVisible is not "false")>
	#additional#<br>
	</cfif>
</cfif>

<cfif isdefined("parent") AND (parent is not "")>
#parent#
</cfif>
<cfif isdefined("grandparent") AND (grandparent is not "")>
, #grandparent#
</cfif><br>

</SPAN>


<a href="query3.cfm?queryID=#queryID#" class="text1sm">Return to full description</a>
</cfoutput>
<hr size="1" width="100%" noshade color="C8D0E0">


<!--- CHECK PARAMETERS --->
<CFIF not(isDefined('transcript')) or transcript is "">
  <h1>ERROR: 'transcript' was not specified.</h1>
  <CFABORT>
</CFIF>

<CFIF not(isDefined('transcriptDir')) or transcriptDir is "">
  <h1>ERROR: 'transcriptDir' was not specified.</h1>
  <CFABORT>
</CFIF>

<CFIF not(isDefined('transcriptDiv')) >
  <CFSET transcriptDiv="">
</CFIF>

<CFIF not(isDefined('mode')) >
  <CFSET mode="">
</CFIF>


<!--- FIND THE TRANSCRIPTION FILE --->
<CFSWITCH expression="#transcriptDir#">
<CFCASE value="masshist">
  <CFSET xmlFile="/var/www/html/database/transcriptions/#transcript#"></CFCASE>
<CFCASE value="adams-autobio">
  <CFSET xmlFile="/var/www/html/digitaladams/aea/autobio/xml/#transcript#"></CFCASE>
<CFCASE value="adams-diary">
  <CFSET xmlFile="/var/www/html/digitaladams/aea/diary/xml/#transcript#"></CFCASE>
<CFCASE value="adams-letter">
  <CFSET xmlFile="/var/www/html/digitaladams/aea/letter/xml/#transcript#"></CFCASE>
<CFCASE value="tjp-arch">
  <CFSET xmlFile="/var/www/html/thomasjeffersonpapers/arch/xml/#transcript#"></CFCASE>
<CFCASE value="tjp-catalog1783">
  <CFSET xmlFile="/var/www/html/thomasjeffersonpapers/catalog1783/xml/#transcript#"></CFCASE>
<CFCASE value="tjp-catalog1789">
  <CFSET xmlFile="/var/www/html/thomasjeffersonpapers/catalog1789/xml/#transcript#"></CFCASE>
<CFCASE value="tjp-declaration">
  <CFSET xmlFile="/var/www/html/thomasjeffersonpapers/declaration/xml/#transcript#"></CFCASE>
<CFCASE value="tjp-farm">
  <CFSET xmlFile="/var/www/html/thomasjeffersonpapers/farm/xml/#transcript#"></CFCASE>
<CFCASE value="tjp-garden">
  <CFSET xmlFile="/var/www/html/thomasjeffersonpapers/garden/xml/#transcript#"></CFCASE>
<CFCASE value="tjp-virginia">
  <CFSET xmlFile="/var/www/html/thomasjeffersonpapers/virginia/xml/#transcript#"></CFCASE>
<CFDEFAULTCASE>
  <h1>ERROR: The value of 'transcriptDir' is invalid.</h1>
  <CFABORT>
</CFDEFAULTCASE>
</CFSWITCH>

<!--- FIND THE TRANSCRIPTION FILE 
<CFSWITCH expression="#transcriptDir#">
<CFCASE value="masshist">
  <CFSET xmlFile="D:\WEB\masshist\database\transcriptions\#transcript#"></CFCASE>
<CFCASE value="adams-autobio">
  <CFSET xmlFile="D:\WEB\masshist\digitaladams\aea\autobio\xml\#transcript#"></CFCASE>
<CFCASE value="adams-diary">
  <CFSET xmlFile="D:\WEB\masshist\digitaladams\aea\diary\xml\#transcript#"></CFCASE>
<CFCASE value="adams-letter">
  <CFSET xmlFile="D:\WEB\masshist\digitaladams\aea\letter\xml\#transcript#"></CFCASE>
<CFCASE value="tjp-arch">
  <CFSET xmlFile="D:\WEB\masshist\thomasjeffersonpapers2\arch\xml\#transcript#"></CFCASE>
<CFCASE value="tjp-catalog1783">
  <CFSET xmlFile="D:\WEB\masshist\thomasjeffersonpapers2\catalog1783\xml\#transcript#"></CFCASE>
<CFCASE value="tjp-catalog1789">
  <CFSET xmlFile="D:\WEB\masshist\thomasjeffersonpapers2\catalog1789\xml\#transcript#"></CFCASE>
<CFCASE value="tjp-declaration">
  <CFSET xmlFile="D:\WEB\masshist\thomasjeffersonpapers2\declaration\xml\#transcript#"></CFCASE>
<CFCASE value="tjp-farm">
  <CFSET xmlFile="D:\WEB\masshist\thomasjeffersonpapers2\farm\xml\#transcript#"></CFCASE>
<CFCASE value="tjp-garden">
  <CFSET xmlFile="D:\WEB\masshist\thomasjeffersonpapers2\garden\xml\#transcript#"></CFCASE>
<CFCASE value="tjp-virginia">
  <CFSET xmlFile="D:\WEB\masshist\thomasjeffersonpapers2\virginia\xml\#transcript#"></CFCASE>
<CFDEFAULTCASE>
  <h1>ERROR: The value of 'transcriptDir' is invalid.</h1>
  <CFABORT>
</CFDEFAULTCASE>
</CFSWITCH>
--->


<!--- LOAD THE DOCUMENT --->
<CFTRY>
   <!--- NH added line defining character set on 25 August 2006 --->
  <CFFILE action="read"
    file="#xmlFile#"
    variable="xmlDoc"
       charset="UTF-8">
  <CFCATCH>
    <h1>Error: The XML document was not found.</h1>
    <CFABORT>
  </CFCATCH>
</CFTRY>



<!--- FIND THE STYLESHEET --->
<CFSWITCH expression="#mode#">
  <CFDEFAULTCASE>
    <CFSET xslFile="/var/www/html/database/transcription-clean.xsl">
  </CFDEFAULTCASE>
  <CFCASE value="dirty">
    <CFSET xslFile="/var/www/html/database/transcription-dirty.xsl">
  </CFCASE>
</CFSWITCH>



<!--- LOAD THE STYLESHEET --->
<CFTRY>
  <CFFILE action="read"
    file="#xslFile#"
    variable="xslDoc">
  <CFCATCH>
    <h1>ERROR: The XSL stylesheet was not found.</h1>
    <CFABORT>
  </CFCATCH>
</CFTRY>

<cfset myxmlDoc = XmlParse(#xmlDoc#)>


<!--- TRANSFORM THE XML INTO HTML --->
<CFTRY>
  <CFSET htmlDoc = XMLTransform(myxmlDoc,xslDoc) >
  <CFCATCH>
    <h1>ERROR: The XML could not be transformed into HTML.  There was a problem with either the XML or the XSL file.</h1>
    <CFABORT>
  </CFCATCH>
</CFTRY>



<!--- CLIP TO THE SPECIFIED DIV --->
<CFIF transcriptDiv is not "">
  <CFIF REFind( '<a id="#transcriptDiv#"', htmlDoc )>
    <CFSET htmlDoc = REReplace( htmlDoc, '^.*?(<a id="#transcriptDiv#".*?)<a id=.*$', "\1\2") >
  <CFELSE>
    <h1>ERROR: The specified DIV could not be found in the XML.</h1>
    <CFABORT>
  </CFIF>
</CFIF>


<!--- OUTPUT CONTENT --->

<div class="padded">
<CFOUTPUT>#htmlDoc#</CFOUTPUT>
</div>




<!--- END LAYOUT --->

<hr size="1" width="100%" noshade color="C8D0E0">

</td></tr></table>


<br>
<br>
<br>
<cfinclude template="../incl/footer_alt.cfm">