<?xsl version="1.0" encoding="utf-8"?>
<!--  covered by the W3C copyright policy http://www.w3.org/Consortium/Copyright -->
<!--  command line to process:
      java org.apache.xalan.xslt.Process -IN wcag-src.html -XSL gl.xsl -OUT temp1.html
      This generates the Web Content Accessibility Guidelines, version 2.0.
      Maintained by Wendy Chisholm -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" version="1.0" encoding="ISO-8859-1" omit-xml-declaration="no" indent="no" media-type="text/html"/>
	<!-- versioning variables -->
	<xsl:variable name="draftDate">8 January 2002</xsl:variable>
	<xsl:variable name="thisVersion">http://www.w3.org/WAI/GL/WCAG20/WD-WCAG20-20030107.html</xsl:variable>
	<xsl:variable name="previousVersion">http://www.w3.org/WAI/GL/WCAG20/WD-WCAG20-20020828.html</xsl:variable>
	<xsl:variable name="latestVersion">http://www.w3.org/WAI/GL/WCAG20/</xsl:variable>
	<!-- apply to root node -->
	<xsl:template match="/">
		<xsl:apply-templates/>
	</xsl:template>
	<!-- by default, copy everything verbatim -->
	<xsl:template match="@*|node()">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
		</xsl:copy>
	</xsl:template>
	<!-- remove anything that is techniques-specific, or source-doc specific -->
	<xsl:template match="*[starts-with(@class,'techniques')]"/>
	<xsl:template match="*[@class='source']"/>
	<xsl:template match="@class[.='guidelines']"/>
	<xsl:template match="@class[.='bbccomment']"/>
	<!-- xsl:template match="html:style"/ -->
	<!-- to exclude issues, uncomment this line 
<xsl:template match="*[@class='issue']"/>-->
	<!-- put in the title, status and version information -->
	<xsl:template match="div[@id='versionInfo']">
		<div id="versionInfo">
			<h1>Web Content Accessibility Guidelines 2.0</h1>
			<h2>W3C Working Draft <xsl:value-of select="$draftDate"/>
			</h2>
			<dl>
				<dt>This version:</dt>
				<dd>
					<a href="{$thisVersion}">
						<xsl:value-of select="$thisVersion"/>
					</a>
				</dd>
				<dt>Latest version:</dt>
				<dd>
					<a href="{$latestVersion}">
						<xsl:value-of select="$latestVersion"/>
					</a>
				</dd>
				<dt>Previous version:</dt>
				<dd>
					<a href="{$previousVersion}">
						<xsl:value-of select="$previousVersion"/>
					</a>
				</dd>
				<dt>Editors:</dt>
				<dd>Ben Caldwell, Trace R&amp;D Center<br/>
				Wendy Chisholm, W3C<br/>
         Jason White, University of Melbourne<br/>
         Gregg Vanderheiden, Trace R&amp;D Center</dd>
			</dl>
		</div>
	</xsl:template>
	<!-- if headers have an id use it as a link destination -->
	<!-- otherwise generate link destinations for headers -->
	<xsl:template match="h2|h3|h4|h5|h6|h7">
	<!-- 20020911 WAC - commented out the xsl:copy and xsl:apply-templates to prevent
	ids from showing up on both the header element and its child a element.
	The link checker balks when both the header and a element define
	the same unique id, even if the header is the parent of the a element.
	Thus, this strips the id from the header element and creates a named anchor from it. -->
		<!-- xsl:copy -->
		<xsl:variable name="eName"><xsl:value-of select="name()"/></xsl:variable>
		<xsl:element name="{$eName}">
			<!-- xsl:apply-templates select="@*"/ -->
			<xsl:choose>
				<xsl:when test="@id">
					<a name="{@id}">
						<xsl:apply-templates/>
					</a>
				</xsl:when>
				<xsl:otherwise>
					<a name="{generate-id()}">
						<xsl:apply-templates/>
					</a>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:element>
		<!-- /xsl:copy -->
	</xsl:template>
	<!-- when we meet div with id="toc", we include the toc -->
	<!-- we keep the id in it so we can keep doing this -->
	<xsl:template match="div[@id='toc']">
		<div id="toc">
			<h2>
				<a name="contents" id="contents" accesskey="c">Table of Contents</a>
			</h2>
			<ul>
				<xsl:apply-templates select="following::h2[not(@class='notoc')]" mode="toc"/>
			</ul>
		</div>
	</xsl:template>
	<!-- generate the toc line for h2 -->
	<xsl:template match="h2" mode="toc">
		<li>
			<a href="#{@id}">
				<xsl:value-of select="."/>
			</a>
			<xsl:variable name="children" select="following::h3[not(@class='notoc')][preceding::h2[1] = current()]"/>
			<xsl:if test="count($children)>0">
				<ul>
					<xsl:apply-templates select="$children" mode="toc"/>
				</ul>
			</xsl:if>
		</li>
	</xsl:template>
	<!-- generate the toc line for h3 -->
	<xsl:template match="h3" mode="toc">
		<li>
			<a href="#{@id}">
				<xsl:value-of select="."/>
			</a>
			<xsl:variable name="children" select="following::dt[@class='toc'][preceding::h3[1] = current()]"/>
			<xsl:if test="count($children)>0">
				<ul>
					<xsl:apply-templates select="$children" mode="toc"/>
				</ul>
			</xsl:if>
		</li>
	</xsl:template>
	<xsl:template match="dt" mode="toc">
		<li>
			<a href="#{@id}">
				<xsl:value-of select="."/>
			</a>
		</li>
	</xsl:template>
	<!-- etc. -->
	<xsl:template match="h4" mode="toc">
		<li>
			<a href="#{@id}">
				<xsl:value-of select="."/>
			</a>
			<xsl:variable name="children" select="following::h5[@class='toc'][preceding::h4[1] = current()]"/>
			<xsl:if test="count($children)>0">
				<ol>
					<xsl:apply-templates select="children" mode="toc"/>
				</ol>
			</xsl:if>
		</li>
	</xsl:template>
	<xsl:template match="h5" mode="toc">
		<xsl:number format="1. "/>
		<a href="#{generate-id()}">
			<xsl:value-of select="."/>
		</a>
		<br/>
		<xsl:apply-templates select="following::h6[not(@class='notoc')][preceding::h5[1] = current()]" mode="toc"/>
	</xsl:template>
	<xsl:template match="h6" mode="toc">
		<xsl:number format="1. "/>
		<a href="#{generate-id()}">
			<xsl:value-of select="."/>
		</a>
		<br/>
	</xsl:template>

	<!-- when we meet div with id="terms", include the list of terms (and eventually their definitions)
	currently listed in the document-->
	<xsl:template match="div[@id='terms']">
		<div id="terms">
			<ol>
				<xsl:apply-templates select="//em[@class='term']" mode="dt"/>
			</ol>
		</div>
	</xsl:template>
	<!-- generate the definition list items -->
	<xsl:template match="em[@class='term']" mode="dt">
		<li>
			<xsl:value-of select="."/>
		</li>
	</xsl:template>
<!--	<xsl:template match="div[@class='criteria']li[@class='sc']">
		<li><xsl:number format="1.a.1.A "/>
			<xsl:value-of select="."/>
		</li>
		<br/>
		<xsl:apply-templates select="following::h5[preceding::h5[1] = current()]" mode="toc"/>
	</xsl:template>-->

</xsl:stylesheet>
