<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <!-- RCSID: $Id: dfg_imaps.xsl 1.6 2004/04/20 17:47:44 emiller modified with permission VCH 201412 $ -->
  <!-- 

    
    This stylesheet is based on the W3C XSLT 1.0 standard and has been tuned to work
    with MSXML 4.0.  It is known that the "br-replace" parameterized template does
    not work with the GNOME xsltproc program.  That program does not accept entity
    declarations for newlines or carriage returns as variables used in string functions
    but it will accept embedded newlines or carriage returns as variables (and MSXML
    does not).  Other than that, all templates should work with any XSLT processor
    that supports 1.0 of the W3C standard.

  -->
  <xsl:output method="html" 
	      cdata-section-elements="script style"
	      omit-xml-declaration="yes"
	      doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
	      doctype-system="http://www.w3.org/TR/html4/loose.dtd"
	      encoding="us-ascii"
	      />
  
  <xsl:template match="/">

    <html>
      <head>
	<xsl:call-template name="title" />
	<meta name="generator" content="dfg_imaps.xsl"/>
	<meta name="author" content="Eric G. Miller"/>
	<meta name="copyright" content="2004, California Department of Fish and Game"/>
	<!-- do not use "description" for a meta "name" as IE matches to it with the
	     document.getElementById("Description") javascript function even though
	     name != id
	-->
	
	<meta name="about" content="Look and Feel adapted from ESRI stylesheets."/>
	<style type="text/css">
	
<![CDATA[
body {padding: 0.9px; margin: 0.25in; font-size: 12pt; color: #005d76;
    background-color: #ececea; font-family: Raleway,sans-serif;}

h1 { font-family: Raleway,sans-serif;}

img { border: solid 1px #668279; margin: 5px; }


#heading {font-size: 22px; font-weight: bold;text-align: center; color: #005d76;}
#subheading {font-size: 15px; font-weight: bold; text-align: center; color: #005d76;}

.label {font-weight: bold; font-size: 15px; 
   font-family: Raleway,sans-serif; color: #668279;}

.lworkcit {display: block; border-left: dashed 1px #cfcfcf;
    font-size: small; padding-left: 1em;}

.indent {margin-left: 20px; color: #000000;}

.hideShow {color: #738787; font-weight: bold;}

.hideShow:hover {color: #005d76; font-weight; bold;}

table#tabChoose {background-color: #668279;}
table#tabChoose td {text-align: center; font-weight: bold; font-size: 15px; 
    font-family: Raleway, sans-serif; padding: 5px;}
.tabActive { background-color: #89aea2;}
.tabActive a {color: #faf7f2;}
.tabInactive {background-color: #faf7f2;}
.tabInactive a {color: #668279;}

#box {border: solid 2px #668279; margin: 0px; padding: 10px; background-color: #ffffff;}
#Description {display: block;}
#Spatial {display: none;}
#Attributes {display: none;}

hr { background-color: #000000; border-style: none; 
    height: 1px; border-color: #668279; width: 150px; text-align: center; }

table.domain {
     border: solid 1px #668279;
}

table.domain thead {
     background-color: #EBF5FC;
     color: #738787;
     font-weight: bold;
}

table.domain th,td {
     padding: 2px 4px 2px 4px;
}

.seclabel { font-size: 18px; font-family: Raleway, sans-serif; 
    text-align: center; margin: 1em; color: #738787; font-weight: bold;}

]]>	
	</style>
	<script type="text/javascript">
<![CDATA[

var elements = {};

function init() {
   // populate our elements object
   elements.Description = document.getElementById("Description");
   elements.DescriptionTab = document.getElementById("DescriptionTab");
   elements.Spatial = document.getElementById("Spatial");
   elements.SpatialTab = document.getElementById("SpatialTab");
   elements.Attributes = document.getElementById("Attributes");
   elements.AttributesTab = document.getElementById("AttributesTab");
   elements.pair = [
                    {div:elements.Description, tab:elements.DescriptionTab},
		    {div:elements.Spatial, tab:elements.SpatialTab},
		    {div:elements.Attributes, tab:elements.AttributesTab}
		    ];
   elements.divChoose = document.getElementById("divChoose");
   elements.tabChoose = document.getElementById("tabChoose");
   return true;
}

function showAll() {
   var divs = document.getElementsByTagName("DIV");
   for (var i = 0; i < divs.length; i++) {
      divs[i].style.display = "block";
   }
   elements.divChoose.style.display = 'none';
   toggleSectionLabels(true);
   return false;
}

function showTabs() {
   // Collapse all divs beneath anchors with className = 'hideShow'
   var anchors = document.getElementsByTagName("A");
   for (var i = 0; i < anchors.length; i++) {
      if (anchors[i].className == 'hideShow') {
         var d = anchors[i].parentNode.getElementsByTagName("DIV")[0];
	 if (d) { d.style.display = 'none'; }
      }
   }

   // hide Spatial && Attributes divs, show Description
   elements.Spatial.style.display = 'none';
   elements.Attributes.style.display = 'none';
   elements.Description.style.display = 'block';

   // Hide section labels
   toggleSectionLabels(false);

   elements.divChoose.style.display = 'block';

   elements.DescriptionTab.className = 'tabActive';
   elements.AttributesTab.className = 'tabInactive';
   elements.SpatialTab.className = 'tabInactive';
   return false;
}

function toggleSectionLabels(on) {
   var h2 = document.getElementsByTagName("H2");
   for (var i = 0; i < h2.length; i++) {
      if (h2[i].className == 'seclabel') {
         h2[i].style.display = (on) ? 'block' : 'none';
      }
   }
}

function hideShow(e) {
   var p = e.parentNode;
   var d = p.getElementsByTagName("DIV")[0];
   if (d) {
     if (d.style.display == "none") {d.style.display = "block";}
     else {d.style.display = "none";}
   }
   return false;
}

function changeTab(a) {
   var td = a.parentNode;
   for (var i = 0; i < elements.pair.length; i++) {
      if (td == elements.pair[i].tab) {
         elements.pair[i].tab.className = 'tabActive';
	 elements.pair[i].div.style.display = 'block';
      }
      else {
         elements.pair[i].tab.className = 'tabInactive';
         elements.pair[i].div.style.display = 'none';
      }
   }
   return false;
}

function ieSaveAs(p) {
   // Add a "Save As" hyperlink if supported by the browser (IE > 4)
   if (p && p.nodeName && p.nodeName == "P") {
      try {
         if (document.queryCommandEnabled('SaveAs')) {
	    p.appendChild(document.createTextNode(" | "));
	    var a = document.createElement("A");
	    a.href = "#";
	    a.className = "label";
	    a.appendChild(document.createTextNode("Save As"));
	    a.onclick = ieClickSave;
	    p.appendChild(a);
	 }
      }
      catch (e) {}
   }
}

function ieClickSave() {
   // Callback for onclick event in "ieSaveAs()"
   document.execCommand('SaveAs',null,'metadata.html');
   return false;
}
]]>
	</script>
      </head>
      <body onload="init()">
	<h1 id="heading">
	  <xsl:value-of select="metadata/idinfo/citation/citeinfo/title"/>
	</h1>
	<xsl:if test="metadata/idinfo/natvform[. != '']">
	  <h2 id="subheading">
	    <xsl:value-of select="metadata/idinfo/natvform"/>
	  </h2>
	</xsl:if>

	<p id="actionLinks">	  
	  <a class="label" href="#" onclick="return showAll();"
	  title="Show all sections for printing">Show All</a>
	  <xsl:text> | </xsl:text>
	  <a class="label" href="#" onclick="return showTabs();"
	  title="Collapse all sections and show tabs">Show Tabs</a>
	  <xsl:text> | </xsl:text>
	  <a class="label" href="javascript:print()"
	  title="Print the currently displayed sections">Print</a>
	  <script type="text/javascript">
	    <![CDATA[
	    ieSaveAs(document.getElementById("actionLinks"));
	  ]]>
	  </script>
	</p>
	<div id="divChoose">
	  <table id="tabChoose" border="0" cellspacing="1" cellpadding="0">
	    <colgroup span="3" width="105"/>
	    <tr>
	      <td id="DescriptionTab" class="tabActive">
		<a href="#" onclick="return changeTab(this);">Description</a>
	      </td>
	      <td id="SpatialTab" class="tabInactive">
		<a href="#" onclick="return changeTab(this);">Spatial</a>
	      </td>
	      <td id="AttributesTab" class="tabInactive">
		<a href="#" onclick="return changeTab(this);">Attributes</a>
	      </td>
	    </tr>
	  </table>
	</div>
	<div id="box">
	  <div id="Description">
	    <h2 class="seclabel" style="display:none;">Description</h2>
	    <xsl:apply-templates select="metadata/Binary/Thumbnail[img/@src != '']" />
	    <span class="label">Keywords</span>
	    <div class="indent">
	      <xsl:apply-templates select="metadata/idinfo/keywords"/>
	    </div>
	    <br/>
	    <div>
	      <span class="label">Descriptive Information</span>
	      <div class="indent">
		<xsl:apply-templates select="metadata/idinfo/descript"/>
	      </div>
	    </div>
	    <hr/>
	    <xsl:apply-templates select="metadata/idinfo/status"/>
	    <br/>
	    <xsl:apply-templates select="metadata/idinfo/timeperd"/>
	    <br/>
	    <div id="citeinfo">
	      <a href="#" class="hideShow" onclick="return hideShow(this);">
		<xsl:text>Publication Information</xsl:text>
	      </a>
	      <div class="indent" style="display: none;">
		<xsl:apply-templates select="metadata/idinfo/citation/citeinfo"/>
	      </div>
	    </div>
	    <hr/>
	    <div id="storage">
	      <a href="#" class="hideShow" onclick="return hideShow(this);">
		<xsl:text>Data storage and access information</xsl:text>
	      </a>
	      <div class="indent" style="display: none;">
		<xsl:apply-templates select="metadata/distinfo"/>
		<xsl:if test="metadata/idinfo[accconst|useconst]">
		  <div id="constraints">
		    <a href="#" class="hideShow" onclick="return hideShow(this);">
		      <xsl:text>Constraints on accessing and using the data</xsl:text>
		    </a>
		    <div class="indent" style="display: none;">
		      <xsl:apply-templates select="metadata/idinfo/accconst"/>
		      <xsl:apply-templates select="metadata/idinfo/useconst"/>
		    </div>
		  </div>
		</xsl:if>
	      </div>
	    </div>
	    <br/>
	    <xsl:if test="metadata/idinfo/ptcontac">
	      <div id="ptcontac">
		<a href="#" class="hideShow" onclick="return hideShow(this);">
		  <xsl:text>Point of Contact</xsl:text>
		</a>
		<div class="indent" style="display: none;">
		  <xsl:apply-templates select="metadata/idinfo/ptcontac"/>
		</div>
	      </div>
	      <br/>
	    </xsl:if>
	    <div id="docdetails">
	      <a href="#" class="hideShow" onclick="return hideShow(this);">
		<xsl:text>Details about this Document</xsl:text>
	      </a>
	      <div class="indent" style="display: none;">
		<xsl:apply-templates select="metadata/metainfo"/>
	      </div>
	    </div>
	  </div>
	  <div id="Spatial">
	    <h2 class="seclabel" style="display:none;">Spatial Information</h2>
	    <xsl:apply-templates select="metadata/spref"/>
	    <hr/>
	    <xsl:apply-templates select="metadata/idinfo/spdom"/>
	    <hr/>
	    <xsl:apply-templates select="metadata/spdoinfo"/>
	  </div>
	  <div id="Attributes">
	    <h2 class="seclabel" style="display:none;">
	      <xsl:text>Entity and Attribute Information</xsl:text>
	    </h2>
	    <xsl:choose>
	      <xsl:when test="metadata/eainfo">
		<xsl:apply-templates select="metadata/eainfo"/>
	      </xsl:when>
	      <xsl:otherwise>
		Attribute information not available.
	      </xsl:otherwise>
	    </xsl:choose>
	  </div>
	</div>
      </body>
    </html>

  </xsl:template>

  <xsl:template match="Thumbnail[img/@src != '']">
    <div align="center">
      <img alt="thumbnail">
	<xsl:attribute name="src"><xsl:value-of select="img/@src"/></xsl:attribute>
      </img>
    </div>
  </xsl:template>

  <!-- output the head/title section -->
  <xsl:template name="title">
    <title>
      <xsl:value-of select="metadata/idinfo/citation/citeinfo/title"/>
    </title>
  </xsl:template>

  <xsl:template name="citeinfo" match="citeinfo">
    <em>Title: </em> 
    <xsl:value-of select="title"/>
    <br/>
    <xsl:if test="edition">
      <em>Edition: </em>
      <xsl:value-of select="edition"/>
      <br/>
    </xsl:if>
    <xsl:if test="serinfo">
      <em>Series: </em> 
      <xsl:value-of select="serinfo/sername"/>
      <xsl:text> &#8211; </xsl:text>
      <xsl:value-of select="serinfo/issue"/>
      <br/>
    </xsl:if>
    <em>Originator: </em>
    <xsl:for-each select="origin">
      <xsl:if test="position() &gt; 1">, </xsl:if>
      <xsl:apply-templates/>
    </xsl:for-each>
    <br/>
    <em>Publication Date: </em>
    <xsl:value-of select="pubdate"/>
    <xsl:text> </xsl:text>
    <xsl:value-of select="pubtime"/>
    <br/>
    <xsl:if test="pubinfo">
      <em>Publisher: </em>
      <xsl:value-of select="publish"/>
      <xsl:text>, </xsl:text>
      <xsl:value-of select="pubplace"/>
      <br/>
    </xsl:if>
    <xsl:if test="geoform">
      <em>Format: </em>
      <xsl:value-of select="geoform"/>
      <br/>
    </xsl:if>
    <xsl:if test="othercit">
      <em>Other: </em>
      <div class="indent">
	<xsl:call-template name="br-replace">
	  <xsl:with-param name="word">
	    <xsl:copy-of select="othercit"/>
	  </xsl:with-param>
	</xsl:call-template>
      </div>
      <br/>
    </xsl:if>
    <xsl:if test="onlink">
      <em>Online: </em>
      <xsl:value-of select="onlink"/>
      <br/>
    </xsl:if>
    <xsl:if test="lworkcit">
      <em>Larger Work: </em>
      <div class="lworkcit">
	<xsl:apply-templates select="lworkcit/citeinfo"/>
      </div>
    </xsl:if>
  </xsl:template>

  <xsl:template name="descript" match="descript">
    <div id="descript">
      <div id="abstract">
	<a class="hideShow" onclick="return hideShow(this);" 
	href="#">Abstract</a>
	<div class="indent">
	  <xsl:call-template name="br-replace">
            <xsl:with-param name="word">
	      <xsl:copy-of select="abstract"/>
	    </xsl:with-param>
	  </xsl:call-template>
	</div>
      </div>
      <div id="purpose">
	<a class="hideShow" onclick="return hideShow(this);" 
	href="#">Purpose</a>
	<div class="indent">
	  <xsl:call-template name="br-replace">
            <xsl:with-param name="word">
	      <xsl:copy-of select="purpose"/>
	    </xsl:with-param>
	  </xsl:call-template>
	</div>
      </div>
      <xsl:if test="supplinf">
	<div id="supplinf">
	  <a class="hideShow" onclick="return hideShow(this);"
	     href="#">Supplemental Information</a>
	  <div class="indent" style="display: none;">
	    <xsl:call-template name="br-replace2">
	      <xsl:with-param name="word">
		<xsl:copy-of select="supplinf"/>
	      </xsl:with-param>
	    </xsl:call-template>
	  </div>
	</div>
      </xsl:if>
    </div>
  </xsl:template>

  <xsl:template name="timeperd" match="timeperd">
    <div id="timeperd">
      <a class="hideShow" onclick="return hideShow(this);" 
	 href="#">Time period for which the data is relevant</a>
      <div class="indent" style="display: none;">
	<xsl:apply-templates select="timeinfo"/>
	<xsl:text> </xsl:text>
	<xsl:apply-templates select="current"/>
      </div>
    </div>
  </xsl:template>

  <xsl:template name="timeinfo" match="timeinfo">
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template name="sngdate" match="sngdate">
    <xsl:value-of select="caldate"/>
    <xsl:text> </xsl:text>
    <xsl:value-of select="time"/>
  </xsl:template>

  <xsl:template name="mdattim" match="mdattim">
    <xsl:for-each select="sngdate">
      <xsl:if test="position() &gt; 1">, </xsl:if>
      <xsl:apply-templates/>
    </xsl:for-each>
  </xsl:template>

  <xsl:template name="rngdates" match="rngdates">
    <xsl:value-of select="begdate"/>
    <xsl:text> </xsl:text>
    <xsl:value-of select="begtime"/>
    <xsl:text> &#8211; </xsl:text>
    <xsl:value-of select="enddate"/>
    <xsl:text> </xsl:text>
    <xsl:value-of select="endtime"/>
  </xsl:template>

  <xsl:template name="current" match="current">
    <xsl:text>(</xsl:text>
    <xsl:apply-templates />
    <xsl:text>)</xsl:text>
  </xsl:template>

  <xsl:template name="status" match="status">
    <div id="status">
      <a class="hideShow" onclick="return hideShow(this);" 
         href="#">Status of the data</a>
      <div class="indent" style="display: none;">
	<em>Progress: </em><xsl:value-of select="progress"/>
	<br/>
	<em>Update Frequency: </em><xsl:value-of select="update"/>
      </div>
    </div>
  </xsl:template>

  <xsl:template name="br-replace">
    <xsl:param name="word"/>
    <!-- </xsl:text> on next line on purpose to get newline -->
    <xsl:variable name="nl"><xsl:text>&#xA;</xsl:text></xsl:variable>
    <xsl:variable name="cr"><xsl:text>&#xD;</xsl:text></xsl:variable>
    <xsl:choose>
      <xsl:when test="contains($word,$cr)">
	<xsl:value-of select="translate(substring-before($word,$nl),$cr,' ')"/>
	<br/>
	<xsl:call-template name="br-replace">
	  <xsl:with-param name="word" 
			  select="substring-after($word,$nl)"/>
	</xsl:call-template>
      </xsl:when>
      <xsl:when test="string-length($word)=0"/>
      <xsl:otherwise>
	<xsl:value-of select="translate(translate($word,$cr,' '),$nl,' ')"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="br-replace2">
    <xsl:param name="word"/>
    <xsl:variable name="beginPre">
      <xsl:text>-- BEGIN ORIGINAL METADATA</xsl:text>
    </xsl:variable>
    <xsl:variable name="endPre">
      <xsl:text>-- END ORIGINAL METADATA --</xsl:text>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="contains($word,$beginPre) and contains($word,$endPre)">
	<xsl:call-template name="br-replace">
	  <xsl:with-param name="word">
	    <xsl:copy-of select="substring-before($word,$beginPre)"/>
	  </xsl:with-param>
	</xsl:call-template>
	<pre>
	  <xsl:value-of select="$beginPre"/><xsl:copy-of 
	  select="substring-before(substring-after($word,$beginPre),$endPre)"/>
	  <xsl:value-of select="$endPre"/>
	</pre>
	<xsl:call-template name="br-replace">
	  <xsl:with-param name="word">
	    <xsl:copy-of select="substring-after($word,$endPre)"/>
	  </xsl:with-param>
	</xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
	<xsl:call-template name="br-replace">
	  <xsl:with-param name="word">
	    <xsl:copy-of select="$word"/>
	  </xsl:with-param>
	</xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="spdom" match="spdom[bounding|lboundng|minalti|maxalti|altunits]">
    <div id="spdom">
      <span class="label">Bounding Coordinates</span>
      <div class="indent">
	<xsl:if test="bounding|lboundng">
	  <span class="label">Horizontal</span>
	  <div class="indent">
	    <xsl:apply-templates select="bounding"/>
	    <xsl:apply-templates select="lboundng"/>
	  </div>
	  <br/>
	</xsl:if>
	<xsl:if test="minalti|maxalti|altunits">
	  <span class="label">Vertical</span>
	  <div class="indent">
	    <xsl:apply-templates select="minalti|maxalti|altunits"/>
	  </div>
	</xsl:if>
      </div>
    </div>
  </xsl:template>
  
  <xsl:template name="bounding" match="bounding">
    <div id="bounding">
      <span class="label">In decimal degrees</span>
      <div class="indent">
	<table border="0" cellspacing="0" cellpadding="0">
	  <tr>
	    <td align="right">West:</td>
	    <td>&#160;</td>
	    <td align="right"><xsl:value-of select="westbc"/></td>
	  </tr>
	  <tr>
	    <td align="right">East:</td>
	    <td>&#160;</td>
	    <td align="right"><xsl:value-of select="eastbc"/></td>
	  </tr>
	  <tr>
	    <td align="right">North:</td>
	    <td>&#160;</td>
	    <td align="right"><xsl:value-of select="northbc"/></td>
	  </tr>
	  <tr>
	    <td align="right">South:</td>
	    <td>&#160;</td>
	    <td align="right"><xsl:value-of select="southbc"/></td>
	  </tr>
	</table>
      </div>
    </div>
  </xsl:template>

  <xsl:template name="lboundng" match="lboundng">
    <div id="lboundng">
      <span class="label">In projected coordinates</span>
      <div class="indent">
	<table border="0" cellspacing="0" cellpadding="0">
	  <tr>
	    <td align="right">Left:</td>
	    <td>&#160;</td>
	    <td align="right"><xsl:value-of select="leftbc"/></td>
	  </tr>
	  <tr>
	    <td align="right">Right:</td>
	    <td>&#160;</td>
	    <td align="right"><xsl:value-of select="rightbc"/></td>
	  </tr>
	  <tr>
	    <td align="right">Top:</td>
	    <td>&#160;</td>
	    <td align="right"><xsl:value-of select="topbc"/></td>
	  </tr>
	  <tr>
	    <td align="right">Bottom:</td>
	    <td>&#160;</td>
	    <td align="right"><xsl:value-of select="bottombc"/></td>
	  </tr>
	</table>
      </div>
    </div>
  </xsl:template>
    
  <xsl:template name="minalti" match="minalti">
    <em>Minimum Altitude: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="maxalti" match="maxalti">
    <em>Maximum Altitude: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="altunits" match="altunits">
    <em>Altitude Units: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="spdoinfo" match="spdoinfo">
    <div id="spdoinfo">
      <span class="label">Spatial data description</span>
      <div class="indent">
	<xsl:apply-templates select="indsprdf"/>
	<xsl:apply-templates select="ptvctinf|rastinfo"/>
      </div>
    </div>
  </xsl:template>

  <xsl:template name="indsprdf" match="indsrdf">
    <div id="indsprdf">
      <a href="#" class="hideShow" onclick="return hideShow(this);">
	Indirect spatial reference
      </a>
      <div class="indent" style="display: none;">
	<xsl:call-template name="br-replace">
	  <xsl:with-param name="word">
	    <xsl:copy-of select="."/>
	  </xsl:with-param>
	</xsl:call-template>
      </div>
    </div>
  </xsl:template>

  <xsl:template name="ptvctinf" match="ptvctinf">
    <span class="label">Vector data information</span>
    <div class="indent">
      <xsl:if test="esriterm">
	<div id="esriterms">
	  <a href="#" class="hideShow" onclick="return hideShow(this);">
	    <acronym title="Environmental Systems Research Institute, Inc.">
	      <xsl:text>ESRI</xsl:text>
	    </acronym>
	    description
	  </a>
	  <div class="indent" style="display: none;">
	    <xsl:apply-templates select="esriterm"/>
	  </div>
	</div>
      </xsl:if>
      <xsl:if test="sdtsterm">
	<div id="sdtsterms">
	  <a href="#" class="hideShow" onclick="return hideShow(this);">
	    <acronym title="Spatial Data Transfer Standard">
	      <xsl:text>SDTS</xsl:text>
	    </acronym>
	    description
	  </a>
	  <div class="indent" style="display: none">
	    <xsl:apply-templates select="sdtsterm"/>
	  </div>
	</div>
      </xsl:if>
      <xsl:apply-templates select="vpfterm"/>
    </div>
  </xsl:template>

  <xsl:template name="esriterm" match="esriterm">
    <xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="efeatyp" match="efeatyp">
    <em>Feature Type: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="efeageom" match="efeageom">
    <em>Feature Geometry: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="esritopo" match="esritopo">
    <em>Topology: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="efeacnt" match="efeacnt">
    <em>Feature Count: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="spindex" match="spindex">
    <em>Spatial Index: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="linrefer" match="linrefer">
    <em>Linear Referencing: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="netwrole" match="netwrole">
    <em>Network Role: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="XYRank" match="XYRank">
    <em>XY Rank: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="ZRank" match="ZRank">
    <em>Z Rank: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="topoWeight" match="topoWeight">
    <em>Topology Weight: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="validateEvents" match="validateEvents">
    <em>Events on Validation: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="partTopoRules" match="partTopoRules">
    <em>Participates in Topology Rules:</em>
    <div class="indent">
      <xsl:apply-templates/>
    </div>
  </xsl:template>

  <xsl:template name="topoRuleID" match="topoRuleID">
    <em>Rule: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="featdesc" match="featdesc">
    <em>Feature Description:</em>
    <div class="indent">
      <xsl:call-template name="br-replace">
	<xsl:with-param name="word">
	  <xsl:copy-of select="."/>
	</xsl:with-param>
      </xsl:call-template>
    </div>
  </xsl:template>
  
  <xsl:template name="sdtsterm" match="sdtsterm">
    <xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template match="sdtstype|vpftype">
    <em>Type: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="ptvctcnt" match="ptvctcnt">
    <em>Count: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="vpfterm" match="vpfterm">
    <div id="vpfterm">
      <a href="#" class="hideShow" onclick="return hideShow(this);">
	<acronymn title="Vector Product Format">
	  <xsl:text>VPF</xsl:text>
	</acronymn>
	description
      </a>
      <div class="indent">
	<xsl:apply-templates/>
      </div>
    </div>
  </xsl:template>

  <xsl:template name="vpflevel" match="vpflevel">
    <em>Level: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="vpfinfo" match="vpfinfo">
    <em>Object Information: </em>
    <div class="indent">
      <xsl:apply-templates/>
    </div>
  </xsl:template>

  <xsl:template name="rastinfo" match="rastinfo">
    <span class="label">Raster data information</span>
    <div class="indent">
      <xsl:apply-templates/>
    </div>
  </xsl:template>

  <xsl:template name="rastifor" match="rastifor">
    <em>Image Format: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="rasttype" match="rasttype">
    <em>Raster Object Type: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="rastityp" match="rastityp">
    <em>Image Type: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="rastband" match="rastband">
    <em>Number of Bands: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="rowcount" match="rowcount">
    <em>Row Count: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="colcount" match="colcount">
    <em>Column Count: </em><xsl:value-of select="."/><br/>
  </xsl:template>
  
  <xsl:template name="vrtcount" match="vrtcount">
    <em>Vertical Count: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="rastxsz" match="rastxsz">
    <em>Cell Size X Direction: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="rastxu" match="rastxu">
    <em>Cell Size X Units: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="rastysz" match="rastysz">
    <em>Cell Size Y Direction: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="rastyu" match="rastyu">
    <em>Cell Size Y Units: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>
  
  <xsl:template name="rastbpp" match="rastbpp">
    <em>Bits Per Pixel: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="rastnodt" match="rastnodt">
    <em>Background Nodata Value: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="rastplyr" match="rastplyr">
    <em>Pyramid Layers: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="rastcmap" match="rastcmap">
    <em>Image Colormap: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="rastcomp" match="rastcomp">
    <em>Compression Type: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="rastdtyp" match="rastdtyp">
    <em>Raster Display Type: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="rastorig" match="rastorig">
    <em>Raster Origin: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="keywords" match="keywords">
    <div id="keywords">
      <xsl:apply-templates select="theme"/>
      <xsl:apply-templates select="place"/>
      <xsl:apply-templates select="stratum"/>
      <xsl:apply-templates select="temporal"/>
    </div>
  </xsl:template>

  <xsl:template name="theme" match="theme">
    <div>
      <span class="label">Theme:</span>
      <xsl:if test="themekt[.!=''] and themekt[.!='none']">
	<xsl:text> (Thesaurus: </xsl:text>
	<xsl:value-of select="themekt"/>
	<xsl:text>)</xsl:text>
      </xsl:if>
      <xsl:text> </xsl:text>
      <xsl:for-each select="themekey">
	<xsl:if test="position() &gt; 1"><xsl:text>, </xsl:text></xsl:if>
	<xsl:value-of select="."/>
      </xsl:for-each>
    </div>
  </xsl:template>

  <xsl:template name="place" match="place">
    <div>
      <span class="label">Place:</span>
      <xsl:if test="placekt[.!=''] and placekt[.!='none']">
	<xsl:text> (Thesaurus: </xsl:text>
	<xsl:value-of select="placekt"/>
	<xsl:text>)</xsl:text>
      </xsl:if>
      <xsl:text> </xsl:text>
      <xsl:for-each select="placekey">
	<xsl:if test="position() &gt; 1"><xsl:text>, </xsl:text></xsl:if>
	<xsl:value-of select="."/>
      </xsl:for-each>
    </div>
  </xsl:template>

  <xsl:template name="stratum" match="stratum">
    <div>
      <span class="label">Stratum:</span>
      <xsl:if test="stratkt[.!=''] and stratkt[.!='none']">
	<xsl:text> (Thesaurus: </xsl:text>
	<xsl:value-of select="stratkt"/>
	<xsl:text>)</xsl:text>
      </xsl:if>
      <xsl:text> </xsl:text>
      <xsl:for-each select="stratkey">
	<xsl:if test="position() &gt; 1"><xsl:text>, </xsl:text></xsl:if>
	<xsl:value-of select="."/>
      </xsl:for-each>
    </div>
  </xsl:template>

  <xsl:template name="temporal" match="temporal">
    <div>
      <span class="label">Temporal:</span>
      <xsl:if test="themekt[.!=''] and themekt[.!='none']">
	<xsl:text> (Thesaurus: </xsl:text>
	<xsl:value-of select="tempkt"/>
	<xsl:text>)</xsl:text>
      </xsl:if>
      <xsl:text> </xsl:text>
      <xsl:for-each select="tempkey">
	<xsl:if test="position() &gt; 1"><xsl:text>, </xsl:text></xsl:if>
	<xsl:value-of select="."/>
      </xsl:for-each>
    </div>
  </xsl:template>

  <xsl:template name="spref" match="spref">
    <xsl:apply-templates select="horizsys"/>
    <xsl:apply-templates select="vertdef"/>
  </xsl:template>
  
  <xsl:template name="horizsys" match="horizsys">
    <div id="horizsys">
      <!-- a href="#" class="hideShow" onclick="return hideShow(this);" -->
	<span class="label">Horizontal coordinate system</span>
      <!--/a -->
      <div id="hsysdetails" class="indent">
	<xsl:apply-templates select="cordsysn"/>
	<a href="#" class="hideShow" onclick="return hideShow(this);">
	  Details
	</a>
	<div class="indent" style="display: none;">
	     <xsl:apply-templates select="geograph"/>
	     <xsl:apply-templates select="planar"/>
	     <xsl:apply-templates select="local"/>
	     <xsl:apply-templates select="geodetic"/>
	</div>
      </div>
      <br/>
    </div>
  </xsl:template>

  <xsl:template name="coordsysn" match="cordsysn">
    <xsl:apply-templates select="projcsn"/>
    <xsl:apply-templates select="geogcsn"/>
  </xsl:template>
  
  <xsl:template name="projcsn" match="projcsn">
    <em>Projected Coordinate System Name: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="geogcsn" match="geogcsn">
    <em>Geographic Coordinate System Name: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="geograph" match="geograph">
    <span class="label">Geographic</span>
    <div class="indent">
      <xsl:apply-templates/>
    </div>
  </xsl:template>

  <xsl:template name="latres" match="latres">
    <em>Latitude Resolution:</em> <xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="longres" match="longres">
    <em>Longitude Resolution:</em> <xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="geogunit" match="geogunit">
    <em>Geographic Units:</em> <xsl:apply-templates/><br/>
  </xsl:template>
  
  <xsl:template name="planar" match="planar">
      <xsl:apply-templates select="mapproj | gridsys | localp"/>
      <xsl:apply-templates select="planci"/>
  </xsl:template>

  <xsl:template name="mapproj" match="mapproj">
    <span class="label">Map projection name: </span>
    <xsl:value-of select="mapprojn"/>
    <div class="indent">
      <xsl:apply-templates select="albers | azimequi | equicon | equirect | gvnsp | gnomonic | lamberta | lambertc | mercator | modsak | miller | obqmerc | orthogr | polarst | polycon | robinson | sinusoid | spaceobq | stereo | transmer | vdgrin | otherprj | mapprojp"/>
      <br/>
    </div>
  </xsl:template>

  <!--
  <xsl:template match="albers | azimequi | equicon | equirect | gvnsp | gnomonic | lamberta | lambertc | mercator | modsak | miller | obqmerc | orthogr | polarst | polycon | robinson | sinusoid | spaceobq | stereo | transmer | vdgrin | otherprj | mapprojp">
    <xsl:apply-templates/>
  </xsl:template>
  -->

  <xsl:template name="stdparll" match="stdparll">
    <em>Standard Parallel: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="azimptl" match="azimptl">
    <em>Azimuth Measure Point Longitude: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="azimangl" match="azimangl">
    <em>Azimuth Angle: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="feast" match="feast">
    <em>False Easting: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="fnorth" match="fnorth">
    <em>False Northing: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="heightpt" match="heightpt">
    <em>Height of Perspective Point above Surface: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="landsat" match="landsat">
    <em>Landsat Number: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="latprjc" match="latprjc">
    <em>Latitude of Projection Center: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="latprjo" match="latprjo">
    <em>Latitude of Projection Origin: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="longcm" match="longcm">
    <em>Longitude of Central Meridian: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="longpc" match="longpc">
    <em>Longitude of Projection Center: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="obqllat" match="obqllat">
    <em>Oblique Line of Latitude: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="obqllong" match="obqllong">
    <em>Oblique Line of Longitude: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="pathnum" match="pathnum">
    <em>Path Number: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="sfctrlin" match="sfctrlin">
    <em>Scale Factor at Center Line: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="sfctrmer" match="sfctrmer">
    <em>Scale Facter at Central Meridian: </em><xsl:apply-templates/><br/>
  </xsl:template>
  
  <xsl:template name="sfequat" match="sfequat">
    <em>Scale Factor at Equator: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="sfprjorg" match="sfprjorg">
    <em>Scale Factor at Projection Origin: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="svlong" match="svlong">
    <em>Straight Vertical Longitude from Pole: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <!-- need to break lines on this one: it's a text description -->
  <xsl:template name="otherprj" match="otherprj">
    <em>Other Projection's Definition:</em>
    <div class="indent">
      <xsl:call-template name="br-replace">
	<xsl:with-param name="word">
	  <xsl:copy-of select="."/>
	</xsl:with-param>
      </xsl:call-template>
    </div>
  </xsl:template>

  <xsl:template name="planci" match="planci">
    <span class="label">Planar coordinate information:</span>
    <div class="indent">
      <xsl:apply-templates select="plance"/>
      <xsl:apply-templates select="coordrep | distbrep"/>
      <xsl:apply-templates select="plandu"/>
      <br/>
    </div>
  </xsl:template>

  <xsl:template name="plance" match="plance">
    <em>Planar Coordinate Encoding Method: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="absres" match="absres">
    <em>Abscissa Resolution: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="ordres" match="ordres">
    <em>Ordinate Resolution: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="distres" match="distres">
    <em>Distance Resolution: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="bearres" match="bearres">
    <em>Bearing Resolution: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="bearunit" match="bearunit">
    <em>Bearing Units: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="bearrefd" match="bearrefd">
    <em>Bearing Reference Direction: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="bearrefm" match="bearrefm">
    <em>Bearing Reference Meridian: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="plandu" match="plandu">
    <em>Planar Distance Units: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="gridsys" match="gridsys">
    <span class="label">Grid Coordinate System: </span>
    <xsl:apply-templates select="gridsysn"/>
    <div class="indent">
      <xsl:apply-templates select="utm | ups | spcs | arcsys | othergrd"/>
    </div>
    <br/>
  </xsl:template>

  <xsl:template name="zone" match="utmzone | upszone | spcszone | arczone">
    <em>Zone: </em><xsl:value-of select="."/><br/>
  </xsl:template>
  
  <xsl:template name="othergrd" match="othergrd">
    <em>Other Grid System's Definition:</em>
    <div class="indent">
      <xsl:call-template name="br-replace">
	<xsl:with-param name="word">
	  <xsl:copy-of select="."/>
	</xsl:with-param>
      </xsl:call-template>
    </div>
  </xsl:template>

  <xsl:template name="localp" match="localp">
    <span class="label">Local Projection</span>
    <div class="indent">
      <span class="label">Description</span>
      <div class="indent">
	<xsl:apply-templates select="localpd"/>
      </div>
      <br/>
      <span class="label">Georeference information</span>
      <div class="indent">
	<xsl:apply-templates select="localgeo"/>
      </div>
    </div>
    <br/>
  </xsl:template>

  <xsl:template match="localpd | localgeo">
    <xsl:call-template name="br-replace">
      <xsl:with-param name="word">
	<xsl:copy-of select="."/>
      </xsl:with-param>
    </xsl:call-template>
  </xsl:template>

  <xsl:template name="geodetic" match="geodetic">
    <span class="label">Geodetic Model</span>
    <div class="indent">
      <xsl:apply-templates/>
    </div>
    <br/>
  </xsl:template>

  <xsl:template name="horizdn" match="horizdn">
    <em>Horizontal Datum Name: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="ellips" match="ellips">
    <em>Ellipsoid Name: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="semiaxis" match="semiaxis">
    <em>Semi-major Axis: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="denflat" match="denflat">
    <em>Denominator of Flattening: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="vertdef" match="vertdef">
    <div id="vertdef">
      <span class="label">Vertical coordinate system</span>
      <div class="indent">
	<xsl:apply-templates />
      </div>
    </div>
  </xsl:template>

  <xsl:template name="altsys" match="altsys">
    <span class="label">Altitude system definition</span>
    <div class="indent">
      <xsl:apply-templates/>
    </div>
    <br/>
  </xsl:template>

  <xsl:template name="depthsys" match="depthsys">
    <span class="label">Depth system definition</span>
    <div class="indent">
      <xsl:apply-templates/>
    </div>
    <br/>
  </xsl:template>

  <xsl:template match="altdatum | depthdn">
    <em>Vertical Datum Name: </em><xsl:apply-templates/><br/>
  </xsl:template>
  
  <xsl:template match="altres | depthres">
    <em>Resolution: </em>
    <xsl:for-each select=".">
      <xsl:if test="position() &gt; 1">
	<xsl:text>, </xsl:text>
      </xsl:if>
      <xsl:value-of select="."/>
    </xsl:for-each>
    <br/>
  </xsl:template>

  <xsl:template match="altunits | depthdu">
    <em>Units: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template match="altenc | depthem">
    <em>Encoding: </em><xsl:apply-templates/><br/>
  </xsl:template>

  <xsl:template name="eainfo" match="eainfo">
    <xsl:choose>
      <xsl:when test="count(overview) &gt; 1">
	<ol>
	  <xsl:for-each select="overview">
	    <li>
	      <xsl:attribute name="id">overview<xsl:value-of select="position()"/></xsl:attribute>
	      <a href="#" class="hideShow" onclick="return hideShow(this);">
		<xsl:text>Overview Summary</xsl:text>
	      </a>
	      <div class="indent">
		<xsl:apply-templates select="eaover"/>
		<br/>
		<xsl:apply-templates select="eadetcit"/>
	      </div>
	    </li>
	  </xsl:for-each>
	</ol>
      </xsl:when>
      <xsl:when test="count(overview) &gt; 1">
	<div id="overview">
	  <a href="#" class="hideShow" onclick="return hideShow(this);">
	    <xsl:text>Overview Summary</xsl:text>
	  </a>
	  <div class="indent">
	    <xsl:apply-templates select="eaover"/>
	    <br/>
	    <xsl:apply-templates select="eadetcit"/>
	  </div>
	</div>
      </xsl:when>
    </xsl:choose>

    <!-- Details -->
    <xsl:choose>
      <xsl:when test="count(detailed) &gt; 1">
	<ol>
	  <xsl:for-each select="detailed">
	    <li>
	      <xsl:attribute name="id">detailed<xsl:value-of select="position()"/></xsl:attribute>
	      <a href="#" class="hideShow" onclick="return hideShow(this);">Details</a>
	      <div class="indent">
		<xsl:apply-templates select="."/>
	      </div>
	      <br/>
	    </li>
	  </xsl:for-each>
	</ol>
      </xsl:when>
      <xsl:when test="count(detailed) = 1">
	<div id="detailed">
	  <a href="#" class="hideShow" onclick="return hideShow(this);">Details</a>
	  <div class="indent">
	    <xsl:apply-templates select="detailed"/>
	  </div>
	</div>
      </xsl:when>
    </xsl:choose>
  </xsl:template>
  
  <xsl:template match="eaover">
    <em>Overview: </em>
    <xsl:call-template name="br-replace">
      <xsl:with-param name="word">
	<xsl:copy-of select="."/>
      </xsl:with-param>
    </xsl:call-template>
  </xsl:template>

  <xsl:template match="eadetcit">
    <em>Citation: </em>
    <xsl:call-template name="br-replace">
      <xsl:with-param name="word">
	<xsl:copy-of select="."/>
      </xsl:with-param>
    </xsl:call-template>
  </xsl:template>

  <xsl:template name="detailed" match="detailed">
    <xsl:apply-templates select="enttyp"/>
    <br/>
    <span class="label">Attributes</span>
    <div class="indent">
      <xsl:apply-templates select="attr"/>
    </div>
  </xsl:template>

  <xsl:template name="enttyp" match="enttyp">
    <span class="label">Entity Type</span>
    <div class="indent">
      <xsl:apply-templates/>
    </div>
  </xsl:template>

  <xsl:template name="enttypl" match="enttypl">
    <em>Label: </em><xsl:value-of select="."/>
    <br/>
  </xsl:template>

  <xsl:template name="enttypt" match="enttypt">
    <em>Type: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="enttypc" match="enttypc">
    <em>Count: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="enttypd" match="enttypd">
    <em>Description: </em>
    <div class="indent">
      <xsl:call-template name="br-replace">
	<xsl:with-param name="word">
	  <xsl:value-of select="."/>
	</xsl:with-param>
      </xsl:call-template>
    </div>
  </xsl:template>

  <xsl:template name="enttypds" match="enttypds">
    <em>Source: </em>
    <div class="indent">
      <xsl:call-template name="br-replace">
	<xsl:with-param name="word">
	  <xsl:copy-of select="."/>
	</xsl:with-param>
      </xsl:call-template>
    </div>
  </xsl:template>

  <xsl:template name="attr" match="attr">
    <div>
      <xsl:attribute name="id">
	<xsl:value-of select="generate-id(.)"/>
      </xsl:attribute>
      <a href="#" class="hideShow" onclick="return hideShow(this);">
	<xsl:value-of select="attrlabl"/>
      </a>
      <div class="indent" style="display: none;">
	<xsl:apply-templates select="attrlabl"/>
	<xsl:apply-templates select="attalias"/>
	<xsl:apply-templates select="attrdef"/>
	<xsl:apply-templates select="attrdefs"/>
	<xsl:apply-templates select="attrtype"/>
	<xsl:apply-templates select="attwidth"/>
	<xsl:apply-templates select="atprecis"/>
	<xsl:apply-templates select="attscale"/>
	<xsl:apply-templates select="atoutwid"/>
	<xsl:apply-templates select="atnumdec"/>
	<xsl:apply-templates select="atindex"/>
	<xsl:apply-templates select="attrdomv"/>
	<xsl:apply-templates select="begdatea|enddatea"/>
	<xsl:apply-templates select="attrvai"/>
	<xsl:apply-templates select="attrmfrq"/>
      </div>
    </div>
  </xsl:template>

  <xsl:template name="attrlabl" match="attrlabl">
    <em>Label: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="attalias" match="attalias">
    <em>Alias: </em><xsl:value-of select="."/><br/>
  </xsl:template>
  
  <xsl:template name="attrdef" match="attrdef">
    <em>Definition: </em>
    <div class="indent">
      <xsl:call-template name="br-replace">
	<xsl:with-param name="word">
	  <xsl:copy-of select="."/>
	</xsl:with-param>
      </xsl:call-template>
    </div>
  </xsl:template>

  <xsl:template name="attrdefs" match="attrdefs">
    <em>Definition Source: </em>
    <div class="indent">
      <xsl:call-template name="br-replace">
	<xsl:with-param name="word">
	  <xsl:copy-of select="."/>
	</xsl:with-param>
      </xsl:call-template>
    </div>
  </xsl:template>

  <xsl:template name="attrtype" match="attrtype">
    <em>Type: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="attwidth" match="attwidth">
    <em>Width: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="atprecis" match="atprecis">
    <em>Precision: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="attscale" match="attscale">
    <em>Scale: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="atoutwid" match="atoutwid">
    <em>Output Width: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="atnumdec" match="atnumdec">
    <em>Number of Decimals: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="atindex" match="atindex">
    <em>Index: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="attrdomv" match="attrdomv">
    <xsl:choose>
      <xsl:when test="edom">
	<em>Enumerated Domain:</em>
	<div class="indent">
	  <table cellspacing="2" class="domain">
	    <colgroup>
	      <col valign="top"/>
	      <col valign="top"/>
	      <col valign="top"/>
	      <col valign="top"/>
	    </colgroup>
	    <thead>
	      <tr>
		<th><b>Value</b></th>
		<th><b>Definition</b></th>
		<th><b>Source</b></th>
		<th><b>Attribute</b></th>
	      </tr>
	    </thead>
	    <tbody>
	      <xsl:apply-templates select="edom"/>
	    </tbody>
	  </table>
	</div>
      </xsl:when>
      <xsl:when test="rdom">
	<em>Range Domain:</em>
	<div class="indent">
          <xsl:apply-templates select="rdom"/>
	</div>
      </xsl:when>
      <xsl:when test="codesetd">
	<em>Code Set Domain:</em>
	<div class="indent">
	  <xsl:apply-templates select="codesetd"/>
	</div>
      </xsl:when>
      <xsl:when test="udom">
	<em>Unrepresentable Domain:</em>
	<div class="indent">
	  <xsl:apply-templates select="udom"/>
	</div>
      </xsl:when>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="edom" match="edom">
    <tr>
      <td valign="top"><xsl:apply-templates select="edomv"/></td>
      <td valign="top"><xsl:apply-templates select="edomvd"/></td>
      <td valign="top"><xsl:apply-templates select="edomvds"/></td>
      <td valign="top"><xsl:apply-templates select="attr"/></td>
    </tr>
  </xsl:template>

  <xsl:template match="edomvd | edomvds">
    <xsl:call-template name="br-replace">
      <xsl:with-param name="word">
	<xsl:copy-of select="."/>
      </xsl:with-param>
    </xsl:call-template>
  </xsl:template>

  <xsl:template name="rdom" match="rdom">
    <xsl:apply-templates select="rdommin"/>
    <xsl:apply-templates select="rdommax"/>
    <xsl:apply-templates select="rdommean"/>
    <xsl:apply-templates select="rdomstdv"/>
    <xsl:apply-templates select="attrunit"/>
    <xsl:apply-templates select="attrmres"/>
    <xsl:apply-templates select="attr"/>
  </xsl:template>

  <xsl:template name="rdommin" match="rdommin">
    <em>Minimum: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="rdommax" match="rdommax">
    <em>Maximum: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="rdommean" match="rdommean">
    <em>Mean: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="rdomstdv" match="rdomstdv">
    <em>Standard Deviation: </em>
    <xsl:value-of select="."/>
  </xsl:template>

  <xsl:template name="attrunit" match="attrunit">
    <em>Units: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="attrmres" match="attrmres">
    <em>Resolution: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="codesetn" match="codesetn">
    <em>Name: </em><xsl:apply-templates/><br/>
  </xsl:template>
  
  <xsl:template name="codesets" match="codesets">
    <em>Source: </em>
    <div class="indent">
      <xsl:call-template name="br-replace">
	<xsl:with-param name="word">
	  <xsl:copy-of select="."/>
	</xsl:with-param>
      </xsl:call-template>
    </div>
  </xsl:template>

  <xsl:template name="udom" match="udom">
    <xsl:call-template name="br-replace">
      <xsl:with-param name="word">
	<xsl:copy-of select="."/>
      </xsl:with-param>
    </xsl:call-template>
  </xsl:template>
  
  <xsl:template name="begdatea" match="begdatea">
    <em>Beginning Date of Attribute Values: </em>
    <xsl:apply-templates />
    <br/>
  </xsl:template>

  <xsl:template name="enddatea" match="enddatea">
    <em>Ending Date of Attribute Values: </em>
    <xsl:apply-templates/>
    <br/>
  </xsl:template>

  <xsl:template name="attrvai" match="attrvai">
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template name="attrva" match="attrva">
    <em>Attribute Value Accuracy: </em>
    <xsl:apply-templates/>
    <br/>
  </xsl:template>

  <xsl:template name="attrvae" match="attrvae">
    <em>Attribute Value Accuracy Explanation:</em>
    <xsl:call-template name="br-replace">
      <xsl:with-param name="word">
	<xsl:copy-of select="."/>
      </xsl:with-param>
    </xsl:call-template>
  </xsl:template>

  <xsl:template name="attrmfrq" match="attrmfrq">
    <em>Attribute Measurement Frequency: </em>
    <xsl:apply-templates/>
    <br/>
  </xsl:template>

  <!-- contact information -->
  <xsl:template name="cntinfo" match="cntinfo">
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template name="cntperp" match="cntperp">
    <em>Primary Person: </em>
    <div class="indent">
      <xsl:apply-templates />
    </div>
  </xsl:template>

  <xsl:template name="cntorgp" match="cntorgp">
    <em>Primary Organization: </em>
    <div class="indent">
      <xsl:apply-templates />
    </div>
  </xsl:template>

  <xsl:template name="cntper" match="cntper">
    <em>Person: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="cntorg" match="cntorg">
    <em>Organization: </em><xsl:value-of select="."/><br/>
  </xsl:template>
  
  <xsl:template name="cntpos" match="cntpos">
    <em>Position: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="cntaddr" match="cntaddr[address|city|state|postal|country]">
    <em>Address: </em><xsl:value-of select="addrtype"/>
    <div class="indent">
      <xsl:apply-templates select="address"/>
      <xsl:if test="city|state|postal">
	<xsl:value-of select="city"/>
	<xsl:if test="state[. != '']">
	  <xsl:text>, </xsl:text>
	  <xsl:value-of select="state"/>
	</xsl:if>
	<xsl:if test="postal[. != '']">
	  <xsl:text> </xsl:text>
	  <xsl:value-of select="postal"/>
	</xsl:if>
	<br/>
      </xsl:if>
      <xsl:value-of select="country"/>
    </div>
  </xsl:template>

  <xsl:template name="address" match="address">
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="cntvoice" match="cntvoice">
    <em>Telephone: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="cnttdd" match="cnttdd">
    <em>TDD/TTY: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="cntfax" match="cntfax">
    <em>FAX: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="cntemail" match="cntemail">
    <em>E-mail: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="hours" match="hours">
    <em>Hours of Service: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="cntinst" match="cntinst">
    <em>Instructions:</em>
    <div class="indent">
      <xsl:call-template name="br-replace">
	<xsl:with-param name="word">
	  <xsl:copy-of select="."/>
	</xsl:with-param>
      </xsl:call-template>
    </div>
  </xsl:template>

  <xsl:template name="metainfo" match="metainfo">
    <xsl:text>Contents last updated: </xsl:text>
    <xsl:value-of select="metd"/>
    <br/>
    <xsl:apply-templates select="metrd"/>
    <xsl:apply-templates select="metfrd"/>
    <div id="metc">
      <a href="#" class="hideShow" onclick="return hideShow(this);">
	<xsl:text>Who completed this document</xsl:text>
      </a>
      <div class="indent" style="display: none">
	<xsl:apply-templates select="metc"/>
      </div>
    </div>
    <br/>
    <div id="metstd">
      <a href="#" class="hideShow" onclick="return hideShow(this);">
	<xsl:text>Standards used to create this document</xsl:text>
      </a>
      <div class="indent" style="display: none">
	<xsl:apply-templates select="metstdn"/>
	<xsl:apply-templates select="metstdv"/>
	<xsl:apply-templates select="mettc"/>
	<xsl:apply-templates select="metac"/>
	<xsl:apply-templates select="metuc"/>
	<xsl:apply-templates select="metsi"/>
	<xsl:if test="metextns">
	  <em>Metadata Profiles Defining Additional Information:</em>
	  <ul>
	    <xsl:apply-templates select="metextns"/>
	  </ul>
	</xsl:if>
      </div>
    </div>
  </xsl:template>

  <xsl:template name="metrd" match="metrd">
    <em>Review Date: </em><xsl:value-of select="."/><br/>
  </xsl:template>
  
  <xsl:template name="metfrd" match="metfrd">
    <em>Future Review Date: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="metstdn" match="metstdn">
    <em>Standard Name: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="metstdv" match="metstdv">
    <em>Standard Version: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="mettc" match="mettc">
    <em>Time Convention Used in this Document: </em>
    <xsl:value-of select="."/>
    <br/>
  </xsl:template>

  <xsl:template name="metac" match="metac">
    <em>Metadata Access Contraints: </em>
    <div class="indent">
      <xsl:call-template name="br-replace">
	<xsl:with-param name="word">
	  <xsl:copy-of select="."/>
	</xsl:with-param>
      </xsl:call-template>
    </div>
  </xsl:template>

  <xsl:template name="metuc" match="metuc">
    <em>Metadata Use Contraints: </em>
    <div class="indent">
      <xsl:call-template name="br-replace">
	<xsl:with-param name="word">
	  <xsl:copy-of select="."/>
	</xsl:with-param>
      </xsl:call-template>
    </div>
  </xsl:template>

  <xsl:template name="metsi" match="metsi">
    <em>Metadata Security Information: </em>
    <div class="indent">
      <xsl:apply-templates />
    </div>
  </xsl:template>

  <xsl:template name="metscs" match="metscs">
    <em>Classification System: </em>
    <xsl:value-of select="."/>
    <br/>
  </xsl:template>

  <xsl:template name="metsc" match="metsc">
    <em>Classification: </em>
    <xsl:value-of select="."/>
    <br/>
  </xsl:template>

  <xsl:template name="metshd" match="metshd">
    <em>Handling Description: </em>
    <div class="indent">
      <xsl:call-template name="br-replace">
	<xsl:with-param name="word">
	  <xsl:copy-of select="."/>
	</xsl:with-param>
      </xsl:call-template>
    </div>
  </xsl:template>

  <xsl:template name="metextns" match="metextns">
    <li>
      <xsl:value-of select="metprof"/>
      <xsl:for-each select="onlink">
	<xsl:if test="position() = 0">
	  <xsl:text>:</xsl:text>
	</xsl:if>
	<xsl:text> </xsl:text>
	<xsl:value-of select="."/>
      </xsl:for-each>
    </li>
  </xsl:template>

  <xsl:template name="accconst" match="accconst">
    <em>Access Constraints:</em>
    <div class="indent">
      <xsl:call-template name="br-replace">
	<xsl:with-param name="word">
	  <xsl:copy-of select="."/>
	</xsl:with-param>
      </xsl:call-template>
    </div>
  </xsl:template>

  <xsl:template name="useconst" match="useconst">
    <em>Use Constraints:</em>
    <div class="indent">
      <xsl:call-template name="br-replace">
	<xsl:with-param name="word">
	  <xsl:copy-of select="."/>
	</xsl:with-param>
      </xsl:call-template>
    </div>
  </xsl:template>

  <xsl:template name="distinfo" match="distinfo">
    <xsl:apply-templates select="resdesc"/>
    <xsl:apply-templates select="/metadata/idinfo/citation/citeinfo/ftname"/>
    <xsl:choose>
      <xsl:when test="count(distrib/cntinfo) &gt; 1">
	<ol>
	  <xsl:for-each select="distrib/cntinfo">
	    <li>
	      <xsl:attribute name="id">
		<xsl:value-of select="generate-id(.)"/>
	      </xsl:attribute>
	      <a href="#" class="hideShow" onclick="return hideShow(this);">
		<xsl:text>Distributor</xsl:text>
	      </a>
	      <div class="indent" style="display: none">
		<xsl:apply-templates select="."/>
	      </div>
	    </li>
	  </xsl:for-each>
	</ol>
      </xsl:when>
      <xsl:when test="count(distrib/cntinfo) = 1">
	<div id="distrib">
	  <a href="#" class="hideShow" onclick="return hideShow(this);">
	    <xsl:text>Distributor</xsl:text>
	  </a>
	  <div class="indent" style="display: none">
	    <xsl:apply-templates select="distrib/cntinfo"/>
	  </div>
	</div>
      </xsl:when>
    </xsl:choose>
    <xsl:if test="stdorder/digform">
      <div id="stdorder">
	<a href="#" class="hideShow" onclick="return hideShow(this);">
	  <xsl:text>Accessing the data</xsl:text>
	</a>
	<div class="indent" style="display: none;">
	  <xsl:apply-templates select="stdorder"/>
	</div>
      </div>
    </xsl:if>
  </xsl:template>

  <xsl:template name="resdesc" match="resdesc">
    <em>Resource Description: </em>
    <xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="ftname" match="ftname">
    <em>File Name: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="stdorder" match="stdorder">
    <xsl:for-each select="digform">
      <xsl:apply-templates select="digtinfo"/>
      <xsl:apply-templates select="digtopt"/>
      <br/>
    </xsl:for-each>
  </xsl:template>

  <xsl:template name="digtinfo" match="digtinfo">
    <xsl:apply-templates select="formname|dssize|transize|filedec"/>
  </xsl:template>

  <xsl:template name="formname" match="formname">
    <em>Data Format: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="dssize" match="dssize">
    <em>Size of the Data: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="transize" match="transize">
    <em>Data Transfer Size: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="filedec" match="filedec">
    <em>How to Decompress the File</em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="digtopt" match="digtopt">
    <xsl:apply-templates select="onlinopt"/>
    <xsl:apply-templates select="offoptn"/>
  </xsl:template>

  <xsl:template name="onlinopt" match="onlinopt">
    <xsl:apply-templates select="computer/networka"/>
    <xsl:apply-templates select="computer/sdeconn"/>
    <xsl:apply-templates select="accinst"/>
  </xsl:template>

  <xsl:template name="networka" match="networka">
    <xsl:if test="networkr">
      <span class="label">Network location:</span>
      <div class="indent">
	<xsl:for-each select="networkr">
	  <xsl:value-of select="."/><br/>
	</xsl:for-each>
      </div>
    </xsl:if>
  </xsl:template>

  <xsl:template name="sdeconn" match="sdeconn">
    <span class="label">SDE connection</span>
    <div class="indent">
      <em>Server: </em><xsl:value-of select="server"/><br/>
      <em>Instance: </em><xsl:value-of select="instance"/><br/>
      <em>Version: </em><xsl:value-of select="version"/><br/>
      <em>Username: </em><xsl:value-of select="user"/><br/>
    </div>
  </xsl:template>

  <xsl:template name="accinst" match="accinst">
    <span class="label">Access instructions</span>
    <div class="indent">
      <xsl:call-template name="br-replace">
	<xsl:with-param name="word">
	  <xsl:copy-of select="."/>
	</xsl:with-param>
      </xsl:call-template>
    </div>
  </xsl:template>

  <xsl:template name="offoptn" match="offoptn">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template name="offmedia" match="offmedia">
    <em>Digital Media: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="recfmt" match="recfmt">
    <em>Recording Format: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="compat" match="compat">
    <em>Compatibility Information: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="recap" match="recap">
    <em>Recording Capacity: </em>
    <div class="indent">
      <xsl:apply-templates/>
    </div>
  </xsl:template>

  <xsl:template name="recden" match="recden">
    <em>Recording Density: </em><xsl:value-of select="."/><br/>
  </xsl:template>

  <xsl:template name="reddenu" match="recdenu">
    <em>Recording Density Units: </em><xsl:value-of select="."/><br/>
  </xsl:template>

</xsl:stylesheet>
