<?xml version="1.0"?>
<!-- faq2.css XSL Stylesheet for QAML 2.2 DTD.

        Stylesheet to create documents using Javascript API (IE 5)
        which go through one question at a time.

        Created: Rick Jelliffe, ricko@gate.sinica.edu.tw, 1999-05-25
        Based on C.T. Chang, ctchang@gate.sinica.edu.tw, 1999-04-04  
        Version: RJ for James Clark's XT, 1999-05-17
        
        QAML 2.1 DTD written by Justin Higgins and Rick Jelliffe.
        See information at http://www.faq.org/ or http://www.ascc.net/xml/
        
        Copyright (C) 1999, Academia Sinica Computing Center
        Permission granted to use freely for any purpose under
        MPL or GPL. However, please keep our names on it.

        Input: A FAQ marked-up in XML using the QAML 2.1 DTD
        Output: An HTML document, containing the FAQ with a table contents.                                                                                                                                            
        
        You can change the look of your FAQ by altering the CSS style
        sheet that is used by the HTML document generated by this stylesheet.
        
        To Do: Autonumbering
-->

<xsl:stylesheet
  xmlns:xsl='http://www.w3.org/XSL/Transform/1.0'
  xmlns="http://www.w3.org/TR/REC-html40"                  
  result-ns="">       
  <!--
 
  -->

  <!-- Root xsl:template - start processing here -->
  <xsl:template match="/" >
  <html>
    <xsl:apply-templates />
  </html>
  </xsl:template>

  <!-- head block -->
  <xsl:template match="head">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="{hdr/content}" />
    <meta name="Author" content="{maintain/name}" />
    <title><xsl:value-of select="title"/> <xsl:value-of select="version" /></title>
    <link rel="stylesheet" href="http://www.ascc.net/xml/resource/qaml/faq2-html.css"/>
    <!-- *** -->
    <script>
        function toggle(e) {
                if (e.style.display == "none") {
                        e.style.display = "";
                } else {
                        e.style.display = "none";
                }
        }
     </script>

  </head>
  </xsl:template>       

  <!-- body block -->
  <xsl:template match="body">
    <body xml-lang="{@xml-lang}">              
    <xsl:apply-templates/>
    <hr />
    <address>FAQ maintained by:
    <a href="mailto:{/faq/head/maintain/email}?subject={/faq/head/maintain/subject}"
    ><xsl:value-of select="/faq/head/maintain/name" /></a></address>      
    <hr />
    <p  >Expanding <a href="http://www.faq.org/">FAQ</a> automatically generated from a QAML document<br/> 
    by QAML Tools from 
    <a href="http://www.ascc.net/xml/">Academia Sinica Computing Center, Taipei, Taiwan</a>
    </p>
    </body>
  </xsl:template>
  
                                                                      
  <!-- section title -->
  <xsl:template match="section/title">
    <h1 class="title"  id="{@id}"><xsl:value-of select="."/></h1>
  </xsl:template>           
  
  
  <xsl:template match="logo"  >
    <center><img src="{@href}" alt="{@alt}"  id="{@id}" /></center>
  </xsl:template>
         

  <xsl:template match="qna">
    <div class="qna" id="{@id}">
    <xsl:apply-templates/>
    </div>
  </xsl:template>

  <xsl:template match="q">
    <!-- ***  -->
    <h3 class="q" id="{@id}" 
    onclick="toggle({../@id}_answer); "
    title="Answer: {../a/@gist} (Click here to show or hide the full Answer.)"><xsl:apply-templates/></h3>
  </xsl:template>

                  
    <!-- ***  -->
  <xsl:template match="author"  >   
  </xsl:template>

  <xsl:template match="span">
    <xsl:choose>
        <xsl:when test='@class="em"'>
          <em id="{@id}"><xsl:apply-templates/></em>
        </xsl:when>
        <xsl:when test='@class="strong"'>
          <strong id="{@id}"><xsl:apply-templates/></strong>
        </xsl:when>
        <xsl:when test='@class="tt"'>
          <tt id="{@id}"><xsl:apply-templates/></tt>
        </xsl:when>
        <xsl:when test='@class="b"'>
          <b id="{@id}"><xsl:apply-templates/></b>
        </xsl:when>
        <xsl:when test='@class="i"'>
          <i id="{@id}"><xsl:apply-templates/></i>
        </xsl:when>
        
        
        <xsl:when test='@class="literal"'>
          <tt xml-space="preserve" id="{@id}"><xsl:apply-templates/></tt>
        </xsl:when>        
        <xsl:when test='@class="abbr"'>
          <abbr  id="{@id}"><xsl:apply-templates/></abbr>
        </xsl:when>
        <xsl:when test='@class="acronym"'>
          <abbr  id="{@id}"><xsl:apply-templates/></abbr>
        </xsl:when>
        <xsl:otherwise>
          <span class="{@class}"  id="{@id}"><xsl:apply-templates/></span>
        </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="faq">
     <xsl:apply-templates/>
  </xsl:template>
   
  
      <!-- *** id="{@id}_answer}"-->
  <xsl:template match="a">      
      
     <div style="display:none" id="{../@id}_answer"
     title="Contributed by: {../author/name}(email: {../author/email})" ><xsl:apply-templates/></div>
  </xsl:template>
    
   
  <xsl:template match="section">
     <div class="section">
     <a name="{@id}" />
     <xsl:apply-templates/>
     </div>
  </xsl:template>
  
                              
  <xsl:template match="p[@class='pre-dc']" priority="+2">
    <pre class="pre-dc" xml-space="preserve" alt="{@alt}"  id="{@id}"><xsl:apply-templates/></pre>
  </xsl:template>
                                
  <xsl:template match="p[@class='pre']" priority="+2">
    <pre xml-space="preserve" alt="{@alt}"  id="{@id}"><xsl:apply-templates/></pre>
  </xsl:template>

  <xsl:template match="p[@class='li']" priority="+2"> 
    <li  id="{@id}"><xsl:apply-templates/></li>
  </xsl:template>



  <xsl:template match="section/p" priority="+1">
    <p class="misc" alt="{@alt}" id="{@id}"><xsl:apply-templates/></p>
  </xsl:template>
  
  <xsl:template match="p">
    <p class="{@class}" alt="{@alt}" id="{@id}"><xsl:apply-templates/></p>
  </xsl:template>


  <xsl:template match="div[@class='ol']" priority="+1"> 
    <ol  id="{@id}"><xsl:apply-templates/></ol>
  </xsl:template>

  <xsl:template match="div[@class='ul']" priority="+1"> 
    <ul  id="{@id}"><xsl:apply-templates/></ul>
  </xsl:template>

  <xsl:template match="div">
    <div class="{@class}" id="{@id}"><xsl:apply-templates/></div>
  </xsl:template>


  <xsl:template match="link[@img]" priority="+1">
    <img src="{@href}" alt="{@alt}"  id="{@id}"><xsl:apply-templates/></img>
  </xsl:template>


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

</xsl:stylesheet>

