<?xml version="1.0" encoding="utf-8"?>

<!--  covered by the W3C copyright policy http://www.w3.org/Consortium/Copyright -->
<!--  based on http://www.w3.org/WAI/AU/sources/toc.xsl -->

<!--  This is for generating the Authoring Tool Accessibility Guidelines -->
<!--  For more information on the way this is done see heetp://www.w3.org/WAI/AU/sources -->


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns="http://www.w3.org/1999/xhtml"
  exclude-result-prefixes="#default"
  version="1.0">

  <!-- import the variable declarations... -->
  <xsl:import href="http://www.w3.org/WAI/AU/sources/techs-make.xsl"/>

  <!-- by default, copy everything verbatim -->
  <xsl:template match="@*|node()"> 
    <xsl:copy> 
      <xsl:apply-templates select="@*|node()"/> 
    </xsl:copy> 
  </xsl:template>

  <!-- put the right stuff in the header -->
  <xsl:template match="html:head">
    <head>
    <title>Techniques for Authoring Tool Accessibility <xsl:value-of select="$subVersion"/></title>
    <link rel="meta" href="metadata.rdf" />
    <link rel="style" href="$styleSheet" />
    </head>
  </xsl:template>

  <!-- put in the title, status and version information -->
  <xsl:template match="html:p[@id='titleStatus']">
    <h1 class="notoc">Techniques for Authoring Tool Accessibility <xsl:value-of select="$subVersion"/></h1>
    <h2 class="notoc">Working Draft <xsl:value-of select="$draftDate"/></h2>
    <dl>
      <dt>This Version:</dt>
      <dd><a href="{$thisVersion}"><xsl:value-of select="$thisVersion"/></a></dd>
    </dl>
    <h2>Warning. This is a test document</h2>
    <p>This document has been generated as a test
    for an XSLT stylesheet, and does not represent anything much.</p>
  </xsl:template>

  <!-- remove anything that is guidelines-specific, or source-doc specific -->
  <xsl:template match="*[@class='source']"/>
  <xsl:template match="*[@class='guidelines']"/>

  <!-- include the stylesheet for generating the table of contents -->
  <!-- xsl:include href="http://www.w3.org/WAI/AU/sources/toc.xsl"/ -->
 
  <!-- include definitions that we use -->
  <!-- when this works properly it will go into a seperate piece, and we'll pass it -->
  <!--  parameters to select definitions or references. From different files? -->

  <xsl:template match="html:div[@id='defs']">
    <div id="defs">
      <dl>
        <xsl:apply-templates select="/descendant::html:a[@rel='glossary']" mode="defs"/>
      </dl>
    </div>
  </xsl:template>

  <xsl:template match="html:a" mode="defs">
    <xsl:variable name="definedTerm" select="substring-after(@href,'#')"/>
    <xsl:copy-of select="document('defs.html')//html:dt[html:a/@id=$definedTerm]"/>
    <xsl:copy-of select="document('defs.html')//following::html:dd[preceding::html:dt[html:a/@id=$definedTerm]]"/>
  <!-- this will give multiple copies. Need to ensure that if we have one we don't get another -->
  <!-- I guess that means we could use a choice, to see if  there is one already... -->
  </xsl:template>

</xsl:stylesheet>
