<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  version="1.0" xmlns:contact="http://www.w3.org/2000/10/swap/pim/contact#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rec="http://www.w3.org/2001/02pd/rec54#" xmlns="http://www.w3.org/1999/xhtml" xmlns:date="http://www.w3.org/2001/08/date-util.xslt" xmlns:str="http://www.w3.org/2001/10/str-util.xsl" xmlns:doc="http://www.w3.org/2000/10/swap/pim/doc#" xmlns:mat="http://www.w3.org/2002/05/matrix/vocab#" exclude-result-prefixes="contact dc rec rdf date str doc h mat">
  <xsl:import href="../../../2001/08/date-util.xslt"/>
  <xsl:import href="../../../2001/10/str-util.xsl"/>
    
  <xsl:output method="xml" encoding="iso-8859-1" indent='yes' doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>

  <xsl:param name="recent-since"><xsl:text>9999-99-99</xsl:text></xsl:param>
  <xsl:param name="source">
    <xsl:text>tr.rdf</xsl:text>
  </xsl:param>
  <xsl:variable name="trdata" select="document($source)/rdf:RDF"/>

  <!-- Identity Transformation, modifications are done on a case by case basis -->
  <xsl:template match="*|@*">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="h:object[@classid='http://www.w3.org/2002/02/tr-automation/rdf2tr?recentTr']">

    <!--@@ rec:REC -->
    <div id="recent">
      <xsl:if test="$trdata/*[local-name()='REC' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#REC'][translate(dc:date,'-','') &gt; translate($recent-since,'-','')]">
	<h2 class="recent">Recently Published Recommendations</h2>
	<ul>
	  <xsl:for-each select="$trdata/*[local-name()='REC' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#REC'][translate(dc:date,'-','') &gt; translate($recent-since,'-','')]">
	    <xsl:sort select="dc:date" order="descending"/>
	    <xsl:variable name="link" select="@rdf:about"/>
	    <li><xsl:call-template name="date:makeDateFriendly"><xsl:with-param name="date" select="translate(dc:date,'-','')"/></xsl:call-template>: <a href="{$link}"><xsl:value-of select="dc:title"/></a></li>
	  </xsl:for-each>
	  <li><a href="#Recommendations">...more Recommendations</a></li>
	</ul>
      </xsl:if>
      <xsl:if test="$trdata/*[local-name()='PR' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#PR'][translate(dc:date,'-','') &gt; translate($recent-since,'-','')]">

	<h2 class="recent">Recently Published Proposed Recommendations</h2>
	<ul>
	  <xsl:for-each select="$trdata/*[local-name()='PR' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#PR'][translate(dc:date,'-','') &gt; translate($recent-since,'-','')]">
	    <xsl:sort select="dc:date" order="descending"/>
	    <xsl:variable name="link" select="@rdf:about"/>
	    <li><xsl:call-template name="date:makeDateFriendly"><xsl:with-param name="date" select="translate(dc:date,'-','')"/></xsl:call-template>: <a href="{$link}"><xsl:value-of select="dc:title"/></a> - Proposed Recommendation Review Ends <xsl:call-template name="date:makeDateFriendly"><xsl:with-param name="date" select="translate(rec:prReviewsDue,'-','')"/></xsl:call-template></li>
	  </xsl:for-each>
	  <li><a href="#PR">...more Proposed Recommendations</a></li>
	</ul>
      </xsl:if>
      <xsl:if test="$trdata/*[local-name()='PER' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#PER'][translate(dc:date,'-','') &gt; translate($recent-since,'-','')]">

	<h2 class="recent">Recently Published Proposed Edited Recommendations</h2>
	<ul>
	  <xsl:for-each select="$trdata/*[local-name()='PER' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#PER'][translate(dc:date,'-','') &gt; translate($recent-since,'-','')]">
	    <xsl:sort select="dc:date" order="descending"/>
	    <!-- a PER has always a previousEdition -->
	    <xsl:variable name="link" select="@rdf:about"/>
	    <li><xsl:call-template name="date:makeDateFriendly"><xsl:with-param name="date" select="translate(dc:date,'-','')"/></xsl:call-template>: <a href="{$link}"><xsl:value-of select="dc:title"/></a> - Proposed Edited Recommendation Review Ends <xsl:call-template name="date:makeDateFriendly"><xsl:with-param name="date" select="translate(rec:perReviewsDue,'-','')"/></xsl:call-template></li>
	  </xsl:for-each>
	  <li><a href="#PER">...more Proposed Edited Recommendations</a></li>
	</ul>
      </xsl:if>

      <xsl:if test="$trdata/*[local-name()='CR' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#CR'][translate(dc:date,'-','') &gt; translate($recent-since,'-','')]">
	<h2 class="recent">Recently Published Candidate Recommendations</h2>
	<ul>
	  <xsl:for-each select="$trdata/*[local-name()='CR' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#CR'][translate(dc:date,'-','') &gt; translate($recent-since,'-','')]">
	    <xsl:sort select="dc:date" order="descending"/>
	    <xsl:variable name="link" select="@rdf:about"/>
	    <li><xsl:call-template name="date:makeDateFriendly"><xsl:with-param name="date" select="translate(dc:date,'-','')"/></xsl:call-template>: <a href="{$link}"><xsl:value-of select="dc:title"/></a> - <xsl:if test="rec:implementationFeedbackDue">Candidate Recommendation Feedback Due <xsl:call-template name="date:makeDateFriendly"><xsl:with-param name="date" select="translate(rec:implementationFeedbackDue,'-','')"/></xsl:call-template></xsl:if><xsl:if test="rec:minTimeCR">Candidate Recommendation will last at least <xsl:value-of select="rec:minTimeCR"/></xsl:if></li>
	    
	  </xsl:for-each>
	  <li><a href="#CR">...more Candidate Recommendations</a></li>
	</ul>
      </xsl:if>
      <xsl:if test="$trdata/*[local-name()='WD' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#WD'][translate(dc:date,'-','') &gt; translate($recent-since,'-','')] or $trdata/rec:LastCall[translate(dc:date,'-','') &gt; translate($recent-since,'-','')]">
	<h2 class="recent">Recently Published Working Drafts</h2>
	<ul>
	  <xsl:for-each select="$trdata/*[local-name()='WD' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#WD'][translate(dc:date,'-','') &gt; translate($recent-since,'-','')]">
	    <xsl:sort select="dc:date" order="descending"/>
	    <xsl:variable name="link" select="@rdf:about"/>
	    <li><xsl:call-template name="date:makeDateFriendly"><xsl:with-param name="date" select="translate(dc:date,'-','')"/></xsl:call-template>: <a href="{$link}"><xsl:value-of select="dc:title"/></a><xsl:if test="local-name()='LastCall' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#LastCall'"> - Last Call Ends <xsl:call-template name="date:makeDateFriendly"><xsl:with-param name="date" select="translate(rec:lastCallFeedBackDue,'-','')"/></xsl:call-template></xsl:if></li>
	  </xsl:for-each>
	  <li><a href="#WD">... more Working Drafts</a></li>
	</ul>
      </xsl:if>
      <xsl:if test="$trdata/*[local-name()='NOTE' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#NOTE'][translate(dc:date,'-','') &gt; translate($recent-since,'-','')]">
	<h2 class="recent">Recently Published Group Notes</h2>
	<ul>
	  <xsl:for-each select="$trdata/*[local-name()='NOTE' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#NOTE'][translate(dc:date,'-','') &gt; translate($recent-since,'-','')]">
	    <xsl:sort select="dc:date" order="descending"/>
	    <xsl:variable name="link" select="@rdf:about"/>
	    <li><xsl:call-template name="date:makeDateFriendly"><xsl:with-param name="date" select="translate(dc:date,'-','')"/></xsl:call-template>: <a href="{$link}"><xsl:value-of select="dc:title"/></a></li>
	  </xsl:for-each>
	  <li><a href="#Notes">... more Notes</a></li>
	</ul>
      </xsl:if>
    </div>
  </xsl:template>

  <xsl:template match="h:dd[h:object[@classid='http://www.w3.org/2002/02/tr-automation/rdf2tr?Recommendations']]">
    <xsl:for-each select="$trdata/*[(local-name()='REC' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#REC') and not(rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#Superseded') and not(rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#FirstEdition' or local-name()='FirstEdition')]">
      <xsl:sort select="substring(concat($trdata/*[@rdf:about=current()/rec:previousEdition/@rdf:resource]/dc:date,dc:date),1,10)" order="descending"/>
      <xsl:call-template name="makeStatusList"/>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="h:dd[h:object[@classid='http://www.w3.org/2002/02/tr-automation/rdf2tr?PR']]">
    <xsl:choose>
      <xsl:when test="$trdata/*[(local-name()='PR' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#PR') and not(rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#Superseded')]">
        <xsl:for-each select="$trdata/*[(local-name()='PR' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#PR') and not(rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#Superseded')]">
        <xsl:sort select="dc:date"  order="descending"/>
        <xsl:call-template name="makeStatusList"/>
      </xsl:for-each>
    </xsl:when>
    <xsl:otherwise>
      <dd>There are currently no document at Proposed Recommendation Status.</dd>
    </xsl:otherwise>
  </xsl:choose>
  </xsl:template>

  <xsl:template match="h:dd[h:object[@classid='http://www.w3.org/2002/02/tr-automation/rdf2tr?PER']]">
    <xsl:choose>
      <xsl:when test="$trdata/*[(local-name()='PER' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#PER') and not(rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#Superseded')]">
        <xsl:for-each select="$trdata/*[(local-name()='PER' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#PER') and not(rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#Superseded')]">
        <xsl:sort select="dc:date"  order="descending"/>
        <xsl:call-template name="makeStatusList"/>
      </xsl:for-each>
    </xsl:when>
    <xsl:otherwise>
      <dd>There are currently no document at Proposed Edited Recommendation Status.</dd>
    </xsl:otherwise>
  </xsl:choose>
  </xsl:template>


  <xsl:template match="h:dd[h:object[@classid='http://www.w3.org/2002/02/tr-automation/rdf2tr?CR']]">
    <xsl:choose>
      <xsl:when test="$trdata/*[(local-name()='CR' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#CR') and not(rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#Superseded')]">
        <xsl:for-each select="$trdata/*[(local-name()='CR' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#CR') and not(rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#Superseded')]">
          <xsl:sort select="dc:date"  order="descending"/>
          <xsl:call-template name="makeStatusList"/>
        </xsl:for-each>
      </xsl:when>
      <xsl:otherwise>
        <dd>There are currently no document at Candidate Recommendation Status.</dd>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="h:dd[h:object[@classid='http://www.w3.org/2002/02/tr-automation/rdf2tr?WD-devel']]">
    <xsl:for-each select="$trdata/*[local-name()='WD' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#WD'][not(rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#Superseded' or local-name()='Superseded') and not(rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#Retired' or local-name()='Retired') and not(rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#LastCall' or local-name()='LastCall') ]">
      <xsl:sort select="dc:date"  order="descending"/>
      <xsl:call-template name="makeStatusList"/>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="h:dd[h:object[@classid='http://www.w3.org/2002/02/tr-automation/rdf2tr?Notes']]">
    <xsl:for-each select="$trdata/*[local-name()='NOTE' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#NOTE'][not(rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#Superseded')]">
      <xsl:sort select="dc:date"  order="descending"/>
      <xsl:call-template name="makeStatusList"/>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="h:dd[h:object[@classid='http://www.w3.org/2002/02/tr-automation/rdf2tr?WD-last-call']]">
    <xsl:for-each select="$trdata/*[local-name()='LastCall' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#LastCall'][not(rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#Superseded')  and not(rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#Retired' or local-name()='Retired')]">
      <xsl:sort select="dc:date"  order="descending"/>
      <xsl:call-template name="makeStatusList"/>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="h:dd[h:object[@classid='http://www.w3.org/2002/02/tr-automation/rdf2tr?WD-dropped']]">
    <xsl:for-each select="$trdata/*[(local-name()='Retired' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#Retired') and (local-name()='WD' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#WD')]">
      <xsl:sort select="dc:date"  order="descending"/>
      <xsl:call-template name="makeStatusList"/>
    </xsl:for-each>
  </xsl:template>


  <xsl:template name="makeStatusList">
    <xsl:param name="baseHref" select="'http://www.w3.org/TR/'"/>
    <xsl:variable name="link">
      <xsl:call-template name="makeLinkRelative">
        <xsl:with-param name="uri" select="@rdf:about"/>
        <xsl:with-param name="base" select="$baseHref"/>
      </xsl:call-template>
    </xsl:variable>
    <!-- to preserve the same a/@id, now that we're using dated URIs -->
    <xsl:variable name="link_old">
      <xsl:choose>
        <xsl:when test="not(rec:previousEdition) or (local-name()='REC' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#REC')">
          <xsl:call-template name="makeLinkRelative">
            <xsl:with-param name="uri" select="doc:versionOf/@rdf:resource"/>
            <xsl:with-param name="base" select="$baseHref"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:call-template name="makeLinkRelative">
            <xsl:with-param name="uri" select="@rdf:about"/>
            <xsl:with-param name="base" select="$baseHref"/>
          </xsl:call-template>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="id">
      <xsl:choose>
        <xsl:when test="contains($link_old,'/')">
          <xsl:variable name="notrailingslash">
            <xsl:choose>
              <xsl:when test="substring($link_old,string-length($link_old))='/'">
                <xsl:value-of select="substring(translate($link_old,'+','-'),1,string-length($link_old)-1)"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="translate($link_old,'+','-')"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:variable>
          <xsl:choose>
            <xsl:when test="contains($notrailingslash,'/')">
              <xsl:value-of select="substring-after($notrailingslash,'/')"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="$notrailingslash"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="translate($link_old,'+','-')"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <dt class="TR">
      <xsl:if test="not(rec:previousEdition) or (local-name()='REC' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#REC')">
        <xsl:for-each select="/rdf:RDF/rdf:Description[@rdf:about=current()/doc:versionOf/@rdf:resource]/rec:formerShortname">
          <a id="{.}" name="{.}"/>
        </xsl:for-each>
      </xsl:if>
<a href="{normalize-space($link)}"><xsl:if test="not(contains($id,'/')) and (not(rec:previousEdition) or (local-name()='REC' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#REC'))"><xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute><xsl:attribute name="name"><xsl:value-of select="$id"/></xsl:attribute></xsl:if><xsl:value-of select="dc:title"/></a>
</dt>
<xsl:text>
</xsl:text>
<dd>
  <xsl:if test="/rdf:RDF/*[@rdf:about=current()/rec:previousEdition/@rdf:resource]/dc:date and (local-name()='REC' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#REC')">
    <xsl:text>First published </xsl:text><xsl:call-template name="date:makeDateFriendly"><xsl:with-param name="date" select="translate(/rdf:RDF/*[@rdf:about=current()/rec:previousEdition/@rdf:resource]/dc:date,'-','')"/></xsl:call-template><xsl:text>, revised </xsl:text>
  </xsl:if>
  <xsl:call-template name="date:makeDateFriendly"><xsl:with-param name="date" select="translate(dc:date,'-','')"/></xsl:call-template>
    <xsl:for-each select="rec:editor[contact:fullName]">
      <xsl:text>, </xsl:text>
      <xsl:value-of select="contact:fullName"/>        
    </xsl:for-each>
    <xsl:if test="mat:hasErrata or mat:hasTranslations or rec:patentRules/@rdf:resource='http://www.w3.org/Consortium/Patent-Policy-20040205/'">
      <xsl:text> - </xsl:text>(<xsl:if test="mat:hasErrata"><a href="{mat:hasErrata/@rdf:resource}">Errata</a>
	<xsl:if test="mat:hasTranslations or rec:patentRules/@rdf:resource='http://www.w3.org/Consortium/Patent-Policy-20040205/'">,</xsl:if>&#xA0;
      </xsl:if> 
      <xsl:if test="mat:hasTranslations">
        <a href="{mat:hasTranslations/@rdf:resource}">Translations</a>
	<xsl:if test="rec:patentRules/@rdf:resource='http://www.w3.org/Consortium/Patent-Policy-20040205/'">,&#xA0;</xsl:if>
      </xsl:if> 
      <xsl:if test="rec:patentRules/@rdf:resource='http://www.w3.org/Consortium/Patent-Policy-20040205/'">
        <a><xsl:attribute name="href"><xsl:text>http://www.w3.org/2004/01/pp-impl/s/</xsl:text><xsl:value-of select="substring-after(doc:versionOf/@rdf:resource,'http://www.w3.org/TR/')"/></xsl:attribute>Royalty-Free Commitments</a>
      </xsl:if> 

      <xsl:text>)</xsl:text>
    </xsl:if>
    <xsl:if test="rec:fromSubmission">
      <xsl:text> (</xsl:text><a href="{rec:fromSubmission/@rdf:resource[starts-with(.,'http')]}"><xsl:value-of select="/rdf:RDF/*[@rdf:about=current()/rec:fromSubmission/@rdf:resource]/dc:title"/></a><xsl:text>)</xsl:text>
    </xsl:if>
    <xsl:if test="rdf:type[@rdf:resource='http://www.w3.org/2001/02pd/rec54#Superseded'] and local-name()='Retired'">
      <xsl:text> - This document has been superseded by </xsl:text>
      <xsl:for-each select="/rdf:RDF/*[rec:supersedes/@rdf:resource=current()/doc:versionOf/@rdf:resource]">
        <a href="{@rdf:about}"><xsl:value-of select="/rdf:RDF/*[doc:versionOf/@rdf:resource=current()/@rdf:about]/dc:title"/></a><xsl:text> </xsl:text>
      </xsl:for-each>
    </xsl:if>
  </dd>
  <xsl:if test="rec:prReviewsDue">
    <dd>Proposed Recommendation Review Ends <xsl:call-template name="date:makeDateFriendly"><xsl:with-param name="date" select="translate(rec:prReviewsDue,'-','')"/></xsl:call-template></dd>
  </xsl:if>
  <xsl:if test="rec:perReviewsDue">
    <dd>Proposed Edited Recommendation Review Ends <xsl:call-template name="date:makeDateFriendly"><xsl:with-param name="date" select="translate(rec:perReviewsDue,'-','')"/></xsl:call-template></dd>
  </xsl:if>
  <xsl:if test="rec:implementationFeedbackDue">
    <dd>Candidate Recommendation Feedback Due <xsl:call-template name="date:makeDateFriendly"><xsl:with-param name="date" select="translate(rec:implementationFeedbackDue,'-','')"/></xsl:call-template></dd>
  </xsl:if>
  <xsl:if test="rec:minTimeCR">
    <dd>Candidate Recommendation will last at least <xsl:value-of select="rec:minTimeCR"/></dd>
  </xsl:if>
  <xsl:if test="rec:lastCallFeedBackDue">
    <dd>Last Call Ends <xsl:call-template name="date:makeDateFriendly"><xsl:with-param name="date" select="translate(rec:lastCallFeedBackDue,'-','')"/></xsl:call-template></dd>
  </xsl:if>
  <!--  <xsl:if test="rec:previousEdition">
    <xsl:variable name="uri" select="rec:previousEdition/@rdf:resource"/>
    <dd>This specification is a revision of the <a href="{$uri}"><xsl:value-of select="/rdf:RDF/rec:FirstEdition[@rdf:about=$uri]/dc:title"/> published on <xsl:call-template name="date:makeDateFriendly"><xsl:with-param name="date" select="translate(/rdf:RDF/*[@rdf:about=$uri]/dc:date,'-','')"/></xsl:call-template></a></dd> 
  </xsl:if> -->
  <xsl:if test="/rdf:RDF/rdf:Description[@rdf:about=current()/doc:versionOf/@rdf:resource]/rec:supersedes and (local-name()='REC' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#REC')">
    <xsl:variable name="superseded" select="/rdf:RDF/rdf:Description[@rdf:about=current()/doc:versionOf/@rdf:resource]/rec:supersedes/@rdf:resource"/>
    <xsl:if test="/rdf:RDF/*[@rdf:about=$superseded][local-name()='REC' or rdf:type/@rdf:resource='http://www.w3.org/2001/02pd/rec54#REC']">
      <dd>This specification supersedes <a href="{$superseded}"><xsl:value-of select="/rdf:RDF/*[@rdf:about=$superseded]/dc:title"/> published on <xsl:call-template name="date:makeDateFriendly"><xsl:with-param name="date" select="translate(/rdf:RDF/*[@rdf:about=$superseded]/dc:date,'-','')"/></xsl:call-template></a>
      <xsl:if test="/rdf:RDF/*[@rdf:about=$superseded]/rec:previousEdition">
        <xsl:variable name="previous" select="/rdf:RDF/*[@rdf:about=$superseded]/rec:previousEdition/@rdf:resource"/>
        <xsl:text> first published as </xsl:text><a href="{$previous}"><xsl:value-of select="/rdf:RDF/*[@rdf:about=$previous]/dc:title"/> on <xsl:call-template name="date:makeDateFriendly"><xsl:with-param name="date" select="translate(/rdf:RDF/*[@rdf:about=$previous]/dc:date,'-','')"/></xsl:call-template></a>
      </xsl:if>
      </dd>
    </xsl:if>
  </xsl:if>
<xsl:text>
</xsl:text>
  </xsl:template>

  <xsl:template name="makeLinkRelative">
    <xsl:param name="uri"/>
    <xsl:param name="base" select="'http://www.w3.org/TR/'"/>
    <xsl:choose>
      <xsl:when test="starts-with($uri,$base)">
        <xsl:value-of select="substring-after($uri,$base)"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="dotdotslash">
          <xsl:with-param name="uri" select="$base"/>
        </xsl:call-template>
        <xsl:value-of select="substring-after($uri,'http://www.w3.org/')"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="dotdotslash">
    <xsl:param name="uri"/>
    <xsl:if test="contains(substring-after($uri,'http://www.w3.org/'),'/')">
      <xsl:text>../</xsl:text>
      <xsl:call-template name="dotdotslash">
        <!-- Caution! The URI sent as parameter is not kept valid -->
        <xsl:with-param name="uri" select="concat('http://www.w3.org/',substring-after(substring-after($uri,'http://www.w3.org/'),'/'))"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
</xsl:stylesheet>
