<?xml version="1.0"?>
<!--  This stylesheet extends the xmlspec.xsl stylesheet with the following
  features:
  1) compatibility for IE5 browsers
  2) uses copyright in the XML source instead of applying boilerplate
  3) additional formatting for infoset properties
  4) better formatting for bibliographies and publocs
  5) handles additional issue-related markup
  
  5/16/2001 jmarsh@microsoft.com--><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

  <xsl:import href="xmlspec.xsl"/>

  <xsl:output indent="yes"/>
  <!--
    This stylesheet conforms to the XSLT 1.0 Recommendation.
    For backward compatibility, this stylesheet embeds an IE5-
    compatible stylesheet using the XSLT 1.0 extension element
    mechanism.
    
    The following removes random junk generated by the XSLT portion 
    of the stylesheet when IE5 is being used.
  -->
  <ie5:if test="." xmlns:ie5="http://www.w3.org/TR/WD-xsl">
    <ie5:eval no-entities="t">'&lt;!--'</ie5:eval>
  </ie5:if>
  <xsl:param name="show.revisions">0</xsl:param>
    <xsl:param name="additional.css">
    <style type="text/css">
      .termdef {color: rgb(133,0,033)}
      .aside {border-left:4px solid green; background-color:#EEFFEE; padding-left:1em}
    </style>
  </xsl:param>    <!-- override header template to call a copyright template -->
  <xsl:template match="header">
    <div class="head">
      <p>
        <a href="http://www.w3.org/">
          <img src="http://www.w3.org/Icons/w3c_home"
            alt="W3C" height="48" width="72"/>
        </a>
      </p>
      <xsl:text>&#10;</xsl:text>
      <h1>
        <xsl:apply-templates select="title"/>
        <xsl:if test="version">
          <xsl:text> </xsl:text>
          <xsl:apply-templates select="version"/>
        </xsl:if>
      </h1>
      <xsl:if test="subtitle">
        <xsl:text>&#10;</xsl:text>
        <h2>
          <xsl:apply-templates select="subtitle"/>
        </h2>
      </xsl:if>
      <xsl:text>&#10;</xsl:text>
      <h2>
        <xsl:apply-templates select="w3c-doctype"/>
        <xsl:text> </xsl:text>
        <xsl:if test="pubdate/day">
          <xsl:apply-templates select="pubdate/day"/>
          <xsl:text> </xsl:text>
        </xsl:if>
        <xsl:apply-templates select="pubdate/month"/>
        <xsl:text> </xsl:text>
        <xsl:apply-templates select="pubdate/year"/>
      </h2>
      <dl>
        <xsl:apply-templates select="publoc"/>
        <xsl:apply-templates select="latestloc"/>
        <xsl:apply-templates select="prevlocs"/>
        <xsl:apply-templates select="authlist"/>
      </dl>
      <!-- begin change -->        <xsl:call-template name="copyright"/>      <!-- end change -->
    </div>
    <hr/>
    <xsl:apply-templates select="notice"/>
    <xsl:apply-templates select="abstract"/>
    <xsl:apply-templates select="status"/>
    <!-- begin change -->      <xsl:if test="$show.revisions != 0">
        <xsl:apply-templates select="revisiondesc"/>
      </xsl:if>
    <!-- end change -->
  </xsl:template>
  <xsl:template match="revisiondesc">
    <div>
      <h2>
        <a name="revisions">Revision History</a>
      </h2>
      <xsl:apply-templates/>
    </div>
  </xsl:template>

  <!-- use a named template so that boilerplate can override it -->
  <xsl:template name="copyright">
    <xsl:apply-templates select="copyright/node()"/>
  </xsl:template>

  <xsl:template match="abbr">
    <abbr>
      <xsl:if test="@title">
        <xsl:copy-of select="@title"/>
      </xsl:if>
      <xsl:if test="@lang">
        <xsl:copy-of select="@lang"/>
      </xsl:if>
      <xsl:apply-templates/>
    </abbr>
  </xsl:template>

  <xsl:template match="loc-content">
    <a href="{@href}">
      <xsl:apply-templates/>
    </a>
  </xsl:template>

  <!-- override specref template to refer to issues -->
  <xsl:template match="specref">
    <xsl:variable name="target" select="id(@ref)[1]"/>
    <a>
      <xsl:attribute name="href">
        <xsl:call-template name="href.target">
          <xsl:with-param name="target" select="id(@ref)"/>
        </xsl:call-template>
      </xsl:attribute>
      <xsl:choose>
	      <xsl:when test="starts-with(local-name($target), 'div')">
	        <b><xsl:apply-templates select="id(@ref)" mode="divnum"/><xsl:apply-templates select="id(@ref)/head" mode="text"/></b>
	      </xsl:when>
	      <xsl:when test="starts-with(local-name($target), 'inform-div')">
	        <b><xsl:apply-templates select="id(@ref)" mode="divnum"/><xsl:apply-templates select="id(@ref)/head" mode="text"/></b>
	      </xsl:when>
	      <xsl:when test="local-name($target) = 'vcnote'">
	        <b><xsl:text>[VC: </xsl:text><xsl:apply-templates select="id(@ref)/head" mode="text"/><xsl:text>]</xsl:text></b>
	      </xsl:when>
	      <xsl:when test="local-name($target) = 'prod'">
	        <b>
            <xsl:text>[PROD: </xsl:text>
            <xsl:apply-templates select="$target" mode="number-simple"/>
            <xsl:text>]</xsl:text>
          </b>
	      </xsl:when>
	      <xsl:when test="local-name($target) = 'label'">
	        <b>
            <xsl:text>[</xsl:text>
            <xsl:value-of select="$target"/>
            <xsl:text>]</xsl:text>
          </b>
	      </xsl:when>
        <!-- begin change -->	        <xsl:when test="local-name($target) = 'issue'">
	          <b>
              <xsl:text>[</xsl:text>              <xsl:value-of select="$target/@id"/>              <xsl:text>: </xsl:text>
              <xsl:value-of select="$target/head"/>
              <xsl:text>]</xsl:text>
            </b>
	        </xsl:when>
        <!-- end change -->	      <xsl:otherwise>
	        <xsl:message>
	          <xsl:text>Unsupported specref to </xsl:text>
	          <xsl:value-of select="local-name($target)"/>
	          <xsl:text> [</xsl:text>
	          <xsl:value-of select="@ref"/>
	          <xsl:text>] </xsl:text>
	          <xsl:text> (Contact stylesheet maintainer).</xsl:text>
	        </xsl:message>
	        <b>???</b>
	      </xsl:otherwise>
      </xsl:choose>
    </a>
  </xsl:template>


  <xsl:template match="emph[@role='info-item']">
    <b><xsl:apply-templates /></b>
  </xsl:template>
  
  <xsl:template match="emph[@role='infoset-property']">
    <b>[<xsl:apply-templates />]</b>
  </xsl:template>
    <xsl:template match="p[@role='definition']">
    <div class="aside">
      <xsl:copy-of select="@id"/>
      <pre>
        <xsl:apply-templates/>
      </pre>
    </div>
  </xsl:template>

  <xsl:template match="prevlocs">    <xsl:choose>
      <xsl:when test="contains(../w3c-doctype,'Recommendation')">
        <dt>Previous version:</dt>
        <dd>          <xsl:apply-templates select="loc[1]"/>
        </dd>
      </xsl:when>
      <xsl:otherwise>
        <dt>Previous version<xsl:if test="loc[2]">s</xsl:if>:</dt>
        <dd>          <xsl:apply-templates select="loc"/>
        </dd>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template match="prevlocs/loc">
    <a href="{@href}">
      <xsl:apply-templates/>
    </a>    <br/>
  </xsl:template>
  <xsl:template match="publoc">
    <dt>This version:</dt>
    <dd>
      <xsl:for-each select="loc[not(@role='available-format')]">
        <xsl:apply-templates select="."/><br />
      </xsl:for-each>
      <xsl:if test="loc[@role='available-format']">
        <xsl:text>(available in: </xsl:text>
        <xsl:for-each select="loc[@role='available-format']">
          <xsl:if test="position()!=1"><xsl:text>, </xsl:text></xsl:if>
          <xsl:apply-templates select="."/>
        </xsl:for-each>
        <xsl:text>)</xsl:text>
      </xsl:if>
    </dd>
  </xsl:template>
  
  <xsl:template match="blist">
    <dl>
      <xsl:for-each select="bibl"><xsl:sort select="@key" />
        <dt class="label"><a name="{@id}">           <xsl:choose>
            <xsl:when test="@key">
              <xsl:value-of select="@key"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="@id"/>
            </xsl:otherwise>
          </xsl:choose>
        </a></dt>
        <dd>
          <xsl:apply-templates />
          <xsl:if test="@href"> (See <a href="{@href}">
              <xsl:value-of select="@href"/>
            </a>.)</xsl:if>
        </dd>
      </xsl:for-each>
    </dl>
  </xsl:template>
  <xsl:template match="bibl">    <xsl:apply-templates/>  </xsl:template>

  <!-- changed templates to auto generate an appendix with a list
       of links to open issues. -->
  <xsl:template match="body">
    <div class="toc">
      <xsl:text>&#10;</xsl:text>
      <h2>
        <a name="contents">Table of Contents</a>
      </h2>
      <p class="toc">
        <xsl:apply-templates mode="toc" select="div1"/>
      </p>
      <xsl:if test="../back">
        <xsl:text>&#10;</xsl:text>
        <h3>
          <xsl:text>Appendi</xsl:text>
          <xsl:choose>
            <xsl:when test="count(../back/div1 | ../back/inform-div1) > 1">
              <xsl:text>ces</xsl:text>
            </xsl:when>
            <xsl:otherwise>
              <xsl:text>x</xsl:text>
            </xsl:otherwise>
          </xsl:choose>
        </h3>
        <p class="toc">
          <xsl:apply-templates mode="toc"
            select="../back/div1 | ../back/inform-div1"/>
          <!-- begin change -->
            <xsl:variable name="number-of-appendices" select="count(../back/div1 | ../back/inform-div1)"/>
            <xsl:choose>
              <xsl:when test="//issue[@status!='closed']">                <xsl:number value="$number-of-appendices + 1" format="A "/>
                <a href="#open-issues">Open Issues</a> (Non-normative)
                <xsl:if test="//issue[@status='closed']">                  <br/>                  <xsl:number value="$number-of-appendices + 2" format="A "/>
                  <a href="#open-issues">Resolved Issues</a> (Non-normative)
                </xsl:if>              </xsl:when>
              <xsl:when test="//issue[@status='closed']">                <xsl:number value="$number-of-appendices + 1" format="A "/>
                <a href="#open-issues">Resolved Issues</a> (Non-normative)
              </xsl:when>            </xsl:choose>
          <!-- end change -->        </p>
      </xsl:if>
      <xsl:if test="//footnote">
        <p class="toc">
          <a href="#endnotes">
            <xsl:text>End Notes</xsl:text>
          </a>
        </p>
      </xsl:if>
    </div>
    <hr/>
    <div class="body">
      <xsl:apply-templates/>
    </div>
  </xsl:template>

  <xsl:template match="back">
    <hr />
    <div class="back">
      <xsl:apply-templates/>
      <!-- begin change -->
        <xsl:if test="//issue[@status!='closed']">          <div class="div1">
            <xsl:text>&#10;</xsl:text>
            <h2>
              <a name="open-issues"/>
              <xsl:number value="count(../back/div1 | ../back/inform-div1) + 1" format="A "/>
              <xsl:text>Open Issues (Non-Normative)</xsl:text>
            </h2>
            <ul>              <xsl:apply-templates select="//issue[@status!='closed']" mode="issues-list">
                <xsl:sort select="@id"/>
              </xsl:apply-templates>
            </ul>          </div>
        </xsl:if>        
        <xsl:if test="//issue[@status='closed']">          <div class="div1">
            <xsl:text>&#10;</xsl:text>
            <h2>
              <a name="resolved-issues"/>
              <xsl:number value="count(../back/div1 | ../back/inform-div1) + 2" format="A "/>
              <xsl:text>Resolved Issues (Non-Normative)</xsl:text>
            </h2>
            <ul>              <xsl:apply-templates select="//issue[@status='closed']" mode="issues-list">
                <xsl:sort select="@id"/>
              </xsl:apply-templates>
            </ul>          </div>
        </xsl:if>        
      <!-- end change -->    </div>
  </xsl:template>    <xsl:template match="issue" mode="issues-list">    <li>
      <a href="#{@id}"><xsl:value-of select="@id"/>:      <xsl:value-of select="head"/></a>
    </li>  </xsl:template>
  
 	<xsl:template name="insertID">
 		<xsl:choose>
 			<xsl:when test="@id">
 				<a name="{@id}"/>
 			</xsl:when>
 			<xsl:otherwise>
 				<a name="section-{translate(head,' ','-')}"/>
 			</xsl:otherwise>
 		</xsl:choose>
  </xsl:template>
	
	<xsl:template match="issue">
    <!-- this complex control structure is for compatibility with xt -->
    <xsl:call-template name="insertID"/>
    <div>
      <xsl:if test="resolution">
        <xsl:attribute name="style">color:green</xsl:attribute>
      </xsl:if>
      <p>
        <b>Issue-<xsl:value-of select="substring-after(@id,'-')"/>: </b>
        <xsl:value-of select="head"/>
      </p>
      <div style="margin-left:3em; margin-right:3em">
        <b>Date:</b>&#160;<xsl:value-of select="@date"/>
        <br/>
        <b>Raised by:</b>&#160;<xsl:value-of select="@raisedby"/>
        <xsl:apply-templates/>
      </div>
    </div>
  </xsl:template>

  <xsl:template match="issue/head"/>

  <xsl:template mode="number" match="issue"/>

  <xsl:template match="description/p[1]" priority="1">
    <p>
      <b>Description:</b>
      <xsl:text> </xsl:text>
      <xsl:apply-templates/>
    </p>
  </xsl:template>

  <xsl:template match="suggestion/p[1]" priority="1">
    <p>
      <b>Suggested Resolution:</b>
      <xsl:text> </xsl:text>
      <xsl:apply-templates/>
    </p>
  </xsl:template>

  <xsl:template match="resolution/p[1]" priority="1">
    <p>
      <b>Resolution:</b>
      <xsl:text> </xsl:text>
      <xsl:apply-templates/>
    </p>
  </xsl:template>

  <xsl:template match="description | suggestion | resolution">
    <xsl:apply-templates/>
  </xsl:template>

  <!-- ednote: editors' note -->
  <xsl:template match="ednote">
    <xsl:if test="$show.ednotes != 0">
      <div class="note">
        <xsl:apply-templates mode="first-note-paragraph">
          <xsl:with-param name="marking"><b>Editorial Note: </b></xsl:with-param>
        </xsl:apply-templates>
      </div>
    </xsl:if>
  </xsl:template>

  <xsl:template mode="first-note-paragraph" match="edtext|p[1]">
    <xsl:param name="marking"><b>Note: </b></xsl:param>
    <p>
      <xsl:copy-of select="$marking"/>
      <xsl:apply-templates />
    </p>
  </xsl:template>

  <xsl:template match="note">
    <div class="note">
      <xsl:apply-templates mode="first-note-paragraph"/>
    </div>
  </xsl:template>

  <!--
    Fallbacks for Microsoft Internet Explorer 5.  Since IE5
    implements an earlier version of XSLT, it does not recognize
    the XSLT namespace, and instead executes the fallback code
    below.  These elements are considered ignorable top-level
    elements by XSLT-conformant processors.
  -->
  <ie5:if test="." xmlns:ie5="http://www.w3.org/TR/WD-xsl">
    <ie5:eval no-entities="t">'--&gt;'</ie5:eval>


    <ie5:apply-templates select="." xmlns:ie5="http://www.w3.org/TR/WD-xsl">>

      <ie5:template match="text()"><ie5:value-of/></ie5:template>
      <ie5:template match="*"><ie5:apply-templates/></ie5:template>
      <ie5:template match="/"><ie5:apply-templates/></ie5:template>
      <ie5:template match="@*"><ie5:copy><ie5:value-of/></ie5:copy></ie5:template>

      <ie5:template match="spec">
        <html>
          <ie5:attribute name="lang"><ie5:value-of select="header/langusage/language/@id"/></ie5:attribute>
          <head>
            <title><ie5:value-of select="header/title"/> <ie5:value-of select="header/version"/></title>
            <style type="text/css">
              code { font-family: monospace }
              .termdef {color: rgb(133,0,033)}
              .aside {border-left:4px solid green; background-color:#EEFFEE; padding-left:1em}
            </style>
            <ie5:choose>
              <ie5:when test="header[w3c-doctype = 'W3C Recommendation']">
                <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-REC" />
              </ie5:when>
              <ie5:when test="header[w3c-doctype = 'W3C Proposed Recommendation']">
                <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-PR" />
              </ie5:when>
              <ie5:when test="header[w3c-doctype = '']">
                <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/base" />
              </ie5:when>
              <ie5:otherwise>
                <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-WD" />
              </ie5:otherwise>
            </ie5:choose>
          </head>          <body bgcolor="#ffffff">
            <ie5:for-each select="header">
              <div class="head">
                <p>
                  <a href="http://www.w3.org/"><img src="http://www.w3.org/Icons/w3c_home" alt="W3C" border="0" height="48" width="72" /></a>
                </p>
              
                <h1 class="title" align="center">
                  <ie5:apply-templates select="title"/>&#160;<ie5:apply-templates select="version"/>
                </h1>
                <ie5:if test="subtitle">
                  <h2>
                    <ie5:apply-templates select="subtitle"/>
                  </h2>
                </ie5:if>
                <h2 class="w3c-doctype" align="center"><ie5:value-of select="w3c-doctype"/> <ie5:value-of select="pubdate/day"/> <ie5:value-of select="pubdate/month"/> <ie5:value-of select="pubdate/year"/></h2>

                <dl>
                <dt>This version:</dt>
                <dd>
                  <ie5:for-each select="publoc">
                    <ie5:choose>
                      <ie5:when test="text()"><ie5:apply-templates /></ie5:when>
                      <ie5:otherwise>
                        <ie5:for-each select="loc[not(@role) or @role!='available-format']"><a class="publoc"><ie5:attribute name="href"><ie5:value-of select="@href"/></ie5:attribute><ie5:value-of select="." /></a><br /></ie5:for-each>
                        <ie5:if test="loc[@role='available-format']">(available in: 
                          <ie5:for-each select="loc[@role='available-format']">
                            <ie5:if test="context()[index()!=0]">, </ie5:if>
                            <a><ie5:attribute name="href"><ie5:value-of select="@href"/></ie5:attribute><ie5:value-of select="." /></a></ie5:for-each>)
                        </ie5:if>
                      </ie5:otherwise>
                    </ie5:choose>
                  </ie5:for-each>
                </dd>
                <ie5:if test="latestloc"><dt>Latest version:</dt>
                <dd>                  <ie5:for-each select="latestloc/loc"><a><ie5:attribute name="href"><ie5:value-of select="@href"/></ie5:attribute><ie5:value-of select="." /></a><br /></ie5:for-each>
                </dd></ie5:if>
                <ie5:choose>
                  <ie5:when test="w3c-doctype[.='W3C Recommendation' or .='W3C Proposed Recommendation' or .='W3C Candidate Recommendation']">
                    <dt>Previous version:</dt>
                    <dd>                      <ie5:for-each select="prevlocs/loc[0]"><a><ie5:attribute name="href"><ie5:value-of select="@href"/></ie5:attribute><ie5:value-of select="." /></a><br /></ie5:for-each>
                    </dd>
                  </ie5:when>
                  <ie5:otherwise>
                    <ie5:if test="prevlocs"><dt>Previous version<ie5:if test="prevlocs/loc[1]">s</ie5:if>:</dt>
                    <dd>                      <ie5:for-each select="prevlocs/loc"><a><ie5:attribute name="href"><ie5:value-of select="@href"/></ie5:attribute><ie5:value-of select="." /></a><br /></ie5:for-each>
                    </dd></ie5:if>
                  </ie5:otherwise>
                </ie5:choose>
                </dl>
                                      <dl>
                <dt>Editor<ie5:if test="authlist/author[1]">s</ie5:if>:</dt>
                <dd><ie5:apply-templates select="authlist/author"/></dd>
                </dl>
  
                <p class="copyright">
                  <a href="http://www.w3.org/Consortium/Legal/ipr-notice-20000612#Copyright"> Copyright</a>
                  <ie5:eval no-entities="yes">' &amp;copy;'</ie5:eval> 2001
                  <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a>
                  <sup><ie5:eval no-entities="yes">'&amp;reg;'</ie5:eval></sup>
                  (<a href="http://www.lcs.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>,
                  <a href="http://www.inria.fr/"><abbr lang="fr" title="Institut National de Recherche en Informatique et Automatique">INRIA</abbr></a>, 
                  <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved.
                  W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice-20000612#Legal_Disclaimer">liability</a>,
                  <a href="http://www.w3.org/Consortium/Legal/ipr-notice-20000612#W3C_Trademarks">trademark</a>,
                  <a href="http://www.w3.org/Consortium/Legal/copyright-documents-19990405">document use</a>
                  and <a href="http://www.w3.org/Consortium/Legal/copyright-software-19980720">software licensing</a>
                  rules apply.
                </p> 
                <hr title="Separator for header" />
              </div>
              <ie5:if test="notice">
                <div class="notice">
                  <p class="prefix">
                    <b>NOTICE:</b>
                  </p>
                  <ie5:apply-templates select="notice"/>
                </div>
              </ie5:if>

              <h2 class="abstract">Abstract</h2>
              <ie5:apply-templates select="abstract"/>
              
              <h2 class="status">Status of this document</h2>
              <ie5:apply-templates select="status"/>
            </ie5:for-each>
            
            <h2 class="table-of-contents">Table of Contents</h2>
            <dl class="table-of-contents">
              <ie5:apply-templates select="body/div1">
                <ie5:template match="div1|div2|div3">
                    <dt style="font-weight:normal"><ie5:eval>sectionNum(this)</ie5:eval>
                      <a><ie5:attribute name="href">#<ie5:choose>
                          <ie5:when test="@id"><ie5:value-of select="@id"/></ie5:when>
                          <ie5:otherwise>ID<ie5:eval>uniqueID(this)</ie5:eval></ie5:otherwise>
                        </ie5:choose></ie5:attribute>
                        <ie5:value-of select="head"/>
                      </a>
                    </dt>
                    <ie5:if test="div2|div3">
                      <dd><dl><ie5:apply-templates select="div2|div3"/></dl></dd>
                    </ie5:if>
                </ie5:template>
              </ie5:apply-templates>
            </dl>
            
          <ie5:if test="back">
            <h3 class="table-of-contents">Appendices</h3>
              <dl>
                <ie5:apply-templates select="back/*">
                  <ie5:template match="div1">
                    <dt style="font-weight:normal"><ie5:eval>sectionNum(this)</ie5:eval>
                      <a><ie5:attribute name="href">#<ie5:choose>
                          <ie5:when test="@id"><ie5:value-of select="@id"/></ie5:when>
                          <ie5:otherwise>ID<ie5:eval>uniqueID(this)</ie5:eval></ie5:otherwise>
                        </ie5:choose></ie5:attribute>
                        <ie5:value-of select="head"/>
                      </a>
                    </dt>
                    <ie5:if test="div2">
                      <dd><dl><ie5:apply-templates select="div2"/></dl></dd>
                    </ie5:if>
                  </ie5:template>
                  <ie5:template match="div2">
                    <dt style="font-weight:normal"><ie5:eval>sectionNum(this)</ie5:eval>
                      <a><ie5:attribute name="href">#<ie5:choose>
                          <ie5:when test="@id"><ie5:value-of select="@id"/></ie5:when>
                          <ie5:otherwise>ID<ie5:eval>uniqueID(this)</ie5:eval></ie5:otherwise>
                        </ie5:choose></ie5:attribute>
                        <ie5:value-of select="head"/>
                      </a>
                    </dt>
                  </ie5:template>
                  <ie5:template match="inform-div1">
                    <dt style="font-weight:normal"><ie5:eval>sectionNum(this)</ie5:eval>
                      <a><ie5:attribute name="href">#<ie5:choose>
                          <ie5:when test="@id"><ie5:value-of select="@id"/></ie5:when>
                          <ie5:otherwise>ID<ie5:eval>uniqueID(this)</ie5:eval></ie5:otherwise>
                        </ie5:choose></ie5:attribute>
                        <ie5:value-of select="head"/>
                      </a> (Non-Normative)
                    </dt>
                    <ie5:if test="div2">
                      <dd><dl><ie5:apply-templates select="div2"/></dl></dd>
                    </ie5:if>
                  </ie5:template>
                </ie5:apply-templates>
              </dl>
            </ie5:if>
            
            <ie5:apply-templates select="body"/>
            <ie5:apply-templates select="back"/>

          </body>
        </html>
      </ie5:template>

      <ie5:template match="loc">
        <a class="loc"><ie5:attribute name="href"><ie5:value-of select="@href"/></ie5:attribute><ie5:apply-templates/></a></ie5:template>

      <ie5:template match="author">
        <ie5:value-of select="name"/><ie5:if test="affiliation"> (<ie5:value-of select="affiliation"/>) </ie5:if>
          <a><ie5:attribute name="href"><ie5:value-of select="email/@href"/></ie5:attribute>&lt;<ie5:value-of select="email"/>&gt;</a>
        <ie5:if test="@part">[<ie5:value-of select="@part"/>]</ie5:if><br/>
      </ie5:template>

      <ie5:template match="back">
        <hr />
        <div class="appendices">
          <h1>Appendices</h1>
          <ie5:apply-templates />
        </div>
        <div class="issues">
          <h2>Open issues (Non-normative)</h2>
          <ie5:for-each select="//issue[not(@status='closed')]" order-by="@id">
            <a class="issue"><ie5:attribute name="href">#<ie5:value-of select="@id"/></ie5:attribute>
              <ie5:value-of select="@id"/>: <ie5:value-of select="head"/>
            </a>
            <br />
          </ie5:for-each>
        </div>
    </ie5:template>

      <ie5:template match="div1">
        <div class="div1">
          <h2><ie5:eval>sectionNum(this)</ie5:eval>
            <a><ie5:attribute name="name"><ie5:choose>
                <ie5:when test="@id"><ie5:value-of select="@id"/></ie5:when>
                <ie5:otherwise>ID<ie5:eval>uniqueID(this)</ie5:eval></ie5:otherwise>
              </ie5:choose></ie5:attribute>
              <ie5:value-of select="head"/>
            </a>
          </h2>
          <ie5:apply-templates/>
        </div>
      </ie5:template>
   
      <ie5:template match="div2">
        <div class="div2">
          <h3><ie5:eval>sectionNum(this)</ie5:eval>
            <a><ie5:attribute name="name"><ie5:choose>
                <ie5:when test="@id"><ie5:value-of select="@id"/></ie5:when>
                <ie5:otherwise>ID<ie5:eval>uniqueID(this)</ie5:eval></ie5:otherwise>
              </ie5:choose></ie5:attribute>
              <ie5:value-of select="head"/>
            </a>
          </h3>
          <ie5:apply-templates/>
        </div>
      </ie5:template>
      
      <ie5:template match="div3">
        <div class="div3">
          <h4><ie5:eval>sectionNum(this)</ie5:eval>
            <a><ie5:attribute name="name"><ie5:choose>
                <ie5:when test="@id"><ie5:value-of select="@id"/></ie5:when>
                <ie5:otherwise>ID<ie5:eval>uniqueID(this)</ie5:eval></ie5:otherwise>
              </ie5:choose></ie5:attribute>
              <ie5:value-of select="head"/>
            </a>
          </h4>
          <ie5:apply-templates/>
        </div>
      </ie5:template>
      
      <ie5:template match="div4">
        <div class="div4">
          <h5><ie5:eval>sectionNum(this)</ie5:eval>
            <a><ie5:attribute name="name"><ie5:choose>
                <ie5:when test="@id"><ie5:value-of select="@id"/></ie5:when>
                <ie5:otherwise>ID<ie5:eval>uniqueID(this)</ie5:eval></ie5:otherwise>
              </ie5:choose></ie5:attribute>
              <ie5:value-of select="head"/>
            </a>
          </h5>
          <ie5:apply-templates/>
        </div>
      </ie5:template>
      
      <ie5:template match="div5">
        <div class="div5">
          <h6><ie5:eval>sectionNum(this)</ie5:eval>
            <a><ie5:attribute name="name"><ie5:choose>
                <ie5:when test="@id"><ie5:value-of select="@id"/></ie5:when>
                <ie5:otherwise>ID<ie5:eval>uniqueID(this)</ie5:eval></ie5:otherwise>
              </ie5:choose></ie5:attribute>
              <ie5:value-of select="head"/>
            </a>
          </h6>
          <ie5:apply-templates/>
        </div>
      </ie5:template>
      
      <ie5:template match="inform-div1">
        <div class="inform-div1">
          <h2><ie5:eval>sectionNum(this)</ie5:eval>
            <a><ie5:attribute name="name"><ie5:choose>
                <ie5:when test="@id"><ie5:value-of select="@id"/></ie5:when>
                <ie5:otherwise>ID<ie5:eval>uniqueID(this)</ie5:eval></ie5:otherwise>
              </ie5:choose></ie5:attribute>
              <ie5:value-of select="head"/><i> (Non-Normative)</i>
            </a>
          </h2>
          <ie5:apply-templates/>
        </div>
      </ie5:template>
      
      <ie5:template match="head"/>
        
      <ie5:template match="p">
        <p>
          <ie5:if test="@role"><ie5:attribute name="class"><ie5:value-of select="@role"/></ie5:attribute></ie5:if>
          <ie5:apply-templates/>
        </p>
      </ie5:template>
      <ie5:template match="blockquote"><blockquote><ie5:apply-templates/></blockquote></ie5:template>
      <ie5:template match="quote"><i><ie5:apply-templates /></i></ie5:template>

      <ie5:template match="att"><code><ie5:apply-templates/></code></ie5:template>
      <ie5:template match="code"><code><ie5:apply-templates/></code></ie5:template>
      <ie5:template match="term"><b class="term"><ie5:apply-templates/></b></ie5:template>
      <ie5:template match="emph"><i><ie5:apply-templates/></i></ie5:template>

      <ie5:template match="bibref">
        <a><ie5:attribute name="href">#<ie5:value-of select="@ref"/></ie5:attribute>[<ie5:value-of select="id(@ref)/@key"/>]</a></ie5:template>
      
      <ie5:template match="specref">
        <a><ie5:attribute name="href">#<ie5:value-of select="@ref"/></ie5:attribute>
          <ie5:for-each select="id(@ref)">
            <b><ie5:value-of select="head"/></b></ie5:for-each></a></ie5:template>

      <ie5:template match="xspecref">
        <a><ie5:attribute name="href"><ie5:value-of select="@ref"/></ie5:attribute><ie5:apply-templates /></a></ie5:template>

      <ie5:template match="termdef">
        <span class="termdef">  
        <a><ie5:attribute name="name"><ie5:value-of select="@id"/></ie5:attribute>[Definition: ] </a>
        <ie5:apply-templates/></span></ie5:template>

      <ie5:template match="termref">
        <a><ie5:attribute name="href">#<ie5:value-of select="@def"/></ie5:attribute><ie5:apply-templates/></a></ie5:template>

      <ie5:template match="xtermref">
        <a class="xtermref"><ie5:attribute name="href"><ie5:value-of select="@href"/></ie5:attribute>
          <ie5:apply-templates /></a></ie5:template>

      <ie5:template match="issue">
        <div class="issue">
          <ie5:apply-templates select="@id"/>
          <div>
            <ie5:if test="resolution">
              <ie5:attribute name="style">color:green</ie5:attribute>
            </ie5:if>
            <p>
              <b><ie5:value-of select="@id"/>: </b>
              <ie5:value-of select="head"/>
            </p>
            <div style="margin-left:3em; margin-right:3em">
              <b>Date:</b>&#160;<ie5:value-of select="@date"/>
              <br/>
              <b>Raised by:</b>&#160;<ie5:value-of select="@raisedby"/>
              <ie5:apply-templates/>
            </div>
          </div>
        </div>
      </ie5:template>

      <ie5:template match="description/p[0]">
        <p>
          <b>Description: </b>
          <ie5:apply-templates/>
        </p>
      </ie5:template>

      <ie5:template match="suggestion/p[0]">
        <p>
          <b>Suggested Resolution: </b>
          <ie5:apply-templates/>
        </p>
      </ie5:template>

      <ie5:template match="resolution/p[0]">
        <p>
          <b>Resolution: </b>
          <ie5:apply-templates/>
        </p>
      </ie5:template>

      <ie5:template match="description | suggestion | resolution">
        <ie5:apply-templates/>
      </ie5:template>
      
      <ie5:template match="options-list"/>

      <ie5:template match="ednote">
        <div class="ednote">
          <blockquote>
            <b>Editorial note: </b>
            <ie5:value-of select="edtext"/>
          </blockquote>
        </div>
      </ie5:template>

      <ie5:template match="eg">
        <div class="eg">
          <table cellpadding="5" border="1" bgcolor="#80ffff" width="100%">
            <tr>
             <td>
              <ie5:choose>
               <ie5:when test=".[@role='error']"><pre style="color: red"><ie5:apply-templates /></pre></ie5:when>
               <ie5:otherwise><pre><ie5:apply-templates /></pre></ie5:otherwise>
              </ie5:choose>
             </td>
            </tr>
          </table>
        </div>
      </ie5:template>

      <ie5:template match="note">
        <div class="note">
          <blockquote>
            <ie5:apply-templates>
              <ie5:template match="p[0]">
                <b>Note: </b>
                <ie5:apply-templates/>
              </ie5:template>
            </ie5:apply-templates>
          </blockquote>
        </div>
      </ie5:template>

      <ie5:template match="table">
        <table>
          <ie5:if test="@border">
            <ie5:attribute name="border"><ie5:value-of select="@border"/></ie5:attribute>
          </ie5:if>
          <ie5:if test="@cellpadding">
            <ie5:attribute name="cellpadding"><ie5:value-of select="@cellpadding"/></ie5:attribute>
          </ie5:if>
          <ie5:if test="@align">
            <ie5:attribute name="align"><ie5:value-of select="@align"/></ie5:attribute>
          </ie5:if>
          <ie5:apply-templates />
        </table>
      </ie5:template>

      <ie5:template match="thead">
        <thead><ie5:apply-templates /></thead>
      </ie5:template>

      <ie5:template match="tbody">
        <tbody><ie5:apply-templates /></tbody>
      </ie5:template>

      <ie5:template match="col">
        <col>
          <ie5:attribute name="align">
            <ie5:value-of select="@align"/>
          </ie5:attribute>
        </col>
      </ie5:template>

      <ie5:template match="tr">
        <tr>
          <ie5:if test="@align">
            <ie5:attribute name="align"><ie5:value-of select="@align"/></ie5:attribute>
          </ie5:if>
          <ie5:if test="@valign">
            <ie5:attribute name="valign"><ie5:value-of select="@valign"/></ie5:attribute>
          </ie5:if>
          <ie5:apply-templates />
        </tr>
      </ie5:template>

      <ie5:template match="th">
        <th>
          <ie5:if test="@bgcolor">
            <ie5:attribute name="bgcolor"><ie5:value-of select="@bgcolor"/></ie5:attribute>
          </ie5:if>
          <ie5:if test="@rowspan">
            <ie5:attribute name="rowspan"><ie5:value-of select="@rowspan"/></ie5:attribute>
          </ie5:if>
          <ie5:if test="@colspan">
            <ie5:attribute name="colspan"><ie5:value-of select="@colspan"/></ie5:attribute>
          </ie5:if>
          <ie5:if test="@align">
            <ie5:attribute name="align"><ie5:value-of select="@align"/></ie5:attribute>
          </ie5:if>
          <ie5:if test="@valign">
            <ie5:attribute name="valign"><ie5:value-of select="@valign"/></ie5:attribute>
          </ie5:if>
          <ie5:apply-templates />
        </th>
      </ie5:template>

      <ie5:template match="td">
        <td>
          <ie5:if test="@bgcolor">
            <ie5:attribute name="bgcolor"><ie5:value-of select="@bgcolor"/></ie5:attribute>
          </ie5:if>
          <ie5:if test="@rowspan">
            <ie5:attribute name="rowspan"><ie5:value-of select="@rowspan"/></ie5:attribute>
          </ie5:if>
          <ie5:if test="@colspan">
            <ie5:attribute name="colspan"><ie5:value-of select="@colspan"/></ie5:attribute>
          </ie5:if>
          <ie5:if test="@align">
            <ie5:attribute name="align"><ie5:value-of select="@align"/></ie5:attribute>
          </ie5:if>
          <ie5:if test="@valign">
            <ie5:attribute name="valign"><ie5:value-of select="@valign"/></ie5:attribute>
          </ie5:if>
          <ie5:apply-templates />
        </td>
      </ie5:template>

      <ie5:template match="rhs/com">
        <i class="com"><ie5:apply-templates /></i>
      </ie5:template>

      <ie5:template match="prod/com">
        <td align="left">
          <code class="com">/* <ie5:apply-templates /> */ </code>
        </td>
      </ie5:template>

      <ie5:template match="olist">
        <ol>
          <ie5:for-each select="item">
            <li><ie5:apply-templates/></li>
          </ie5:for-each>
        </ol>
      </ie5:template>

      <ie5:template match="ulist">
        <ul>
          <ie5:for-each select="item">
            <li><ie5:apply-templates/></li>
          </ie5:for-each>
        </ul>
      </ie5:template>

      <ie5:template match="slist">
        <ul class="slist">
          <ie5:for-each select="sitem">
            <li><ie5:apply-templates/></li>
          </ie5:for-each>
        </ul>
      </ie5:template>
      
      <ie5:template match="glist">
        <dl>
          <ie5:for-each select="gitem">
            <dt class="label"><b><ie5:apply-templates select="label"/></b></dt>
            <dd class="def"><ie5:apply-templates select="def"/></dd>
          </ie5:for-each>
        </dl>
      </ie5:template>
      
      <ie5:template match="label"><ie5:apply-templates/></ie5:template>

      <ie5:template match="def">
        <ie5:for-each select="p[0]">
          <ie5:apply-templates />
        </ie5:for-each>
        <ie5:for-each select="text()|*[index()!=0]">
          <ie5:choose>
            <ie5:when test=".[nodeName()='p']">
              <p />
              <ie5:apply-templates />
            </ie5:when>
            <ie5:otherwise><ie5:apply-templates select="."/></ie5:otherwise>
          </ie5:choose>
        </ie5:for-each>
      </ie5:template>

      <ie5:template match="blist">
        <dl>
          <ie5:for-each select="bibl" order-by="@key">
            <dt><a><ie5:attribute name="name"><ie5:value-of select="@id"/></ie5:attribute><ie5:value-of select="@key"/></a></dt>
            <dd><ie5:apply-templates/>
              <ie5:if test="@href">(See <a><ie5:attribute name="href"><ie5:value-of select="@href"/></ie5:attribute>
                <ie5:value-of select="@href"/></a>.)</ie5:if></dd>
          </ie5:for-each>
        </dl>
      </ie5:template>

      <ie5:template match="titleref">
        <ie5:choose>
          <ie5:when test="@href">
            <a><ie5:attribute name="href"><ie5:value-of select="@href"/></ie5:attribute>
              <cite><ie5:apply-templates/></cite>
            </a>
          </ie5:when>
          <ie5:otherwise>
            <cite><ie5:apply-templates/></cite>
          </ie5:otherwise>
        </ie5:choose>
      </ie5:template>

      <ie5:template match="scrap">
        <div class="scrap">
          <table bgcolor="#f5dcb3" width="100%" border="1" cellpadding="5">
          <tbody><tr align="left">
            <td>
              <strong>
                <font color="red"><ie5:value-of select="head"/></font>
              </strong>
            </td>
          </tr>
          <tr><td>
            <table border="0" bgcolor="#f5dcb3">
              <ie5:for-each select="prod">
                <tr>
                  <td align="RIGHT" valign="TOP">
                    <a class="prod"><ie5:attribute name="name"><ie5:value-of select="@id"/></ie5:attribute>
                      <ie5:if test=".[not(@role and @role='prefig')]">
                        <code>[<ie5:eval>prodNum()</ie5:eval>]</code>
                      </ie5:if>
                    </a>
                  </td>
                  <td align="RIGHT" valign="TOP">
                    <ie5:apply-templates select="lhs"/>
                  </td>
                  <td align="RIGHT" valign="TOP"><code>::=</code></td>
                  <td align="LEFT">
                    <ie5:apply-templates select="rhs[0]"/>
                  </td>
                </tr>
                <ie5:for-each select="rhs[index()$gt$0]">
                  <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td align="LEFT"><ie5:apply-templates select="."/></td>
                  </tr>
                </ie5:for-each>
              </ie5:for-each>
            </table></td></tr></tbody>
          </table>
        </div>
      </ie5:template>

      <ie5:template match="lhs | rhs"><ie5:apply-templates/></ie5:template>
      <ie5:template match="xnt"><a><ie5:attribute name="href"><ie5:value-of select="@href"/></ie5:attribute><i><ie5:apply-templates/></i></a></ie5:template>
      <ie5:template match="prod//xnt"><a><ie5:attribute name="href"><ie5:value-of select="@href"/></ie5:attribute><ie5:apply-templates/></a></ie5:template>
      <ie5:template match="nt"><a><ie5:attribute name="href">#<ie5:value-of select="@def"/></ie5:attribute><i><ie5:apply-templates/></i></a></ie5:template>
      <ie5:template match="pt"><i><ie5:apply-templates/></i></ie5:template>

      <ie5:template match="p[@role='definition']">
        <div class="aside">
          <ie5:apply-templates select="@id"/>
          <pre>
            <ie5:apply-templates/>
          </pre>
        </div>
      </ie5:template>

      <ie5:template match="emph[@role='info-item']">
        <b><ie5:apply-templates /></b>
      </ie5:template>
  
      <ie5:template match="emph[@role='infoset-property']">
        <b>[<ie5:apply-templates />]</b>
      </ie5:template>
      </ie5:apply-templates>
  </ie5:if>
  
  <!-- Script for IE5 fallback -->
  <ie5:script xmlns:ie5="http://www.w3.org/TR/WD-xsl"><![CDATA[
    function sectionNum(e) {
      if (e)
      {
        if (e.parentNode.nodeName == "back") {
          if (e.nodeName == 'div1')
            return formatIndex(childNumber(e), "A") + ".";
          else
            return formatIndex(
                   childNumber(e) + 
                   childNumber(e.selectSingleNode('../div1[end()]')),
                 "A") + ".";
        }
        else
          return sectionNum(e.selectSingleNode("ancestor(inform-div1|div1|div2|div3|div4|div5)")) +
               formatIndex(childNumber(e), "1") + ".";
      }
      else
      {
        return "";
      }
    }
        
    var prodCount = 1;
    function prodNum() {
      return formatIndex(prodCount++, "1");
    }
  ]]></ie5:script>

</xsl:stylesheet>
