XSLT for Savant Demo


<?xml version="1.0"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="html" indent="yes" />
    <xsl:variable name="hi" select="ResultData/End"/>
    <xsl:variable name="lo" select="ResultData/Start"/>
    <xsl:variable name="nr" select="ResultData/NumRows"/>
    <xsl:variable name="url" select="ResultData/URL"/>
    
    <xsl:template match="ResultData">
      <table WIDTH="100%" BORDER="0" cellspacing="0"  BGCOLOR="#AAAAFF" cols="2">
        <TR>
          <xsl:apply-templates select="Desc"/>
          <xsl:apply-templates select="NumRows"/>
        </TR>
      </table>


        <xsl:for-each select="Row">
           <xsl:apply-templates/>
         </xsl:for-each>
 
      <table BORDER="0" cellspacing="0"  BGCOLOR="#AAAAFF" cols="2">
        <TR>
          <TD>
            <b>
              <xsl:choose>
                <xsl:when test="$lo = 1">
                  <FONT COLOR="#AAAAFF">No Previous Results</FONT>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:text disable-output-escaping="yes">
                    &lt;A HREF=
                  </xsl:text>
                  <xsl:value-of select="$url"/>
                  <xsl:text disable-output-escaping="yes">&amp;amp;</xsl:text>start=<xsl:value-of select="$lo - 10"/>
                  <xsl:text disable-output-escaping="yes">
                    >
                  </xsl:text>
                  Previous Page
                  <xsl:text disable-output-escaping="yes">
                    &lt;/A>
                  </xsl:text>
                </xsl:otherwise>
              </xsl:choose>
            </b>
          </TD>
          <TD align="right">
            <b>	       
            <xsl:choose>
              <xsl:when test="$hi >= $nr">
                No more results
              </xsl:when>
              <xsl:when test="($hi + 10) > $nr">
                <xsl:text disable-output-escaping="yes">
                  &lt;A HREF=
                </xsl:text>
                <xsl:value-of select="$url"/>
                <xsl:text disable-output-escaping="yes">&amp;amp;</xsl:text>start=<xsl:value-of select="$hi+1"/>
                <xsl:text disable-output-escaping="yes">
                  >
                </xsl:text>
                Results <xsl:value-of select="$hi + 1"/>-<xsl:value-of select="$nr"/>
                <xsl:text disable-output-escaping="yes">
                  &lt;/A>
                </xsl:text>
              </xsl:when>
              <xsl:otherwise>
                <xsl:text disable-output-escaping="yes">
                  &lt;A HREF=
                </xsl:text>
                <xsl:value-of select="$url"/>
                <xsl:text disable-output-escaping="yes">&amp;amp;</xsl:text>start=<xsl:value-of select="$hi+1"/>
                <xsl:text disable-output-escaping="yes">
                  >
                </xsl:text>
                Results <xsl:value-of select="$hi + 1"/>-<xsl:value-of select="$hi + 10"/>
                <xsl:text disable-output-escaping="yes">
                  &lt;/A>
                </xsl:text>
              </xsl:otherwise>
            </xsl:choose>
          </b>
        </TD>
      </TR>
    </table>
  </xsl:template>
  
  <xsl:template match="Desc">
    <TD>
      <b><xsl:value-of select="."/></b>
    </TD>
  </xsl:template>
  
  <xsl:template match="NumRows">
    <TD align="right">
      <B>
        Results <xsl:value-of select="$lo"/>-<xsl:value-of select="$hi"/> of <xsl:value-of select="."/>
    </B>
  </TD>
</xsl:template>

 <xsl:template match="Row/HexSmiles">
  </xsl:template>

<xsl:template match="Row/Tanimoto">
  </xsl:template>

<xsl:template match="Row/REFERENCES">
    <xsl:text disable-output-escaping="yes">
        &lt;A HREF=&quot;/mariner/jsp/savant/savant2.jsp?smiles=</xsl:text><xsl:value-of select="../HexSmiles"/>
      <xsl:text disable-output-escaping="yes">
        &quot;>
        &lt;IMG SRC=&quot;/mariner/servlet/Smi2Gif?smiles=</xsl:text>
<xsl:value-of select="../HexSmiles"/><xsl:text disable-output-escaping="yes">&amp;label1=</xsl:text>
<xsl:value-of select="format-number(../Tanimoto, '0.00%')"/><xsl:text disable-output-escaping="yes">25_similar&amp;label2=</xsl:text>
<xsl:value-of select="format-number(., 000)"/>
<xsl:text disable-output-escaping="yes">_Articles&quot;>&lt;/A></xsl:text>
  </xsl:template>

</xsl:stylesheet>


XSLT for Part 2 of Savant:




<?xml version="1.0"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="html" indent="yes" />
    
    <xsl:variable name="hi" select="ResultData/End"/>
    <xsl:variable name="lo" select="ResultData/Start"/>
    <xsl:variable name="nr" select="ResultData/NumRows"/>
    <xsl:variable name="url" select="ResultData/URL"/>
    
    <xsl:template match="ResultData">
      <table width="100%" BORDER="0" cellspacing="0"  BGCOLOR="#AAAAFF" cols="2">
        <TR>
          <xsl:apply-templates select="Desc"/>
          <xsl:apply-templates select="NumRows"/>
        </TR>
      </table>
      <TABLE border="0" cellspacing="0" cellpadding="5" width="100%">
        <xsl:apply-templates select="ResultItems"/>
        <xsl:for-each select="Row">
          <xsl:choose>
            <xsl:when test="HexSmiles=' null '">
            </xsl:when>
            <xsl:when test="string-length(HexSmiles)=0">
            </xsl:when>
            <xsl:otherwise>      
            <xsl:if test="not(HexSmiles=preceding-sibling::Row/HexSmiles)">
              <tr>
                <td>
                  <xsl:text disable-output-escaping="yes">
                    &lt;IMG SRC=&quot;/mariner/servlet/Smi2Gif?smiles=</xsl:text><xsl:value-of select="HexSmiles"/>
                  <xsl:text disable-output-escaping="yes">&quot;></xsl:text>
                </td>
              </tr>
            </xsl:if>
          </xsl:otherwise>
        </xsl:choose>
        <xsl:choose>
          <xsl:when test="position() mod 2 = 0">
              <xsl:text disable-output-escaping="yes">
                &lt;TR BGCOLOR="#EEEEFF">
              </xsl:text>
            </xsl:when>
            <xsl:otherwise>
              <xsl:text disable-output-escaping="yes">
                &lt;TR>
              </xsl:text>
            </xsl:otherwise>
          </xsl:choose>
          <td>
            <xsl:apply-templates/>
          </td>
          <xsl:text disable-output-escaping="yes">
            &lt;/TR>
          </xsl:text>
        </xsl:for-each>
      </TABLE><BR/>
      <table width="100%" BORDER="0" cellspacing="0"  BGCOLOR="#AAAAFF" cols="2">
        <TR>
          <TD>
            <b>
              <xsl:choose>
                <xsl:when test="$lo = 1">
                  <font face="arial,sans-serif" size="-1" color="#AAAAFF">No Previous Results</font>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:text disable-output-escaping="yes">
                    &lt;A HREF=
                  </xsl:text>
                  <xsl:value-of select="$url"/>
                  <xsl:text disable-output-escaping="yes">&amp;amp;</xsl:text>start=<xsl:value-of select="$lo - 10"/>
                  <xsl:text disable-output-escaping="yes">
                    >
                  </xsl:text>
                  <font face="arial,sans-serif" size="-1">
                    Previous Page
                  </font>
                  <xsl:text disable-output-escaping="yes">
                    &lt;/A>
                  </xsl:text>
                </xsl:otherwise>
              </xsl:choose>
            </b>
          </TD>
          <TD align="right">
            <b>        
            <xsl:choose>
              <xsl:when test="$hi >= $nr">
                <font face="arial,sans-serif" size="-1">
                No more results
                </font>
              </xsl:when>
              <xsl:when test="($hi + 10) > $nr">
                <xsl:text disable-output-escaping="yes">
                  &lt;A HREF=
                </xsl:text>
                <xsl:value-of select="$url"/>&amp;start=<xsl:value-of select="$hi+1"/>
                <xsl:text disable-output-escaping="yes">
                  >
                </xsl:text>
                <font face="arial,sans-serif" size="-1">
                Results <xsl:value-of select="$hi + 1"/>-<xsl:value-of select="$nr"/>
                <xsl:text disable-output-escaping="yes">
                  &lt;/A>
                </xsl:text>
              </font>
              </xsl:when>
              <xsl:otherwise>
                <xsl:text disable-output-escaping="yes">
                  &lt;A HREF=
                </xsl:text>
                <xsl:value-of select="$url"/>&amp;start=<xsl:value-of select="$hi+1"/>
                <xsl:text disable-output-escaping="yes">
                  >
                </xsl:text>
                <font face="arial,sans-serif" size="-1">
                  Results <xsl:value-of select="$hi + 1"/>-<xsl:value-of select="$hi + 10"/>
                <xsl:text disable-output-escaping="yes">
                  &lt;/A>
                </xsl:text>
              </font>
            </xsl:otherwise>
          </xsl:choose>
        </b>
      </TD>
      </TR>
    </table>
  </xsl:template>

  <xsl:template match="Desc">
    <TD><font face="arial,sans-serif" size="-1">
    <b><xsl:value-of select="."/></b></font>
    </TD>
  </xsl:template>

  <xsl:template match="NumRows">
    <TD align="right"><font face="arial,sans-serif" size="-1">
      <b>Results <xsl:value-of select="$lo"/>-
      <xsl:value-of select="$hi"/>
      of <xsl:value-of select="."/>
    </b></font>
  </TD>
</xsl:template>

<xsl:template match="Row/*">
  <xsl:value-of select="."/><br/>
</xsl:template>

<xsl:template match="Row/SMI_SNO">
  <font face="arial,sans-serif" size="-1" color="gray">
    Spresi ID: <B><xsl:value-of select="."/></B>
</font>
<br/>
</xsl:template>

<xsl:template match="Row/LANGUAGE">
  <br/>
    <font face="arial,sans-serif" size="-1" color="green">
      Languages: <B><xsl:value-of select="."/></B> - 
  </font>
</xsl:template>

<xsl:template match="Row/TITLE">
  <B><font face="arial,sans-serif"><xsl:value-of select="."/></font></B><br/>
</xsl:template>

<xsl:template match="Row/AUTHORS">
  <font face="arial,sans-serif" size="-1" color="blue"><xsl:value-of select="."/><br/></font>
</xsl:template>

<xsl:template match="Row/CITATION">
  <font face="arial,sans-serif" size="-1" color="black">
  <xsl:value-of select="."/></font>
</xsl:template>

<xsl:template match="Row/ISM">
  <xsl:choose>
    <xsl:when test=".=' null '">
    </xsl:when>
    <xsl:otherwise>
      SMILES: <xsl:value-of select="."/><br/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template match="Row/HexSmiles">
</xsl:template>

<xsl:template match="ResultItems">
  <tr>
   <TD></TD>
</tr>
</xsl:template>

</xsl:stylesheet>


Last modified: Wed Mar 7 07:35:48 MST 2001