<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="http://www.w3.org/2002/02/style-xsl.css" type="text/css"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:an="http://www.w3.org/2003/05/tr-history/analysis#"
 xmlns:contact="http://www.w3.org/2000/10/swap/pim/contact#"
 xmlns:org="http://www.w3.org/2001/04/roadmap/org#"
 xmlns:doc="http://www.w3.org/2000/10/swap/pim/doc#"
 xmlns:dc="http://purl.org/dc/elements/1.1/"
 xmlns:rec="http://www.w3.org/2001/02pd/rec54#"
 xmlns:xlink="http://www.w3.org/1999/xlink"
 xmlns:daml="http://www.daml.org/2001/03/daml+oil#"
 xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
 xmlns="http://www.w3.org/2000/svg"
 version="1.0">

 <xsl:output method="xml" encoding="utf-8" indent="yes"/>

 <xsl:param name="animate"/>
 <xsl:variable name="trdb" select="document('http://www.w3.org/2002/01/tr-automation/tr.rdf')"/>
 <xsl:variable name="controldb" select="document('shortnames.rdf')"/>
 <xsl:variable name="this" select="/"/>
 <xsl:variable name="beginning" select="'1997-04-06'"/>
 <xsl:variable name="height" select="100*(count($controldb/rdf:RDF/rec:*[not(daml:equivalentTo)])+1)"/>

 <xsl:template match="/rdf:RDF">
  <xsl:processing-instruction name="xml-stylesheet">href="svg-history.css" type="text/css"</xsl:processing-instruction>
  <svg>
   <xsl:choose>
    <xsl:when test="string-length($animate)&gt;0">
     <xsl:attribute name="onload">
      <xsl:value-of select="'init()'"/>
     </xsl:attribute>
     <xsl:attribute name="a:scriptImplementation">
      <xsl:value-of select="'Adobe'"/>
     </xsl:attribute>
     <xsl:attribute name="viewBox">
      <xsl:value-of select="'-10 -60 2000 600'"/>
     </xsl:attribute>
     <script a:scriptImplementation="Adobe" type="text/ecmascript" xlink:href="scroll.es" />
    </xsl:when>
    <xsl:otherwise>
     <xsl:attribute name="viewBox">
      <xsl:value-of select="concat('-10 -60 2400 ',$height)"/>
     </xsl:attribute>
    </xsl:otherwise>
   </xsl:choose>
   <title>Current W3C Technical Reports</title>
   <defs>
    <linearGradient id="wdgrad">
     <stop offset="5%" stop-color="#c9f"/>
     <stop offset="95%" stop-color="#fff"/>
    </linearGradient>
    <rect height="50" id="WDbox" width="120" fill="url(#wdgrad)"/>
    <linearGradient id="lcgrad">
     <stop offset="5%" stop-color="#fcc"/>
     <stop offset="95%" stop-color="#fff"/>
    </linearGradient>
    <rect height="50" id="LastCallbox" width="120" fill="url(#lcgrad)"/>
    <linearGradient id="crgrad">
     <stop offset="5%" stop-color="#fa0"/>
     <stop offset="95%" stop-color="#fff"/>
    </linearGradient>
    <rect height="50" id="CRbox" width="120" fill="url(#crgrad)"/>
    <linearGradient id="prgrad">
     <stop offset="5%" stop-color="#ff6"/>
     <stop offset="95%" stop-color="#fff"/>
    </linearGradient>
    <rect height="50" id="PRbox" width="120" fill="url(#prgrad)"/>
    <linearGradient id="pergrad">
     <stop offset="5%" stop-color="#6ff"/>
     <stop offset="95%" stop-color="#fff"/>
    </linearGradient>
    <rect height="50" id="PERbox" width="120" fill="url(#pergrad)"/>
   </defs>
   <xsl:call-template name="legend"/>
   <g id="whole">
    <xsl:call-template name="header"/>
    <xsl:for-each select="$controldb/rdf:RDF/rec:*[not(daml:equivalentTo)]">
     <xsl:sort select="dc:date" data-type="text" order="ascending"/>
     <xsl:variable name="lasturi" select="@rdf:about"/>
     <xsl:variable name="pos" select="position()-1"/>
     <xsl:apply-templates select="$this/rdf:RDF/rec:*[@rdf:about=$lasturi]" mode="pub">
      <xsl:with-param name="pos" select="$pos"/>
     </xsl:apply-templates>
    </xsl:for-each>
   </g>
   <xsl:call-template name="footer"/>
  </svg>
 </xsl:template>

 <xsl:template match="rec:*" mode="pub">
  <xsl:param name="pos"/>
  <xsl:variable name="recuri" select="doc:versionOf/@rdf:resource"/>
  <xsl:variable name="y-offset" select="$pos*100"/>
  <g transform="{concat('translate(0,',$y-offset,')')}">
   <xsl:apply-templates select="//rec:*[doc:versionOf/@rdf:resource=$recuri]" mode="setup">
    <xsl:sort select="dc:date" data-type="text" order="ascending"/>
   </xsl:apply-templates>
   <a xlink:href="{$recuri}">
    <xsl:variable name="x-coord">
     <xsl:call-template name="approximate-date-difference">
      <xsl:with-param name="start-date" select="$beginning"/>
      <xsl:with-param name="end-date" select="//rec:*[doc:versionOf/@rdf:resource=$recuri][not(doc:obsoletes)]/dc:date"/>
     </xsl:call-template>
    </xsl:variable>
    <text class="caption" x="{$x-coord}" y="20">
     <xsl:value-of select="normalize-space($trdb/rdf:RDF/rec:*[doc:versionOf/@rdf:resource=$recuri]/dc:title)"/>
    </text>
   </a>
  </g>
 </xsl:template>

 <xsl:template match="rec:*[doc:versionOf/@rdf:resource]" mode="setup">
  <xsl:variable name="display-class" select="local-name()"/>
  <xsl:variable name="docuri" select="@rdf:about"/>
  <xsl:variable name="next-date" select="//rec:*[doc:obsoletes/@rdf:resource=$docuri]/dc:date"/>
  <xsl:variable name="x-coord">
   <xsl:call-template name="approximate-date-difference">
    <xsl:with-param name="start-date" select="$beginning"/>
    <xsl:with-param name="end-date" select="dc:date"/>
   </xsl:call-template>
  </xsl:variable>
  <xsl:variable name="end-coord">
   <xsl:call-template name="approximate-date-difference">
    <xsl:with-param name="start-date" select="$beginning"/>
    <xsl:with-param name="end-date" select="$next-date"/>
   </xsl:call-template>
  </xsl:variable>
  <a xlink:href="{$docuri}">
   <g>
   <xsl:choose>
    <xsl:when test="number($end-coord)=number($end-coord)">
     <xsl:variable name="diff" select="$end-coord - $x-coord"/>
     <rect class="{$display-class}" height="50" width="{$diff}" x="{$x-coord}" y="35"/>
    </xsl:when>
    <xsl:otherwise>
     <use transform="{concat('translate(',$x-coord,',35)')}" xlink:href="{concat('#',$display-class,'box')}"/>
     <text class="inner" x="{$x-coord+10}" y="65">
      <xsl:value-of select="$display-class"/>
      <xsl:text> last published on </xsl:text>
      <xsl:value-of select="dc:date"/>
     </text>
    </xsl:otherwise>
   </xsl:choose>
   </g>
  </a>
 </xsl:template>

 <xsl:template match="rec:*[not(doc:versionOf/@rdf:resource)]">
 </xsl:template>

 <xsl:template name="approximate-date-difference">
  <xsl:param name="start-date"/>
  <xsl:param name="end-date"/>
  <xsl:variable name="year-diff">
   <xsl:choose>
    <xsl:when test="substring($end-date,1,4) - substring($start-date,1,4)&lt;=1">
     <xsl:value-of select="'0'"/>
    </xsl:when>
    <xsl:otherwise>
     <xsl:value-of select="(substring($end-date,1,4) - substring($start-date,1,4) - 1) * 372"/>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:variable>

  <xsl:variable name="month-diff">
   <xsl:choose>
    <xsl:when test="substring($end-date,1,4)-substring($start-date,1,4)=0">
     <xsl:choose>
      <xsl:when test="substring($end-date,6,2)-substring($start-date,6,2)=0">
       <xsl:value-of select="substring($end-date,9,2)-substring($start-date,9,2)"/>
      </xsl:when>
      <xsl:otherwise>
       <xsl:value-of select="(substring($end-date,6,2) - substring($start-date,6,2)) * 31 + substring($start-date,9,2) - (31 - substring($end-date,9,2))"/>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
     <xsl:value-of select="(substring($end-date,6,2) - 1) * 31 + substring($end-date,9,2) + (12 - substring($start-date,6,2)) * 31 + (31 - substring($start-date,9,2))"/>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:variable>

  <xsl:value-of select="$year-diff + $month-diff"/>
 </xsl:template>

 <xsl:template name="header">
  <xsl:variable name="y1998">
   <xsl:call-template name="approximate-date-difference">
    <xsl:with-param name="start-date" select="$beginning"/>
    <xsl:with-param name="end-date" select="'1998-01-01'"/>
   </xsl:call-template>
  </xsl:variable>
  <xsl:variable name="y1999">
   <xsl:call-template name="approximate-date-difference">
    <xsl:with-param name="start-date" select="$beginning"/>
    <xsl:with-param name="end-date" select="'1999-01-01'"/>
   </xsl:call-template>
  </xsl:variable>
  <xsl:variable name="y2000">
   <xsl:call-template name="approximate-date-difference">
    <xsl:with-param name="start-date" select="$beginning"/>
    <xsl:with-param name="end-date" select="'2000-01-01'"/>
   </xsl:call-template>
  </xsl:variable>
  <xsl:variable name="y2001">
   <xsl:call-template name="approximate-date-difference">
    <xsl:with-param name="start-date" select="$beginning"/>
    <xsl:with-param name="end-date" select="'2001-01-01'"/>
   </xsl:call-template>
  </xsl:variable>
  <xsl:variable name="y2002">
   <xsl:call-template name="approximate-date-difference">
    <xsl:with-param name="start-date" select="$beginning"/>
    <xsl:with-param name="end-date" select="'2002-01-01'"/>
   </xsl:call-template>
  </xsl:variable>
  <xsl:variable name="y2003">
   <xsl:call-template name="approximate-date-difference">
    <xsl:with-param name="start-date" select="$beginning"/>
    <xsl:with-param name="end-date" select="'2003-01-01'"/>
   </xsl:call-template>
  </xsl:variable>
  <g id="years">
   <text x="{$y1998}" y="-20" class="year">1998</text>
   <line x1="{$y1998}" y1="0" x2="{$y1998}" y2="{$height}" stroke="#333" stroke-width="1"/>
   <text x="{$y1999}" y="-20" class="year">1999</text>
   <line x1="{$y1999}" y1="0" x2="{$y1999}" y2="{$height}" stroke="#333" stroke-width="1"/>
   <text x="{$y2000}" y="-20" class="year">2000</text>
   <line x1="{$y2000}" y1="0" x2="{$y2000}" y2="{$height}" stroke="#333" stroke-width="1"/>
   <text x="{$y2001}" y="-20" class="year">2001</text>
   <line x1="{$y2001}" y1="0" x2="{$y2001}" y2="{$height}" stroke="#333" stroke-width="1"/>
   <text x="{$y2002}" y="-20" class="year">2002</text>
   <line x1="{$y2002}" y1="0" x2="{$y2002}" y2="{$height}" stroke="#333" stroke-width="1"/>
   <text x="{$y2003}" y="-20" class="year">2003</text>
   <line x1="{$y2003}" y1="0" x2="{$y2003}" y2="{$height}" stroke="#333" stroke-width="1"/>
  </g>
 </xsl:template>

 <xsl:template name="legend">
  <xsl:variable name="opacity">
   <xsl:choose>
    <xsl:when test="string-length($animate)&gt;0">
     <xsl:value-of select="'0.6'"/>
    </xsl:when>
    <xsl:otherwise>
     <xsl:value-of select="'1'"/>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:variable>
  <xsl:variable name="transform">
   <xsl:choose>
    <xsl:when test="string-length($animate)&gt;0">
     <xsl:value-of select="'translate(0,0)'"/>
    </xsl:when>
    <xsl:otherwise>
     <xsl:value-of select="'translate(2300,40)'"/>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:variable>
  <g id="legend" transform="{$transform}" opacity="{$opacity}">
   <text class="legendText" x="0" y="0">Legend</text>
   <rect class="NOTE" x="0" y="20" width="50" height="50"/>
   <text class="legendText" x="60" y="55" fill="#000">Note</text>
   <rect class="WD" x="0" y="80" width="50" height="50"/>
   <text class="legendText" x="60" y="115" fill="#000">Working Draft</text>
   <rect class="LastCall" x="0" y="140" width="50" height="50"/>
   <text class="legendText" x="60" y="175" fill="#000">Last Call</text>
   <rect class="CR" x="0" y="200" width="50" height="50"/>
   <text class="legendText" x="60" y="235" fill="#000">Candidate Recommendation</text>
   <rect class="PR" x="0" y="260" width="50" height="50"/>
   <text class="legendText" x="60" y="295" fill="#000">Proposed Recommendation</text>
   <rect class="PER" x="0" y="320" width="50" height="50"/>
   <text class="legendText" x="60" y="355" fill="#000">Proposed Edited Recommendation</text>
   <rect class="REC" x="0" y="380" width="50" height="50"/>
   <text class="legendText" x="60" y="415" fill="#000">Recommendation</text>
   <text x="0" y="500" fill="#333">Last Updated $Date: 2003/08/14 18:20:19 $</text>
  </g>
 </xsl:template>

 <xsl:template name="footer">
  <xsl:if test="string-length($animate)&gt;0">
   <g id="play" transform="translate(0,500)" fill="#999999" visibility="hidden" onclick="toggleMove()">
    <rect width="40" height="40" rx="9" stroke="black" stroke-width="2"/>
    <path fill="black" stroke="black" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" d="M 18 10 L 26 20 L 18 30 Z"/>
    <set begin="mouseover" attributeName="fill" attributeType="css" to="rgb(255, 255, 255)"/>
    <set begin="mouseout" attributeName="fill" attributeType="css" to="#999999"/>
   </g>
   <g id="pause" transform="translate(0,500)" fill="#999999" visibility="visible" onclick="toggleMove()">
    <rect width="40" height="40" rx="9" stroke="black" stroke-width="2"/>
    <path fill="none" stroke="black" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" d="M 16 10 L 16 30"/>
    <path fill="none" stroke="black" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" d="M 24 10 L 24 30"/>
    <set begin="mouseover" attributeName="fill" attributeType="css" to="rgb(255, 255, 255)"/>
    <set begin="mouseout" attributeName="fill" attributeType="css" to="#999999"/>
   </g>
  </xsl:if>
 </xsl:template>
</xsl:stylesheet>
