<?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" />
<!-- bindxml_result.xsl -->
<!--    
Headers: BIND-descr_simple-descr 	docid==bindid Molecule_a, Molecule_b, MolID_a, MolID_b, url ...
input of SearchResult from this
45049   RETE|docid 1 45049      BIND-descr_simple-descr 1 dpp protein interacts with E5 pr
otein in a high-throughput yeast 2-hybrid screen.  This interaction was associated with a 
low confidence value (less than 0.5).   Molecule_a 1 dpp        Molecule_b 1 E5 MolID_a 1 
FBgn0000490     MolID_b 1 FBgn0008646   url 1 bind-taxid7227.1.xml,370848807-370868294  id
ocid 1 20216    iscore 1 0.064657696
-->

<xsl:param name="docurl">http://bind.ca/Action?idsearch=bindid:</xsl:param>
<xsl:param name="fbidurl">/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}iscore">BIND ID</a></th>
  <th bgcolor="#DODODO" ><a href="{$resorturl}Molecule_a">Molecule A</a></th>
  <th bgcolor="#DODODO" ><a href="{$resorturl}Molecule_b">Molecule B</a></th>
  <th bgcolor="#DODODO" >Description</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="docid"/></td>
  <td bgcolor="white" align="right"><xsl:apply-templates select="Molecule_a"/></td>      
  <td bgcolor="white" align="left"><xsl:apply-templates select="Molecule_b"/></td>      
  <td bgcolor="white" align="left"><xsl:apply-templates select="BIND-descr_simple-descr"/></td>      
  <!-- <td bgcolor="white" align="right"><xsl:apply-templates select="url"/></td>       -->
  </tr><xsl:text>
  </xsl:text>
</xsl:template>

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

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

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

<xsl:template match="url">
  <xsl:variable name="url" select="text()"/>
  <a href="{$urlbase}{$url}">Report</a>
</xsl:template>

<!-- shorten long titles -->
<xsl:template match="BIND-descr_simple-descr">
  <xsl:variable name="url" select="../url/text()"/>
  <a href="{$urlbase}{$url}">
  <xsl:choose>
   <xsl:when test="string-length(text()) > 75">
     <xsl:value-of select="substring( text(), 0, 75)"/>
     <xsl:value-of select="' ...'"/>
   </xsl:when>
   <xsl:otherwise>
      <xsl:apply-templates/>
   </xsl:otherwise>
   </xsl:choose>
  </a>
</xsl:template>


</xsl:stylesheet>
