<?xml version="1.0"?>
<xsl:stylesheet xsl:version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns="http://www.w3.org/TR/xhtml1/strict">

<xsl:output method="html" />
<xsl:preserve-space elements="*"/>

<xsl:template match="PERSONNAME">
  <xsl:value-of select="FIRSTNAMEA"/><xsl:text> </xsl:text>
  <xsl:value-of select="FIRSTNAMEB"/><xsl:text> </xsl:text>
  <xsl:value-of select="FIRSTNAMEC"/><xsl:text> </xsl:text>
  <xsl:value-of select="LASTNAME"/>
</xsl:template>

<xsl:template match="PI|COI" >
  <xsl:text>
    </xsl:text><td>
  <xsl:choose>
    <xsl:when test="@prefname">
	<xsl:value-of select="@prefname"/>
    </xsl:when>
    <xsl:when test="PERSONNAME">
	<xsl:apply-templates select="PERSONNAME"/>
    </xsl:when>
    <xsl:when test="@defname">
	<xsl:value-of select="@defname"/>
    </xsl:when>
    <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise>
  </xsl:choose>
	</td><xsl:text>
    </xsl:text><td>
  <xsl:if test="AFFILIATION"><xsl:value-of select="AFFILIATION"/></xsl:if>
	</td><xsl:text>
    </xsl:text><td>
  <xsl:if test="@email">
    <a href="mailto:{@email}"><xsl:value-of select="@email"/></a>
  </xsl:if>
	</td><xsl:text>
  </xsl:text>
</xsl:template>

<xsl:template match="/">
<html><xsl:text>
</xsl:text><head><xsl:text>
</xsl:text>
<title>BIMA Archive Project: <xsl:value-of select="PROJECT/PROJID"/></title>
<xsl:text>
</xsl:text></head><xsl:text>
</xsl:text>

<body bgcolor="#ffffff"><xsl:text>
</xsl:text>
<h1><xsl:value-of select="PROJECT/PROJID"/><xsl:if test="PROJECT/TITLE">.
  <xsl:value-of select="PROJECT/TITLE"/></xsl:if>
</h1><xsl:text>
</xsl:text>

<h3>Authors:</h3> <xsl:text>

</xsl:text><p><xsl:text>
</xsl:text>
<table width="95%" cellpadding="0" border="2" ><xsl:text>
  </xsl:text>
  <tr><th></th><th>Name</th><th>Affiliation</th><th>Email</th></tr><xsl:text>
  </xsl:text>
  <tr><td>PI:</td>
  <xsl:apply-templates select="PROJECT/INVESTIGATORS/PI"/>
</tr><xsl:text>
</xsl:text>
<xsl:for-each select="PROJECT/INVESTIGATORS/COI">
  <xsl:text>  </xsl:text><tr><td>CoI:</td>
  <xsl:apply-templates select="."/>
  </tr><xsl:text>
</xsl:text>
</xsl:for-each>      
</table></p><xsl:text>

</xsl:text>
  
<p><strong>Contact:</strong><xsl:text>
</xsl:text>
<a href="mailto:{PROJECT/CONTACT/@email}">
<xsl:value-of select="PROJECT/CONTACT"/><xsl:text> (</xsl:text>
<xsl:value-of select="PROJECT/CONTACT/@email"/><xsl:text>)</xsl:text>
</a></p><xsl:text>
</xsl:text>

<hr/><xsl:text>
</xsl:text>
</body> </html><xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>

