<?xml version="1.0"?>
<!-- Basic stylesheet for processing documents written in "faq.dtd" into
	HTML equivalents. Not very sophisticated, doesn't handle all the
	possible details (eg of <link/>), but it suffices.

	$Id: faqxsl.xsl,v 1.3 2003/10/22 20:13:54 plehegar Exp $
-->

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

  <xsl:output method="xml" indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
     
  <xsl:template match="/">
    <html lang="en" xml:lang="en">
        <xsl:apply-templates/>
    </html>
  </xsl:template>

  <xsl:template match="faq">
     <head>
	<title><xsl:value-of select="head/title"/></title>	
        <link href="/StyleSheets/activity-home.css" rel="stylesheet" type="text/css"/>
     </head>
     <body>
        <p align="right" class="navbar"><a href="/"><img align="left" src="/Icons/w3c_home" border="0" alt="W3C"/></a> <a href="/Architecture/" rel="in-domain"><img src="/Icons/arch" align="left" alt="Architecture Domain" border="0"/></a>
        <small><a href='Overview'>About DOM</a> .
        <a href='Activity'>DOM Activity statement</a><br />
        <a href='DOMTR'>Technical Reports</a> .
        <a href='DOMTM'>Technical Materials</a> <br />
        <a href='Test'>Test Suites</a> . FAQ
        . <a href='MailingList'>Mailing List</a><br />
        Member-restricted resource: <a href='Group/'>DOM Working Group</a>
	</small></p>
	<xsl:apply-templates/>
     </body>
  </xsl:template>

  <xsl:template match="head">
     <xsl:apply-templates mode="head"/>
     <!-- Gather and generate the table of contents -->
     <xsl:apply-templates select="/faq/body" mode="toc"/>
  </xsl:template>

  <xsl:template match="title" mode="head">
     <h1 align="center" class="title" id="top"><xsl:value-of select="."/></h1> 
  </xsl:template>

  <xsl:template match="version" mode="head">
     <small><xsl:value-of select="."/></small> 
  </xsl:template>

  <xsl:template match="maintain" mode="head">
    <address>Maintained by:
        <a href="mailto:{email}?subject={subject}"><xsl:value-of select="name"/></a>
     </address>  
  </xsl:template>

  <xsl:template match="intro" mode="head">
     <xsl:apply-templates/>
     <p>
     <small>(Note: We maintain this document's source as
	<a href="faq.xml">faq.xml</a>, using the markup
	language defined by <a href="faq.dtd">faq.dtd</a>.
	This XHTML version is generated from that source using
	<a href="faqxsl.xsl">faq.xsl</a>.)
     </small>
     </p>
  </xsl:template>


  <xsl:template match="body" mode="toc">
     <div class="toc">
       <h2><a id='toc' name="toc">table of contents</a></h2>
       <xsl:apply-templates select="section" mode="toc"/>
     </div>
  </xsl:template>

  <xsl:template match="section" mode="toc">
     <h3>
       <a href="#{@id}"><xsl:value-of select="title"/></a>
     </h3>
     <ul>
       <xsl:apply-templates select="qna" mode="toc"/>
     </ul>
  </xsl:template>

  <xsl:template match="qna" mode="toc">
     <li>
        <a href="#{@id}"><xsl:value-of select="q"/></a>
     </li>
  </xsl:template>



  <xsl:template match="section">
     <hr/>
     <h2><a name="{@id}" id="{@id}"><xsl:value-of select="title"/></a></h2>
     <dl>
	<xsl:apply-templates select="qna"/>
     </dl>
  </xsl:template>

  <xsl:template match="qna">
     <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="q">
     <dt><b>
        <a name="{../@id}" id="{../@id}"><xsl:value-of select="."/></a>
     </b></dt>
  </xsl:template>

  <!-- Note that "a" means answer, not anchor, in the faq.dtd language!
       If you want to generate a reference, use <link/>.
  -->
  <xsl:template match="a">
     <dd>
        <xsl:apply-templates/>

        <p align="left">
          <a href="#top">Return to Top</a>
        </p>
     </dd>
  </xsl:template>



  <xsl:template match="body">
       <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="link">
     <a href="{@href}">
      <xsl:apply-templates/>
     </a>
  </xsl:template>

  <xsl:template match="p">
     <p><xsl:apply-templates/></p>
  </xsl:template>

  <xsl:template match="ul">
     <ul><xsl:apply-templates/></ul>
  </xsl:template>
  <xsl:template match="ol">
     <ol><xsl:apply-templates/></ol>
  </xsl:template>
  <xsl:template match="code">
     <code><xsl:apply-templates/></code>
  </xsl:template>
  <xsl:template match="i">
     <i><xsl:apply-templates/></i>
  </xsl:template>
  <xsl:template match="li">
     <li><xsl:apply-templates/></li>
  </xsl:template>
  <xsl:template match="dl">
     <dl><xsl:apply-templates/></dl>
  </xsl:template>
  <xsl:template match="dd">
     <dd><xsl:apply-templates/></dd>
  </xsl:template>
  <xsl:template match="dt">
     <dt><xsl:apply-templates/></dt>
  </xsl:template>
  <!-- Anything not specifically handled is presumed to be
       HTML markup adopted into the FAQ DTD, and gets the
       identity transform. This is an attempt to avoid
       writing all the individual templates. -->
  <xsl:template match="@*|node()" priority="-1000">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>
