<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/TR/WD-xsl' xmlns:e='http://www.jclark.com/XSLT/ElementSyntax'>
 <!-- Updated by Henry S. Thompson for use with
   http://www.w3.org/1999/05/06-xmlschema-1/structures.xml,
   based on http://www.w3.org/1999/05/06-xmlschema-1/XMLspec-19990503.xsl
   and an original from Jonathan Marsh -->
  <xsl:template><xsl:value-of/></xsl:template>

  <xsl:template match='*'><SPAN STYLE='color:pink'><xsl:attribute name='TITLE'><xsl:node-name/></xsl:attribute><xsl:apply-templates/></SPAN></xsl:template>

<xsl:template match='e:element-syntax-summary'>
  <xsl:for-each select='//e:element-syntax'>
<!--    <xsl:sort select='@name'/> -->
    <p class='element-syntax-summary'><code>
      <xsl:apply-templates select='e:in-category'/>
      &lt;
      <a>
       <xsl:attribute name='href'>#element-<xsl:value-of select='@name'/></xsl:attribute>
       <xsl:value-of select='@name'/>
      </a>
      <xsl:apply-templates mode='top'/>
   </code></p>
  </xsl:for-each>
</xsl:template>

<xsl:template match='e:element-syntax'>
<p class='element-syntax' style='border: solid thin'><a>
<xsl:attribute name='name'>#element-<xsl:value-of select='@name'/></xsl:attribute>
<code>
<xsl:apply-templates select='e:in-category'/>
&lt;<xsl:value-of select='@name'/><xsl:apply-templates select='e:attribute|e:empty'/><xsl:if test='e:sequence|e:choice|e:all|e:model|e:element|e:text'>&gt;
<br/>
&#160;&#160;&lt;-- Content: <xsl:apply-templates select='e:sequence|e:choice|e:all|e:model|e:element|e:text'/> --&gt;
<br/>
&lt;/<xsl:value-of select='@name'/>&gt;</xsl:if></code></a></p>
</xsl:template>

<xsl:template match='e:in-category'>
&lt;-- Category: 
<xsl:value-of select='@name'/>
 --&gt;
<br/>
</xsl:template>

<xsl:template match='e:sequence'>
(<xsl:for-each select='*'><xsl:eval>hackSep(this,",")</xsl:eval><xsl:apply-templates select='.'/></xsl:for-each>)<xsl:choose>
   <xsl:when test='.[@repeat="one-or-more"]'>+</xsl:when>
   <xsl:when test='.[@repeat=&apos;zero-or-more&apos;]'>*</xsl:when>
   <xsl:when test='.[@repeat=&apos;zero-or-one&apos;]'>?</xsl:when>
  </xsl:choose>
</xsl:template>

<xsl:template match='e:choice'>
(<xsl:for-each select='*'><xsl:eval>hackSep(this,"|")</xsl:eval><xsl:apply-templates select='.'/></xsl:for-each>)<xsl:choose><xsl:when test='.[@repeat="one-or-more"]'>+</xsl:when><xsl:when test='.[@repeat=&apos;zero-or-more&apos;]'>*</xsl:when><xsl:when test='.[@repeat=&apos;zero-or-one&apos;]'>?</xsl:when>
  </xsl:choose>
</xsl:template>

<xsl:template match='e:choice'>
(<xsl:for-each select='*'><xsl:eval>hackSep(this,"|")</xsl:eval><xsl:apply-templates select='.'/></xsl:for-each>)<xsl:choose><xsl:when test='.[@repeat="one-or-more"]'>+</xsl:when><xsl:when test='.[@repeat=&apos;zero-or-more&apos;]'>*</xsl:when><xsl:when test='.[@repeat=&apos;zero-or-one&apos;]'>?</xsl:when>
  </xsl:choose>
</xsl:template>

<xsl:template match='e:all'>
(<xsl:for-each select='*'><xsl:eval>hackSep(this,"&amp;")</xsl:eval><xsl:apply-templates select='.'/></xsl:for-each>)<xsl:choose><xsl:when test='.[@repeat="one-or-more"]'>+</xsl:when><xsl:when test='.[@repeat=&apos;zero-or-more&apos;]'>*</xsl:when><xsl:when test='.[@repeat=&apos;zero-or-one&apos;]'>?</xsl:when>
  </xsl:choose>
</xsl:template>
<xsl:template match='e:text'>
<var>text</var>
</xsl:template>

<xsl:template match='e:element'>
<a>
<xsl:attribute name='href'>#element-<xsl:value-of select='@name'/></xsl:attribute>
<xsl:value-of select='@name'/></a><xsl:choose>
   <xsl:when test='.[@repeat=&apos;one-or-more&apos;]'>+</xsl:when>
   <xsl:when test='.[@repeat=&apos;zero-or-more&apos;]'>*</xsl:when>
   <xsl:when test='.[@repeat=&apos;zero-or-one&apos;]'>?</xsl:when>
  </xsl:choose>
</xsl:template>

<xsl:template match='e:empty' mode='top'>&#160;/&gt;</xsl:template>

<xsl:template match='e:attribute' mode='top'>
<br/>
&#160;&#160;
<xsl:choose>
<xsl:when test='.[@required="yes"]'>
<b><xsl:value-of select='@name'/></b>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select='@name'/>
</xsl:otherwise>
</xsl:choose>
 = 
<xsl:apply-templates/></xsl:template>

<xsl:template match='e:data-type'>
<var><xsl:value-of select='@name'/></var></xsl:template>

<xsl:template match='e:constant'>
 <xsl:eval>hackSep(this,"|")</xsl:eval>
"<xsl:value-of select='@value'/>"
</xsl:template>

<xsl:template match='e:attribute-value-template'>
{ 
<xsl:apply-templates/>
 }
</xsl:template>


  <xsl:template match='/'>
    <!--<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">-->
    <html>
      <head>
        <title><xsl:value-of select='spec/header/title'/></title>
       <style type='text/css'>
                        BODY {  margin: 2em 1em 2em 70px;  
                                font-family: Arial, sans-serif;    
                                color: black;    
                                background-color: white;    
                                background-image: url(http://www.w3.org/StyleSheets/TR/WD.gif);
                                background-position: top left;    
                                background-attachment: fixed;    
                                background-repeat: no-repeat;}
                        H1, H2, H3 {      
                                text-align: left;    
                                font-family: Tahoma, Verdana, "Myriad Web", Syntax, sans-serif;
                                font-weight: normal;    
                                color: #0050B2; }
                        P {     margin-top: 0.6em;      
                                margin-bottom: 0.6em;}
                        PRE {   font-family: monospace 
                                margin-left: 2em }  
                        DT, DD { margin-top: 0; margin-bottom: 0 }
                        DT {    font-weight: bold }  
                        A:hover { background: #FFA }    
                        .termdef {color: rgb(133,0,033)}
       </style>
      </head>
      <body>
        <xsl:for-each select='spec/header'>
          <img src='http://www.w3.org/pub/WWW/Icons/WWW/w3c_home' alt='W3C Logo' border='0' align='left'/>
          <h4 align='right'><xsl:value-of select='w3c-designation'/></h4>
          <br clear='ALL'/>
          <h1><xsl:value-of select='title'/></h1>
          <h3>W3C Internal Working Draft <xsl:value-of select='pubdate/day'/>-<xsl:value-of select='pubdate/month'/>-<xsl:value-of select='pubdate/year'/></h3>

          <h4>This version</h4>
          <p><xsl:for-each select='publoc/loc'><xsl:apply-templates select='.'/><br/></xsl:for-each></p>
          
          <h4>Latest version</h4>
          <p><xsl:for-each select='latestloc/loc'><xsl:apply-templates select='.'/><br/></xsl:for-each></p>
          
          <h4>Previous versions</h4>
          <p><xsl:for-each select='prevlocs/loc'><xsl:apply-templates select='.'/><br/></xsl:for-each><xsl:apply-templates select='prevlocs/loc'/></p>

          <h4>Editors</h4>
          <p><xsl:apply-templates select='authlist/author'/></p>

          <p><small><a href='http://www.w3.org/Consortium/Legal/ipr-notice.html#Copyright'>
          Copyright</a>  1999 <a href='http://www.w3.org'>
          W3C</a> (<a href='http://www.lcs.mit.edu'>MIT</a>, <a href='http://www.inria.fr/'>INRIA</a>, <a href='http://www.keio.ac.jp/'>
          Keio</a>), All Rights Reserved. W3C <a href='http://www.w3.org/Consortium/Legal/ipr-notice.html#Legal
          Disclaimer'>liability</a>, <a href='http://www.w3.org/Consortium/Legal/ipr-notice.html#W3C
          Trademarks'>trademark</a>, <a href='http://www.w3.org/Consortium/Legal/copyright-documents.html'>
          document use</a> and <a href='http://www.w3.org/Consortium/Legal/copyright-software.html'>
          software licensing</a> rules apply.</small></p>

          <h2 class='status'>Status of this document</h2>
          <xsl:apply-templates select='status'/>

          <h2 class='abstract'>Abstract</h2>
          <xsl:apply-templates select='abstract'/>
        </xsl:for-each>
        
        <h2 class='table-of-contents'>Table of Contents</h2>
        <dl class='table-of-contents'>
          <xsl:apply-templates select='spec/body/div1'>
            <xsl:template match='div1|div2|div3'>
                <dt>
                 <xsl:choose>
                  <xsl:when test='.[nodeName()="div1"]'>
                   <xsl:eval>sectionNum(this)+"."</xsl:eval>
                  </xsl:when>
                  <xsl:otherwise>
                   <xsl:eval>sectionNum(this)</xsl:eval>
                  </xsl:otherwise>
                 </xsl:choose>
                 <a><xsl:attribute name='href'>#<xsl:choose>
                      <xsl:when test='@id'><xsl:value-of select='@id'/></xsl:when>
                      <xsl:otherwise>AEN<xsl:eval>uniqueID(this)</xsl:eval></xsl:otherwise>
                    </xsl:choose></xsl:attribute>
                    <xsl:value-of select='head'/>
                  </a>
                </dt>
                <xsl:if test='div2|div3'>
                  <dd><dl><xsl:apply-templates select='div2|div3'/></dl></dd>
                </xsl:if>
            </xsl:template>
          </xsl:apply-templates>
        </dl>
        
        <h3 class='table-of-contents'>Appendices</h3>
        <dl>
          <xsl:apply-templates select='spec/back/*'>
            <xsl:template match='inform-div1|div1'>
                <dt><xsl:eval>sectionNum(this)+"."</xsl:eval>
                  <a><xsl:attribute name='href'>#<xsl:choose>
                      <xsl:when test='@id'><xsl:value-of select='@id'/></xsl:when>
                      <xsl:otherwise>AEN<xsl:eval>uniqueID(this)</xsl:eval></xsl:otherwise>
                    </xsl:choose></xsl:attribute>
                    <xsl:value-of select='head'/>
                  </a>
                </dt>
                <xsl:if test='div2'>
                  <dd><dl><xsl:apply-templates select='div2'/></dl></dd>
                </xsl:if>
            </xsl:template>
            <xsl:template match='div2'>
                <dt><xsl:eval>sectionNum(this)</xsl:eval>
                  <a><xsl:attribute name='href'>#<xsl:choose>
                      <xsl:when test='@id'><xsl:value-of select='@id'/></xsl:when>
                      <xsl:otherwise>AEN<xsl:eval>uniqueID(this)</xsl:eval></xsl:otherwise>
                    </xsl:choose></xsl:attribute>
                    <xsl:value-of select='head'/>
                  </a>
                </dt>
            </xsl:template>
            <xsl:template match='inform-div1'>
                <dt><xsl:eval>sectionNum(this)</xsl:eval>
                  <a><xsl:attribute name='href'>#<xsl:choose>
                      <xsl:when test='@id'><xsl:value-of select='@id'/></xsl:when>
                      <xsl:otherwise>AEN<xsl:eval>uniqueID(this)</xsl:eval></xsl:otherwise>
                    </xsl:choose></xsl:attribute>
                    <xsl:value-of select='head'/>
                  </a> (Non-Normative)
                </dt>
            </xsl:template>
          </xsl:apply-templates>
        </dl>

        <xsl:apply-templates select='spec/body'/>
        <xsl:apply-templates select='spec/back'/>

      </body>
    </html>
  </xsl:template>
  
  <xsl:template match='loc'>
    <a class='loc'><xsl:attribute name='href'><xsl:value-of select='@href'/></xsl:attribute><xsl:value-of/></a>
  </xsl:template>

  <xsl:template match='author'>
    <span class='author'>
      <span class='name'><xsl:value-of select='name'/></span><xsl:if test='affiliation'> (<xsl:value-of select='affiliation'/>)</xsl:if>
      <a>
       <xsl:attribute name='href'><xsl:value-of select='email/@href'/></xsl:attribute><span class='email'><xsl:value-of select='email'/></span>></a>
      <xsl:if test='@part'>[<xsl:value-of select='@part'/>]</xsl:if>
      <br/>
    </span>
  </xsl:template>
 
 <xsl:template match='back'>
  <hr/>
  <div class='appendices'>
   <h1>Appendices</h1>
   <xsl:apply-templates/>
  </div>
  <div class='issues'>
   <xsl:for-each select='//issue'>
    <a class='issue'>
     <xsl:attribute name='href'>#<xsl:value-of select='@id'/></xsl:attribute>
     <xsl:value-of select='@id'/>
    </a>
    <br/>
   </xsl:for-each>
  </div>
 </xsl:template>

  <xsl:template match='status | abstract | body'><xsl:apply-templates/></xsl:template>
  
  <xsl:template match='div1'>
    <div class='div1'>
      <h2><xsl:eval>sectionNum(this)+"."</xsl:eval>
        <a><xsl:attribute name='name'><xsl:choose>
            <xsl:when test='@id'><xsl:value-of select='@id'/></xsl:when>
            <xsl:otherwise>AEN<xsl:eval>uniqueID(this)</xsl:eval></xsl:otherwise>
          </xsl:choose></xsl:attribute>
          <xsl:value-of select='head'/>
        </a>
      </h2>
      <xsl:apply-templates/>
    </div>
  </xsl:template>
  
  <xsl:template match='div2'>
    <div class='div2'>
      <h3><xsl:eval>sectionNum(this)</xsl:eval>
        <a><xsl:attribute name='name'><xsl:choose>
            <xsl:when test='@id'><xsl:value-of select='@id'/></xsl:when>
            <xsl:otherwise>AEN<xsl:eval>uniqueID(this)</xsl:eval></xsl:otherwise>
          </xsl:choose></xsl:attribute>
          <xsl:value-of select='head'/>
        </a>
      </h3>
      <xsl:apply-templates/>
    </div>
  </xsl:template>
  
  <xsl:template match='div3'>
    <div class='div3'>
      <h4><xsl:eval>sectionNum(this)</xsl:eval>
        <a><xsl:attribute name='name'><xsl:choose>
            <xsl:when test='@id'><xsl:value-of select='@id'/></xsl:when>
            <xsl:otherwise>AEN<xsl:eval>uniqueID(this)</xsl:eval></xsl:otherwise>
          </xsl:choose></xsl:attribute>
          <xsl:value-of select='head'/>
        </a>
      </h4>
      <xsl:apply-templates/>
    </div>
  </xsl:template>
  
  <xsl:template match='div4'>
    <div class='div4'>
      <h5><xsl:eval>sectionNum(this)</xsl:eval>
        <a><xsl:attribute name='name'><xsl:choose>
            <xsl:when test='@id'><xsl:value-of select='@id'/></xsl:when>
            <xsl:otherwise>AEN<xsl:eval>uniqueID(this)</xsl:eval></xsl:otherwise>
          </xsl:choose></xsl:attribute>
          <xsl:value-of select='head'/>
        </a>
      </h5>
      <xsl:apply-templates/>
    </div>
  </xsl:template>
  
  <xsl:template match='div5'>
    <div class='div5'>
      <h6><xsl:eval>sectionNum(this)</xsl:eval>
        <a><xsl:attribute name='name'><xsl:choose>
            <xsl:when test='@id'><xsl:value-of select='@id'/></xsl:when>
            <xsl:otherwise>AEN<xsl:eval>uniqueID(this)</xsl:eval></xsl:otherwise>
          </xsl:choose></xsl:attribute>
          <xsl:value-of select='head'/>
        </a>
      </h6>
      <xsl:apply-templates/>
    </div>
  </xsl:template>
  
  <xsl:template match='inform-div1'>
    <div class='inform-div1'>
      <h2><xsl:eval>sectionNum(this)</xsl:eval>
        <a><xsl:attribute name='name'><xsl:choose>
            <xsl:when test='@id'><xsl:value-of select='@id'/></xsl:when>
            <xsl:otherwise>AEN<xsl:eval>uniqueID(this)</xsl:eval></xsl:otherwise>
          </xsl:choose></xsl:attribute>
          <xsl:value-of select='head'/> (Non-Normative)
        </a>
      </h2>
      <xsl:apply-templates/>
    </div>
  </xsl:template>
  
  <xsl:template match='head'/>
    
  <xsl:template match='p'><p><xsl:apply-templates/></p></xsl:template>

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

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

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

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

  <xsl:template match='quote'>
  <blockquote>
   <xsl:apply-templates/>
  </blockquote>
  </xsl:template>
  <xsl:template match='code'>
   <code>
    <xsl:apply-templates/></code></xsl:template>
  <xsl:template match='term'>
   <b class='term'>
    <xsl:apply-templates/></b></xsl:template>
  <xsl:template match='emph'>
   <i>
    <xsl:apply-templates/></i></xsl:template>
 <xsl:template match='B'>
  <b>
  <xsl:apply-templates/></b></xsl:template>
  
  <xsl:template match='bibref'>
    <a><xsl:attribute name='href'>#<xsl:value-of select='@ref'/></xsl:attribute>[<xsl:value-of select='id(@ref)/@key'/>]</a></xsl:template>
  
  <!-- BUGBUG  sectionNum adds the trailing ".", in this case a ":" is more appropriate -->
  <xsl:template match='specref'>
    <a><xsl:attribute name='href'>#<xsl:value-of select='@ref'/></xsl:attribute>
      <xsl:for-each select='id(@ref)'>
        <b><xsl:value-of select='head'/></b></xsl:for-each></a></xsl:template>

  <xsl:template match='xspecref'>
    <a><xsl:attribute name='href'><xsl:value-of select='@href'/></xsl:attribute>
      <xsl:apply-templates/></a></xsl:template>

  <xsl:template match='termdef'>
    <span class='termdef'>
     <a><xsl:attribute name='name'><xsl:value-of select='@id'/></xsl:attribute>[Definition: ] </a>
    <xsl:apply-templates/></span></xsl:template>

  <xsl:template match='termref'>
   <a><xsl:attribute name='href'>#<xsl:value-of select='@def'/></xsl:attribute><xsl:apply-templates/></a></xsl:template>
 
 <xsl:template match='xtermref'>
  <a class='xtermref'>
   <xsl:attribute name='href'><xsl:value-of select='@href'/></xsl:attribute>
   <xsl:apply-templates/>
  </a>
 </xsl:template>

  <!-- BUGBUG  strip off "issue-" from the id to turn it into the name -->
  <xsl:template match='issue'>
    <div class='issue'>
      <blockquote>
        <xsl:apply-templates>
          <xsl:template match='p[0]'>
            <b><a><xsl:attribute name='name'><xsl:value-of select='../@id'/></xsl:attribute>
              Issue (<xsl:value-of select='../@id'/>):</a></b>
            <xsl:apply-templates/>
          </xsl:template>
        </xsl:apply-templates>
      </blockquote>
    </div>
  </xsl:template>

  <xsl:template match='ednote'>
    <div class='ednote'>
      <blockquote>
        <b>Ed. note:</b>
        <xsl:value-of select='edtext'/>
      </blockquote>
    </div>
  </xsl:template>


<!-- **************************************************************** -->
<!-- 'Choose' cases for XML Schema spec  -->
        <xsl:template match='constraintnote'>
             <div class='constraintnote'>
               <a>
                <xsl:attribute name='name'><xsl:value-of select='@id'/></xsl:attribute>
               </a>
               <p><b>
                 <xsl:choose>
                      <xsl:when test='.[@type=&apos;cos&apos;]'>Constraint on Schemas:  </xsl:when>
                      <xsl:when test='.[@type=&apos;svc&apos;]'>Schema-validity Constraint:  </xsl:when>
                      <xsl:when test='.[@type=&apos;sic&apos;]'>Schema Information Set Contribution:  </xsl:when>
                      <xsl:otherwise>Constraint:  </xsl:otherwise>
                 </xsl:choose>
               <xsl:value-of select='head'/>
               </b><br/>
               <xsl:apply-templates/>
               </p>
             </div>
        </xsl:template>




<!-- **************************************************************** -->
        <xsl:template match='eg'>
        <div class='eg'>
        <table cellpadding='5' border='1' bgcolor='#80ffff' width='100%'>
        <tr>
         <td>
          <xsl:choose>
           <xsl:when test='.[@role=&apos;error&apos;]'>
            <pre style='color: red'><xsl:apply-templates/></pre>
           </xsl:when>
           <xsl:otherwise>
            <pre><xsl:apply-templates/></pre>
           </xsl:otherwise>
          </xsl:choose>
         </td>
        </tr>
        </table>
        </div>
        </xsl:template>

  <xsl:template match='note'>
    <div class='note'>
      <blockquote>
        <xsl:apply-templates>
          <xsl:template match='p[0]'>
            <b>NOTE:</b>
            <xsl:apply-templates/>
          </xsl:template>
        </xsl:apply-templates>
      </blockquote>
    </div>
  </xsl:template>

<!-- HST: special treatment for special common case:  eg inside note -->
        <xsl:template match='note[@role="example"]|note[eg]'>
          <blockquote class='example'>
           <table border='1'>
                  <tbody>
                    <tr align='left'>
                      <td><strong><font color='blue'>Example</font></strong></td>
                    </tr>
                    <tr><td><table border='0'><tbody><xsl:apply-templates/></tbody></table></td></tr>
                 </tbody>
             </table>
           </blockquote>
         </xsl:template>



<!-- **************************************************************** -->
<!-- Tables -->
<!-- **************************************************************** -->
        <xsl:template match='table'>
          <table>
           <xsl:if test='@border'>
            <xsl:attribute name='border'><xsl:value-of select='@border'/></xsl:attribute>
           </xsl:if>
           <xsl:if test='@cellpadding'>
            <xsl:attribute name='cellpadding'><xsl:value-of select='@cellpadding'/></xsl:attribute></xsl:if>
           <xsl:if test='@align'>
            <xsl:attribute name='align'><xsl:value-of select='@align'/></xsl:attribute></xsl:if>
           <xsl:apply-templates/>
          </table>
        </xsl:template>

        <xsl:template match='thead'>
             <thead><xsl:apply-templates/></thead>
        </xsl:template>

        <xsl:template match='tbody'>
             <tbody><xsl:apply-templates/></tbody>
        </xsl:template>

        <xsl:template match='col'>
            <xsl:element name='col'>
                <xsl:attribute name='align'>
                    <xsl:value-of select='@align'/>
                </xsl:attribute>
            </xsl:element>
        </xsl:template>

        <xsl:template match='tr'>
             <tr>
              <xsl:if test='@align'>
               <xsl:attribute name='align'><xsl:value-of select='@align'/></xsl:attribute>
              </xsl:if>
              <xsl:if test='@valign'>
               <xsl:attribute name='valigh'><xsl:value-of select='@valign'/></xsl:attribute>
              </xsl:if>
                 <xsl:apply-templates/>
             </tr>
        </xsl:template>

        <xsl:template match='th'>
            <th>
             <xsl:if test='@bgcolor'>
              <xsl:attribute name='bgcolor'><xsl:value-of select='@bgcolor'/></xsl:attribute>
             </xsl:if>
             <xsl:if test='@rowspan'>
              <xsl:attribute name='rowspan'><xsl:value-of select='@rowspan'/></xsl:attribute>
             </xsl:if>
             <xsl:if test='@colspan'>
              <xsl:attribute name='colspan'><xsl:value-of select='@colspan'/></xsl:attribute>
             </xsl:if>
             <xsl:if test='@align'>
               <xsl:attribute name='align'><xsl:value-of select='@align'/></xsl:attribute>
              </xsl:if>
              <xsl:if test='@valign'>
               <xsl:attribute name='valign'><xsl:value-of select='@valign'/></xsl:attribute>
              </xsl:if>
                <xsl:apply-templates/>
            </th>
        </xsl:template>

        <xsl:template match='td'>
             <td>
              <xsl:if test='@bgcolor'>
              <xsl:attribute name='bgcolor'><xsl:value-of select='@bgcolor'/></xsl:attribute>
             </xsl:if>
             <xsl:if test='@rowspan'>
              <xsl:attribute name='rowspan'><xsl:value-of select='@rowspan'/></xsl:attribute>
             </xsl:if>
             <xsl:if test='@colspan'>
              <xsl:attribute name='colspan'><xsl:value-of select='@colspan'/></xsl:attribute>
             </xsl:if>
             <xsl:if test='@align'>
               <xsl:attribute name='align'><xsl:value-of select='@align'/></xsl:attribute>
              </xsl:if>
              <xsl:if test='@valign'>
               <xsl:attribute name='valign'><xsl:value-of select='@valign'/></xsl:attribute>
              </xsl:if>
                 <xsl:apply-templates/>
             </td>
        </xsl:template>


<!-- com on RHS added for XML Schema -->
        <xsl:template match='rhs/com'>
             <i class='com'><xsl:apply-templates/></i>
        </xsl:template>

        <xsl:template match='prod/com'>
             <td align='left'>
               <code class='com'>/* <xsl:apply-templates/> */ </code>
             </td>
        </xsl:template>
 

  <xsl:template match='olist'>
    <ol>
      <xsl:for-each select='item'>
        <li><xsl:apply-templates/></li>
      </xsl:for-each>
    </ol>
  </xsl:template>

  <xsl:template match='ulist'>
    <ul>
      <xsl:for-each select='item'>
        <li><xsl:apply-templates/></li>
      </xsl:for-each>
    </ul>
  </xsl:template>

  <xsl:template match='slist'>
    <ul class='slist'>
      <xsl:for-each select='sitem'>
        <li><xsl:apply-templates/></li>
      </xsl:for-each>
    </ul>
  </xsl:template>
  
  <xsl:template match='glist'>
    <dl>
      <xsl:for-each select='gitem'>
        <dt class='label'><b><xsl:apply-templates select='label'/></b></dt>
        <dd class='def'><xsl:apply-templates select='def'/></dd>
      </xsl:for-each>
    </dl>
  </xsl:template>
 
  <xsl:template match='label'><xsl:apply-templates/></xsl:template>
 
 <xsl:template match='def'>
  <xsl:for-each select='p[0]'>
   <xsl:apply-templates/>
  </xsl:for-each>
  <xsl:for-each select='text()|p[not(index()=0)]'>
   <xsl:choose>
    <xsl:when test='.[nodeName()="p"]'>
     <p/>
     <xsl:apply-templates/>
    </xsl:when>
    <xsl:otherwise><xsl:apply-templates select='.'/></xsl:otherwise>
   </xsl:choose>
  </xsl:for-each>
 </xsl:template>

  <xsl:template match='blist'>
    <dl>
      <xsl:for-each select='bibl' order-by='@key'>
        <dt><a>
              <xsl:attribute name='name'><xsl:value-of select='@id'/></xsl:attribute>
<xsl:apply-templates select='@key'/></a></dt>
        <dd><xsl:apply-templates/></dd>
      </xsl:for-each>
    </dl>
  </xsl:template>

  <xsl:template match='scrap'>
    <div class='scrap'>
      <table bgcolor='#f5dcb3' width='100%' border='1' cellpadding='5'>
       <tbody><tr align='left'>
        <td>
         <strong>
          <font color='red'><xsl:value-of select='head'/></font>
         </strong>
        </td>
       </tr>
       <tr><td><table border='0' bgcolor='#f5dcb3'>
        <xsl:for-each select='prod'>
          <tr>
            <td align='RIGHT' valign='TOP'>
             <a class='prod'>
              <xsl:attribute name='name'><xsl:value-of select='@id'/></xsl:attribute>
              <xsl:if test='.[not(@role and @role="prefig")]'>
               <code>[<xsl:eval>prodNum()</xsl:eval>]</code>
              </xsl:if>
             </a>
            </td>
            <td align='RIGHT' valign='TOP'>
             <xsl:apply-templates select='lhs'/>
            </td>
            <td align='RIGHT' valign='TOP'><code> ::= </code></td>
            <td align='LEFT'>             
              <xsl:apply-templates select='rhs[0]'/>             
            </td>
          </tr>
          <xsl:for-each select='rhs[index()$gt$0]'>
            <tr>
              <td></td>
              <td></td>
              <td></td>
              <td align='LEFT'><xsl:apply-templates select='.'/></td>
            </tr>
          </xsl:for-each>
        </xsl:for-each>
      </table></td></tr></tbody>
</table>
    </div>
  </xsl:template>

  <xsl:template match='lhs | rhs'><code><xsl:apply-templates/></code></xsl:template>

  <xsl:template match='xnt'><a><xsl:attribute name='href'><xsl:value-of select='@href'/></xsl:attribute><i><xsl:apply-templates/></i></a></xsl:template>

  <xsl:template match='prod//xnt'>
    <a><xsl:attribute name='href'><xsl:value-of select='@href'/></xsl:attribute><xsl:apply-templates/></a></xsl:template>

  <xsl:template match='nt'><a><xsl:attribute name='href'>#<xsl:value-of select='@def'/></xsl:attribute><xsl:apply-templates/></a></xsl:template>

  <xsl:template match='prod//nt'>
   <a><xsl:attribute name='href'>#<xsl:value-of select='@def'/></xsl:attribute>
    <xsl:apply-templates/></a></xsl:template>

 <xsl:template match='pt'>
  <i>
   <xsl:apply-templates/></i></xsl:template>
  <xsl:script><![CDATA[
    function hackSep(e,s) {
      if (absoluteChildNumber(e) > 1)
         return " "+s+" ";
     else
      return "";
   }

    function sectionNum(e) {
      if (e)
      {
        if (e.parentNode.nodeName == "back")
          return formatIndex(absoluteChildNumber(e), "A");
        else
          an= sectionNum(e.selectSingleNode("ancestor(inform-div1|div1|div2|div3|div4|div5)"));
          mn=formatIndex(childNumber(e), "1");
          if (an)
            return an + "." + mn;
          else
            return mn;
      }
      else
      {
        return "";
      }
    }
    
    var prodCount = 1;
    function prodNum() {
      return formatIndex(prodCount++, "1");
    }

  ]]></xsl:script>

</xsl:stylesheet>
