<?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: schemafaq.xsl,v 1.3 2006/11/15 12:20:20 ht Exp $
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xlink="http://www.w3.org/1999/xlink" exclude-result-prefixes="xlink #default" xmlns="http://www.w3.org/1999/xhtml">

  <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 select="faq"/>
    </html>
  </xsl:template>

  <xsl:template match="faq">
     <head>
	<title><xsl:value-of select="head/title"/></title>	
        <link href="base.css" rel="stylesheet" type="text/css"/>
     </head>
     <body>

      <p class="navbar">
      <a href="http://www.w3.org/" name="top" id="top">
        <img src="http://www.w3.org/Icons/w3c_home.png" border="0" alt="W3C" height="48" width="72"/>
      </a>
      <a rel="in-domain" shape="rect" href="http://www.w3.org/Architecture/">
        <img border="0" width="212" src="http://www.w3.org/Icons/arch.png" alt="Architecture Domain" height="48"/>
      </a>
      <a href="http://www.nist.gov/">
        <img src="http://www.nist.gov/itl/div897/images/nist_home.gif" alt="National Institute of Standards and Technology" height="45" width="231" border="0"/>
      </a>
       <br/>
        <small>
	  <a href="http://www.w3.org/XML/Schema">About XML Schema</a> .
          <a href="index.html">XML Schema Test Suite Home</a> .
          Member-only resource:
	  <a href="http://www.w3.org/XML/Group/Schemas">XML Schema 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><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">
    Maintained by: <xsl:value-of select="name"/>, contact at
        <address><xsl:value-of select="subject"/>, <a href="mailto:{email}"><code><xsl:value-of select="email"/></code></a></address>
     
   <p>
     <small>(Note: We maintain this document's source as
	<a href="schemafaq.xml">schemafaq.xml</a>,
	using the markup language defined by 
	<a href="schemafaq.dtd">schemafaq.dtd</a>.
	This XHTML version is generated from that source using
	<a href="schemafaq.xsl">schemafaq.xsl</a>.)
     </small>
     </p>
  </xsl:template>

  <xsl:template match="intro" mode="head">
     <xsl:apply-templates/>
  </xsl:template>


  <xsl:template match="body" mode="toc">
     <div class="toc">
       <h2><a 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}"><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}"><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="foot">
  <hr/>
  <xsl:apply-templates/>  
  <div align="right">
   <a href="http://validator.w3.org/check?uri=referer">
    <img alt="Valid XHTML 1.0!" height="31" src="http://www.w3.org/Icons/valid-xhtml10" width="88"/>
   </a>
  </div>
 </xsl:template>
 
 <xsl:template match="contact">
  <address>
<small>
<a href="mailto:{email}"><xsl:value-of select="name"/></a>
   <xsl:text>, </xsl:text>
   <xsl:value-of select="org"/>
   <xsl:text>, </xsl:text>
   <xsl:value-of select="@role"/>
</small>
</address>
 </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>
