Bio-Das-ProServer

 view release on metacpan or  search on metacpan

stylesheets/xsl_sequence.xsl  view on Meta::CPAN

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns="http://www.w3.org/1999/xhtml"
  version="1.0">
  <xsl:output method="xml" version="1.0" indent="no" standalone="no" omit-xml-declaration="no"
    media-type="text/html"
    encoding="UTF-8"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"/>
  <xsl:template match="/">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <style type="text/css">html,body{background:#ffc;font-family:helvetica,arial,sans-serif;font-size:0.8em}thead{background:#700;color:#fff}thead th{margin:0;padding:2px}a{color:#a00}a:hover{color:#aaa}.tr1{background:#ffd}.tr2{background:#ffb}t...
        <title>ProServer: Sequence</title>
      </head>
      <body>
        <div id="header"><h4>ProServer: Sequence</h4></div>
        <div id="mainbody">
          <p>Format:
            <input type="radio" name="format" onclick="document.getElementById('numbered').style.display='block';document.getElementById('fasta').style.display='none';document.getElementById('xml').style.display='none';" value="Numbered" checked="che...
            <input type="radio" name="format" onclick="document.getElementById('fasta').style.display='block';document.getElementById('numbered').style.display='none';document.getElementById('xml').style.display='none';" value="Fasta"/>Fasta
            <input type="radio" name="format" onclick="document.getElementById('xml').style.display='block';document.getElementById('numbered').style.display='none';document.getElementById('fasta').style.display='none';" value="XML"/>XML
          </p>
          <div id="numbered" style="font-family:courier;display:block;">
            <xsl:apply-templates select="*/SEQUENCE" mode="numbered"/>
          </div>
          <div id="fasta" style="font-family:courier;display:none;">
            <xsl:apply-templates select="*/SEQUENCE" mode="fasta"/>
          </div>
          <div id="xml" style="font-family:courier;display:none;">
            <xsl:apply-templates select="*" mode="xml-main"/>
          </div>
        </div>
      </body>
    </html>
  </xsl:template>
  <xsl:template match="SEQUENCE" mode="fasta">
    <xsl:variable name="start">
      <xsl:choose><xsl:when test="@start"><xsl:value-of select="@start"/></xsl:when><xsl:otherwise>1</xsl:otherwise></xsl:choose>
    </xsl:variable>
    <xsl:variable name="seq">
      <xsl:choose><xsl:when test="DNA"><xsl:value-of select="translate(normalize-space(DNA/text()),' ','')"/></xsl:when><xsl:otherwise><xsl:value-of select="translate(normalize-space(text()),' ','')"/></xsl:otherwise></xsl:choose>
    </xsl:variable>
    <xsl:variable name="stop" select="$start + string-length($seq) -1"/>
    <div>
      &gt;<xsl:value-of select="@id"/>:<xsl:value-of select="$start"/>,<xsl:value-of select="$stop"/>
      <xsl:if test="@version">|<xsl:value-of select="@version"/></xsl:if><br/>
      <xsl:call-template name="writeseq">
        <xsl:with-param name="seq" select="$seq"/>
      </xsl:call-template>
    </div>
  </xsl:template>
  <xsl:template match="SEQUENCE" mode="numbered">
    <xsl:variable name="pos">
      <xsl:choose><xsl:when test="@start"><xsl:value-of select="@start"/></xsl:when><xsl:otherwise>1</xsl:otherwise></xsl:choose>
    </xsl:variable>
    <xsl:variable name="seq">
      <xsl:choose><xsl:when test="DNA"><xsl:value-of select="translate(normalize-space(DNA/text()),' ','')"/></xsl:when><xsl:otherwise><xsl:value-of select="translate(normalize-space(text()),' ','')"/></xsl:otherwise></xsl:choose>
    </xsl:variable>
    <table>
      <thead>
        <tr><th colspan="3"><xsl:value-of select="@id"/><xsl:if test="@version"> version <xsl:value-of select="@version"/></xsl:if></th></tr>
      </thead>
      <tbody>
        <xsl:call-template name="writeseq">
          <xsl:with-param name="seq" select="$seq"/>
          <xsl:with-param name="pos" select="$pos"/>
        </xsl:call-template>
      </tbody>



( run in 1.331 second using v1.01-cache-2.11-cpan-39bf76dae61 )