<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="html" version="4.0" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"
  doctype-system="http://www.w3.org/TR/html4/strict.dtd"
  encoding="utf-8" indent="yes"/>
  
  <xsl:variable name="gpocollection">Public Papers of the Presidents of the United States</xsl:variable>
  <xsl:variable name="president" select="granule/fdsys-metadata/President"/>
  <xsl:variable name="dateIssued" select="granule/fdsys-metadata/dateIssued"/>
  <xsl:variable name="bookNumber" select="granule/fdsys-metadata/bookNumber"/>
  <xsl:variable name="firstPage" select="granule/fdsys-metadata/printPageRange/@first"/>
  <xsl:variable name="lastPage" select="granule/fdsys-metadata/printPageRange/@last"/>
  <!-- <xsl:variable name="book" select="XML/bookinfo"/>-->
  <xsl:variable name="gposource">From the U.S. Government Publishing Office, <A href="http://www.gpo.gov">http://www.gpo.gov</A></xsl:variable> 
    
  <xsl:template match="/">
    <html>
      <head>      	
        <title><xsl:value-of select="$gpocollection" /></title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <style type="text/css">
        	
        	.body { margin-left:50px;margin-right:50px; }
        	
        	.PGHEAD { display:block;width:100%;margin-top:24pt;margin-bottom:10pt;margin-left:0pt;margin-right:0pt;text-indent:0cm;font-style:normal;}
        
        	.PGHEAD2 { display:block;width:100%;margin-top:24pt;margin-bottom:10pt;margin-left:0pt;margin-right:0pt;text-indent:0cm;font-size:15pt;font-style:normal;}        	
        	
        	.titlehd1 {display:block;margin-top:20px;margin-bottom:20px;font-style:italic;text-align:center;font-size:15pt;}
        	
			.para { display:block;margin-top:10px;margin-bottom:10px;clear:both;width:100%; }
		
			.para2 { display:block;clear:both;margin-bottom:10px;width:100%;}
		
			.para-ital{display:block;margin-top:10px;margin-bottom:10px;clear:both;width:100%;font-style:italic;}
			
			.para-indent{display:block;text-align:justify;text-indent:10pt; margin-top:10px;margin-bottom:10px;clear:both;width:100%;}
			
			.item-date {text-align:left;margin-bottom:10px;width:100%;display:block;font-style:italic;font-size:14pt;}		
			
			.indexl1 {font-size:12pt;text-indent:0cm;display:block;text-align:left;margin-top:10px;margin-bottom:10px;font-size:12pt;}
			
			.indexl2 {font-size:12pt;display:block;margin-left:20px;margin-top:10px;margin-bottom:10px;font-size:12pt;}
			
			.indexl3 {font-size:12pt;display:block;margin-left:40px;margin-top:10px;margin-bottom:10px;font-size:12pt;}
		
			.Emphasis {font-style: Italic;}
			
			.break {page-break-after: always;}
			
			.date {display:block;margin-top:20px;margin-bottom:20px;font-style:italic;}
			
			.hd1 {display:block;margin-top:20px;margin-bottom:20px;font-style:italic;}			
					
			.hd2 {display:block;margin-top:20px;margin-bottom:20px;font-style:italic;}
					
			.hd3 {display: block;text-align: justify;text-indent: 10.079987pt;}	
						
			.appendix-title {display: block; width:100%; margin-top:20px;margin-bottom:10px;text-align:center;text-transform:uppercase;font-size:14pt}
			
			.appendix-head {font-style:italic;}
			
			.Title {display:block; font-weight:bold;}	
			
			.white-house {display:block;font-style:normal; font-size:13pt;text-align:left;}	
			
			.pres-sig {display:block; font-style:normal;text-align:right;text-transform:uppercase;font-size:13pt;font-weight:bold;}
			
			.ul { list-style-type: circle; } 
			
			.list-bullet {display:block; text-align:justify; margin-left:20px;margin-top:20px;}
			
			.prtpage {display:block; font-style:normal;text-align:right;margin-top:30px;margin-bottom:30px;margin-right:20px;}
			
			.president {display:block; font-size:25pt;font-weight:bold;text-align:center;}
			
			.image {display:block;width:100%;}
			
			.PRTPAGELN1 {display:block;border-bottom-style:solid;border-width:6px;border-color:black;padding-bottom:3pt;}
			
			.PRTPAGELN2 {display:block;border-bottom-style:solid;border-width:1px;border-color:black;margin-bottom:24pt;padding-bottom:3pt;}
			
			.bookinfo {display:block;text-align:center;font-size:25pt;font-weight:bold;}
			
			.Fraction {}
			.pubdate{}
			.name{}
			.no {}
			.note {}
			.ROW { display:table-row; }
			.TH {display:table-cell;}
			.CELL { display:table-cell } 						
			.A { color: blue;text-decoration: underline;}
				
		</style>
      </head>
      <body class="body">
        <center><h2>PUBLIC PAPERS OF THE PRESIDENTS OF THE UNITED STATES</h2></center>
        <xsl:apply-templates/>
      </body>
    </html>
  </xsl:template>
  
  <!-- Tags being Ignored -->
  <xsl:template match="fdsys-metadata | fdsys-metadata/President | fdsys-metadata/dateIssued | fdsys-metadata/bookNumber | fdsys-metadata/printPageRange | pppCategory | level1 | level2 | level3 
  						| list-bullet">
  </xsl:template>
  
	<xsl:template match="granule">	     
	     <span class="PGHEAD">   
	     	<hr/>
	       <xsl:text>Book: Public Papers of the Presidents of the United States: </xsl:text><xsl:value-of select="$president" /> (<xsl:value-of select="substring($dateIssued,0,5)"/>, Book <xsl:value-of select="$bookNumber"/>) <br/>
	       <xsl:text>Pages: </xsl:text><xsl:value-of select="$firstPage"/> To <xsl:value-of select="$lastPage"/><br/>
	       <span>From the U.S. Government Publishing Office, <a href="http://www.gpo.gov">http://www.gpo.gov</a></span>
	       <hr/>
	       <xsl:apply-templates/>	             
	 	</span> 	 	
	</xsl:template>     
	
	<xsl:template match="item-head">
	    <span class="PGHEAD2">
	       <xsl:apply-templates/>
	       <br/> 	       	       
	    </span>	    
	</xsl:template>
  	
  	<xsl:template match="para | para2 | para-ital | para-indent | Emphasis | item-date | indexl1 | indexl2 | indexl3 | date | name | appendix-title | appendix-head | Title |
  						white-house | pres-sig | hd1 | hd2 | hd3 | titlehd1">
      <span>
        <xsl:attribute name="class">
          <xsl:value-of select="name()"/>                   
        </xsl:attribute>
         <xsl:apply-templates/>
      </span>  
    </xsl:template>
  	
  	<xsl:template match="TABLE">  	
  		<TABLE style="width:100%;align:center;">  			
  			<!-- <xsl:choose>
  				<xsl:when test="count(ROW[position()=1]/CELL) &lt; 3 or count(ROW[position()=1]/TH) &lt; 3">
  					<xsl:attribute name="width">75%</xsl:attribute>
  				</xsl:when>
  				<xsl:otherwise>
  					<xsl:attribute name="width">100%</xsl:attribute>
  				</xsl:otherwise>
  			</xsl:choose>  -->
  			<xsl:apply-templates/>
  		</TABLE>
  	</xsl:template>
  	
  	<xsl:template match="ROW">
		<TR style="display:table-row;">
 			<xsl:if test="@COLSPAN">
	 			<xsl:attribute name="colspan">
	 				<xsl:value-of select="@COLSPAN" />
	 			</xsl:attribute>		  			
			</xsl:if>
			<xsl:if test="@ROWSPAN">
	 			<xsl:attribute name="rowspan">
	 				<xsl:value-of select="@ROWSPAN" />
	 			</xsl:attribute>
			</xsl:if>
			<xsl:apply-templates/>
		</TR>
  	</xsl:template>  
  	
  	<xsl:template match="TH">
		<TH style="text-align:left;display:table-cell;font-weight:bold;padding: 5px;">
 			<xsl:if test="@COLSPAN">
	 			<xsl:attribute name="colspan">
	 				<xsl:value-of select="@COLSPAN" />
	 			</xsl:attribute>		  			
			</xsl:if>
			<xsl:if test="@ROWSPAN">
	 			<xsl:attribute name="rowspan">
	 				<xsl:value-of select="@ROWSPAN" />
	 			</xsl:attribute>
			</xsl:if>
			<xsl:apply-templates/>
		</TH>
  	</xsl:template>  	  
  	
  	<xsl:template match="CELL">
		<TD style="text-align:left;display:table-cell;padding: 5px;">
 			<xsl:if test="@COLSPAN">
	 			<xsl:attribute name="colspan">
	 				<xsl:value-of select="@COLSPAN" />
	 			</xsl:attribute>		  			
			</xsl:if>
			<xsl:if test="@ROWSPAN">
	 			<xsl:attribute name="rowspan">
	 				<xsl:value-of select="@ROWSPAN" />
	 			</xsl:attribute>
			</xsl:if>
			<xsl:apply-templates/>
		</TD>
  	</xsl:template> 
  	
  	<xsl:template match="CellBody">
  		<xsl:apply-templates />
  	</xsl:template>
  	

  	<xsl:template match="FOOTNOTES">
  		<span class="para"><br/>*White House correction.
	    </span>
	</xsl:template>
  	
  	<xsl:template match="A[@CLASS='footnote']">
		<xsl:text>*</xsl:text>  		
	</xsl:template>
  	
  	<xsl:template match="List-BulletList">
  		<ul>
  			<xsl:apply-templates/>
  		</ul>
  	</xsl:template>
  	
  	<xsl:template match="list-bullet">
  		<li>
  			<span class="list-bullet">
  				<xsl:apply-templates/>
  			</span>
  		</li>
  	</xsl:template>
  	
  	<xsl:template match="PRTPAGE">  		
		<span class="prtpage">			
			<xsl:value-of select="@P" />
		</span>  
		<span class="PRTPAGELN2">
			<span class="PRTPAGELN1"> 
			</span>
		</span>
  	</xsl:template>
  	
  	<xsl:template match="b">  		
		<b>			
			<xsl:value-of select="." />
		</b>  
  	</xsl:template>    
  	
  	<!-- <xsl:template match="president">  		
		<span class="president">
			<xsl:value-of select="." />
		</span>  		
  	</xsl:template>
  	
  	
  	<xsl:template match="IMAGE">  				
		<span class="image">
			<img width="25%" height="25%">
				<xsl:attribute name="src"><xsl:value-of select="@href" /></xsl:attribute>
			</img>
		</span>
  	</xsl:template>-->
  	
  	<!-- <xsl:template match="bookinfo">  		
		<span class="bookinfo">
			<xsl:value-of select="." />
			<br/><br/>
			<hr width="25%" style="margin-top:100px;"/>
		</span>  		
		
  	</xsl:template> -->
  	
  	<xsl:template name="apply-span">
	    <span>
	      <xsl:attribute name="class">
	        <xsl:value-of select="name()"/><xsl:text> </xsl:text><xsl:value-of select="name(parent::*)"/>-<xsl:value-of select="name()"/>        
	      </xsl:attribute>
	      <xsl:apply-templates/>
	    </span> 
  	</xsl:template>
  
</xsl:stylesheet>