XSLT for Similarity Search 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 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="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:value-of select="$lo -1 + position()"/></td>
          <xsl:apply-templates/>
          <xsl:text disable-output-escaping="yes">
            &lt;/TR>
          </xsl:text>
        </xsl:for-each>
      </TABLE><BR/>
      <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"/>&amp;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"/>&amp;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"/>&amp;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/*">
      <td><xsl:value-of select="."/></td>
    </xsl:template>

    <xsl:template match="Row/HexSmiles">
      <td>
        <xsl:text disable-output-escaping="yes">
	  &lt;IMG SRC=&quot;http://dell.daylight.com/daycgi/smi2gif?
	</xsl:text>
	<xsl:value-of select="."/>
	<xsl:text disable-output-escaping="yes">
	  &quot;>
	</xsl:text>
      </td>
    </xsl:template>

    <xsl:template match="ResultItems">
      <tr>
        <TD><B>#</B></TD>
	<xsl:for-each select="Item">
	  <TD><B>
	    <xsl:apply-templates/>
	  </B></TD>
	</xsl:for-each>
      </tr>
    </xsl:template>

  </xsl:stylesheet>


Last modified: Wed Mar 7 07:36:57 MST 2001