<?xml-stylesheet href="http://www.w3.org/StyleSheets/base.css" type="text/css"?><?xml-stylesheet href="http://www.w3.org/2002/02/style-xsl.css" type="text/css"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns:rfc="http://www.rfc-editor.org/rfc-index" 
  exclude-result-prefixes="rfc">

<!-- Output method XML -->
<xsl:output method="xml" 
  indent="yes"
  omit-xml-declaration="no" 
  encoding="utf-8" 
  doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
  doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"  />

<!-- useful for tools based on the XSLT servlet -->
  <xsl:param name="xmlfile"/>
  <xsl:variable name="doc_uri">
    <xsl:choose>
      <xsl:when test="starts-with($xmlfile,'http://services.w3.org/tidy/tidy?docAddr=')">
        <xsl:value-of select="substring-after($xmlfile,'http://services.w3.org/tidy/tidy?docAddr=')"/>
      </xsl:when>
      <xsl:when test="starts-with($xmlfile,'http://services.w3.org/tidy/tidy?docAddr=')">
        <xsl:value-of select="substring-after($xmlfile,'http://services.w3.org/tidy/tidy?docAddr=')"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$xmlfile"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

 
<!-- Documenting the XSLT : fill the @@@-->
<html xmlns="http://www.w3.org/1999/xhtml" lang='en' xml:lang='en'>
  <head>
    <link rel="stylesheet" href="http://www.w3.org/StyleSheets/base"/>
    <title>IETF RFC References checker</title>
  </head>
  <body>
    <div class='head'><a href="/"><img src="/Icons/w3c_home" alt="W3C"/></a> <a href="http://www.w3.org/2002/01/tr-automation/">TR Automation</a></div>
    <h1>IETF RFC References checker</h1>

    <p>This XSLT style sheet flags links to <a href="http://www.ietf.org/rfc">IETF RFC documents</a> in a given XHTML that aren't the latest version of a document; this makes it a convenient tool to detect outdated references.</p>

    <form action="http://www.w3.org/2002/08/xslt4html" method="get">
      <div>
        <input type="hidden" name="xslfile" value="http://www.w3.org/2007/05/ietf-references-checker" />
        <p><label>URI of the HTML page: <input type="text" name="xmlfile" value="http://www.w3.org/" /></label></p>
        <p><input type="submit" value="Process" /><input type="reset" /></p>
      </div>
    </form>


    <p class="copyright">Copyright &#169; 1994-2007 <a href="http://www.w3.org/">World Wide Web Consortium</a>, (<a
href="http://www.csail.mit.edu/"><acronym title="Massachusetts Institute of
Technology">M.I.T.</acronym></a>, <a
href="http://www.ercim.org/"><acronym
title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>, <a
href="http://www.keio.ac.jp/">Keio University</a>). All Rights
    Reserved. http://www.w3.org/Consortium/Legal/. W3C <a href="http://www.w3.org/Consortium/Legal/copyright-software">software licensing</a> rules apply.</p>
    <address><a href="http://www.w3.org/People/LeHegaret/">Philippe Le H&#233;garet</a> - $Id: ietf-references-checker.xml,v 1.11 2012/03/30 15:51:45 plehegar Exp $</address>
    </body>
</html>

<xsl:variable name="rfcdata" select="document('http://www.w3.org/2007/05/rfc-index.xml')/rfc:rfc-index"/>

<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml" lang='en' xml:lang='en'>
  <head>
    <link rel="stylesheet" href="http://www.w3.org/StyleSheets/base"/>
    <title>IETF RFC References checker applied to <xsl:value-of select="/html:html/html:head/html:title"/></title>
  </head>
  <body>
    <div class='head'><a href="/"><img src="/Icons/w3c_home" alt="W3C"/></a> <a href="http://www.w3.org/2002/01/tr-automation/">TR Automation</a></div>
    <h1>IETF RFC References checker applied to <a href="{$doc_uri}"><xsl:value-of select="/html:html/html:head/html:title"/></a></h1>

    <p>The following references were found in this document, and point to an outdated version of an RFC:</p>
    <ul>
      <!-- finding all dated links to TR space -->
      <xsl:for-each select="//html:a[starts-with(@href,'http://www.ietf.org/rfc/rfc')]">
        <xsl:variable name="uri" select='@href'/>
	<xsl:variable name='number'
		      select='substring-before(substring-after($uri, "http://www.ietf.org/rfc/rfc"), ".txt")'/>
	<xsl:variable name='number'>
	  <xsl:choose>
	    <xsl:when test='substring-before(substring-after($uri, "http://www.ietf.org/rfc/rfc"), ".txt") != ""'>
	      <xsl:value-of select='substring-before(substring-after($uri, "http://www.ietf.org/rfc/rfc"), ".txt")'/>
	    </xsl:when>
	    <xsl:otherwise>
	      <xsl:value-of select='substring-after($uri, "http://www.ietf.org/rfc/rfc")'/>
	    </xsl:otherwise>
	  </xsl:choose>
	</xsl:variable>
	<xsl:variable name='rfc'
		      select='$rfcdata//rfc:rfc-entry[rfc:doc-id[text()=concat("RFC", $number)]]'/>
	<xsl:if test='$rfc/rfc:obsoleted-by'>
	  <li>The reference <q><xsl:apply-templates select="."/></q> is obsoleted by 
	  <xsl:for-each select='$rfc/rfc:obsoleted-by/rfc:doc-id'>
	    <a>
	      <xsl:attribute name='href'>
		<xsl:text>http://www.ietf.org/rfc/rfc</xsl:text>
		<xsl:value-of select='substring-after(., "RFC")'/>
		<xsl:text>.txt</xsl:text>
	      </xsl:attribute>
	      <xsl:text>RFC </xsl:text>
	      <xsl:value-of select='substring-after(., "RFC")'/>
	    </a>
	    <xsl:text>, </xsl:text>
	  </xsl:for-each>
	  </li>
	</xsl:if>
      </xsl:for-each>
      <xsl:for-each select="//html:a[starts-with(@href,'http://tools.ietf.org/html/rfc')]">
        <xsl:variable name="uri" select='@href'/>
	<xsl:variable name='number'>
	  <xsl:choose>
	    <xsl:when test='substring-before(substring-after($uri, "http://tools.ietf.org/html/rfc"), ".html") != ""'>
	      <xsl:value-of select='substring-before(substring-after($uri, "http://tools.ietf.org/html/rfc"), ".html")'/>
	    </xsl:when>
	    <xsl:otherwise>
	      <xsl:value-of select='substring-after($uri, "http://tools.ietf.org/html/rfc")'/>
	    </xsl:otherwise>
	  </xsl:choose>
	</xsl:variable>
	<xsl:variable name='rfc'
		      select='$rfcdata//rfc:rfc-entry[rfc:doc-id[text()=concat("RFC", $number)]]'/>
	<xsl:if test='$rfc/rfc:obsoleted-by'>
	  <li>The reference <q><xsl:apply-templates select="."/></q> is obsoleted by 
	  <xsl:for-each select='$rfc/rfc:obsoleted-by/rfc:doc-id'>
	    <a>
	      <xsl:attribute name='href'>
		<xsl:text>http://www.ietf.org/rfc/rfc</xsl:text>
		<xsl:value-of select='substring-after(., "RFC")'/>
		<xsl:text>.txt</xsl:text>
	      </xsl:attribute>
	      <xsl:text>RFC </xsl:text>
	      <xsl:value-of select='substring-after(., "RFC")'/>
	    </a>
	    <xsl:text>, </xsl:text>
	  </xsl:for-each>
	  </li>
	</xsl:if>
      </xsl:for-each>
      <li>nothing else</li>
    </ul>

    <h2>Check another page</h2>

    <p>This XSLT style sheet flags links to <a href="http://www.ietf.org/rfc/">IETF RFC documents</a> in a given XHTML that aren't the latest version of a document; this makes it a convenient tool to detect outdated references.</p>

    <form action="http://www.w3.org/2002/08/xslt4html" method="get">
      <div>
        <input type="hidden" name="xslfile" value="http://www.w3.org/2007/05/ietf-references-checker" />
        <p><label>URI of the HTML page: <input type="text" name="xmlfile" value="{$doc_uri}" /></label></p>
        <p><input type="submit" value="Process" /><input type="reset" /></p>
      </div>
    </form>

    <p class="copyright">Copyright &#169; 1994-2012 <a href="http://www.w3.org/">World Wide Web Consortium</a>, (<a
href="http://www.csail.mit.edu/"><acronym title="Massachusetts Institute of
Technology">M.I.T.</acronym></a>, <a
href="http://www.ercim.org/"><acronym
title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>, <a
href="http://www.keio.ac.jp/">Keio University</a>). All Rights
    Reserved. http://www.w3.org/Consortium/Legal/. W3C <a href="http://www.w3.org/Consortium/Legal/copyright-software">software licensing</a> rules apply.</p>
    <address>Produced by <a href="http://www.w3.org/2007/05/ietf-references-checker">an XSLT</a>, developed by <a href="http://www.w3.org/People/LeHegaret/">Philippe Le H&#233;garet</a> $Id: ietf-references-checker.xml,v 1.11 2012/03/30 15:51:45 plehegar Exp $</address>
    </body>
</html>
  
</xsl:template>

  <!-- default: Identity Transformation -->
  <xsl:template match="*|@*|comment()|text()">
    <xsl:copy>
      <xsl:apply-templates select="*|@*|comment()|text()"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>
