<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.1" 
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
   xmlns:java="http://xml.apache.org/xalan/java"
   exclude-result-prefixes="java" 
   > 

<xsl:output  indent="no" method="html" />
<!-- medline_result.xsl -->
<!--    
Headers: LastName 	Year 	ArticleTitle 	docclass url
input of SearchResult from this
FBrf0068744     RETE|docid 1 FBrf0068744        docclass 1 Journal Article      ArticleTit
le 1 The Drosophila saxophone gene: a serine-threonine kinase receptor of the TGF-beta sup
erfamily.       PMID 1 8134837  MedlineID 1 94182135    LastName 3 Xie  Year 4 1994     ur
l 1 medline.xml,83155088-83161135       idocid 1 15842  iscore 1 0.017278513
-->

<xsl:param name="docurl">/cgi-bin/fbidq.html?</xsl:param>
<xsl:param name="urlbase">lookup?url=</xsl:param>
<xsl:param name="resorturl">results?sort=</xsl:param>
<xsl:param name="pubmedurl">http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&amp;db=PubMed&amp;dopt=Abstract&amp;tool=FlyBase&amp;list_uids=</xsl:param>

<xsl:template match="SearchResultList">
  <table border="1" width="100%" bgcolor="#f9f9f9" cellpadding="1">
  <tr><td>
  <table width="100%" cellpadding="3" cellspacing="0">
  <xsl:call-template name="theader" />
  <xsl:apply-templates/>      
  </table>
  </td></tr></table>
</xsl:template>

<xsl:template name="theader">
  <tr bgcolor="#EEEEEE"> 
  <th align="right" bgcolor="#DODODO" >#</th>
  <th bgcolor="#DODODO" ><a href="{$resorturl}LastName">Author</a></th>
  <th bgcolor="#DODODO" ><a href="{$resorturl}Year">Year</a></th>
  <th bgcolor="#DODODO" ><a href="{$resorturl}ArticleTitle">Title</a></th>
  <th bgcolor="#DODODO" ><a href="{$resorturl}docclass">Class</a></th>
  <th bgcolor="#DODODO" >Report</th>
  </tr>
</xsl:template>

<xsl:template match="SearchResult">
  <tr valign="top"> 
  <td bgcolor="white" align="right"><xsl:value-of select="@i+1" /></td>
  <td bgcolor="white" align="left"><xsl:apply-templates select="LastName"/></td>
  <td bgcolor="white" align="right"><xsl:apply-templates select="Year"/></td>      
  <td bgcolor="white" align="left"><xsl:apply-templates select="ArticleTitle"/></td>      
  <td bgcolor="white" align="right"><xsl:apply-templates select="docclass"/></td>      
  <td bgcolor="white" align="right"><xsl:apply-templates select="url"/></td>      
  </tr><xsl:text>
  </xsl:text>
</xsl:template>

<xsl:template match="LastName">
  <xsl:variable name="id" select="../docid/text()"/>
  <a href="{$docurl}{$id}"><xsl:apply-templates/></a>
</xsl:template>

<xsl:template match="url">
  <xsl:variable name="pmid" select="../PMID/text()"/>
  <xsl:variable name="url" select="text()"/>
  <a href="{$urlbase}{$url}">Report</a>
  <xsl:if test="string-length($pmid) > 1">
    <xsl:value-of select="'; '"/><a href="{$pubmedurl}{$pmid}">PubMed</a>
  </xsl:if>
</xsl:template>

<!-- shorten long titles -->
<xsl:template match="ArticleTitle">
   <xsl:choose>
   <xsl:when test="string-length(text()) > 70">
     <xsl:value-of select="substring( text(), 0, 66)"/>
     <xsl:value-of select="' ...'"/>
   </xsl:when>
   <xsl:otherwise>
      <xsl:apply-templates/>
   </xsl:otherwise>
   </xsl:choose>
</xsl:template>

<!-- this disable-output-escaping works  for xsl, but how to get &greek;
  past the xml checker ?? -->
<xsl:template match="gr">
<xsl:value-of select="'&amp;'" disable-output-escaping="yes"/>
<xsl:apply-templates/>
<xsl:value-of select="';'"/>
</xsl:template>

</xsl:stylesheet>
