<?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>


  <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>
