<?xml version="1.0"?>
<!-- 
The aim of this stylesheet is to produce a pubrules check HTML rapport from a xhtml document.

$Id: pubrules-checker.xml,v 1.420 2005/08/23 07:19:31 dom Exp $
-->
<?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 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:uri="http://www.w3.org/2000/07/uri43/uri.xsl?template="
xmlns:trd="http://www.w3.org/2001/10/trdoc-data.xsl"
xmlns:str="http://www.w3.org/2001/10/str-util.xsl"
xmlns:vld="http://www.w3.org/2001/11/is-valid.xsl"
xmlns:http="http://www.w3.org/2001/11/http-head.xsl"
exclude-result-prefixes="html uri trd str vld http"
xmlns:xt="http://www.jclark.com/xt"
extension-element-prefixes="xt">
  <xsl:import href="http://www.w3.org/2000/07/uri43/uri.xsl" />

  <xsl:import href="http://www.w3.org/2001/10/str-util.xsl" />

  <xsl:import href="http://www.w3.org/2001/10/trdoc-data.xsl" />

  <xsl:import href="http://www.w3.org/2001/11/is-valid.xsl" />

  <xsl:import href="http://www.w3.org/2001/11/http-head.xsl" />

  <xsl:output method="html" media-type="text/html"
  doctype-public="-//W3C//DTD HTML 4.01//EN"
  indent="yes" encoding="utf-8"/>

  <div xmlns="http://www.w3.org/1999/xhtml">
    
    <p><a href="http://www.w3.org/">
      <img src="http://www.w3.org/Icons/w3c_home" alt="W3C" width="72" height="48" />
      </a></p>

      <h1>XSLT stylesheet to check conformance to pubrules</h1>

    <p>$Id: pubrules-checker.xml,v 1.420 2005/08/23 07:19:31 dom Exp $</p>

    <p>More info on the <a href="pubrules-form">pubrules checker tool</a></p>
  </div>

<!-- doc_uri is the URI of the document -->
  <xsl:param name="doc_uri"/>

  <xsl:param name="xmlfile"/>

  <xsl:param name="auth"/>

  <xsl:param name="debug" select="0"/>

  <xsl:param name="recursive">
    <xsl:choose>
      <xsl:when test="normalize-space($doc_uri)">
        <xsl:value-of select="1"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="0"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:param>

  <xsl:variable name="long_status">
    <xsl:call-template name="trd:getStatus" />
  </xsl:variable>

  <xsl:variable name="short_status">
    <xsl:call-template name="trd:getShortStatus" />
  </xsl:variable>

  <xsl:variable name="origin">
    <xsl:call-template name="trd:getOrigin"/>
  </xsl:variable>

  <xsl:variable name="css_suffix">
    <xsl:if test="$short_status='SUBM' or $short_status='NOTE'">
      <xsl:value-of select="$origin"/>
      <xsl:text>-</xsl:text>
    </xsl:if>
    <xsl:value-of select="$short_status"/>
  </xsl:variable>

  <xsl:variable name="title"><xsl:call-template
  name="trd:getTitle"/></xsl:variable>

  <xsl:variable name="status_line"><xsl:call-template
  name="trd:getStatusSubtitle"/></xsl:variable>

  <xsl:variable name="this_version"><xsl:call-template name="trd:getVersionURI">
      <xsl:with-param name="which">this</xsl:with-param>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="latest_version"><xsl:call-template name="trd:getVersionURI">
      <xsl:with-param name="which">latest</xsl:with-param>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="previous_version"><xsl:call-template name="trd:getVersionURI">
      <xsl:with-param name="which">previous</xsl:with-param>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="date_status"><xsl:call-template
  name="trd:getNumericDate" /></xsl:variable>

  <xsl:variable name="editors_section"><xsl:call-template
  name="trd:getEditorsSectionName" /></xsl:variable>

  <xsl:variable name="tidy">
    <xsl:choose>
      <xsl:when test="starts-with($xmlfile,'http://cgi.w3.org/cgi-bin/tidy?docAddr=')"><xsl:text>http://cgi.w3.org/cgi-bin/tidy?docAddr=</xsl:text></xsl:when>
      <xsl:when test="starts-with($xmlfile,'http://cgi.w3.org/cgi-bin/tidy?docAddr=')"><xsl:text>http://cgi.w3.org/cgi-bin/tidy-if?docAddr=</xsl:text></xsl:when>
    </xsl:choose>
  </xsl:variable>

  <xsl:variable name="proxy_auth">
    <xsl:if test="$auth='proxy'">
      <xsl:text>&amp;auth=proxy</xsl:text>
    </xsl:if>
  </xsl:variable>

  <xsl:template match="/">
    <xsl:variable name="SOTD" select="/html:html/html:body//html:h2[translate(normalize-space() ,$str:uc,$str:lc)='status of this document']"/>

    <xsl:variable name="BoilerplateInSOTD"><xsl:apply-templates select="$SOTD/following-sibling::html:*[1]" mode="sotd-bp"/></xsl:variable>
    <xsl:variable name="BoilerplateInSOTD2"><xsl:apply-templates select="$SOTD/following-sibling::html:*[1]" mode="sotd-bp2"/></xsl:variable>
    <xsl:variable name="BoilerplateInSOTD3"><xsl:apply-templates select="$SOTD/following-sibling::html:*[1]" mode="sotd-bp3"/></xsl:variable>

    <xsl:variable name="ImplOrInteropLinkInSOTD">
      <xsl:apply-templates select="$SOTD/following-sibling::html:*[1]" mode="sotd-impl"/>        
    </xsl:variable>

    <xsl:variable name="TRLinkInSOTD">
      <xsl:apply-templates select="$SOTD/following-sibling::html:*[1]" mode="sotd-tr">
        <xsl:with-param name="TRLink">
          <xsl:choose>
            <xsl:when test="$short_status='SUBM' and $origin='Member'">
              <xsl:text>http://www.w3.org/Submission/</xsl:text>
            </xsl:when>
            <xsl:when test="$short_status='SUBM' and $origin='Team'">
              <xsl:text>http://www.w3.org/TeamSubmission/</xsl:text>
            </xsl:when>
            <xsl:otherwise>
              <xsl:text>http://www.w3.org/TR/</xsl:text>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
      </xsl:apply-templates>
    </xsl:variable>

    <xsl:variable name="FeedbackInSOTD"><xsl:if test="not(normalize-space($short_status)='SUBM')"><xsl:apply-templates select="$SOTD/following-sibling::html:*[1]" mode="sotd-feedback"/></xsl:if></xsl:variable>

    <xsl:variable name="MLArchivesInSOTD"><xsl:if test="not(normalize-space($short_status)='SUBM')"><xsl:apply-templates select="$SOTD/following-sibling::html:*[1]" mode="sotd-archives"/></xsl:if></xsl:variable>

    <xsl:variable name="PatentDisclosuresInSOTD">
      <xsl:apply-templates select="$SOTD/following-sibling::html:*[1]" mode="sotd-patent"/>
    </xsl:variable>

  <xsl:variable name="FeedBackDue">
    <xsl:call-template name="trd:getFeedbackDueDate"/>
  </xsl:variable>

    <xsl:variable name="isLastCall">
      <xsl:call-template name="trd:isLastCall"/>
    </xsl:variable>
    
    <xsl:variable name="isFirstPublicWorkingDraft">
      <xsl:call-template name="trd:isFirstPublicWorkingDraft"/>
    </xsl:variable>
    
    <xsl:variable name="isW3CPatentPolicy">
      <xsl:call-template name="trd:isW3CPatentPolicy"/>
    </xsl:variable>
    
    <xsl:variable name="is5February2004">
      <xsl:call-template name="trd:is5February2004"/>
    </xsl:variable>
    
    <xsl:variable name="fiveFeb04PP">
      <xsl:if test="normalize-space($isW3CPatentPolicy)='yes' and normalize-space($is5February2004)='yes'">
        <xsl:text>yes</xsl:text>
      </xsl:if>
    </xsl:variable>
    
    <xsl:variable name="PPTransitionProcedureLinkInSOTD">
      <xsl:apply-templates select="$SOTD/following-sibling::html:*[1]" mode="sotd-tr">
        <xsl:with-param name="TRLink">
          <xsl:text>http://www.w3.org/2004/02/05-pp-transition</xsl:text>
        </xsl:with-param>
      </xsl:apply-templates>
    </xsl:variable>
    
    <xsl:variable name="CallForExclusion">
      <!-- <xsl:call-template name="trd:isCallForExclusion"/> -->
      <xsl:apply-templates select="$SOTD/following-sibling::html:*[1]" mode="sotd-tr">
        <xsl:with-param name="TRLink">
          <xsl:text>http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Exclusion</xsl:text>
        </xsl:with-param>
      </xsl:apply-templates>
    </xsl:variable>
    
    
    <xsl:variable name="HTMLValidity">
      <xsl:choose>
        <xsl:when test="not($auth='proxy')">
          <xsl:call-template
            name="vld:is-html-valid"><xsl:with-param name="doc_uri"
          select="$doc_uri"/></xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <a href="http://validator.w3.org/check?uri={$doc_uri}">to check</a>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    
    <xsl:variable name="CSSValidity">
      <xsl:choose>
        <xsl:when test="not($auth='proxy')">
      <xsl:call-template name="vld:is-css-valid"><xsl:with-param name="doc_uri" select="$doc_uri"/></xsl:call-template>
              </xsl:when>
        <xsl:otherwise>
          <a href="http://jigsaw.w3.org/css-validator/validator?uri={$doc_uri}">to check</a>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    
    <xsl:variable name="newTR">
      <xsl:variable name="statusCode">
        <xsl:call-template name="http:get-status-code">
          <xsl:with-param name="doc_uri" select="$latest_version"/>
        </xsl:call-template>
      </xsl:variable>
      <xsl:if test="normalize-space($statusCode)='404'">yes</xsl:if>
    </xsl:variable>

    <html>
      <head>
        <title>Pubrules checker results</title>

        <link href="http://www.w3.org/StyleSheets/base" rel="stylesheet" />
	<link href="http://www.w3.org/2001/11/results" rel="stylesheet" />
	<meta http-equiv="Content-Type"
          content="text/html; charset=utf-8"/>
        <meta name="ROBOTS" content="NOINDEX,NOFOLLOW"/>
      </head>

      <body>
            <xsl:if test="$debug"><xsl:comment>status_line: <xsl:value-of
            select="$status_line"/> ; date: <xsl:value-of select="$date_status"/> ; long_status: <xsl:value-of select="$long_status"/></xsl:comment></xsl:if>

        <p>
        <a href="http://www.w3.org/">
          <img src="/Icons/w3c_home" alt="W3C" width="72" height="48" />
        </a>
        </p>

        <h1>Pubrules checker</h1>

        <h2>Status</h2>

        <p>This is a work in progress. The intent is to produce a 
        <a href="http://www.w3.org/TR/xslt">XSLT</a> <a href="http://www.w3.org/Guide/pubrules">pubrules</a>

        checker to help the editors and the webmaster to publish
        compliant <a href="http://www.w3.org/TR/">technical reports</a> (on the Recommendation tracks, but also <a href="http://www.w3.org/Submission/">Member Submissions</a> and <a href="http://www.w3.org/TeamSubmission/">Team Submissions</a>).</p>

        <p>This tool doesn't and probably won't ever be able to
        check all the points in pubrules: it may be used as a
        helper, not as a certificate.</p>

        <p>There is 
        <a href="http://www.w3.org/2001/07/pubrules-form">an HTML interface for this
        tool</a>

        and 
        <a href="http://www.w3.org/2001/09/pubrules-checker-doc">some
        documentation</a>

        .</p>

        <h2>
        <a name="results" id="results">
        </a>

        Results</h2>
        <xsl:choose>
          <xsl:when test="normalize-space($tidy) and /html:html/html:body/html:h1='Tidy your HTML'">
            <xsl:copy-of select="/html:html/html:body/html:p[@style]"/>
          </xsl:when>
          <xsl:otherwise>

        <p>Document checked: 
        <a href="{$doc_uri}">
          <xsl:value-of select="$title" />
        </a>
        </p>

        <dl>
<!--
There must be an absolute link to the appropriate
    technical report style sheet as follows. Any internal style sheets are
    cascaded before this link; i.e. the internal style sheets must not override the W3C tech report styles:
  
-->
          <dt>
            <span class="test">Is the last style sheet used the W3C
            one?</span></dt>
            <dd>
            <xsl:choose>
              <xsl:when test="/html:html/html:head/html:link[@rel='stylesheet']">
                <xsl:apply-templates
                select="/html:html/html:head/html:link[@rel='stylesheet'][position()=last()]" />
              </xsl:when>

              <xsl:otherwise>
              <span class="no">no</span>
              : No linked style sheet found</xsl:otherwise>
            </xsl:choose>
          </dd>

        <xsl:if test="normalize-space($short_status)">
          <dt>
            <span class="test">Is the W3C style sheet used the
            correct one (wrt the status)?</span></dt>
            <dd>
            <xsl:choose>
<!-- The following test takes the status part of style sheet href -->
<!-- (looking after - which separates W3C from the short status) and -->
<!-- remove a possible extension before comparing it to the short status -->
              <xsl:when
              test="/html:html/html:head/html:link[@rel='stylesheet'][position()=last()]/@href=concat('http://www.w3.org/StyleSheets/TR/W3C-',normalize-space($css_suffix)) or /html:html/html:head/html:link[@rel='stylesheet'][position()=last()]/@href=concat('http://www.w3.org/StyleSheets/TR/W3C-',normalize-space($css_suffix),'.css') or /html:html/html:head/html:link[@rel='stylesheet'][position()=last()]/@href=concat('/StyleSheets/TR/W3C-',normalize-space($css_suffix)) or /html:html/html:head/html:link[@rel='stylesheet'][position()=last()]/@href=concat('/StyleSheets/TR/W3C-',normalize-space($css_suffix),'.css')">
                <span class="yes">yes</span>
              </xsl:when>

              <xsl:otherwise>
              <span class="no">no</span>
              . The W3C style sheet shoud be
              http://www.w3.org/StyleSheets/TR/W3C-<xsl:value-of
              select="normalize-space($css_suffix)" /> (whereas it is currently 
              <xsl:value-of
              select="/html:html/html:head/html:link[@rel='stylesheet'][position()=last()]/@href" />
              )</xsl:otherwise>
            </xsl:choose>
          </dd>
        </xsl:if>

<!-- The following markup at the beginning of the head of the document:
  
<div class="head"> -->
          <dt>
            <span class="test">Is there a &lt;div class="head"&gt;
            section?:</span></dt>
            <dd>
            <xsl:choose>
              <xsl:when test="$trd:divHead">
                <span class="yes">yes</span>
              </xsl:when>

              <xsl:otherwise>
                <span class="no">no</span>, many other structural
                tests depends on the presence of this and won't be
                done due to its absence.
              </xsl:otherwise>
            </xsl:choose>
          </dd>

<xsl:if test="$trd:divHead">
<!-- The W3C logo must appear and must be
    referenced as follows:
 
<a href="http://www.w3.org/">
     <img height="48" width="72" alt="W3C"
      src="http://www.w3.org/Icons/w3c_home" /></a> -->
          <dt>
            <span class="test">Is the W3C Logo correct?</span></dt>
            <dd>
            <xsl:choose>
              <xsl:when
              test="$trd:divHead//html:a[@href='http://www.w3.org/']/html:img[@alt='W3C' and @src='http://www.w3.org/Icons/w3c_home' and @height='48' and @width='72']">

                <span class="yes">yes</span>
              </xsl:when>

              <xsl:otherwise>
                <xsl:choose>
                  <xsl:when
              test="$trd:divHead//html:a[@href='http://www.w3.org/']/html:img">
                    <span class="no">no</span><xsl:text>: The errors are: </xsl:text>
                    <ul>
                      <xsl:apply-templates
                        select="$trd:divHead//html:a[starts-with(@href,'http://www.w3.org') and html:img]" />
                      </ul>
                    </xsl:when>
                    <xsl:otherwise>
                      <span class="no">no</span><xsl:text>, logo not found in &lt;div class='head'&gt;</xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
              </xsl:otherwise>
            </xsl:choose>
          </dd>

          <xsl:if test="$short_status='SUBM'">
            <dt>
              <span class="test">Is there the appropriate Submission logo?</span></dt>
              <dd>
              <xsl:choose>
                <xsl:when test="$origin='Team'">
                  <xsl:choose>
                    <xsl:when test="$trd:divHead//html:a[@href='http://www.w3.org/TeamSubmission/']/html:img[@alt='W3C Team Submission' and @src='http://www.w3.org/Icons/team_subm']">
                      <span class="yes">yes</span>
                    </xsl:when>
                    <xsl:otherwise>
                      <span class="no">no</span>, check the markup used with the one required
                    </xsl:otherwise>
                  </xsl:choose>
                </xsl:when>
                <xsl:when test="$origin='Member'">
                  <xsl:choose>
                    <xsl:when test="$trd:divHead//html:a[@href='http://www.w3.org/Submission/']/html:img[@alt='W3C Member Submission' and @src='http://www.w3.org/Icons/member_subm']">
                      <span class="yes">yes</span>
                    </xsl:when>
                    <xsl:otherwise>
                      <span class="no">no</span>, check the markup used with the one required
                    </xsl:otherwise>
                  </xsl:choose>
                </xsl:when>
                <xsl:otherwise>
                  <span class="no">Something is wrong</span>, the type of submissions could not be determined (Team or Member?)
                </xsl:otherwise>
              </xsl:choose>
            </dd>
          </xsl:if>

<!-- The document's title is in the title element and an h1 element. -->
          <dt>
            <span class="test">Are the title in &lt;title&gt; and
            &lt;h1&gt; the same?</span></dt>
            <dd>
            <xsl:choose>
              <xsl:when
              test="normalize-space($trd:divHead//html:h1)=normalize-space($title)">

                <span class="yes">yes</span>
              </xsl:when>

              <xsl:otherwise>
              <span class="no">no</span>

              : 
              <pre><xsl:value-of
              select="normalize-space($trd:divHead//html:h1)" /></pre>

              different from 
              <pre><xsl:value-of
              select="normalize-space($title)" /></pre>
              </xsl:otherwise>
            </xsl:choose>
          </dd>

          <dt>
            <span class="test">Is the dated status subtitle
            correct?</span></dt>
            <dd>
            <xsl:choose>
              <xsl:when test="normalize-space($status_line) and normalize-space($long_status)">
                <span class="yes">yes</span> (<xsl:value-of select="$long_status" /> <xsl:comment><xsl:value-of select="$status_line"/></xsl:comment>)
              </xsl:when>
              <xsl:otherwise>
              <span class="no">no</span>: no h2 heading beginning with
              'W3C ' found in the head div or failed to parse it</xsl:otherwise>
            </xsl:choose>
          </dd>

          <xsl:if test="normalize-space($short_status)='REC'">
            <xsl:variable name="errata">
              <xsl:call-template name="trd:getErrata"/>
            </xsl:variable>
            <xsl:variable name="translations">
              <xsl:call-template name="trd:getTranslations"/>
            </xsl:variable>
            <dt><span class="test">Is there a link to the errata and the translations after the authors and before the copyright?</span></dt>
            <dd>
              <xsl:choose>
                <xsl:when test="normalize-space($errata)">
                  <xsl:choose>
                    <xsl:when test="normalize-space($translations)">
                      <span class="yes">yes</span>
                    </xsl:when>
                    <xsl:otherwise>
                      link to translations <span class="no">not found</span>
                    </xsl:otherwise>
                  </xsl:choose>
                </xsl:when>
                <xsl:otherwise>
                  link to the errata <span class="no">not found</span>
                </xsl:otherwise>
              </xsl:choose>
            </dd>
        </xsl:if>
        <xsl:choose>
          <xsl:when test="not($short_status='SUBM' and $origin='Member')">
            <dt>
            <span class="test">Are there errors in the copyright:</span></dt>
            <dd>
              <ul>
                <xsl:choose>
                  <xsl:when test="$trd:divHead//html:p[@class='copyright']">
                    <xsl:apply-templates
                      select="$trd:divHead//html:p[@class='copyright']"/>
		    <p>Note that &quot;software licensing&quot; must not be mentioned anymore in the copyright (<a href="http://www.w3.org/2004/02/02-pubrules.html#head">See Pubrules section 7.10</a>)</p>
                  </xsl:when>
                  <xsl:otherwise>
                    <li>
                      <span class="no">no</span>
                      : &lt;p class="copyright"&gt; not found in
                      &lt;div class="head"&gt;
                    </li>
                  </xsl:otherwise>
                </xsl:choose>
                <!-- This is to prevent the HTML to be invalid... ugly -->
                <li>No other errors found</li>
              </ul>
            </dd>
            <dt>
              <span class="test">Is there a &lt;hr/&gt; after the
              copyright?</span></dt>
              <dd>
              <xsl:choose>
                <xsl:when
                  test="($trd:divHead/following-sibling::html:*[1][local-name()='hr']) or ($trd:divHead/descendant::*[position()=last()][local-name()='hr'][preceding-sibling::html:*[1][local-name()='p' and @class='copyright']])">
                  <span class="yes">yes</span>
                </xsl:when>
                <xsl:otherwise>
                  <span class="no">No</span>
                </xsl:otherwise>
              </xsl:choose>
            </dd>
          </xsl:when>
          <xsl:otherwise>
            <dt>
              <span class="test">Is there a link to the W3C document notice?</span><xsl:text> </xsl:text></dt>
              <dd>
              <xsl:choose>
                <xsl:when test="$trd:divHead/descendant::*[local-name()='a']/@href='http://www.w3.org/Consortium/Legal/ipr-notice#Copyright'">
                  <span class="yes">yes</span>
                </xsl:when>
                <xsl:otherwise>
                  <span class="no">No</span>
                </xsl:otherwise>

              </xsl:choose>
            </dd>
          </xsl:otherwise>
        </xsl:choose>
        <dt>Versions links</dt>
            <xsl:choose>
              <xsl:when
              test="normalize-space($latest_version)">
                <xsl:apply-templates
                select="$trd:divHead//html:dt[translate(normalize-space(),'V:','v')='Latest version']" />
              </xsl:when>
              <xsl:otherwise><dd>"Latest version" link 
              <span class="no">not found</span></dd>
              </xsl:otherwise>
            </xsl:choose>

            <xsl:choose>
              <xsl:when
              test="normalize-space($this_version)">
                <xsl:apply-templates
                select="$trd:divHead//html:dt[translate(normalize-space(),'V:','v')='This version']" />
              </xsl:when>
              <xsl:otherwise>"This version" link 
              <span class="no">not found</span>
              </xsl:otherwise>
            </xsl:choose>

            <xsl:choose>
              <xsl:when
              test="normalize-space($previous_version)">
                <xsl:apply-templates
                  select="$trd:divHead//html:dt[starts-with(translate(normalize-space(),'V:','v'),'Previous version')]" />. 

                  <xsl:variable name="previous_etag">
                    <xsl:call-template name="http:get-etag">
                      <xsl:with-param name="doc_uri" select="normalize-space($previous_version)"/>
                    </xsl:call-template>
                  </xsl:variable>
                  <xsl:variable name="latest_etag">
                    <xsl:call-template name="http:get-etag">
                      <xsl:with-param name="doc_uri" select="normalize-space($latest_version)"/>
                    </xsl:call-template>
                  </xsl:variable>
                  <xsl:variable name="change_of_sn">
                    <xsl:call-template name="trd:hasNewShortname"/>
                  </xsl:variable>
                  <xsl:comment><xsl:value-of select="$previous_etag"/> <xsl:value-of select="$previous_etag"/></xsl:comment>
                  <xsl:if test="not(normalize-space($latest_etag)=normalize-space($previous_etag))">
                    <dd>The <a href="{$previous_version}">previous version</a> <span class="no">doesn't seem to match</span> with the current latest version (ETags differs).</dd>
                  </xsl:if>
                  <xsl:if test="normalize-space($change_of_sn)">
                    <dd>The shortnames are different in the previous version URI and in the latest version URI.<span class="tocheck">check that the new shortname got director's approval</span></dd>
                  </xsl:if>
              </xsl:when>
              <xsl:otherwise>
                <dd>"Previous version" link not found</dd>
                <xsl:choose>
                  <xsl:when test="normalize-space($newTR)='yes'"><span class='yes'>OK</span>, <xsl:value-of select="$latest_version"/> returns 404. <span class='tocheck'>Check that the doc got Director's approval</span></xsl:when>
                  <xsl:otherwise>
                    <dd>Something seems <span class='no'>wrong</span>, <xsl:value-of select="$latest_version"/> exists.</dd>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:otherwise>
            </xsl:choose>



        <dt><span class="test">Is there an Editor or Author
        section in the head of the document?</span></dt>
        <dd><xsl:choose><xsl:when
        test="normalize-space($editors_section)"><span
        class="yes">yes</span> (<xsl:call-template
        name="trd:getEditorsList"/>)</xsl:when><xsl:otherwise><span
        class="no">no</span> (no &lt;dt&gt; elements begining by
        'Author' or 'Editor' found)</xsl:otherwise></xsl:choose>
        </dd>


</xsl:if>
          <dt>
            <span class="test">If there is an abstract, is it
            marked up by &lt;h2&gt; and is it at the right location (just after the hr)?</span></dt>
            <dd>
              <xsl:choose>
                <xsl:when test="/html:html/html:body//html:h2[normalize-space()='Abstract']">
                  <xsl:choose>
                    <xsl:when test="/html:html/html:body//html:div[@class='head']/html:hr/following::html:*[1][normalize-space()='Abstract'] or /html:html/html:body//html:div[@class='head']/following::html:hr[1]/following::html:*[not(local-name()='div')][1][normalize-space()='Abstract']">
                      <span class="yes">yes</span>
                    </xsl:when>
                    <xsl:otherwise>
                      <span class="no">no</span>, not at the right location
                    </xsl:otherwise>
                  </xsl:choose>

                </xsl:when>

                <xsl:otherwise>
                <span class="tocheck">No</span>, check that if there
                is an abstract, its title is in a h2 tag.
        </xsl:otherwise>
              </xsl:choose>
          </dd>

          <dt>
            <span class="test">Is there a status of the document
            and is it correctly marked up?</span>
          </dt>
          <dd>
            <xsl:choose>
              <xsl:when
              test="$SOTD">
                <span class="yes">yes</span>
              </xsl:when>

              <xsl:otherwise>
              <span class="no">no</span>
              : SOTD not found (note that some tests relying on the SOTD won't be done because of this)</xsl:otherwise>
            </xsl:choose>
          </dd>
          <xsl:if test="$SOTD">
            <!-- Is it at the right location in the document: either just after the abstract, or, if there is no abstract, just after div class='head' or hr -->
            <dt>
              <xsl:text>Is it at the right place in the document (i.e. after the head and the abstract if there is one)? </xsl:text></dt>
              <dd>
              <xsl:choose>
                <xsl:when test="(/html:html/html:body//html:h2[normalize-space()='Abstract'] and /html:html/html:body//html:h2[normalize-space()='Abstract']/following::html:h2[1][translate(normalize-space(.),$str:uc,$str:lc)='status of this document']) or (not(/html:html/html:body//html:h2[normalize-space()='Abstract']) and /html:html/html:body//html:hr/following::html:*[1][translate(normalize-space(.),$str:uc,$str:lc)='status of this document'])">
                  <span class='yes'>yes</span>
                </xsl:when>
                <xsl:otherwise>
                  <span class='no'>no</span>
                </xsl:otherwise>
              </xsl:choose>
            </dd>
            <xsl:if test="$short_status='SUBM' and $origin='Member'">
              <dt><span class="test">Does the status section contain the standard boilerplate?</span></dt>
              <dd>
              <xsl:choose>
                <xsl:when test="normalize-space($BoilerplateInSOTD3)">
                  <span class="yes">yes</span>                    
                </xsl:when>
                <xsl:otherwise>
                  <span class='no'>no</span> (the SOTD must contain the following boilerplate: <code>By publishing this document, W3C acknowledges that [Submitting Members] have made a formal submission to W3C for discussion. Publication of this document by W3C indicates no endorsement of its content by W3C, nor that W3C has, is, or will be allocating any resources to the issues addressed by it. This document is not the product of a chartered W3C group, but is published as potential input to the &lt;a href="/Consortium/Process">W3C Process&lt;/a>. Publication of acknowledged Member Submissions at the W3C site is one of the benefits of &lt;a href="/Consortium/Prospectus/Joining">W3C Membership&lt;/a>. Please consult the requirements associated with Member Submissions of &lt;a href="http://www.w3.org/Consortium/Patent-Policy-20030520.html#sec-submissions">section 3.3 of the W3C Patent Policy&lt;/a>. Please consult the complete &lt;a href="/Submission">list of acknowledged W3C Member Submissions&lt;/a>.</code>
                </xsl:otherwise>
              </xsl:choose>  
              </dd>
            </xsl:if>

            <xsl:if test="not($short_status='SUBM')">
            <dt><span class="test">Does the status section contain the standard boilerplate?</span></dt>
            <dd>
            <xsl:choose>
              <xsl:when
            test="normalize-space($BoilerplateInSOTD)">
                <xsl:choose>
                  <xsl:when test="normalize-space($short_status)='REC' or normalize-space($BoilerplateInSOTD2)">
                    <span class="yes">yes</span>                    
                  </xsl:when>
                  <xsl:otherwise>
                    <span class='no'>no</span> (the SOTD must contain the following boilerplate: <code>Publication as a <xsl:value-of select="$long_status"/> does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.</code>
                  </xsl:otherwise>
                </xsl:choose>

              </xsl:when>
              <xsl:otherwise>
                <span
                  class="no">no</span> (the SOTD must contain the following markup: <code>&lt;p>&lt;em>This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the &lt;a href="http://www.w3.org/TR/">W3C technical reports index&lt;/a> at http://www.w3.org/TR/.&lt;/em>&lt;/p></code>
              </xsl:otherwise>
            </xsl:choose>
            </dd>
            </xsl:if>
            
            <dt><span class="test">Does the status section contain a link
            to the TR page (or the appropriate Submissions page)?</span></dt>
            <dd>
            <xsl:choose><xsl:when
            test="normalize-space($TRLinkInSOTD)"><span
            class="yes">yes</span></xsl:when><xsl:otherwise><span
            class="no">no</span> (not found)</xsl:otherwise></xsl:choose></dd>

            <xsl:if test="normalize-space($short_status)='CR' or normalize-space($short_status)='PR' or (normalize-space($short_status)='REC' and not(contains($previous_version,'/PER-')))">
              <dt>
                <span class="test">Does the status section contain a link to an interoperability or implementation report?</span>
              </dt>
              <dd>
                <xsl:choose>
                  <xsl:when test="normalize-space($ImplOrInteropLinkInSOTD)">
                    <span class="yes">candidate(s) found</span>: <xsl:copy-of select="$ImplOrInteropLinkInSOTD"/>
                  </xsl:when>
                  <xsl:otherwise>
                    <span class="no">no candidate found</span> (looking for links containing the word 'implementation' or 'interoperability', ignore if you're using other terms)
                  </xsl:otherwise>
                </xsl:choose>
            </dd>
            </xsl:if>
            
            <xsl:if test="not(normalize-space($short_status)='SUBM')">
              <dt><span class="test">Does the status section contain a link to an archived mailing list for feedback?</span></dt>
              <dd>
              <xsl:choose><xsl:when
              test="normalize-space($FeedbackInSOTD)"><span
              class="yes">yes</span> (<xsl:value-of
              select="$FeedbackInSOTD"/> <xsl:if test="not(contains($FeedbackInSOTD,'@'))">, but the email address <span class='tocheck'>looks bogus</span></xsl:if>) <xsl:if test="not(normalize-space($MLArchivesInSOTD))"><span class="tocheck">no link found to archives</span></xsl:if></xsl:when><xsl:otherwise><span
              class="no">no</span> (no mailto: link found)</xsl:otherwise></xsl:choose></dd>
            </xsl:if>
            
            <xsl:if test="not(normalize-space($short_status)='SUBM')">
              <xsl:variable name="activity_uris">
                <xsl:call-template name="trd:getActivity"/>
              </xsl:variable>
              <dt><span class="test">Is there a link to the Activity home page or the Activity statement in the status of the document?</span></dt>
              <dd>
              <xsl:choose>
                <xsl:when test="normalize-space($activity_uris)">
                  <span class="yes">yes</span> (<xsl:value-of select="$activity_uris"/>)
                </xsl:when>
                <xsl:otherwise>
                  <span class="no">no</span>, no link to an Activity information page found.
                </xsl:otherwise>
              </xsl:choose>
              </dd>
            </xsl:if>
        
            <xsl:if test="not(normalize-space($short_status)='SUBM')">
              <xsl:variable name="workinggroup_uris">
                <xsl:call-template name="trd:getWorkingGroup"/>
              </xsl:variable>
              <dt><span class="test">Is there a link to the Working Group home page in the status of the document?</span></dt>
              <dd>
              <xsl:choose>
                <xsl:when test="normalize-space($workinggroup_uris)">
                  <span class="yes">yes</span> (<xsl:value-of select="$workinggroup_uris"/>)
                </xsl:when>
                <xsl:otherwise>
                  <span class="no">no</span>, no link to a Working Group page found.
                </xsl:otherwise>
              </xsl:choose>
              </dd>
            </xsl:if>
        
        <xsl:if test="normalize-space($short_status)='WD' and normalize-space($newTR)='yes'">
          <dt><span class="test">Is there an indication that this is a First Public Working Draft?</span></dt>
          <dd>
          <xsl:choose>
            <xsl:when test="$isFirstPublicWorkingDraft='yes'">
              <span class="yes">yes</span>
            </xsl:when>
            <xsl:otherwise>
              <span class="no">no</span><xsl:text>, The expression "First Public Working Draft" was not found in the status section.</xsl:text>
            </xsl:otherwise>
          </xsl:choose>
          </dd>
          <xsl:if test="normalize-space($fiveFeb04PP)='yes'">
            <dt><span class="test">Does the status section include call for exclusions?</span></dt>
            <dd>
              <xsl:choose>
                <xsl:when test="normalize-space($CallForExclusion)='yes'">
                  <span class="yes">yes</span>
                </xsl:when>
                <xsl:otherwise>
                  <span class="no">No candidate found (see related <a href="http://www.w3.org/2004/02/02-pubrules.html#status">Pubrules section 1.3.1 point 2</a>)</span> (Note that the checker is searching for the following uri: http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Exclusion)
                </xsl:otherwise>
              </xsl:choose>
            </dd>
          </xsl:if>
        </xsl:if>

        <xsl:if test="normalize-space($short_status)='PR'">
          <dt><span class="test">Is there an email feedback link for the AC Reps to a team only mailing for PR Review?</span></dt>
          <dd>
          <xsl:choose>
            <!-- we check that we have found at least 2 email addresses for feedback -->
            <xsl:when test="contains(substring-after(normalize-space($FeedbackInSOTD),'@'),'@')">
              2 email addresses found in the status section. Check that <span class="tocheck">one of <xsl:value-of select="$FeedbackInSOTD"/> is a team only mailing list</span>
            </xsl:when>
            <xsl:otherwise>
              <span class="no">no</span>, only one email address has been found in the status section. There must be at least two of them.
            </xsl:otherwise>
          </xsl:choose>
          </dd>
        </xsl:if>

        <xsl:if test="normalize-space($short_status)='PER'">
          <dt><span class="test">Is there a date for the end of the PER review?</span></dt>
          <dd>
            <xsl:choose>
              <xsl:when test="normalize-space($FeedBackDue)">
                <span class="yes">yes</span> (<xsl:value-of select="$FeedBackDue"/>)
              </xsl:when>
              <xsl:otherwise>
                <span class="no">no</span>, no date found in the format DD Month YYYY in the SOTD <xsl:comment><xsl:value-of select="$FeedBackDue"/></xsl:comment>
              </xsl:otherwise>
            </xsl:choose>
          </dd>
        </xsl:if>
        
        
        <xsl:if test="normalize-space($short_status)='PR' or normalize-space($short_status)='CR' or (normalize-space($short_status)='WD' and normalize-space($isLastCall))">
          <dt><span class="test">Is there a deadline for feedback in the SOTD?</span></dt>
          <dd>
            <xsl:choose>
              <xsl:when test="normalize-space($FeedBackDue)">
                <span class="yes">yes</span> (<xsl:value-of select="$FeedBackDue"/>)
              </xsl:when>
              <xsl:otherwise>
                <span class="no">no</span>, no date found in the format DD Month YYYY in the SOTD <xsl:comment><xsl:value-of select="$FeedBackDue"/></xsl:comment> <xsl:if test="normalize-space($short_status)='WD' and normalize-space($isLastCall)">(Note that the checker believes this is a Last Call WD (because "last call" appears somewhere in the SOTD; if it is mistaken, ignore this message)</xsl:if>
              </xsl:otherwise>
            </xsl:choose>
          </dd>
        </xsl:if>  
        
        
        <xsl:if test="not(normalize-space($short_status)='SUBM') and not(normalize-space($short_status)='NOTE')">
          <dt><span class="test">Is there information about under which patent policy the document was produced?</span></dt>
          <dd>
            <xsl:choose>
              <xsl:when test="normalize-space($PPTransitionProcedureLinkInSOTD)">
                <span class="yes">yes</span> (This doc was produced under the CPP)
              </xsl:when>
              <xsl:when test="normalize-space($fiveFeb04PP)='yes'">
                <span class="yes">yes</span> (This doc was produced under the 5 February 2004 W3C patent Policy)
              </xsl:when>
              <xsl:otherwise>
                <span class="tocheck">No candidate found</span>, (Note that the checker is searching for either the expressions "W3C Patent Policy" &amp; "5 February 2004" or a link to the Patent Policy Transition Procedure for the document under the CPP: http://www.w3.org/2004/02/05-pp-transition; this doesn't apply if the document is produced by a PP Group and not expected to become a Recommendation
              </xsl:otherwise>
            </xsl:choose>
          </dd>
          <dt>Is the patent policy information consistent with information in IPP?</dt>
          <dd>
            <xsl:variable name="workinggroup_uris">
              <xsl:call-template name="trd:getWorkingGroup"/>
            </xsl:variable>
            <xsl:variable name="wgIpp" select="document('http://www.w3.org/2004/01/pp-impl/')/html:html/html:body//html:ol/html:li[html:a/@href=substring-before($workinggroup_uris,',')]/html:a[2]/@href"/>
            <xsl:choose>
              <!-- @@@ We don't deal with docs produced by more than 1 WG for now -->
              <xsl:when test="normalize-space(substring-after($workinggroup_uris,','))">
                Document produced by more than 1 group, <span class="tocheck">check manually</span>
              </xsl:when>
              <xsl:when test="normalize-space($fiveFeb04PP)='yes'">
                <xsl:choose>
                  <xsl:when test="$wgIpp and document($wgIpp)/html:html/html:body//html:table[1]//html:tr[descendant::html:a[@href=$latest_version] and not(contains(.,'CPP'))]">
                    <span class="yes">yes</span> (the group is in IPP, and lists this spec as a Patent Policy spec)
                  </xsl:when>
                  <xsl:when test="$wgIpp and $isFirstPublicWorkingDraft">
                    <span class="yes">probably OK</span> (group in IPP, and this spec is a FPWD)
                  </xsl:when>
                  <xsl:otherwise>
                    <span class="no">something seems wrong</span> (the group is not in IPP, or is in IPP but doesn't list this spec as PP)
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:when>
              <xsl:when test="normalize-space($PPTransitionProcedureLinkInSOTD)">
                <xsl:choose>
                  <xsl:when test="$wgIpp and document($wgIpp)/html:html/html:body//html:table[1]//html:tr[descendant::html:a[@href=$latest_version] and contains(.,'CPP')]">
                    <span class="yes">looks OK</span> (group in IPP, lists the spec as CPP)
                  </xsl:when>
                  <xsl:when test="$wgIpp">
                    <span class="no">something seems wrong</span> (the group is in IPP, and doesn't refer to this spec as CPP)
                  </xsl:when>
                  <xsl:otherwise>
                    Can't tell, probably OK but <span class="tocheck">check manually</span>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:when>
              <xsl:otherwise>
                <xsl:choose>
                  <xsl:when test="$wgIpp and document($wgIpp)/html:html/html:body//html:table[1]//html:tr[descendant::html:a[@href=$latest_version]]">
                    <span class="no">Something is wrong</span>, IPP knows about this spec, but this spec doesn't refer to any patent policy
                  </xsl:when>
                  <xsl:otherwise>
                    Can't tell,  <span class="tocheck">check manually</span>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:otherwise>
            </xsl:choose>
          </dd>
          <dt><span class="test">Does the status section contain a link to patents disclosures?</span></dt>
          <dd>
          <xsl:choose>
            <xsl:when test="normalize-space($PatentDisclosuresInSOTD)">
              <span class="yes">yes</span>
              <!-- Degree of confidentiality of the patent disclosure page (namely public or not) -->
              <xsl:variable name="confidentiality">
                <!-- Domain Qualified URI of the patent disclosure page -->
                <xsl:variable name="DQUri">
                  <xsl:if test="not(starts-with($PatentDisclosuresInSOTD,'http://'))">
                    <xsl:text>http://www.w3.org</xsl:text>
                  </xsl:if>
                  <xsl:value-of select="$PatentDisclosuresInSOTD"/>
                </xsl:variable>
                <!-- Status Code of the said page -->
                <xsl:variable name="status_code">
                  <xsl:call-template name="http:get-status-code">
                    <xsl:with-param name="doc_uri" select="$DQUri"/>
                  </xsl:call-template>
                </xsl:variable>
                <xsl:if test="$status_code=401 or $status_code=403">
                  <xsl:text>private</xsl:text>
                </xsl:if>
              </xsl:variable>
               (<a href="{$PatentDisclosuresInSOTD}"><xsl:value-of select="$PatentDisclosuresInSOTD"/></a>)
              <xsl:if test="$confidentiality = 'private'">
                <xsl:text>, but this page has a </xsl:text><span class="no">restricted access</span>
              </xsl:if>
            </xsl:when>
            <xsl:otherwise>
              <span class="tocheck">No candidate found</span> (this doesn't apply if the document is produced in a PP group and not expected to become a Recommendation) (Suggestion: use a link with <code>rel="disclosure"</code>; this is not mandatory, just recommended for pubrules checking ease)
            </xsl:otherwise>
          </xsl:choose>
          </dd>
        </xsl:if>
        
     </xsl:if>

          <dt>
            <span class="test">List of heading without id:</span></dt>
            <dd>
            <ul>
              <xsl:for-each
              select="/html:html/html:body//html:*[local-name()='h1' or
              local-name()='h2' or local-name()='h3' or
              local-name()='h4' or local-name='h5' or local-name='h6'][not(.//@id or .//@name) and not(translate(normalize-space(.),$str:uc,$str:lc)='status of this document' or translate(normalize-space(.),$str:uc,$str:lc)='abstract' or normalize-space(.)=normalize-space($title) or normalize-space(.)=normalize-space($status_line))]">
                  <li>
                    <span class="no">heading without id
                    found:</span>
                    <xsl:value-of select="." />
                  </li>
              </xsl:for-each>

              <li>No other heading without ids found
<!-- This is to prevent the HTML to be invalid... ugly -->
              </li>
            </ul>
          </dd>

          <dt><span class="test">Is the document HTML valid?</span></dt><dd> <span class="{$HTMLValidity}"><xsl:copy-of
         select="$HTMLValidity"/></span></dd>
        <dt><span class="test">Is the document CSS valid?</span></dt><dd> <span class="{$CSSValidity}"><xsl:copy-of select="$CSSValidity"/></span></dd>
        <dt><span class="test">Is there no relative link using "../"?</span></dt><dd> <xsl:choose><xsl:when test="/html:html/html:body//html:a[starts-with(@href,'../')]"><span class="no">no</span>; it will be broken at publication time</xsl:when><xsl:otherwise><span class="yes">yes</span></xsl:otherwise></xsl:choose></dd>
        </dl>

        <xsl:if test="normalize-space($short_status) and normalize-space($date_status) and normalize-space($title) and
        normalize-space($this_version) and normalize-space($latest_version)">
        <p>Collect your <a href="http://www.w3.org/2000/06/webdata/xslt?xmlfile={$xmlfile}&amp;xslfile=http%3A%2F%2Fwww.w3.org%2F2001%2F10%2Ftrdoc2rdf{$proxy_auth}">document metadata</a> and attach
        it to your publication request.</p>
        </xsl:if>

        <h3>Points which still need human check, but where I can
        help</h3>

        <dl>
          <dt>Do all the images have a <span class="tocheck">meaningful alternative text</span>?</dt>
          <dd>
          <ul>
            <xsl:for-each select="/html:html/html:body//html:img">
              <li>img: 
              <img alt="{@alt}">
                <xsl:attribute name="src">
                  <xsl:call-template name="uri:expand">
                    <xsl:with-param name="base"
                    select="$doc_uri" />
                    <xsl:with-param name="there" select="@src" />
                  </xsl:call-template>
                </xsl:attribute>
              </img>

              -&gt; alt: 
              <xsl:value-of select="@alt" />
	      <xsl:if test="not(normalize-space(@alt))">
                <span class="no">[this alt attribute is empty; this is only valid if the image doesn't bear any meaning]</span>
              </xsl:if>
              </li>
            </xsl:for-each>
          </ul>
          </dd>
        </dl>

        <h3>Points which still need to be checked by some other
        way</h3>

        <ul>
          <li>Are there 
          <span class="tocheck"><a href="http://validator.w3.org/checklink?uri={$doc_uri}&amp;recursive=on" title="Checking recursively for broken links in {$doc_uri}">broken link</a></span>?</li>
          <xsl:if test="$short_status='SUBM'">
            <li>Has the document publication been <span class="tocheck">approved by the Director</span> (needed even for minor revision of any submissions)?</li>
          </xsl:if>
          <li>Is the Status of the Document section correct?
          <ul>
            <li>The status section <span class="tocheck">must contain a customized paragraph</span> that has not been copied from another document. This section should include the title page date of the document and the publication date.</li>
            <xsl:if test="normalize-space($short_status)='SUBM'">
              <li>the status section <span class="tocheck">must explain</span> why W3C has published them (result of ack'd Member Submission; decision to publish Team Submission), that these are not W3C Recommendation track documents, and that publication does not imply endorsement by W3C, and that publication does not imply that any further action will be taken by W3C.</li>
            </xsl:if>
            <xsl:if test="not(normalize-space($short_status)='SUBM')">
              <li>is there <span class="tocheck">a link to changes since the previous transition</span> (e.g., a list of changes or a diff document or both)?</li>              
            </xsl:if>
            <xsl:if test="normalize-space($short_status)='PER'">
              <li><span class="tocheck">is there a link to a list of changes that may affect conformance</span>?</li>
            </xsl:if>
            <xsl:if test="normalize-space($short_status)='RSCND'">
              <li><span class="tocheck">is there a link to the rationale for rescinding</span>?</li>
            </xsl:if>
</ul>
</li>
          <li>Are all the 
          <span class="tocheck"><a href="http://www.w3.org/2003/09/nschecker?uri={$doc_uri}">
          visible URIs</a></span>
          in the whole document <a href="http://www.w3.org/1999/10/nsuri">valid</a>?</li>
          <li>if there has been a previous recommendation, <span class="tocheck"><a href="http://www.w3.org/Guide/pubrules#head">check the rules for versioning</a></span></li>
        </ul>

        <h3>For a compound document, these tests need to be done on
        the dependent pages:</h3>
          
          <p>List of dependent pages:</p>
          
          <table border="1">
            <thead>
              <tr>
                <th>URI</th>
                
                <th>HTML validation</th>
                
                <th>CSS Validation</th>
                
                <th>Other checks</th>
            </tr>
          </thead>
          
          <tbody>
            <xsl:call-template name="makeUnique">
              <xsl:with-param name="list">
                <xsl:for-each select="/html:html/html:body//html:a[@href]">
                  <xsl:sort select="@href"/>

                  <xsl:variable name="abs_uri">
                    <xsl:call-template name="uri:expand">
                      <xsl:with-param name="base"
                        select="$doc_uri" />
                      <xsl:with-param name="there"
                        select="@href"/>
                    </xsl:call-template>
                  </xsl:variable>
                    
                      
                      <xsl:if
                        test="substring-after($abs_uri,$doc_uri)">
                        <xsl:variable name="page_uri"><xsl:call-template
                        name="str:keep-before"><xsl:with-param
                        name="string" select="$abs_uri"/><xsl:with-param
                        name="delimiter">#</xsl:with-param></xsl:call-template></xsl:variable>
                        <xsl:if test="not($page_uri=$doc_uri)">
                          <xsl:variable name="ContentType"><xsl:if test="not($recursive=0)"><xsl:call-template name="http:get-content-type"><xsl:with-param name="doc_uri" select="$page_uri"/><xsl:with-param name="with-param">no</xsl:with-param></xsl:call-template></xsl:if></xsl:variable>
                          
                          <tr>

                            <td><a href="{$page_uri}"><xsl:value-of select="$page_uri"/></a></td>
                            <td>
                              <xsl:choose>
                                <xsl:when test="not($recursive=0 or $auth='proxy')">
                                  <xsl:variable name="HTMLValidity-dep"><xsl:if
                                  test="$ContentType='text/html'"><xsl:call-template
                                  name="vld:is-html-valid"><xsl:with-param
                                  name="doc_uri"
                                  select="$page_uri"/></xsl:call-template></xsl:if></xsl:variable>
                                  <xsl:choose><xsl:when test="normalize-space($HTMLValidity-dep)"><span class="{$HTMLValidity-dep}"><xsl:copy-of select="$HTMLValidity-dep"/></span></xsl:when><xsl:otherwise>N/A</xsl:otherwise></xsl:choose>
                                </xsl:when>
                                <xsl:otherwise>
                                  <span class="tocheck"><a href="http://validator.w3.org/check?uri={$page_uri}">Results</a></span>
                                </xsl:otherwise>
                              </xsl:choose>
                              
                            </td>
                            
                            <td>
                              <xsl:choose>
                                <xsl:when test="not($recursive=0 or $auth='proxy')">
                                  <xsl:variable name="CSSValidity-dep"><xsl:if
                                  test="$ContentType='text/html'"><xsl:call-template name="vld:is-css-valid"><xsl:with-param name="doc_uri" select="$page_uri"/></xsl:call-template></xsl:if></xsl:variable>
                                  
                                  <xsl:choose><xsl:when test="normalize-space($CSSValidity-dep)"><span class="{$CSSValidity-dep}"><xsl:copy-of select="$CSSValidity-dep"/></span></xsl:when><xsl:otherwise>N/A</xsl:otherwise></xsl:choose>
                                </xsl:when>
                                <xsl:otherwise>
                                  <span class="tocheck"><a href="http://jigsaw.w3.org/css-validator/validator?uri={$page_uri}">Results</a></span>
                                </xsl:otherwise>
                              </xsl:choose>
                              
                            </td>

                            <td>
                              <span class="tocheck"><a href="http://www.w3.org/2000/06/webdata/xslt?xmlfile={$tidy}{$page_uri}&amp;xslfile=http%3A%2F%2Fwww.w3.org%2F2002%2F02%2Fpubrules-compound&amp;status={$short_status}&amp;origin={$origin}{$proxy_auth}">Results</a></span>
                            </td>
                          </tr>
                        </xsl:if>
                      </xsl:if>
                    </xsl:for-each>
                  </xsl:with-param>
                </xsl:call-template>
                <!-- Ugly hack for HTML validity -->
                <tr><td colspan="4">No other dependent document found</td></tr>
              </tbody>
            </table>

        <p>Tests that subpart must pass:</p>

        <ul>
          <li>Does their images have appropriate alternative
          textes?</li>

          <li>Is the W3C style sheet the last called and the good
          one?</li>

          <li>Are they HTML and CSS valid?</li>

          <li>Are they using valid www.w3.org URIs?</li>
        </ul>
          </xsl:otherwise>
        </xsl:choose>
        <h2>Check another document</h2>
        <form action="http://www.w3.org/2001/07/pubrules-form" method="get">
          <div>
            <label>URI of the document to check against pubrules: <input
            name="uri" value=""/></label><br />
            <label><input type="checkbox" name="recursive"><xsl:if test="not($recursive=0)"><xsl:attribute name="checked">checked</xsl:attribute></xsl:if></input>Check the HTML and CSS validity of the dependent documents (useful for compound document, if they are not too big!)? </label> <br />
            <label><input type="checkbox" name="auth"><xsl:if test="normalize-space($proxy_auth)"><xsl:attribute name="checked">checked</xsl:attribute></xsl:if></input>Needs to proxy authorization (for resources behind HTTP Basic Authentication - experimental)? </label> <br />
            <input type="hidden" name="auth" value="proxy"/><input type="submit" value="Submit" />
          </div></form>
        <hr />

        <address>
        <a href="http://www.w3.org/People/Dom/">Dominique Haza&#235;l-Massieux</a>

        <br />

        Produced by $Id: pubrules-checker.xml,v 1.420 2005/08/23 07:19:31 dom Exp $</address>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="*|@*">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()" />
    </xsl:copy>
  </xsl:template>

<!-- Check that the last style sheet called is the W3C one -->
  <xsl:template
  match="html:link[@rel='stylesheet'][position()=last()]">
    <xsl:choose>
      <xsl:when
      test="starts-with(@href,'http://www.w3.org/StyleSheets/TR/W3C-') or starts-with(@href,'/StyleSheets/TR/W3C-')">

        <xsl:choose>
          <xsl:when test="following-sibling::html:style">
            <span class="no">no: style element detected after the
            W3C style sheet</span>
          </xsl:when>

          <xsl:otherwise>
            <span class="yes">yes</span>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>

      <xsl:otherwise>
        <span class="no">no: last style sheet called is 
        <xsl:value-of select="@href" />, expecting one matching <code>http://www.w3.org/StyleSheets/TR/W3C-<var>status</var></code>
        </span>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>


<!-- Check that the logo is correct -->
  <xsl:template
  match="html:div[@class='head']//html:a[starts-with(@href,'http://www.w3.org') and html:img]">

    <xsl:call-template name="compare-childs">
      <xsl:with-param name="element"
      select="document('http://www.w3.org/2001/07/pubrules-copyright.xml')/html:html/html:body/html:div[@id='logo']/html:a" />
    </xsl:call-template>
  </xsl:template>

<!-- Check that the copyright is correct-->
  <xsl:template
  match="html:div[@class='head']/html:p[@class='copyright']">
    <xsl:call-template name="compare-childs">
      <xsl:with-param name="element"
      select="document('pubrules-copyright.xml')/html:html/html:body/html:p[@class='copyright']" />
    </xsl:call-template>
    <xsl:if
    test="number($date_status) and not(contains(.,substring($date_status,1,4)))"><li><span
    class="no">No mention</span> of the year of the document
    (<xsl:value-of select="substring($date_status,1,4)"/>)
    in the copyright (<xsl:value-of select="."/>)[check they
    match]</li></xsl:if>
    <xsl:if test="not(normalize-space(.))"><li><span class='no'>Empty copyright</span>?</li></xsl:if>
  </xsl:template>


  <!-- @@@ This looks really broken, honestly -->
  <xsl:template name="compare-childs">
    <xsl:param name="element" />

    <xsl:for-each select="*">
      <xsl:variable name="pos" select="position()" />

      <xsl:call-template name="compare-attributes">
        <xsl:with-param name="node"
        select="$element/*[position() - $pos = 0]" />
      </xsl:call-template>

      <xsl:if
      test="not(normalize-space(.)=normalize-space($element/*[position() - $pos = 0])) or not($element/*[position() - $pos = 0])">
        <li>
        <span class="no">Incorrect text</span>: "<xsl:value-of
        select="normalize-space()" />" should be "<xsl:value-of
        select="$element/*[position() - $pos = 0]" />"
        .</li>
      </xsl:if>

      <xsl:call-template name="compare-childs">
        <xsl:with-param name="element"
        select="$element/*[position() - $pos = 0]" />
      </xsl:call-template>
    </xsl:for-each>
  </xsl:template>

  <xsl:template name="compare-attributes">
    <xsl:param name="node" />
    <xsl:variable name="node2" select="." />

    <xsl:for-each select="$node/@*">
      <xsl:variable name="attribute-name" select="local-name()" />
      <xsl:choose>
        <xsl:when
        test="not($node2/@*[local-name()=$attribute-name])">
          <li>
            <span class="no">Could not find attribute <xsl:value-of
            select="$attribute-name" /> in <xsl:copy-of select="$node2" />
            </span>
          </li>
        </xsl:when>

        <xsl:otherwise>
          <xsl:if
          test="not(normalize-space($node2/@*[local-name()=$attribute-name])=normalize-space(.))">
            <li>Attribute <xsl:value-of select="$attribute-name" />
            in <xsl:copy-of select="$node2" /> has the <span
            class="no">incorrect value</span> <xsl:value-of
            select="$node2/@*[local-name()=$attribute-name]" />
            (should be <xsl:value-of select="." />
            </li>
          </xsl:if>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="html:div[@class='head']//html:dt">
    <dd><span class="test">Is the "
    <xsl:value-of select="." />
    " link correct?</span>

    <xsl:call-template name="versions_link" /></dd>
  </xsl:template>

<!-- check that the href and the printed URIs are the same -->
  <xsl:template name="versions_link">
    <xsl:choose>
      <xsl:when
        test="following-sibling::html:dd[1]//html:a[1]/@href=normalize-space(following-sibling::html:dd[1]//html:a[1])">

        <xsl:choose>
          <xsl:when test="translate(normalize-space(),'V:','v')='This version'">
            <xsl:call-template name="this_version" />
          </xsl:when>

          <xsl:otherwise>
            <span class="yes">yes</span>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>

      <xsl:otherwise>
      <span class="no">no</span>(<xsl:value-of
      select="following-sibling::html:dd[1]//html:a[1]/@href" /> different from 
      <xsl:value-of
        select="normalize-space(following-sibling::html:dd[1]//html:a[1])" />)</xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="this_version">
    <xsl:choose>
      <xsl:when
        test="contains($this_version,concat('/',$short_status,'-')) and ($short_status='SUBM' or (starts-with($this_version,'http://www.w3.org') and substring(substring-before($this_version,'-'),27)=$short_status))">
        <xsl:variable name="shortname">
          <xsl:call-template name="extractShortNameFromLatestVersionURI">
            <xsl:with-param name="string" select="substring-after($latest_version,'http://www.w3.org/')"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:choose>
          <xsl:when
            test="($short_status!='SUBM' and starts-with($this_version,concat('http://www.w3.org/TR/',substring($date_status,1,4),'/',$short_status,'-',$shortname,'-'))) or contains($this_version,concat('/',$short_status,'-',$shortname,'-'))">
            <xsl:variable name="date_link"
            select="translate(substring-after($this_version,concat($short_status,'-',$shortname,'-')),'/','')" />
<!-- Testing if the date matches the document's date-->
            <xsl:choose>
              <xsl:when test="$date_status=$date_link">
                <xsl:choose>
                  <xsl:when test="count(following-sibling::html:dd[1]//html:a[@href])=1">
                    <span class="yes">yes</span>
                  </xsl:when>
                  <xsl:otherwise>
                    <span class="no">no</span>, several links in the "this version" link. Only one is admitted (alternative formats must be as described in pubrules 7.8)
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:when>

              <xsl:otherwise>
              <span class="no">no</span>, the date of the document
              (<xsl:value-of select="$date_status" />) and the one of
              the URI (<xsl:value-of select="$date_link" />) doesn't
              match (or the status subtitle is not in the expected format 
              <em>W3C Status [D]D Month YYYY</em>)</xsl:otherwise>
            </xsl:choose>
          </xsl:when>

          <xsl:otherwise>
          <span class="no">no</span>
          (the link <xsl:value-of
          select="following-sibling::html:dd[1]/html:a/@href"/>
          <xsl:choose>
            <xsl:when test="$short_status!='SUBM'">
              doesn't start with <code><xsl:value-of select="concat('http://www.w3.org/TR/',substring($date_status,1,4),'/',$short_status,'-',$shortname,'-')" /></code>      
            </xsl:when>
            <xsl:otherwise>
              doesn't contain <code><xsl:value-of select="concat('/',$short_status,'-',$shortname,'-')"/></code>
            </xsl:otherwise>
          </xsl:choose>
          <xsl:text>)</xsl:text>
        </xsl:otherwise>
        </xsl:choose>
      </xsl:when>
      <xsl:otherwise>
        <span class="no">no</span>The short status (<xsl:value-of select="substring(substring-before($this_version,'-'),27)" />) doesn't match the long one (<xsl:value-of select="$long_status" />), or the "this version" link is not well formatted (a la http://www.w3.org/TR/<var>YYYY</var>/<var>status</var>-<var>shortname</var>-<var>YYYYMMDD</var>)</xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="extractShortNameFromLatestVersionURI">
    <xsl:param name="string"/>
    <xsl:choose>
      <xsl:when test="contains($string,'/') and substring-after($string,'/')">
        <xsl:call-template name="extractShortNameFromLatestVersionURI">
          <xsl:with-param name="string" select="substring-after($string,'/')"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="translate($string,'/','')"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>


  <!-- This uses an XT extension to keep only unique dependent documents -->
  <xsl:template name="makeUnique">
    <xsl:param name="list"/>
    <xsl:choose>
      <xsl:when test="function-available('xt:node-set')">
        <xsl:for-each select="xt:node-set($list)/tr">
          <xsl:if test="not(preceding::tr[1]/td[1] = ./td[1])">
            <xsl:copy>
              <xsl:apply-templates select="@*|node()"/>
            </xsl:copy>
          </xsl:if>
        </xsl:for-each>
      </xsl:when>
      <xsl:otherwise>
        <xsl:copy-of select="$list"/>
      </xsl:otherwise>
    </xsl:choose>

  </xsl:template>

  <!-- This is the recursive template to look for the boilerplate in the SOTD -->
  <xsl:template match="html:*[not(starts-with(local-name(),'h'))]" mode="sotd-bp">
    <xsl:choose>
      <xsl:when test="normalize-space(descendant-or-self::html:p/html:em)='This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.' and normalize-space(descendant-or-self::html:p/html:em/html:a[@href='http://www.w3.org/TR/'])='W3C technical reports index'">
        <xsl:text>yes</xsl:text>
      </xsl:when>
      <xsl:otherwise>        
        <xsl:if test="following-sibling::html:*[1][not(descendant-or-self::*[(starts-with(local-name(),'h'))])]">
          <xsl:apply-templates select="following-sibling::html:*[1]" mode="sotd-bp"/>
        </xsl:if>
      </xsl:otherwise>

    </xsl:choose>
  </xsl:template>

  <!-- This is the recursive template to look for another boilerplate in the SOTD -->
  <xsl:template match="html:*[not(starts-with(local-name(),'h'))]" mode="sotd-bp2">
    
    <xsl:choose>
      <xsl:when test='contains(normalize-space(self::html:p),concat("Publication as a ",$long_status," does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than &apos;work in progress.&apos;"))'>
        <xsl:text>yes</xsl:text>
      </xsl:when>
      <xsl:when test="contains(normalize-space(self::html:p),concat('Publication as a ',$long_status,' does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than &quot;work in progress.&quot;'))">
        <xsl:text>yes</xsl:text>
      </xsl:when>
      <xsl:when test="contains(normalize-space(self::html:p),concat('Publication as a ',$long_status,' does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.'))">
        <xsl:text>yes</xsl:text>
      </xsl:when>
      <xsl:otherwise>        
        <xsl:if test="following-sibling::html:*[1][not(descendant-or-self::*[(starts-with(local-name(),'h'))])]">
          <xsl:apply-templates select="following-sibling::html:*[1]" mode="sotd-bp2"/>
        </xsl:if>
      </xsl:otherwise>

    </xsl:choose>
  </xsl:template>

  <!-- This is the recursive template to look for another the boilerplate in the SOTD (Member Submission) -->
  <xsl:template match="html:*[not(starts-with(local-name(),'h'))]" mode="sotd-bp3">
    <xsl:choose>
      <xsl:when test="descendant-or-self::html:p[contains(normalize-space(.),'By publishing this document, W3C acknowledges that')  and  contains(normalize-space(.),' made a formal submission to W3C for discussion. Publication of this document by W3C indicates no endorsement of its content by W3C, nor that W3C has, is, or will be allocating any resources to the issues addressed by it. This document is not the product of a chartered W3C group, but is published as potential input to the W3C Process. Publication of acknowledged Member Submissions at the W3C site is one of the benefits of W3C Membership. Please consult the requirements associated with Member Submissions of section 3.3 of the W3C Patent Policy. Please consult the complete list of acknowledged W3C Member Submissions.')]">
        <xsl:text>yes</xsl:text>
      </xsl:when>
      <xsl:otherwise>        
        <xsl:if test="following-sibling::html:*[1][not(descendant-or-self::*[(starts-with(local-name(),'h'))])]">
          <xsl:apply-templates select="following-sibling::html:*[1]" mode="sotd-bp3"/>
        </xsl:if>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>


  <!-- This is the recursive template to look for a link to the TR (or Member Subimissions or Team Submissions) page in the SOTD -->
  <xsl:template match="html:*[not(starts-with(local-name(),'h'))]" mode="sotd-tr">
    <xsl:param name="TRLink"/>
    <xsl:choose>
      <xsl:when test="descendant::html:a/@href=$TRLink 
                      or descendant::html:a/@href=substring-after($TRLink,'http://www.w3.org') 
                      or (substring($TRLink,string-length($TRLink))='/' and 
                      (descendant::html:a/@href=substring($TRLink,1,string-length($TRLink)-1) or descendant::html:a/@href=substring-after(substring($TRLink,1,string-length($TRLink)-1),'http://www.w3.org')))">
        <xsl:text>yes</xsl:text>
      </xsl:when>
      <xsl:otherwise>        
        <xsl:if test="following-sibling::html:*[1][not(descendant-or-self::*[(starts-with(local-name(),'h'))])]">
          <xsl:apply-templates select="following-sibling::html:*[1]" mode="sotd-tr">
            <xsl:with-param name="TRLink" select="$TRLink"/>
          </xsl:apply-templates>
        </xsl:if>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  

  <!-- This is the recursive template to look for a link to an implemantation report in the SOTD -->
  <xsl:template match="html:*[not(starts-with(local-name(),'h'))]" mode="sotd-impl">
    <xsl:for-each
      select="descendant::html:a"><xsl:if
    test="contains(.,'implementation') or contains(.,'Implementation') or contains(.,'interoperability') or contains(.,'Interoperability')"><a href="{@href}"><xsl:value-of
    select="@href"/></a>, </xsl:if></xsl:for-each>
    <xsl:if test="following-sibling::html:*[1][not(descendant-or-self::*[(starts-with(local-name(),'h'))])]">
      <xsl:apply-templates select="following-sibling::html:*[1]" mode="sotd-impl"/>
    </xsl:if>
  </xsl:template>


  <!-- This is the recursive template to look for mailto links in the SOTD -->
  <xsl:template match="html:*[not(starts-with(local-name(),'h'))]" mode="sotd-feedback">
    <xsl:for-each
      select="descendant::html:a"><xsl:if
    test="starts-with(@href,'mailto:')"><xsl:value-of
    select="substring-after(@href,'mailto:')"/>, </xsl:if></xsl:for-each>
    <xsl:if test="following-sibling::html:*[1][not(descendant-or-self::*[(starts-with(local-name(),'h'))])]">
      <xsl:apply-templates select="following-sibling::html:*[1]" mode="sotd-feedback"/>
    </xsl:if>
  </xsl:template>

  <!-- This is the recursive template to look for links to public ml archives -->
  <xsl:template match="html:*[not(starts-with(local-name(),'h'))]" mode="sotd-archives">
    <xsl:for-each
      select="descendant::html:a"><xsl:if
    test="starts-with(@href,'http://lists.w3.org/Archives/Public/')"><xsl:value-of
    select="@href"/>, </xsl:if></xsl:for-each>
    <xsl:if test="following-sibling::html:*[1][not(descendant-or-self::*[(starts-with(local-name(),'h'))])]">
      <xsl:apply-templates select="following-sibling::html:*[1]" mode="sotd-archives"/>
    </xsl:if>
  </xsl:template>

  <!-- This is the recursive template to look for links to a patent disclosure page -->
  <xsl:template match="html:*[not(starts-with(local-name(),'h'))]" mode="sotd-patent">
    <xsl:choose>
      <xsl:when test="descendant::html:a[@rel='disclosure' or contains(translate(@href,$str:uc,$str:lc),'disclosure') or contains(translate(@href,$str:uc,$str:lc),'ipr')]">
        <xsl:value-of select="descendant::html:a[@rel='disclosure' or contains(translate(@href,$str:uc,$str:lc),'disclosure') or contains(translate(@href,$str:uc,$str:lc),'ipr')]/@href"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:if test="following-sibling::html:*[1][not(descendant-or-self::*[(starts-with(local-name(),'h'))])]">
          <xsl:apply-templates select="following-sibling::html:*[1]" mode="sotd-patent"/>  
        </xsl:if>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>

