<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="no" method="html"/>

<xsl:template match="/">
	<html>
	<head>
	<title> <xsl:value-of select="GeneSummary/Title"/> </title>
  <link 
    href="ugpxml.css" 
    type="text/css" rel="stylesheet" title="GeneSummary2"/>
  <!-- ../conf/; add css inline to avoid this finding hassle ? -->
  <style>
body { background-color: whitesmoke; }
legend { font-weight: bold; font-size: larger; }
fieldset { background-color: gainsboro; }
A { color: blue;  font-weight: normal; }
A:link { text-decoration: none;  }
A:visited { text-decoration: none; color: green;  }
A:hover { text-decoration: underline;  }

.GeneSummary { background-color: snow; }
.commonblock { color: darkgreen;  font-style: italic;  }

table { 
  font-size: small;
  border-style: inset; border-width: thin; 
  float: left;   
  vertical-align: top;
  width: 33%;   
  background-color: snow; 
  }

table.BASIC_INFORMATION { 
  font-size: medium;
  border-style: outset; border-width: medium; 
  float: left;   
  vertical-align: top;
  width: 33%;   
  background-color: gainsboro; 
  }

table.SUMMARY { 
  font-size: small;
  border-style: inset; border-width: thin; 
  float: left;   
  width: 99%;   
  background-color: snow; 
  }
    
  </style>
	</head>
	
	<body id="body">
	
	<h1 align="left">Unified Gene Pages. Style #2</h1>
	
  <xsl:apply-templates/>
  
	</body>
	</html>
</xsl:template>

<xsl:template match="GeneSummary">
<xsl:variable name="legend">
<xsl:value-of select="Title"/> -- (Source: <xsl:value-of select="Source"/>)
</xsl:variable>

<div id="GeneSummary" >
<fieldset> 
<legend ><xsl:value-of select="$legend"/></legend>

	<h2 align="left"> 
  <xsl:value-of select="Type"/>  for 
  <xsl:choose>
  <xsl:when test='BASIC_INFORMATION/Symbol/text()'>
    <i><xsl:value-of select="BASIC_INFORMATION/Symbol"/></i>
  </xsl:when>
  <xsl:otherwise>
    <xsl:value-of select="BASIC_INFORMATION/GeneID"/>
  </xsl:otherwise>
  </xsl:choose>
  </h2>
  
  <xsl:apply-templates/>
  
</fieldset></div>
<br/><br/>
</xsl:template>

<!-- <xsl:template match="GeneSummary/*" mode="legend"> -->
<!-- <div id="{name()}" > -->
<!-- <fieldset> -->
<!-- <legend><xsl:value-of select="name()"/></legend> -->
<!-- <xsl:apply-templates/> -->
<!-- </fieldset></div> -->
<!-- </xsl:template> -->


<xsl:template name="commonhead" > 
  <tr bgcolor="#EEEEEE"> 
  <td colspan="2"><b><font color="#993333">
  <xsl:value-of select="name()"/> 
  </font></b></td>
  </tr>
</xsl:template>

<xsl:template name="commonlabel" > 
  <td width="15%"><b><xsl:value-of select="name()"/> </b>:</td>
</xsl:template>

<xsl:template  mode="commonfield"  match="GeneSummary/*/*"> 
  <tr> 
  <xsl:call-template name="commonlabel" />
  <td> <xsl:apply-templates select="." /></td>
  </tr>
</xsl:template>

<xsl:template  mode="longfield"  match="GeneSummary/*/*"> 
  <tr> 
  <td colspan="2"> <b><xsl:value-of select="name()"/> </b>:<br/>
  <xsl:apply-templates select="." /> </td> 
  </tr>
</xsl:template>

<!-- greek patch for &amp;agr;TUB  &amp;bgr;Tub60D -->
<xsl:template match="gr">
  <xsl:value-of select="'&amp;'" disable-output-escaping="yes"/>
  <xsl:apply-templates/><xsl:value-of select="';'"/>
</xsl:template>

<!-- //this isnt working; need to recode as <gr>beta</gr> ?
<xsl:template match="Name">
  <xsl:choose>
  <xsl:when test="contains(text(),'&amp;')">
    <xsl:value-of select="substring-before(text(), '&amp;')" />
    <xsl:value-of select="'&amp;'" disable-output-escaping="yes"/>
    <xsl:value-of select="substring-after(text(), '&amp;')" />
  </xsl:when>
  <xsl:otherwise>
    <xsl:apply-templates/>
  </xsl:otherwise>
  </xsl:choose>
</xsl:template>
-->

<!-- top level blocks -->

<xsl:template priority="1" match="GeneSummary/*"> 
  <table id="{name()}" width="33%" >
  <xsl:call-template name="commonhead" />
  <xsl:apply-templates mode="commonfield" />
	</table>
</xsl:template>

<xsl:template priority="5" match="GeneSummary/FUNCTION"> 
  <table id="{name()}" width="33%" >
  <xsl:call-template name="commonhead" />
  <xsl:apply-templates mode="longfield" />
	</table>
</xsl:template>

<xsl:template priority="5" match="GeneSummary/GENE_ONTOLOGY"> 
  <table id="{name()}" width="33%" >
  <xsl:call-template name="commonhead" />
  <xsl:apply-templates mode="longfield" />
	</table>
</xsl:template>

<xsl:template priority="5" match="GeneSummary/GENE_PRODUCT"> 
  <table id="{name()}" width="33%" >
  <xsl:call-template name="commonhead" />
  <xsl:apply-templates mode="longfield" />
	</table>
</xsl:template>

<!-- refs could be numbered -->
<xsl:template priority="5" match="GeneSummary/LITERATURE"> 
  <table id="{name()}" width="33%" >
  <xsl:call-template name="commonhead" />
  <xsl:apply-templates mode="longfield" />
	</table>
</xsl:template>

<xsl:template priority="5" match="GeneSummary/ADDITIONAL_INFORMATION"> 
  <table id="{name()}" width="33%" >
  <xsl:call-template name="commonhead" />
  <xsl:apply-templates mode="longfield" />
	</table>
</xsl:template>

<!-- <xsl:template  priority="6"  match="GeneSummary/BASIC_INFORMATION"> -->
<!--   <div id="{name()}" > -->
<!--   <table id="{name()}" >  -->
<!--   <xsl:call-template name="commonhead" /> -->
<!--   <xsl:apply-templates mode="commonfield" /> -->
<!--   </table> -->
<!--   </div> -->
<!-- </xsl:template> -->
<!--  -->

<xsl:template mode="commonfield" priority="6"  match="GeneSummary/LOCATION/Map">
  <tr>
  <xsl:call-template name="commonlabel" />
  <td> 
  <xsl:apply-templates select="."  />
  <xsl:if test='@type'>
  <xsl:text> (</xsl:text> <i><xsl:value-of select="@type"/></i> <xsl:text>) </xsl:text>
  </xsl:if>
  </td>
  </tr>
</xsl:template>


<!-- field content handlers, links, etc. -->

<xsl:template match="Polypeptide"> 
<a href="/cgi-bin/fbidq.html?{@id}"> <xsl:apply-templates/></a> <br/>
</xsl:template>

<xsl:template match="Transcript"> 
<a href="/cgi-bin/fbidq.html?{@id}"> <xsl:apply-templates/> </a>, 
</xsl:template>

<xsl:template  match="Species"> 
<i><xsl:apply-templates/></i> 
</xsl:template>

<xsl:template  match="ref/Title"> <i><xsl:apply-templates/></i> </xsl:template>
<xsl:template  match="ref/Source"> <b><xsl:apply-templates/></b> </xsl:template>
<xsl:template  match="ref/Identifier"> <u><xsl:apply-templates/></u> </xsl:template>

<xsl:template match="goterm"> 
<a href="/cgi-bin/goreport?{@id}"> <xsl:apply-templates/> </a>, 
</xsl:template>

<xsl:template match="anatomy"> 
<a href="/cgi-bin/cvreport?{text()}"> <xsl:apply-templates/> </a>, 
</xsl:template>

<xsl:template match="db_xref"> 
  <xsl:choose>
  <xsl:when test='@id'> <a href="/cgi-bin/db_xref?{@id}"><xsl:apply-templates/> </a>, </xsl:when>
  <xsl:otherwise> <a href="/cgi-bin/db_xref?{text()}"> <xsl:apply-templates/> </a>,</xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template priority="10" match="url"> 
  <xsl:choose>
  <xsl:when test='@href'> <a href="{@href}"><xsl:apply-templates/> </a> </xsl:when>
  <xsl:otherwise> <a href="{text()}"> <xsl:apply-templates/> </a> </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- <xsl:template match="Expressions">  -->
<!--   <tr>  -->
<!--   <td  width="15%"><b><xsl:value-of select="name()"/> </b>:</td> -->
<!--   <td>  -->
<!--   <xsl:for-each select="Expressions/*"> -->
<!--     <xsl:value-of select="@type"/> <xsl:value-of select="text()"/> -->
<!--     <xsl:apply-templates/> <br/> -->
<!--   </xsl:for-each> -->
<!--   </td> -->
<!--   </tr> -->
<!-- </xsl:template> -->


<xsl:template priority="6"  match="GeneSummary/SIMILAR_GENES"> 
  <table id="{name()}" width="33%" >
  <xsl:call-template name="commonhead" />
  <tr><td>
  <table>
		<tr>
		<xsl:for-each select="./Similarity[1]/*">
		 <th align="left"><xsl:value-of select="name()"/></th>
		</xsl:for-each>
		</tr>
    <xsl:apply-templates mode="simtable"/>
  </table>
  </td></tr> 
	</table>
</xsl:template>

<xsl:template  mode="simtable" match="GeneSummary/SIMILAR_GENES/Similarity">
  <tr> 
		<xsl:for-each select="*">
		 <td><xsl:apply-templates select="."/></td> <!-- <xsl:value-of select="."/>  -->
		</xsl:for-each>
  </tr> 
</xsl:template>

<xsl:template  match="Reagent" mode="reagents"></xsl:template>
<xsl:template  match="Reagent"><xsl:apply-templates/>, </xsl:template>

<xsl:template mode="reagents" match="Name">
  <tr> 
  <td><b> <xsl:value-of select="text()"/></b>:</td> 
  <td><xsl:apply-templates select="Reagent"/></td>
  </tr> 
</xsl:template>

<xsl:template priority="6" match="GeneSummary/REAGENTS"> 
  <table id="{name()}" width="100%" >
  <xsl:call-template name="commonhead" />
  <xsl:apply-templates mode="reagents"/>
	</table>
</xsl:template>


<xsl:template priority="6" match="GeneSummary/SUMMARY"> 
  <div id="{name()}" >
  <table id="{name()}" width="100%" style="width:auto">
  <xsl:call-template name="commonhead" />
  <xsl:apply-templates mode="sumtable" />
	</table>
	</div>
</xsl:template>

<xsl:template mode="sumtable" match="GeneSummary/SUMMARY/*">
  <tr><td> <xsl:apply-templates /></td></tr> <!-- <xsl:value-of select="."/> --> 
</xsl:template>

<!-- hide metadata pulled at top -->
<xsl:template priority="10" match="GeneSummary/Title"></xsl:template>
<xsl:template priority="10" match="GeneSummary/Source"></xsl:template>
<xsl:template priority="10" match="GeneSummary/Type"></xsl:template>


</xsl:stylesheet>
