source: rfc2629xslt/rfc2629.xslt @ 189

Last change on this file since 189 was 189, checked in by julian.reschke@…, 12 years ago

Update to latest version of rfc2629.xslt

  • Property svn:eol-style set to native
File size: 174.7 KB
Line 
1<!--
2    XSLT transformation from RFC2629 XML format to HTML
3
4    Copyright (c) 2006-2008, Julian Reschke (julian.reschke@greenbytes.de)
5    All rights reserved.
6
7    Redistribution and use in source and binary forms, with or without
8    modification, are permitted provided that the following conditions are met:
9
10    * Redistributions of source code must retain the above copyright notice,
11      this list of conditions and the following disclaimer.
12    * Redistributions in binary form must reproduce the above copyright notice,
13      this list of conditions and the following disclaimer in the documentation
14      and/or other materials provided with the distribution.
15    * Neither the name of Julian Reschke nor the names of its contributors
16      may be used to endorse or promote products derived from this software
17      without specific prior written permission.
18
19    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29    POSSIBILITY OF SUCH DAMAGE.
30-->
31
32<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
33                version="1.0"
34               
35                xmlns:ed="http://greenbytes.de/2002/rfcedit"
36                xmlns:exslt="http://exslt.org/common"
37                xmlns:msxsl="urn:schemas-microsoft-com:xslt"
38                xmlns:myns="mailto:julian.reschke@greenbytes.de?subject=rcf2629.xslt"
39                xmlns:saxon="http://icl.com/saxon"
40                xmlns:x="http://purl.org/net/xml2rfc/ext"
41                xmlns:xhtml="http://www.w3.org/1999/xhtml"
42
43                exclude-result-prefixes="ed exslt msxsl myns saxon x xhtml"
44                >
45
46<xsl:strip-space elements="back front list middle rfc section"/>               
47               
48<xsl:output method="html" encoding="iso-8859-1" version="4.0" doctype-public="-//W3C//DTD HTML 4.01//EN" indent="no"/>
49
50<!-- process some of the processing instructions supported by Marshall T. Rose's
51     xml2rfc sofware, see <http://xml.resource.org/> -->
52
53<!-- delimiters in PIs -->
54<xsl:variable name="quote-chars">"'</xsl:variable>     
55     
56<!-- rfc comments PI -->
57
58<xsl:param name="xml2rfc-comments"
59  select="substring-after(
60      translate(/processing-instruction('rfc')[contains(.,'comments=')], concat($quote-chars,' '), ''),
61        'comments=')"
62/>
63
64<!-- rfc compact PI -->
65
66<xsl:param name="xml2rfc-compact"
67  select="substring-after(
68      translate(/processing-instruction('rfc')[contains(.,'compact=')], concat($quote-chars,' '), ''),
69        'compact=')"
70/>
71
72<!-- rfc footer PI -->
73
74<xsl:param name="xml2rfc-footer"
75  select="substring-after(
76      translate(/processing-instruction('rfc')[contains(.,'footer=')], concat($quote-chars,' '), ''),
77        'footer=')"
78/>
79
80<!-- rfc header PI -->
81
82<xsl:param name="xml2rfc-header"
83  select="substring-after(
84      translate(/processing-instruction('rfc')[contains(.,'header=')], concat($quote-chars,' '), ''),
85        'header=')"
86/>
87
88<!-- rfc inline PI -->
89
90<xsl:param name="xml2rfc-inline"
91  select="substring-after(
92      translate(/processing-instruction('rfc')[contains(.,'inline=')], concat($quote-chars,' '), ''),
93        'inline=')"
94/>
95
96<!-- rfc strict PI -->
97
98<xsl:param name="xml2rfc-strict"
99  select="substring-after(
100      translate(/processing-instruction('rfc')[contains(.,'strict=')], concat($quote-chars,' '), ''),
101        'strict=')"
102/>
103
104<!-- include a table of contents if a processing instruction <?rfc?>
105     exists with contents toc="yes". Can be overriden by an XSLT parameter -->
106
107<xsl:param name="xml2rfc-toc"
108  select="substring-after(
109      translate(/processing-instruction('rfc')[contains(.,'toc=')], concat($quote-chars,' '), ''),
110        'toc=')"
111/>
112
113<!-- optional tocdepth-->
114
115<xsl:param name="xml2rfc-tocdepth"
116  select="substring-after(
117      translate(/processing-instruction('rfc')[contains(.,'tocdepth=')], concat($quote-chars,' '), ''),
118        'tocdepth=')"
119/>
120
121<xsl:variable name="parsedTocDepth">
122  <xsl:choose>
123    <xsl:when test="$xml2rfc-tocdepth='1'">1</xsl:when>
124    <xsl:when test="$xml2rfc-tocdepth='2'">2</xsl:when>
125    <xsl:when test="$xml2rfc-tocdepth='3'">3</xsl:when>
126    <xsl:when test="$xml2rfc-tocdepth='4'">4</xsl:when>
127    <xsl:when test="$xml2rfc-tocdepth='5'">5</xsl:when>
128    <xsl:otherwise>99</xsl:otherwise>
129  </xsl:choose>
130</xsl:variable>
131
132<!-- suppress top block if a processing instruction <?rfc?>
133     exists with contents tocblock="no". Can be overriden by an XSLT parameter -->
134
135<xsl:param name="xml2rfc-topblock"
136  select="substring-after(
137      translate(/processing-instruction('rfc')[contains(.,'topblock=')], concat($quote-chars,' '), ''),
138        'topblock=')"
139/>
140
141<!-- use symbolic reference names instead of numeric ones unless a processing instruction <?rfc?>
142     exists with contents symrefs="no". Can be overriden by an XSLT parameter -->
143
144<xsl:param name="xml2rfc-symrefs"
145  select="substring-after(
146      translate(/processing-instruction('rfc')[contains(.,'symrefs=')], concat($quote-chars,' '), ''),
147        'symrefs=')"
148/>
149
150<!-- sort references if a processing instruction <?rfc?>
151     exists with contents sortrefs="yes". Can be overriden by an XSLT parameter -->
152
153<xsl:param name="xml2rfc-sortrefs"
154  select="substring-after(
155      translate(/processing-instruction('rfc')[contains(.,'sortrefs=')], concat($quote-chars,' '), ''),
156        'sortrefs=')"
157/>
158
159<!-- insert editing marks if a processing instruction <?rfc?>
160     exists with contents editing="yes". Can be overriden by an XSLT parameter -->
161
162<xsl:param name="xml2rfc-editing"
163  select="substring-after(
164      translate(/processing-instruction('rfc')[contains(.,'editing=')], concat($quote-chars,' '), ''),
165        'editing=')"
166/>
167
168<!-- make it a private paper -->
169
170<xsl:param name="xml2rfc-private"
171  select="substring-after(
172      translate(/processing-instruction('rfc')[contains(.,'private=')], $quote-chars, ''),
173        'private=')"
174/>
175
176<!-- background image? -->
177
178<xsl:param name="xml2rfc-background"
179  select="substring-after(
180      translate(/processing-instruction('rfc')[contains(.,'background=')], $quote-chars, ''),
181        'background=')"
182/>
183
184<!-- extension for XML parsing in artwork -->
185
186<xsl:param name="xml2rfc-ext-parse-xml-in-artwork"
187  select="substring-after(
188      translate(/processing-instruction('rfc-ext')[contains(.,'parse-xml-in-artwork=')], concat($quote-chars,' '), ''),
189        'parse-xml-in-artwork=')"
190/>
191
192<!-- extension for excluding DCMI properties in meta tag (RFC2731) -->
193
194<xsl:param name="xml2rfc-ext-support-rfc2731"
195  select="substring-after(
196      translate(/processing-instruction('rfc-ext')[contains(.,'support-rfc2731=')], concat($quote-chars,' '), ''),
197        'support-rfc2731=')"
198/>
199
200<!-- extension for allowing markup inside artwork -->
201
202<xsl:param name="xml2rfc-ext-allow-markup-in-artwork"
203  select="substring-after(
204      translate(/processing-instruction('rfc-ext')[contains(.,'allow-markup-in-artwork=')], concat($quote-chars,' '), ''),
205        'allow-markup-in-artwork=')"
206/>
207
208<!-- extension for including references into index -->
209
210<xsl:param name="xml2rfc-ext-include-references-in-index"
211  select="substring-after(
212      translate(/processing-instruction('rfc-ext')[contains(.,'include-references-in-index=')], concat($quote-chars,' '), ''),
213        'include-references-in-index=')"
214/>
215
216<!-- position of author's section -->
217
218<xsl:param name="xml2rfc-ext-authors-section"
219  select="substring-after(
220      translate(/processing-instruction('rfc-ext')[contains(.,'authors-section=')], concat($quote-chars,' '), ''),
221        'authors-section=')"
222/>
223
224<!-- justification? -->
225
226<xsl:param name="xml2rfc-ext-justification"
227  select="substring-after(
228      translate(/processing-instruction('rfc-ext')[contains(.,'justification=')], concat($quote-chars,' '), ''),
229        'justification=')"
230/>
231
232<!-- trailing dots in section numbers -->
233
234<xsl:param name="xml2rfc-ext-sec-no-trailing-dots"
235  select="substring-after(
236      translate(/processing-instruction('rfc-ext')[contains(.,'sec-no-trailing-dots=')], concat($quote-chars,' '), ''),
237        'sec-no-trailing-dots=')"
238/>
239
240<!-- choose whether or not to do mailto links --> 
241 
242 <xsl:param name="xml2rfc-linkmailto" 
243   select="substring-after(
244       translate(/processing-instruction('rfc')[contains(.,'linkmailto=')], concat($quote-chars,' '), ''),
245         'linkmailto=')" 
246 /> 
247
248
249<!-- iprnotified switch --> 
250 
251 <xsl:param name="xml2rfc-iprnotified" 
252   select="substring-after(
253       translate(/processing-instruction('rfc')[contains(.,'iprnotified=')], concat($quote-chars,' '), ''),
254         'iprnotified=')" 
255 /> 
256
257
258<!-- URL templates for RFCs and Internet Drafts. -->
259
260<!-- Reference the authorative ASCII versions
261<xsl:param name="rfcUrlPrefix" select="'http://www.ietf.org/rfc/rfc'" />
262<xsl:param name="rfcUrlPostfix" select="'.txt'" />
263-->
264<!-- Reference the marked up versions over on http://tools.ietf.org/html. -->
265<xsl:param name="rfcUrlPrefix" select="'http://tools.ietf.org/html/rfc'" />
266<xsl:param name="rfcUrlPostfix" select="''" />
267<xsl:param name="rfcUrlFrag" select="'section-'" />
268<xsl:param name="internetDraftUrlPrefix" select="'http://tools.ietf.org/html/'" />
269<xsl:param name="internetDraftUrlPostfix" select="''" />
270<xsl:param name="internetDraftUrlFrag" select="'section-'" />
271
272<!-- warning re: absent node-set ext. function -->
273<xsl:variable name="node-set-warning">
274  This stylesheet requires either an XSLT-1.0 processor with node-set()
275  extension function, or an XSLT-2.0 processor. Therefore, parts of the
276  document couldn't be displayed.
277</xsl:variable>
278
279<!-- character translation tables -->
280<xsl:variable name="lcase" select="'abcdefghijklmnopqrstuvwxyz'" />
281<xsl:variable name="ucase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />       
282
283<xsl:variable name="plain" select="' #/ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
284<xsl:variable name="touri" select="'___abcdefghijklmnopqrstuvwxyz'" />
285
286<!-- build help keys for indices -->
287<xsl:key name="index-first-letter"
288  match="iref|reference"
289    use="translate(substring(concat(@anchor,@item),1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
290
291<xsl:key name="index-item"
292  match="iref"
293    use="@item" />
294
295<xsl:key name="index-item-subitem"
296  match="iref"
297    use="concat(@item,'..',@subitem)" />
298
299<xsl:key name="index-xref-by-sec"
300  match="xref[@x:sec]"
301    use="concat(@target,'..',@x:sec)" />
302
303<xsl:key name="index-xref-by-anchor"
304  match="xref[@x:rel]"
305    use="concat(@target,'..',@x:rel)" />
306
307<!-- prefix for automatically generated anchors -->
308<xsl:variable name="anchor-prefix" select="'rfc'" />
309
310<!-- IPR version switch -->
311<xsl:variable name="ipr-rfc3667" select="(
312  /rfc/@number &gt; 3708) or
313  not(
314    (/rfc/@ipr = 'full2026') or
315    (/rfc/@ipr = 'noDerivativeWorks2026') or
316    (/rfc/@ipr = 'noDerivativeWorksNow') or
317    (/rfc/@ipr = 'none') or
318    (/rfc/@ipr = '') or
319    not(/rfc/@ipr)
320  )" />
321
322<xsl:variable name="ipr-rfc4748" select="(
323  $ipr-rfc3667 and
324    (
325      (/rfc/@number &gt; 4671) or
326      (/rfc/front/date/@year &gt; 2006) or
327      (/rfc/front/date/@year &gt; 2005 and (/rfc/front/date/@month='November' or /rfc/front/date/@month='December'))
328    )
329  )" />
330
331<!-- will document have an index -->
332<xsl:variable name="has-index" select="//iref or (//xref and $xml2rfc-ext-include-references-in-index='yes')" />
333         
334<!-- Templates for the various elements of rfc2629.dtd -->
335             
336<xsl:template match="text()[not(ancestor::artwork)]">
337  <xsl:variable name="starts-with-ws" select="translate(substring(.,1,1),'&#9;&#10;&#13;&#32;','')"/>
338  <xsl:variable name="ends-with-ws" select="translate(substring(.,string-length(.),1),'&#9;&#10;&#13;&#32;','')"/>
339  <!--<xsl:message> Orig: "<xsl:value-of select="."/>"</xsl:message>
340  <xsl:message>Start: "<xsl:value-of select="$starts-with-ws"/>"</xsl:message>
341  <xsl:message>  End: "<xsl:value-of select="$ends-with-ws"/>"</xsl:message> -->
342  <xsl:if test="$starts-with-ws='' and preceding-sibling::node()">
343    <xsl:text> </xsl:text>
344  </xsl:if>
345  <xsl:value-of select="normalize-space(.)"/>
346  <xsl:if test="$ends-with-ws='' and following-sibling::node()">
347    <xsl:text> </xsl:text>
348  </xsl:if>
349</xsl:template>
350             
351             
352<xsl:template match="abstract">
353  <h1 id="{$anchor-prefix}.abstract"><a href="#{$anchor-prefix}.abstract">Abstract</a></h1>
354  <xsl:apply-templates />
355</xsl:template>
356
357<msxsl:script language="JScript" implements-prefix="myns">
358  function parseXml(str) {
359    try {
360      var doc = new ActiveXObject("MSXML2.DOMDocument");
361      doc.async = false;
362      if (doc.loadXML(str)) {
363        return "";
364      }
365      else {
366        return doc.parseError.reason + "\n" + doc.parseError.srcText + " (" + doc.parseError.line + "/" + doc.parseError.linepos + ")";
367      }
368    }
369    catch(e) {
370      return "";
371    }
372  }
373</msxsl:script>
374
375<xsl:template name="add-artwork-class">
376  <xsl:choose>
377    <xsl:when test="@type='abnf' or @type='abnf2616' or @type='application/xml-dtd' or @type='inline' or @type='application/relax-ng-compact-syntax'">
378      <xsl:attribute name="class">inline</xsl:attribute>
379    </xsl:when>
380    <xsl:when test="starts-with(@type,'message/http') and contains(@type,'msgtype=&quot;request&quot;')">
381      <xsl:attribute name="class">text2</xsl:attribute>
382    </xsl:when>
383    <xsl:when test="starts-with(@type,'message/http')">
384      <xsl:attribute name="class">text</xsl:attribute>
385    </xsl:when>
386    <xsl:when test="starts-with(@type,'drawing')">
387      <xsl:attribute name="class">drawing</xsl:attribute>
388    </xsl:when>
389    <xsl:when test="starts-with(@type,'text/plain') or @type='example' or @type='code'">
390      <xsl:attribute name="class">text</xsl:attribute>
391    </xsl:when>
392    <xsl:otherwise/>
393  </xsl:choose>
394</xsl:template>
395
396<xsl:template match="artwork">
397  <xsl:if test="not(ancestor::ed:del) and $xml2rfc-ext-parse-xml-in-artwork='yes' and function-available('myns:parseXml')">
398    <xsl:if test="contains(.,'&lt;?xml')">
399      <xsl:variable name="body" select="substring-after(substring-after(.,'&lt;?xml'),'?>')" /> 
400      <xsl:if test="$body!='' and myns:parseXml($body)!=''">
401        <table style="background-color: red; border-width: thin; border-style: solid; border-color: black;">
402        <tr><td>
403        XML PARSE ERROR; parsed the body below:
404        <pre>
405        <xsl:value-of select="$body"/>
406        </pre>
407        resulting in:
408        <pre>
409        <xsl:value-of select="myns:parseXml($body)" />
410        </pre>
411        </td></tr></table>
412      </xsl:if>
413    </xsl:if>
414    <xsl:if test="@ed:parse-xml-after">
415      <xsl:if test="myns:parseXml(string(.))!=''">
416        <table style="background-color: red; border-width: thin; border-style: solid; border-color: black;">
417        <tr><td>
418        XML PARSE ERROR:
419        <pre><xsl:value-of select="myns:parseXml(string(.))" /></pre>
420        </td></tr></table>
421      </xsl:if>
422    </xsl:if>
423  </xsl:if>
424  <xsl:variable name="display">
425    <xsl:choose>
426      <xsl:when test="$xml2rfc-ext-allow-markup-in-artwork='yes'">
427        <xsl:apply-templates/>
428      </xsl:when>
429      <xsl:otherwise>
430        <xsl:value-of select="."/>
431      </xsl:otherwise>
432    </xsl:choose>
433  </xsl:variable> 
434  <xsl:choose>
435    <xsl:when test="@align='right'">
436      <div style="display:table; margin-left: auto; margin-right: 0pt;">
437        <pre style="margin-left: 0em;">
438          <xsl:call-template name="add-artwork-class"/>
439          <xsl:call-template name="insertInsDelClass"/>
440          <xsl:copy-of select="$display"/>
441        </pre>         
442      </div>
443    </xsl:when>
444    <xsl:when test="@align='center'">
445      <div style="display:table; margin-left: auto; margin-right: auto;">
446        <pre style="margin-left: 0em;">
447          <xsl:call-template name="add-artwork-class"/>
448          <xsl:call-template name="insertInsDelClass"/>
449          <xsl:copy-of select="$display"/>
450        </pre>         
451      </div>
452    </xsl:when>
453    <xsl:otherwise>
454      <pre>
455        <xsl:call-template name="add-artwork-class"/>
456        <xsl:call-template name="insertInsDelClass"/>
457        <xsl:copy-of select="$display"/>
458      </pre>
459    </xsl:otherwise>
460  </xsl:choose>
461  <xsl:call-template name="check-artwork-width">
462    <xsl:with-param name="content"><xsl:apply-templates/></xsl:with-param>
463  </xsl:call-template>
464</xsl:template>
465
466<!-- special case for first text node in artwork -->
467<xsl:template match="artwork/text()[1]">
468  <xsl:choose>
469    <xsl:when test="starts-with(.,'&#10;')">
470      <!-- reduce leading whitespace -->
471      <xsl:value-of select="substring(.,2)"/>
472    </xsl:when>
473    <xsl:otherwise>
474      <xsl:value-of select="."/>
475    </xsl:otherwise>
476  </xsl:choose>
477</xsl:template>
478
479
480<xsl:template name="check-artwork-width">
481  <xsl:param name="content"/>
482  <xsl:choose>
483    <xsl:when test="not(contains($content,'&#10;'))">
484      <xsl:if test="string-length($content) > 69">
485        <xsl:message>artwork line too long: <xsl:value-of select="$content"/></xsl:message>
486      </xsl:if>
487    </xsl:when>
488    <xsl:otherwise>
489      <xsl:variable name="start" select="substring-before($content,'&#10;')"/> 
490      <xsl:variable name="end" select="substring-after($content,'&#10;')"/> 
491      <xsl:if test="string-length($start) > 69">
492        <xsl:message>WARNING: artwork line too long: <xsl:value-of select="$start"/><xsl:call-template name="lineno"/></xsl:message>
493      </xsl:if>
494      <xsl:call-template name="check-artwork-width">
495        <xsl:with-param name="content" select="$end"/>
496      </xsl:call-template>
497    </xsl:otherwise>
498  </xsl:choose>
499</xsl:template>
500
501<xsl:template match="artwork[@src and starts-with(@type,'image/')]">
502  <p>
503    <img src="{@src}" alt="{.}">
504      <xsl:copy-of select="@width|@height"/>
505    </img>
506  </p>
507</xsl:template>
508
509<xsl:template match="author">
510
511    <address class="vcard">
512      <span class="vcardline">
513        <span class="fn">
514          <xsl:value-of select="@fullname" />
515        </span>
516        <xsl:if test="@role">
517          (<xsl:value-of select="@role" />)
518        </xsl:if>
519        <!-- components of name (hidden from display -->
520        <span class="n hidden">
521          <span class="family-name"><xsl:value-of select="@surname"/></span>
522          <!-- given-name family-name -->
523          <xsl:if test="@surname=substring(@fullname,1 + string-length(@fullname) - string-length(@surname))">
524            <span class="given-name"><xsl:value-of select="normalize-space(substring(@fullname,1,string-length(@fullname) - string-length(@surname)))"/></span>
525          </xsl:if>
526          <!-- family-name given-name -->
527          <xsl:if test="starts-with(@fullname,@surname)">
528            <span class="given-name"><xsl:value-of select="normalize-space(substring-after(@fullname,@surname))"/></span>
529          </xsl:if>
530        </span>
531      </span>
532      <xsl:if test="normalize-space(organization) != ''">
533        <span class="org vcardline">
534          <xsl:value-of select="organization" />
535        </span>
536      </xsl:if>
537      <xsl:if test="address/postal">
538        <span class="adr">
539          <xsl:if test="address/postal/street!=''">
540            <xsl:for-each select="address/postal/street">
541              <span class="street-address vcardline">
542                <xsl:value-of select="." />
543              </span>
544            </xsl:for-each>
545          </xsl:if>
546          <xsl:if test="address/postal/city|address/postal/region|address/postal/code">
547            <span class="vcardline">
548              <xsl:if test="address/postal/city"><span class="locality"><xsl:value-of select="address/postal/city" /></span>, </xsl:if>
549              <xsl:if test="address/postal/region"><span class="region"><xsl:value-of select="address/postal/region" /></span>&#160;</xsl:if>
550              <xsl:if test="address/postal/code"><span class="postal-code"><xsl:value-of select="address/postal/code" /></span></xsl:if>
551            </span>
552          </xsl:if>
553          <xsl:if test="address/postal/country">
554            <span class="country-name vcardline"><xsl:value-of select="address/postal/country" /></span>
555          </xsl:if>
556        </span>
557      </xsl:if>
558      <xsl:if test="address/phone">
559        <span class="vcardline tel">
560          <xsl:text>Phone: </xsl:text>
561          <a href="tel:{translate(address/phone,' ','')}"><span class="value"><xsl:value-of select="address/phone" /></span></a>
562        </span>
563      </xsl:if>
564      <xsl:if test="address/facsimile">
565        <span class="vcardline tel">
566          <span class="type">Fax</span><xsl:text>: </xsl:text>
567          <a href="fax:{translate(address/facsimile,' ','')}"><span class="value"><xsl:value-of select="address/facsimile" /></span></a>
568        </span>
569      </xsl:if>
570      <xsl:if test="address/email">
571        <span class="vcardline">
572        <xsl:text>EMail: </xsl:text>
573        <a>
574          <xsl:if test="$xml2rfc-linkmailto!='no'">
575            <xsl:attribute name="href">mailto:<xsl:value-of select="address/email" /></xsl:attribute>
576          </xsl:if>
577          <span class="email"><xsl:value-of select="address/email" /></span>
578        </a>
579        </span>
580      </xsl:if>
581      <xsl:if test="address/uri">
582        <span class="vcardline">
583          <xsl:text>URI: </xsl:text>
584          <a href="{address/uri}" class="url"><xsl:value-of select="address/uri" /></a>
585        </span>
586      </xsl:if>
587    </address>
588
589</xsl:template>
590
591<xsl:template match="back">
592
593  <!-- add references section first, no matter where it appears in the
594    source document -->
595  <!-- as of April 2004, process from middle section
596  <xsl:apply-templates select="references" />
597  -->
598 
599  <!-- add editorial comments -->
600  <xsl:if test="//cref and $xml2rfc-comments='yes' and $xml2rfc-inline!='yes'">
601    <xsl:call-template name="insertComments" />
602  </xsl:if>
603 
604  <!-- next, add information about the document's authors -->
605  <xsl:if test="$xml2rfc-ext-authors-section!='end'">
606    <xsl:call-template name="insertAuthors" />
607  </xsl:if>
608     
609  <!-- add all other top-level sections under <back> -->
610  <xsl:apply-templates select="*[not(self::references) and not(self::ed:replace and .//references)]" />
611
612  <xsl:if test="$xml2rfc-ext-authors-section='end'">
613    <xsl:call-template name="insertAuthors" />
614  </xsl:if>
615
616  <xsl:if test="not($xml2rfc-private)">
617    <!-- copyright statements -->
618    <xsl:variable name="copyright"><xsl:call-template name="insertCopyright" /></xsl:variable>
619 
620    <!-- emit it -->
621    <xsl:choose>
622      <xsl:when test="function-available('msxsl:node-set')">
623        <xsl:apply-templates select="msxsl:node-set($copyright)" />
624      </xsl:when>
625      <xsl:when test="function-available('exslt:node-set')">
626        <xsl:apply-templates select="exslt:node-set($copyright)" />
627      </xsl:when>
628      <xsl:otherwise>
629        <xsl:call-template name="error">
630          <xsl:with-param name="msg" select="$node-set-warning"/>
631        </xsl:call-template>
632      </xsl:otherwise>
633    </xsl:choose>
634  </xsl:if>
635 
636  <!-- insert the index if index entries exist -->
637  <xsl:if test="$has-index">
638    <xsl:call-template name="insertIndex" />
639  </xsl:if>
640
641</xsl:template>
642
643<xsl:template match="eref[node()]">
644  <a href="{@target}"><xsl:apply-templates /></a>
645</xsl:template>
646               
647<xsl:template match="eref[not(node())]">
648  <xsl:text>&lt;</xsl:text>
649  <a href="{@target}"><xsl:value-of select="@target" /></a>
650  <xsl:text>&gt;</xsl:text>
651</xsl:template>
652
653<xsl:template match="figure">
654  <xsl:if test="@anchor!=''">
655    <div id="{@anchor}"/>
656  </xsl:if>
657  <xsl:variable name="anch">
658    <xsl:call-template name="get-figure-anchor"/>
659  </xsl:variable>
660  <div id="{$anch}" />
661  <xsl:apply-templates />
662  <xsl:if test="(@title!='' or @anchor!='') and not(@suppress-title='true')">
663    <xsl:variable name="n"><xsl:number level="any" count="figure[(@title!='' or @anchor!='') and not(@suppress-title='true')]" /></xsl:variable>
664    <p class="figure">Figure <xsl:value-of select="$n"/><xsl:if test="@title!=''">: <xsl:value-of select="@title" /></xsl:if></p>
665  </xsl:if>
666</xsl:template>
667
668<xsl:template match="front">
669 
670  <xsl:if test="$xml2rfc-topblock!='no'">
671    <!-- collect information for left column -->
672     
673    <xsl:variable name="leftColumn">
674      <xsl:call-template name="collectLeftHeaderColumn" />   
675    </xsl:variable>
676 
677    <!-- collect information for right column -->
678     
679    <xsl:variable name="rightColumn">
680      <xsl:call-template name="collectRightHeaderColumn" />   
681    </xsl:variable>
682     
683    <!-- insert the collected information -->
684    <table summary="header information" class="header" border="0" cellpadding="1" cellspacing="1">
685      <xsl:choose>
686        <xsl:when test="function-available('msxsl:node-set')">
687          <xsl:call-template name="emitheader">
688            <xsl:with-param name="lc" select="msxsl:node-set($leftColumn)" />   
689            <xsl:with-param name="rc" select="msxsl:node-set($rightColumn)" />   
690          </xsl:call-template>
691        </xsl:when>   
692        <xsl:when test="function-available('exslt:node-set')">
693          <xsl:call-template name="emitheader">
694            <xsl:with-param name="lc" select="exslt:node-set($leftColumn)" />   
695            <xsl:with-param name="rc" select="exslt:node-set($rightColumn)" />   
696          </xsl:call-template>
697        </xsl:when>   
698        <xsl:otherwise>
699          <xsl:call-template name="error">
700            <xsl:with-param name="msg" select="$node-set-warning"/>
701          </xsl:call-template>
702        </xsl:otherwise>
703      </xsl:choose>
704    </table>
705  </xsl:if>
706   
707  <p class="title">
708    <!-- main title -->
709    <xsl:apply-templates select="title"/>
710    <xsl:if test="/rfc/@docName">
711      <br/>
712      <span class="filename"><xsl:value-of select="/rfc/@docName"/></span>
713     
714      <xsl:if test="contains(/rfc/@docName,'.')">
715        <xsl:call-template name="warning">
716          <xsl:with-param name="msg">The @docName attribute should contain the base name, not the filename (thus no file extension).</xsl:with-param>
717        </xsl:call-template>
718      </xsl:if>
719    </xsl:if> 
720  </p>
721 
722  <!-- insert notice about update -->
723  <xsl:variable name="published-as" select="/*/x:link[@rel='Alternate' and starts-with(@title,'RFC')]"/>
724  <xsl:if test="$published-as">
725    <p style="color: green; text-align: center; font-size: 14pt; background-color: yellow;">
726      <b>Note:</b> a later version of this document has been published as <a href="{$published-as/@href}"><xsl:value-of select="$published-as/@title"/></a>.
727    </p>
728  </xsl:if>
729   
730  <xsl:if test="not($xml2rfc-private)">
731    <!-- Get status info formatted as per RFC2629-->
732    <xsl:variable name="preamble"><xsl:call-template name="insertPreamble" /></xsl:variable>
733   
734    <!-- emit it -->
735    <xsl:choose>
736      <xsl:when test="function-available('msxsl:node-set')">
737        <xsl:apply-templates select="msxsl:node-set($preamble)" />
738      </xsl:when>
739      <xsl:when test="function-available('exslt:node-set')">
740        <xsl:apply-templates select="exslt:node-set($preamble)" />
741      </xsl:when>
742      <xsl:otherwise>
743        <xsl:call-template name="error">
744          <xsl:with-param name="msg" select="$node-set-warning"/>
745        </xsl:call-template>
746      </xsl:otherwise>
747    </xsl:choose>
748  </xsl:if>
749           
750  <xsl:apply-templates select="abstract" />
751  <xsl:apply-templates select="note" />
752  <!-- show notes inside change tracking as well -->
753  <xsl:apply-templates select="ed:replace[.//note]" />
754   
755  <xsl:if test="$xml2rfc-toc='yes'">
756    <xsl:apply-templates select="/" mode="toc" />
757    <xsl:call-template name="insertTocAppendix" />
758  </xsl:if>
759
760</xsl:template>
761
762
763<xsl:template match="iref">
764  <xsl:variable name="anchor"><xsl:call-template name="compute-iref-anchor"/></xsl:variable>
765  <xsl:choose>
766    <xsl:when test="ancestor::t|ancestor::figure">
767      <span id="{$anchor}"/>
768    </xsl:when>
769    <xsl:otherwise>
770      <div id="{$anchor}"/>
771    </xsl:otherwise>
772  </xsl:choose>
773</xsl:template>
774
775<xsl:template name="compute-iref-anchor">
776  <xsl:variable name="first" select="translate(substring(@item,1,1),$ucase,$lcase)"/>
777  <xsl:variable name="nkey" select="translate($first,$lcase,'')"/>
778  <xsl:choose>
779    <xsl:when test="$nkey=''">
780      <xsl:value-of select="$anchor-prefix"/>.iref.<xsl:value-of select="$first"/>.<xsl:number level="any" count="iref[starts-with(translate(@item,$ucase,$lcase),$first)]"/>
781    </xsl:when>
782    <xsl:otherwise>
783      <xsl:value-of select="$anchor-prefix"/>.iref.<xsl:number level="any" count="iref[translate(substring(@item,1,1),concat($lcase,$ucase),'')='']"/>
784    </xsl:otherwise>
785  </xsl:choose>
786</xsl:template>
787
788<xsl:template name="compute-extref-anchor">
789  <xsl:variable name="first" select="translate(substring(.,1,1),$ucase,$lcase)"/>
790  <xsl:variable name="nkey" select="translate($first,$lcase,'')"/>
791  <xsl:choose>
792    <xsl:when test="$nkey=''">
793      <xsl:value-of select="$anchor-prefix"/>.extref.<xsl:value-of select="$first"/>.<xsl:number level="any" count="x:ref[starts-with(translate(.,$ucase,$lcase),$first)]"/>
794    </xsl:when>
795    <xsl:otherwise>
796      <xsl:value-of select="$anchor-prefix"/>.extref.<xsl:number level="any" count="x:ref[translate(substring(.,1,1),concat($lcase,$ucase),'')='']"/>
797    </xsl:otherwise>
798  </xsl:choose>
799</xsl:template>
800
801<!-- list templates depend on the list style -->
802
803<xsl:template match="list[@style='empty' or not(@style)]">
804  <dl class="empty">
805    <xsl:call-template name="insertInsDelClass"/>
806    <xsl:apply-templates />
807  </dl>
808</xsl:template>
809
810<xsl:template match="list[starts-with(@style,'format ')]">
811  <dl>
812    <xsl:call-template name="insertInsDelClass"/>
813    <xsl:apply-templates />
814  </dl>
815</xsl:template>
816
817<xsl:template match="list[@style='hanging']">
818  <dl>
819    <xsl:call-template name="insertInsDelClass"/>
820    <xsl:apply-templates />
821  </dl>
822</xsl:template>
823
824<xsl:template match="list[@style='numbers']">
825  <ol>
826    <xsl:call-template name="insertInsDelClass"/>
827    <xsl:apply-templates />
828  </ol>
829</xsl:template>
830
831<!-- numbered list inside numbered list -->
832<xsl:template match="list[@style='numbers']/t/list[@style='numbers']" priority="9">
833  <ol style="list-style-type: lower-alpha">
834    <xsl:call-template name="insertInsDelClass"/>
835    <xsl:apply-templates />
836  </ol>
837</xsl:template>
838
839<xsl:template match="list[@style='letters']">
840  <ol style="list-style-type: lower-alpha">
841    <xsl:call-template name="insertInsDelClass"/>
842    <xsl:apply-templates />
843  </ol>
844</xsl:template>
845
846<!-- nested lettered list uses uppercase -->
847<xsl:template match="list//t//list[@style='letters']" priority="9">
848  <ol style="list-style-type: upper-alpha">
849    <xsl:call-template name="insertInsDelClass"/>
850    <xsl:apply-templates />
851  </ol>
852</xsl:template>
853   
854<xsl:template match="list[@style='symbols']">
855  <ul>
856    <xsl:call-template name="insertInsDelClass"/>
857    <xsl:apply-templates />
858  </ul>
859</xsl:template>
860
861
862<!-- same for t(ext) elements -->
863
864<xsl:template match="list[@style='empty' or not(@style)]/t | list[@style='empty' or not(@style)]/ed:replace/ed:*/t">
865  <!-- Inherited through CSS now <dd style="margin-top: .5em">-->
866  <dd>
867    <xsl:call-template name="insertInsDelClass"/>
868    <xsl:if test="@anchor"><xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute></xsl:if>
869    <xsl:apply-templates />
870  </dd>
871</xsl:template>
872
873<xsl:template match="list[@style='numbers' or @style='symbols' or @style='letters']/x:lt">
874  <li>
875    <xsl:if test="@anchor"><xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute></xsl:if>
876    <xsl:apply-templates select="t" />
877  </li>
878</xsl:template>
879
880<xsl:template match="list[@style='numbers' or @style='symbols' or @style='letters']/t | list[@style='numbers' or @style='symbols' or @style='letters']/ed:replace/ed:*/t">
881  <li>
882    <xsl:call-template name="insertInsDelClass"/>
883    <xsl:for-each select="../..">
884      <xsl:call-template name="insert-issue-pointer"/>
885    </xsl:for-each>
886    <xsl:if test="@anchor"><xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute></xsl:if>
887    <xsl:apply-templates />
888  </li>
889</xsl:template>
890
891<xsl:template match="list[@style='hanging']/x:lt">
892  <xsl:if test="@hangText!=''">
893    <dt>
894      <xsl:call-template name="insertInsDelClass"/>
895      <xsl:variable name="del-node" select="ancestor::ed:del"/>
896      <xsl:variable name="rep-node" select="ancestor::ed:replace"/>
897      <xsl:variable name="deleted" select="$del-node and ($rep-node/ed:ins)"/>
898      <xsl:for-each select="../..">
899        <xsl:call-template name="insert-issue-pointer">
900          <xsl:with-param name="deleted-anchor" select="$deleted"/>
901        </xsl:call-template>
902      </xsl:for-each>
903      <xsl:if test="@anchor"><xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute></xsl:if>
904      <xsl:value-of select="@hangText" />
905    </dt>
906  </xsl:if>
907  <dd>
908    <xsl:call-template name="insertInsDelClass"/>
909    <!-- if hangIndent present, use 0.7 of the specified value (1em is the width of the "m" character -->
910    <xsl:if test="../@hangIndent and ../@hangIndent!='0'">
911      <xsl:attribute name="style">margin-left: <xsl:value-of select="../@hangIndent * 0.7"/>em</xsl:attribute>
912    </xsl:if>
913    <xsl:apply-templates select="t" />
914  </dd>
915</xsl:template>
916
917<xsl:template match="list[@style='hanging']/t | list[@style='hanging']/ed:replace/ed:*/t">
918  <xsl:if test="@hangText!=''">
919    <dt>
920      <xsl:call-template name="insertInsDelClass"/>
921      <xsl:if test="count(preceding-sibling::t)=0">
922        <xsl:variable name="del-node" select="ancestor::ed:del"/>
923        <xsl:variable name="rep-node" select="ancestor::ed:replace"/>
924        <xsl:variable name="deleted" select="$del-node and ($rep-node/ed:ins)"/>
925        <xsl:for-each select="../..">
926          <xsl:call-template name="insert-issue-pointer">
927            <xsl:with-param name="deleted-anchor" select="$deleted"/>
928          </xsl:call-template>
929        </xsl:for-each>
930      </xsl:if>
931      <xsl:if test="@anchor"><xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute></xsl:if>
932      <xsl:value-of select="@hangText" />
933    </dt>
934  </xsl:if>
935
936  <xsl:variable name="dd-content">
937    <xsl:apply-templates/>
938  </xsl:variable>
939
940  <xsl:if test="$dd-content!=''">
941    <dd>
942      <xsl:call-template name="insertInsDelClass"/>
943      <!-- if hangIndent present, use 0.7 of the specified value (1em is the width of the "m" character -->
944      <xsl:if test="../@hangIndent and ../@hangIndent!='0'">
945        <xsl:attribute name="style">margin-left: <xsl:value-of select="../@hangIndent * 0.7"/>em</xsl:attribute>
946      </xsl:if>
947      <xsl:apply-templates />
948    </dd>
949  </xsl:if>
950</xsl:template>
951
952<xsl:template match="list[starts-with(@style,'format ') and (contains(@style,'%c') or contains(@style,'%d'))]/t">
953  <xsl:variable name="list" select=".." />
954  <xsl:variable name="format" select="substring-after(../@style,'format ')" />
955  <xsl:variable name="pos">
956    <xsl:choose>
957      <xsl:when test="$list/@counter">
958        <xsl:number level="any" count="list[@counter=$list/@counter or (not(@counter) and @style=concat('format ',$list/@counter))]/t" />
959      </xsl:when>
960      <xsl:otherwise>
961        <xsl:number level="any" count="list[concat('format ',@counter)=$list/@style or (not(@counter) and @style=$list/@style)]/t" />
962      </xsl:otherwise>
963    </xsl:choose>
964  </xsl:variable>
965  <dt>
966    <xsl:if test="@anchor"><xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute></xsl:if>
967    <xsl:choose>
968      <xsl:when test="contains($format,'%c')">
969        <xsl:value-of select="substring-before($format,'%c')"/><xsl:number value="$pos" format="a" /><xsl:value-of select="substring-after($format,'%c')"/>
970      </xsl:when>
971      <xsl:otherwise>
972        <xsl:value-of select="substring-before($format,'%d')"/><xsl:number value="$pos" format="1" /><xsl:value-of select="substring-after($format,'%d')"/>
973      </xsl:otherwise>
974    </xsl:choose>
975  </dt>
976  <dd>
977    <xsl:apply-templates />
978  </dd>
979</xsl:template>
980
981<xsl:template match="middle">
982  <xsl:apply-templates />
983  <xsl:apply-templates select="../back//references"/>
984</xsl:template>
985
986<xsl:template match="note">
987  <xsl:variable name="num"><xsl:number/></xsl:variable>
988    <h1 id="{$anchor-prefix}.note.{$num}">
989      <xsl:call-template name="insertInsDelClass"/>
990      <a href="#{$anchor-prefix}.note.{$num}">
991        <xsl:value-of select="@title" />
992      </a>
993    </h1>
994  <xsl:apply-templates />
995</xsl:template>
996
997<xsl:template match="postamble">
998  <xsl:if test="normalize-space(.) != ''">
999    <p>
1000      <xsl:call-template name="insertInsDelClass"/>
1001      <xsl:call-template name="editingMark" />
1002      <xsl:apply-templates />
1003    </p>
1004  </xsl:if>
1005</xsl:template>
1006
1007<xsl:template match="preamble">
1008  <xsl:if test="normalize-space(.) != ''">
1009    <p>
1010      <xsl:if test="@anchor">
1011        <xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute>
1012      </xsl:if>
1013      <xsl:call-template name="insertInsDelClass"/>
1014      <xsl:call-template name="editingMark" />
1015      <xsl:apply-templates />
1016    </p>
1017  </xsl:if>
1018</xsl:template>
1019
1020<xsl:template name="computed-auto-target">
1021  <xsl:param name="bib"/>
1022  <xsl:param name="ref"/>
1023
1024  <xsl:choose>
1025    <xsl:when test="$ref and $bib/x:source/@href and $bib/x:source/@basename and $ref/@x:rel">
1026      <xsl:value-of select="concat($bib/x:source/@basename,'.html',$ref/@x:rel)" />
1027    </xsl:when>
1028    <xsl:when test="$bib/seriesInfo/@name='RFC'">
1029      <xsl:variable name="sec">
1030        <xsl:choose>
1031          <xsl:when test="$ref and starts-with($ref/@x:rel,'#') and not($ref/@x:sec)">
1032            <xsl:variable name="extdoc" select="document($bib/x:source/@href)"/>
1033            <xsl:for-each select="$extdoc//*[@anchor=substring-after($ref/@x:rel,'#')]">
1034              <xsl:call-template name="get-section-number"/>
1035            </xsl:for-each>
1036          </xsl:when>
1037          <xsl:when test="$ref">
1038            <xsl:value-of select="$ref/@x:sec"/>
1039          </xsl:when>
1040          <xsl:otherwise/>
1041        </xsl:choose>
1042      </xsl:variable>
1043      <xsl:value-of select="concat($rfcUrlPrefix,$bib/seriesInfo[@name='RFC']/@value,$rfcUrlPostfix)" />
1044      <xsl:if test="$ref and $sec!='' and $rfcUrlFrag">
1045        <xsl:value-of select="concat('#',$rfcUrlFrag,$sec)"/>
1046      </xsl:if>
1047    </xsl:when>
1048    <xsl:when test="$bib/seriesInfo/@name='Internet-Draft'">
1049      <xsl:value-of select="concat($internetDraftUrlPrefix,$bib/seriesInfo[@name='Internet-Draft']/@value,$internetDraftUrlPostfix)" />
1050      <xsl:if test="$ref and $ref/@x:sec and $internetDraftUrlFrag">
1051        <xsl:value-of select="concat('#',$internetDraftUrlFrag,$ref/@x:sec)"/>
1052      </xsl:if>
1053    </xsl:when>
1054    <xsl:otherwise />
1055  </xsl:choose> 
1056 
1057</xsl:template>
1058
1059<xsl:template name="computed-target">
1060  <xsl:param name="bib"/>
1061  <xsl:param name="ref"/>
1062
1063  <xsl:choose>
1064    <xsl:when test="$bib/@target">
1065      <xsl:if test="$ref and $ref/@x:sec and $ref/@x:rel">
1066        <xsl:value-of select="concat($bib/@target,$ref/@x:rel)"/>
1067      </xsl:if>
1068    </xsl:when>
1069    <xsl:otherwise>
1070      <xsl:call-template name="computed-auto-target">
1071        <xsl:with-param name="bib" select="$bib"/>
1072        <xsl:with-param name="ref" select="$ref"/>
1073      </xsl:call-template>
1074    </xsl:otherwise>
1075  </xsl:choose> 
1076 
1077</xsl:template>
1078
1079<xsl:template match="reference">
1080
1081  <!-- check for reference to reference -->
1082  <xsl:variable name="anchor" select="@anchor"/>
1083  <xsl:if test="not(ancestor::ed:del) and not(//xref[@target=$anchor])">
1084    <xsl:message>WARNING: unused reference '<xsl:value-of select="@anchor"/>'<xsl:call-template name="lineno"/></xsl:message>
1085  </xsl:if>
1086
1087  <xsl:variable name="target">
1088    <xsl:choose>
1089      <xsl:when test="@target"><xsl:value-of select="@target" /></xsl:when>
1090      <xsl:otherwise>
1091        <xsl:call-template name="computed-auto-target">
1092          <xsl:with-param name="bib" select="."/>
1093        </xsl:call-template>
1094      </xsl:otherwise>
1095    </xsl:choose>
1096  </xsl:variable>
1097 
1098  <tr>
1099    <td class="reference">
1100      <xsl:call-template name="insertInsDelClass"/>
1101      <xsl:variable name="del-node" select="ancestor::ed:del"/>
1102      <xsl:variable name="rep-node" select="ancestor::ed:replace"/>
1103      <xsl:variable name="deleted" select="$del-node and ($rep-node/ed:ins)"/>
1104      <xsl:for-each select="../..">
1105        <xsl:call-template name="insert-issue-pointer">
1106          <xsl:with-param name="deleted-anchor" select="$deleted"/>
1107        </xsl:call-template>
1108      </xsl:for-each>
1109      <b id="{@anchor}">
1110        <xsl:call-template name="referencename">
1111          <xsl:with-param name="node" select="." />
1112        </xsl:call-template>
1113      </b>
1114    </td>
1115   
1116    <td class="top">
1117      <xsl:call-template name="insertInsDelClass"/>
1118      <xsl:for-each select="front/author">
1119        <xsl:variable name="initials">
1120          <xsl:call-template name="format-initials"/>
1121        </xsl:variable>
1122     
1123        <xsl:choose>
1124          <xsl:when test="@surname and @surname!=''">
1125            <xsl:variable name="displayname">
1126              <!-- surname/initials is reversed for last author except when it's the only one -->
1127              <xsl:choose>
1128                <xsl:when test="position()=last() and position()!=1">
1129                  <xsl:value-of select="concat($initials,' ',@surname)" />
1130                </xsl:when>
1131                <xsl:otherwise>
1132                  <xsl:value-of select="concat(@surname,', ',$initials)" />
1133                </xsl:otherwise>
1134              </xsl:choose>
1135              <xsl:if test="@role='editor'">
1136                <xsl:text>, Ed.</xsl:text>
1137              </xsl:if>
1138            </xsl:variable>
1139            <xsl:choose>
1140              <xsl:when test="address/email">
1141                <a>
1142                  <xsl:if test="$xml2rfc-linkmailto!='no'">
1143                    <xsl:attribute name="href">mailto:<xsl:value-of select="address/email" /></xsl:attribute>
1144                  </xsl:if>
1145                  <xsl:if test="organization/text()">
1146                    <xsl:attribute name="title"><xsl:value-of select="organization/text()"/></xsl:attribute>
1147                  </xsl:if>
1148                  <xsl:value-of select="$displayname" />
1149                </a>
1150              </xsl:when>
1151              <xsl:otherwise>
1152                <xsl:value-of select="$displayname" />
1153              </xsl:otherwise>
1154            </xsl:choose>
1155           
1156            <xsl:choose>
1157              <xsl:when test="position()=last() - 1">
1158                <xsl:if test="last() &gt; 2">,</xsl:if>
1159                <xsl:text> and </xsl:text>
1160              </xsl:when>
1161              <xsl:otherwise>
1162                <xsl:text>, </xsl:text>
1163              </xsl:otherwise>
1164            </xsl:choose>
1165          </xsl:when>
1166          <xsl:when test="organization/text()">
1167            <xsl:choose>
1168              <xsl:when test="address/uri">
1169                <a href="{address/uri}"><xsl:value-of select="organization" /></a>
1170              </xsl:when>
1171              <xsl:otherwise>
1172                <xsl:value-of select="organization" />
1173              </xsl:otherwise>
1174            </xsl:choose>
1175           
1176            <xsl:choose>
1177              <xsl:when test="position()=last() - 1">
1178                <xsl:if test="last() &gt; 2">,</xsl:if>
1179                <xsl:text> and </xsl:text>
1180              </xsl:when>
1181              <xsl:otherwise>
1182                <xsl:text>, </xsl:text>
1183              </xsl:otherwise>
1184            </xsl:choose>
1185          </xsl:when>
1186          <xsl:otherwise />
1187        </xsl:choose>
1188      </xsl:for-each>
1189         
1190      <xsl:choose>
1191        <xsl:when test="string-length($target) &gt; 0">
1192          <xsl:text>&#8220;</xsl:text><a href="{$target}"><xsl:value-of select="front/title" /></a><xsl:text>&#8221;</xsl:text>
1193        </xsl:when>
1194        <xsl:otherwise>
1195          <xsl:text>&#8220;</xsl:text><xsl:value-of select="front/title" /><xsl:text>&#8221;</xsl:text>
1196        </xsl:otherwise>
1197      </xsl:choose>
1198           
1199      <xsl:for-each select="seriesInfo">
1200        <xsl:text>, </xsl:text>
1201        <xsl:choose>
1202          <xsl:when test="not(@name) and not(@value) and ./text()"><xsl:value-of select="." /></xsl:when>
1203          <xsl:otherwise>
1204            <xsl:value-of select="@name" />
1205            <xsl:if test="@value!=''">&#0160;<xsl:value-of select="@value" /></xsl:if>
1206            <xsl:if test="translate(@name,$ucase,$lcase)='internet-draft'"> (work in progress)</xsl:if>
1207          </xsl:otherwise>
1208        </xsl:choose>
1209      </xsl:for-each>
1210     
1211      <xsl:if test="front/date/@year != '' and front/date/@year != '???'">
1212        <xsl:text>, </xsl:text>
1213        <xsl:if test="front/date/@month and (front/date/@month!='???' and front/date/@month!='')"><xsl:value-of select="front/date/@month" />&#0160;</xsl:if>
1214        <xsl:value-of select="front/date/@year" />
1215      </xsl:if>
1216     
1217      <xsl:if test="@target">
1218        <xsl:text>, &lt;</xsl:text>
1219        <a href="{@target}"><xsl:value-of select="@target"/></a>
1220        <xsl:text>&gt;</xsl:text>
1221      </xsl:if>
1222     
1223      <xsl:text>.</xsl:text>
1224
1225      <xsl:for-each select="annotation">
1226        <br />
1227        <xsl:apply-templates />
1228      </xsl:for-each>
1229
1230    </td>
1231  </tr>
1232 
1233 
1234</xsl:template>
1235
1236
1237<xsl:template match="references">
1238
1239  <xsl:variable name="name">
1240    <xsl:if test="ancestor::ed:del">
1241      <xsl:text>del-</xsl:text>
1242    </xsl:if>
1243    <xsl:number level="any"/>     
1244  </xsl:variable>
1245 
1246  <xsl:variable name="refseccount" select="count(/rfc/back/references)+count(/rfc/back/ed:replace/ed:ins/references)"/>
1247
1248  <!-- insert pseudo section when needed -->
1249  <xsl:if test="not(preceding::references) and $refseccount!=1">
1250    <xsl:call-template name="insert-conditional-hrule"/>
1251    <h1 id="{$anchor-prefix}.references">
1252      <xsl:call-template name="insert-conditional-pagebreak"/>
1253      <xsl:variable name="sectionNumber">
1254        <xsl:call-template name="get-references-section-number"/>
1255      </xsl:variable>
1256      <a id="{$anchor-prefix}.section.{$sectionNumber}" href="#{$anchor-prefix}.section.{$sectionNumber}">
1257        <xsl:call-template name="emit-section-number">
1258          <xsl:with-param name="no" select="$sectionNumber"/>
1259        </xsl:call-template>
1260      </a>
1261      <xsl:text> References</xsl:text>
1262    </h1>
1263  </xsl:if>
1264 
1265  <xsl:variable name="elemtype">
1266    <xsl:choose>
1267      <xsl:when test="$refseccount!=1">h2</xsl:when>
1268      <xsl:otherwise>h1</xsl:otherwise>
1269    </xsl:choose>
1270  </xsl:variable>
1271 
1272  <xsl:variable name="title">
1273    <xsl:choose>
1274      <xsl:when test="not(@title) or @title=''">References</xsl:when>
1275      <xsl:otherwise><xsl:value-of select="@title"/></xsl:otherwise>
1276    </xsl:choose>
1277  </xsl:variable>
1278 
1279  <xsl:element name="{$elemtype}"> 
1280    <xsl:if test="$name='1'">
1281      <xsl:call-template name="insert-conditional-pagebreak"/>
1282    </xsl:if>
1283    <xsl:variable name="sectionNumber">
1284      <xsl:call-template name="get-section-number"/>
1285    </xsl:variable>
1286    <xsl:variable name="anchorpref">
1287      <xsl:choose>
1288        <xsl:when test="$elemtype='h1'"></xsl:when>
1289        <xsl:otherwise>.<xsl:value-of select="$name"/></xsl:otherwise>
1290      </xsl:choose>
1291    </xsl:variable>
1292    <xsl:attribute name="id"><xsl:value-of select="concat($anchor-prefix,'.references',$anchorpref)"/></xsl:attribute>
1293    <a href="#{$anchor-prefix}.section.{$sectionNumber}" id="{$anchor-prefix}.section.{$sectionNumber}">
1294      <xsl:call-template name="emit-section-number">
1295        <xsl:with-param name="no" select="$sectionNumber"/>
1296      </xsl:call-template>
1297    </a>
1298    <xsl:text> </xsl:text>
1299    <xsl:value-of select="$title"/>
1300  </xsl:element>
1301 
1302  <table summary="{$title}">
1303    <xsl:choose>
1304      <xsl:when test="$xml2rfc-sortrefs='yes' and $xml2rfc-symrefs!='no'">
1305        <xsl:apply-templates>
1306          <xsl:sort select="@anchor|.//ed:ins//reference/@anchor" />
1307        </xsl:apply-templates>
1308      </xsl:when>
1309      <xsl:otherwise>
1310        <xsl:apply-templates />
1311      </xsl:otherwise>
1312    </xsl:choose>
1313  </table>
1314
1315</xsl:template>
1316
1317<xsl:template match="rfc">
1318 
1319  <!-- conformance checks -->
1320  <xsl:if test="$xml2rfc-symrefs!='no' and $xml2rfc-symrefs!='yes' and //reference">
1321    <xsl:message>WARNING: symrefs PI not specified; default has changed from 'no' to 'yes'.</xsl:message>
1322  </xsl:if>
1323 
1324  <xsl:variable name="lang">
1325    <xsl:call-template name="get-lang" />
1326  </xsl:variable>
1327
1328  <html lang="{$lang}">
1329    <head profile="http://www.w3.org/2006/03/hcard">
1330      <title>
1331        <xsl:apply-templates select="front/title" mode="get-text-content" />
1332      </title>
1333      <style type="text/css" title="Xml2Rfc (sans serif)">
1334        <xsl:call-template name="insertCss" />
1335      </style>
1336      <!-- <link rel="alternate stylesheet" type="text/css" media="screen" title="Plain (typewriter)" href="rfc2629tty.css" /> -->
1337           
1338      <!-- link elements -->
1339      <xsl:if test="$xml2rfc-toc='yes'">
1340        <link rel="Contents" href="#{$anchor-prefix}.toc" />
1341      </xsl:if>
1342      <link rel="Author" href="#{$anchor-prefix}.authors" />
1343      <xsl:if test="not($xml2rfc-private)">
1344        <link rel="Copyright" href="#{$anchor-prefix}.copyright" />
1345      </xsl:if>
1346      <xsl:if test="$has-index">
1347        <link rel="Index" href="#{$anchor-prefix}.index" />
1348      </xsl:if>
1349      <xsl:apply-templates select="/" mode="links" />
1350      <xsl:for-each select="/rfc/x:link">
1351        <link><xsl:copy-of select="@*" /></link>
1352      </xsl:for-each>
1353      <xsl:if test="/rfc/@number">
1354        <link rel="Alternate" title="Authorative ASCII version" href="http://www.ietf.org/rfc/rfc{/rfc/@number}.txt" />
1355      </xsl:if>
1356
1357      <!-- generator -->
1358      <xsl:variable name="gen">
1359        <xsl:call-template name="get-generator" />
1360      </xsl:variable>
1361      <meta name="generator" content="{$gen}" />
1362     
1363      <!-- keywords -->
1364      <xsl:if test="front/keyword">
1365        <xsl:variable name="keyw">
1366          <xsl:call-template name="get-keywords" />
1367        </xsl:variable>
1368        <meta name="keywords" content="{$keyw}" />
1369      </xsl:if>
1370
1371      <xsl:if test="$xml2rfc-ext-support-rfc2731!='no'">
1372        <!-- Dublin Core Metadata -->
1373        <link rel="schema.DC" href="http://purl.org/dc/elements/1.1/" />
1374             
1375        <!-- DC creator, see RFC2731 -->
1376        <xsl:for-each select="/rfc/front/author">
1377          <xsl:variable name="initials">
1378            <xsl:call-template name="format-initials"/>
1379          </xsl:variable>
1380          <meta name="DC.Creator" content="{concat(@surname,', ',$initials)}" />
1381        </xsl:for-each>
1382       
1383        <xsl:if test="not($xml2rfc-private)">
1384          <xsl:choose>
1385            <xsl:when test="/rfc/@number">
1386              <meta name="DC.Identifier" content="urn:ietf:rfc:{/rfc/@number}" />
1387            </xsl:when>
1388            <xsl:when test="/rfc/@docName">
1389              <meta name="DC.Identifier" content="urn:ietf:id:{/rfc/@docName}" />
1390            </xsl:when>
1391            <xsl:otherwise/>
1392          </xsl:choose>
1393          <xsl:variable name="month"><xsl:call-template name="get-month-as-num"/></xsl:variable>
1394          <meta name="DC.Date.Issued" scheme="ISO8601" content="{/rfc/front/date/@year}-{$month}" />
1395 
1396          <xsl:if test="/rfc/@obsoletes!=''">
1397            <xsl:call-template name="rfclist-for-dcmeta">
1398              <xsl:with-param name="list" select="/rfc/@obsoletes"/>
1399            </xsl:call-template>
1400          </xsl:if>
1401        </xsl:if>
1402 
1403        <xsl:if test="/rfc/front/abstract">
1404          <meta name="DC.Description.Abstract" content="{normalize-space(/rfc/front/abstract)}" />
1405        </xsl:if>     
1406      </xsl:if>     
1407    </head>
1408    <body>
1409      <!-- insert diagnostics -->
1410      <xsl:call-template name="insert-diagnostics"/>
1411
1412      <xsl:apply-templates select="front" />
1413      <xsl:apply-templates select="middle" />
1414      <xsl:apply-templates select="back" />
1415    </body>
1416  </html>
1417</xsl:template>               
1418
1419
1420<xsl:template match="t">
1421  <xsl:if test="preceding-sibling::section or preceding-sibling::appendix">
1422    <xsl:call-template name="warning">
1423      <xsl:with-param name="msg">The paragraph below is misplaced; maybe a section is closed in the wrong place: </xsl:with-param>
1424      <xsl:with-param name="msg2"><xsl:value-of select="."/></xsl:with-param>
1425    </xsl:call-template>
1426  </xsl:if>
1427  <xsl:choose>
1428    <xsl:when test="@anchor">
1429      <div id="{@anchor}"><xsl:apply-templates mode="t-content" select="node()[1]" /></div>
1430    </xsl:when>
1431    <xsl:otherwise>
1432      <xsl:apply-templates mode="t-content" select="node()[1]" />
1433    </xsl:otherwise>
1434  </xsl:choose>
1435</xsl:template>
1436
1437<!-- for t-content, dispatch to default templates if it's block-level content -->
1438<xsl:template mode="t-content" match="list|figure|texttable">
1439  <!-- <xsl:comment>t-content block-level</xsl:comment>  -->
1440  <xsl:apply-templates select="." />
1441  <xsl:apply-templates select="following-sibling::node()[1]" mode="t-content" />
1442</xsl:template>               
1443               
1444<!-- ... otherwise group into p elements -->
1445<xsl:template mode="t-content" match="*|node()">
1446  <xsl:variable name="p">
1447    <xsl:call-template name="get-paragraph-number" />
1448  </xsl:variable>
1449
1450  <!-- do not open a new p element if this is a whitespace-only text node and no siblings follow --> 
1451  <xsl:if test="not(self::text() and normalize-space(.)='' and not(following-sibling::node()))">
1452    <p>
1453      <xsl:if test="$p!='' and not(ancestor::ed:del) and not(ancestor::ed:ins) and not(ancestor::x:lt) and count(preceding-sibling::node())=0">
1454        <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$p"/></xsl:attribute>
1455      </xsl:if>
1456      <xsl:call-template name="insertInsDelClass"/>
1457      <xsl:call-template name="editingMark" />
1458      <xsl:apply-templates mode="t-content2" select="." />
1459    </p>
1460  </xsl:if>
1461  <xsl:apply-templates mode="t-content" select="following-sibling::*[self::list or self::figure or self::texttable][1]" />
1462</xsl:template>               
1463               
1464<xsl:template mode="t-content2" match="*">
1465  <xsl:apply-templates select="." />
1466  <xsl:if test="not(following-sibling::node()[1] [self::list or self::figure or self::texttable])">
1467    <xsl:apply-templates select="following-sibling::node()[1]" mode="t-content2" />
1468  </xsl:if>
1469</xsl:template>       
1470
1471<xsl:template mode="t-content2" match="text()">
1472  <xsl:apply-templates select="." />
1473  <xsl:if test="not(following-sibling::node()[1] [self::list or self::figure or self::texttable])">
1474    <xsl:apply-templates select="following-sibling::node()[1]" mode="t-content2" />
1475  </xsl:if>
1476</xsl:template>               
1477
1478<xsl:template match="title">
1479  <xsl:apply-templates />
1480</xsl:template>
1481
1482<xsl:template name="insertTitle">
1483  <xsl:choose>
1484    <xsl:when test="@ed:old-title">
1485      <del>
1486        <xsl:if test="ancestor-or-self::*[@ed:entered-by] and @ed:datetime">
1487          <xsl:attribute name="title"><xsl:value-of select="concat(@ed:datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
1488        </xsl:if>
1489        <xsl:value-of select="@ed:old-title"/>
1490      </del>
1491      <ins>
1492        <xsl:if test="ancestor-or-self::*[@ed:entered-by] and @ed:datetime">
1493          <xsl:attribute name="title"><xsl:value-of select="concat(@ed:datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
1494        </xsl:if>
1495        <xsl:value-of select="@title"/>
1496      </ins>
1497    </xsl:when>
1498    <xsl:otherwise>
1499      <xsl:value-of select="@title"/>
1500    </xsl:otherwise>
1501  </xsl:choose>
1502</xsl:template>
1503
1504<xsl:template match="section|appendix">
1505
1506  <xsl:variable name="sectionNumber">
1507    <xsl:choose>
1508      <xsl:when test="@myns:unnumbered"></xsl:when>
1509      <xsl:otherwise><xsl:call-template name="get-section-number" /></xsl:otherwise>
1510    </xsl:choose>
1511  </xsl:variable>
1512   
1513  <xsl:if test="not(ancestor::section) and not(@myns:notoclink)">
1514    <xsl:call-template name="insert-conditional-hrule"/>
1515  </xsl:if>
1516 
1517  <xsl:variable name="elemtype">
1518    <xsl:choose>
1519      <xsl:when test="count(ancestor::section) = 0">h1</xsl:when>
1520      <xsl:when test="count(ancestor::section) = 1">h2</xsl:when>
1521      <xsl:when test="count(ancestor::section) = 2">h3</xsl:when>
1522      <xsl:when test="count(ancestor::section) = 3">h4</xsl:when>
1523      <xsl:otherwise>h5</xsl:otherwise>
1524    </xsl:choose>
1525  </xsl:variable>
1526 
1527  <!-- process irefs immediadetely following the section so that their anchor
1528  actually is the section heading -->
1529  <xsl:apply-templates select="iref[count(preceding-sibling::*[not(self::iref)])=0]"/>
1530
1531  <xsl:element name="{$elemtype}">
1532    <xsl:if test="$sectionNumber!=''">
1533      <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$sectionNumber"/></xsl:attribute>
1534    </xsl:if>
1535    <xsl:choose>
1536      <xsl:when test="$sectionNumber='1'">
1537        <!-- pagebreak, this the first section -->
1538        <xsl:attribute name="class">np</xsl:attribute>
1539      </xsl:when>
1540      <xsl:when test="not(ancestor::section) and not(@myns:notoclink)">
1541        <xsl:call-template name="insert-conditional-pagebreak"/>
1542      </xsl:when>
1543      <xsl:otherwise/>
1544    </xsl:choose>
1545   
1546    <xsl:call-template name="insertInsDelClass" />
1547       
1548    <xsl:if test="$sectionNumber!=''">
1549      <a href="#{$anchor-prefix}.section.{$sectionNumber}">
1550        <xsl:call-template name="emit-section-number">
1551          <xsl:with-param name="no" select="$sectionNumber"/>
1552        </xsl:call-template>
1553      </a>
1554      <xsl:text>&#0160;</xsl:text>
1555    </xsl:if>
1556   
1557    <!-- issue tracking? -->
1558    <xsl:if test="@ed:resolves">
1559      <xsl:call-template name="insert-issue-pointer"/>
1560    </xsl:if>
1561   
1562    <xsl:choose>
1563      <xsl:when test="@anchor">
1564        <a id="{@anchor}" href="#{@anchor}"><xsl:call-template name="insertTitle"/></a>
1565      </xsl:when>
1566      <xsl:otherwise>
1567        <xsl:call-template name="insertTitle"/>
1568      </xsl:otherwise>
1569    </xsl:choose>
1570  </xsl:element>
1571  <!-- continue with all child elements but the irefs processed above -->
1572  <xsl:apply-templates select="*[not(self::iref)]|iref[count(preceding-sibling::*[not(self::iref)])!=0]" />
1573</xsl:template>
1574
1575<xsl:template match="spanx[@style='emph' or not(@style)]">
1576  <em>
1577    <xsl:if test="@anchor">
1578      <xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute>
1579    </xsl:if>
1580    <xsl:apply-templates />
1581  </em>
1582</xsl:template>
1583
1584<xsl:template match="spanx[@style='verb']">
1585  <samp>
1586    <xsl:if test="@anchor">
1587      <xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute>
1588    </xsl:if>
1589    <xsl:apply-templates />
1590  </samp>
1591</xsl:template>
1592
1593<xsl:template match="spanx[@style='strong']">
1594  <strong>
1595    <xsl:if test="@anchor">
1596      <xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute>
1597    </xsl:if>
1598    <xsl:apply-templates />
1599  </strong>
1600</xsl:template>
1601
1602<xsl:template name="insert-blank-lines">
1603  <xsl:param name="no"/>
1604  <xsl:choose>
1605    <xsl:when test="$no &lt;= 0">
1606      <br/>
1607      <!-- done -->
1608    </xsl:when>
1609    <xsl:otherwise>
1610      <br/>
1611      <xsl:call-template name="insert-blank-lines">
1612        <xsl:with-param name="no" select="$no - 1"/>
1613      </xsl:call-template>
1614    </xsl:otherwise>
1615  </xsl:choose>
1616</xsl:template>
1617
1618<xsl:template match="vspace[not(@blankLines)]">
1619  <br />
1620</xsl:template>
1621
1622<xsl:template match="vspace">
1623  <xsl:call-template name="insert-blank-lines">
1624    <xsl:with-param name="no" select="@blankLines"/>
1625  </xsl:call-template>
1626</xsl:template>
1627
1628<!-- keep the root for the case when we process XSLT-inline markup -->
1629<xsl:variable name="src" select="/" />
1630
1631<xsl:template name="render-section-ref">
1632  <xsl:param name="from" />
1633  <xsl:param name="to" />
1634
1635  <xsl:variable name="refname">
1636    <xsl:for-each select="$to">
1637      <xsl:call-template name="get-section-type">
1638        <xsl:with-param name="prec" select="$from/preceding-sibling::node()[1]" />
1639      </xsl:call-template>
1640    </xsl:for-each>
1641  </xsl:variable>
1642  <xsl:variable name="refnum">
1643    <xsl:for-each select="$to">
1644      <xsl:call-template name="get-section-number" />
1645    </xsl:for-each>
1646  </xsl:variable>
1647  <xsl:attribute name="title">
1648    <xsl:value-of select="$to/@title" />
1649  </xsl:attribute>
1650  <xsl:choose>
1651    <xsl:when test="@format='counter'">
1652      <xsl:value-of select="$refnum"/>
1653    </xsl:when>
1654    <xsl:when test="@format='title'">
1655      <xsl:value-of select="$to/@title"/>
1656    </xsl:when>
1657    <xsl:otherwise>
1658      <xsl:value-of select="normalize-space(concat($refname,'&#160;',$refnum))"/>
1659    </xsl:otherwise>
1660  </xsl:choose>
1661</xsl:template>
1662
1663<xsl:template match="xref[node()]">
1664
1665  <xsl:variable name="target" select="@target" />
1666  <xsl:variable name="node" select="$src//*[@anchor=$target]" />
1667  <xsl:variable name="anchor"><xsl:value-of select="$anchor-prefix"/>.xref.<xsl:value-of select="@target"/>.<xsl:number level="any" count="xref[@target=$target]"/></xsl:variable>
1668
1669  <xsl:choose>
1670
1671    <!-- x:fmt='none': do not generate any links -->
1672    <xsl:when test="@x:fmt='none'">
1673      <xsl:choose>
1674        <xsl:when test="name($node)='reference'">
1675          <cite title="{normalize-space($node/front/title)}">
1676            <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
1677              <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1678            </xsl:if>
1679            <!-- insert id when a backlink to this xref is needed in the index -->
1680            <xsl:if test="//iref[@x:for-anchor=$target] | //iref[@x:for-anchor='' and ../@anchor=$target]">
1681              <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1682            </xsl:if>
1683            <xsl:apply-templates/>
1684          </cite>
1685        </xsl:when>
1686        <xsl:otherwise>
1687          <xsl:apply-templates/>
1688        </xsl:otherwise>
1689      </xsl:choose>
1690    </xsl:when>
1691 
1692    <!-- Other x:fmt values than "none": unsupported -->
1693    <xsl:when test="@x:fmt and @x:fmt!='none'">
1694      <xsl:call-template name="error">
1695        <xsl:with-param name="msg" select="concat('unknown xref/@x:fmt extension: ',@x:fmt)"/>
1696      </xsl:call-template>
1697    </xsl:when>
1698
1699    <!-- Section links -->
1700    <xsl:when test="name($node)='section' or name($node)='appendix'">
1701      <xsl:apply-templates/>
1702      <xsl:variable name="context" select="."/>
1703      <xsl:text> (</xsl:text>
1704      <a href="#{@target}">
1705        <!-- insert id when a backlink to this xref is needed in the index -->
1706        <xsl:if test="//iref[@x:for-anchor=$target] | //iref[@x:for-anchor='' and ../@anchor=$target]">
1707          <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1708        </xsl:if>
1709        <xsl:call-template name="render-section-ref">
1710          <xsl:with-param name="from" select="."/>
1711          <xsl:with-param name="to" select="$node"/>
1712        </xsl:call-template>
1713      </a>
1714      <xsl:text>)</xsl:text>
1715    </xsl:when>
1716
1717    <xsl:otherwise>
1718      <a href="#{$target}"><xsl:apply-templates /></a>
1719      <xsl:for-each select="$src/rfc/back/references//reference[@anchor=$target]">
1720        <xsl:text> </xsl:text>
1721        <cite title="{normalize-space(front/title)}">
1722          <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
1723            <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1724          </xsl:if>
1725          <xsl:call-template name="referencename">
1726             <xsl:with-param name="node" select="." />
1727          </xsl:call-template>
1728        </cite>
1729      </xsl:for-each>
1730    </xsl:otherwise>
1731  </xsl:choose>
1732
1733</xsl:template>
1734               
1735<xsl:template match="xref[not(node())]">
1736
1737  <xsl:variable name="context" select="." />
1738  <xsl:variable name="target" select="@target" />
1739  <xsl:variable name="anchor"><xsl:value-of select="$anchor-prefix"/>.xref.<xsl:value-of select="@target"/>.<xsl:number level="any" count="xref[@target=$target]"/></xsl:variable>
1740  <xsl:variable name="node" select="$src//*[@anchor=$target]" />
1741  <xsl:if test="count($node)=0 and not(ancestor::ed:del)">
1742    <xsl:call-template name="error">
1743      <xsl:with-param name="msg" select="concat('Undefined target: ',@target)"/>
1744    </xsl:call-template>
1745  </xsl:if>
1746
1747  <xsl:choose>
1748 
1749    <!-- Section links -->
1750    <xsl:when test="name($node)='section' or name($node)='appendix'">
1751      <a href="#{@target}">
1752        <!-- insert id when a backlink to this xref is needed in the index -->
1753        <xsl:if test="//iref[@x:for-anchor=$target] | //iref[@x:for-anchor='' and ../@anchor=$target]">
1754          <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1755        </xsl:if>
1756        <xsl:call-template name="render-section-ref">
1757          <xsl:with-param name="from" select="."/>
1758          <xsl:with-param name="to" select="$node"/>
1759        </xsl:call-template>
1760      </a>
1761    </xsl:when>
1762
1763    <!-- Figure links -->
1764    <xsl:when test="name($node)='figure'">
1765      <a href="#{$target}">
1766        <xsl:variable name="figcnt">
1767          <xsl:for-each select="$node">
1768            <xsl:number level="any" count="figure[(@title!='' or @anchor!='') and not(@suppress-title='true')]" />
1769          </xsl:for-each>
1770        </xsl:variable>
1771        <xsl:choose>
1772          <xsl:when test="@format='counter'">
1773            <xsl:value-of select="$figcnt" />
1774          </xsl:when>
1775          <xsl:when test="@format='title'">
1776            <xsl:value-of select="$node/@title" />
1777          </xsl:when>
1778          <xsl:otherwise>
1779            <xsl:value-of select="normalize-space(concat('Figure&#160;',$figcnt))"/>
1780          </xsl:otherwise>
1781        </xsl:choose>
1782      </a>
1783    </xsl:when>
1784   
1785    <!-- Table links -->
1786    <xsl:when test="name($node)='texttable'">
1787      <a href="#{$target}">
1788        <xsl:variable name="tabcnt">
1789          <xsl:for-each select="$node">
1790            <xsl:number level="any" count="texttable[(@title!='' or @anchor!='') and not(@suppress-title='true')]" />
1791          </xsl:for-each>
1792        </xsl:variable>
1793        <xsl:choose>
1794          <xsl:when test="@format='counter'">
1795            <xsl:value-of select="$tabcnt" />
1796          </xsl:when>
1797          <xsl:when test="@format='title'">
1798            <xsl:value-of select="$node/@title" />
1799          </xsl:when>
1800          <xsl:otherwise>
1801            <xsl:value-of select="normalize-space(concat('Table&#160;',$tabcnt))"/>
1802          </xsl:otherwise>
1803        </xsl:choose>
1804      </a>
1805    </xsl:when>
1806   
1807    <!-- Reference links -->
1808    <xsl:when test="name($node)='reference'">
1809
1810      <xsl:variable name="href">
1811        <xsl:call-template name="computed-target">
1812          <xsl:with-param name="bib" select="$node"/>
1813          <xsl:with-param name="ref" select="."/>
1814        </xsl:call-template>
1815      </xsl:variable>
1816     
1817      <xsl:variable name="sec">
1818        <xsl:choose>
1819          <xsl:when test="starts-with(@x:rel,'#') and not(@x:sec) and $node/x:source/@href">
1820            <xsl:variable name="extdoc" select="document($node/x:source/@href)"/>
1821            <xsl:variable name="nodes" select="$extdoc//*[@anchor=substring-after(current()/@x:rel,'#')]"/>
1822            <xsl:if test="not($nodes)">
1823              <xsl:call-template name="error">
1824                <xsl:with-param name="msg">Anchor '<xsl:value-of select="substring-after(current()/@x:rel,'#')"/>' not found in <xsl:value-of select="$node/x:source/@href"/>.</xsl:with-param>
1825              </xsl:call-template>
1826            </xsl:if>
1827            <xsl:for-each select="$nodes">
1828              <xsl:call-template name="get-section-number"/>
1829            </xsl:for-each>
1830          </xsl:when>
1831          <xsl:otherwise>
1832            <xsl:value-of select="@x:sec"/>
1833          </xsl:otherwise>
1834        </xsl:choose>
1835      </xsl:variable>
1836     
1837      <xsl:variable name="secterm">
1838        <xsl:choose>
1839          <!-- starts with letter? -->
1840          <xsl:when test="translate(substring($sec,1,1),$ucase,'')=''">Appendix</xsl:when>
1841          <xsl:otherwise>Section</xsl:otherwise>
1842        </xsl:choose>
1843      </xsl:variable>
1844
1845      <xsl:variable name="fmt">
1846        <xsl:choose>
1847          <xsl:when test="@x:fmt!=''"><xsl:value-of select="@x:fmt"/></xsl:when>
1848          <xsl:when test="ancestor::artwork">,</xsl:when>
1849          <xsl:otherwise>of</xsl:otherwise>
1850        </xsl:choose>
1851      </xsl:variable>
1852
1853      <xsl:variable name="title">
1854        <xsl:choose>
1855          <xsl:when test="starts-with(@x:rel,'#') and not(@x:sec) and $node/x:source/@href">
1856            <xsl:variable name="extdoc" select="document($node/x:source/@href)"/>
1857            <xsl:variable name="nodes" select="$extdoc//*[@anchor=substring-after(current()/@x:rel,'#')]"/>
1858            <xsl:if test="not($nodes)">
1859              <xsl:call-template name="error">
1860                <xsl:with-param name="msg">Anchor '<xsl:value-of select="substring-after(current()/@x:rel,'#')"/>' not found in <xsl:value-of select="$node/x:source/@href"/>.</xsl:with-param>
1861              </xsl:call-template>
1862            </xsl:if>
1863            <xsl:for-each select="$nodes">
1864              <xsl:value-of select="@title"/>
1865            </xsl:for-each>
1866          </xsl:when>
1867          <xsl:otherwise />
1868        </xsl:choose>
1869      </xsl:variable>
1870
1871      <!--
1872      Formats:
1873     
1874        ()      [XXXX] (Section SS)
1875        ,       [XXXX], Section SS
1876        of      Section SS of [XXXX]
1877        sec     Section SS
1878        number  SS
1879      -->
1880     
1881      <xsl:if test="$fmt and not($fmt='()' or $fmt=',' or $fmt='of' or $fmt='sec' or $fmt='anchor' or $fmt='number')">
1882        <xsl:call-template name="error">
1883          <xsl:with-param name="msg" select="concat('unknown xref/@x:fmt extension: ',$fmt)"/>
1884        </xsl:call-template>
1885      </xsl:if>
1886
1887      <xsl:if test="$sec!=''">
1888             
1889        <xsl:choose>
1890          <xsl:when test="$fmt='of' or $fmt='sec'">
1891            <xsl:choose>
1892              <xsl:when test="$href!=''">
1893                <a href="{$href}">
1894                  <xsl:if test="$title!=''">
1895                    <xsl:attribute name="title"><xsl:value-of select="$title"/></xsl:attribute>
1896                  </xsl:if>
1897                  <xsl:if test="$fmt='sec' and $xml2rfc-ext-include-references-in-index='yes'">
1898                    <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1899                  </xsl:if>
1900                  <xsl:value-of select="$secterm"/>
1901                  <xsl:text> </xsl:text>
1902                  <xsl:value-of select="$sec"/>
1903                </a>
1904              </xsl:when>
1905              <xsl:otherwise><xsl:value-of select="$secterm"/><xsl:text> </xsl:text><xsl:value-of select="$sec"/></xsl:otherwise>
1906            </xsl:choose>
1907            <xsl:if test="$fmt='of'">
1908              <xsl:text> of </xsl:text>
1909            </xsl:if>
1910          </xsl:when>
1911          <xsl:when test="$fmt='number'">
1912            <xsl:choose>
1913              <xsl:when test="$href!=''">
1914                <a href="{$href}">
1915                  <xsl:if test="$title!=''">
1916                    <xsl:attribute name="title"><xsl:value-of select="$title"/></xsl:attribute>
1917                  </xsl:if>
1918                  <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
1919                    <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1920                  </xsl:if>
1921                  <xsl:value-of select="$sec"/>
1922                </a>
1923              </xsl:when>
1924              <xsl:otherwise><xsl:value-of select="$sec"/></xsl:otherwise>
1925            </xsl:choose>
1926          </xsl:when>
1927          <xsl:otherwise />
1928        </xsl:choose>
1929      </xsl:if>
1930
1931      <xsl:if test="$sec='' or ($fmt!='sec' and $fmt!='number')">
1932        <a href="#{$target}">
1933          <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
1934            <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1935          </xsl:if>
1936          <cite title="{normalize-space($node/front/title)}">
1937            <xsl:variable name="val">
1938              <xsl:call-template name="referencename">
1939                <xsl:with-param name="node" select="$node" />
1940              </xsl:call-template>
1941            </xsl:variable>
1942            <xsl:choose>
1943              <xsl:when test="$fmt='anchor'">
1944                <!-- remove brackets -->
1945                <xsl:value-of select="substring($val,2,string-length($val)-2)"/>
1946              </xsl:when>
1947              <xsl:otherwise>
1948                <xsl:value-of select="$val"/>
1949              </xsl:otherwise>
1950            </xsl:choose>
1951          </cite>
1952        </a>
1953      </xsl:if>
1954     
1955      <xsl:if test="$sec!=''">
1956        <xsl:choose>
1957          <xsl:when test="$fmt='()'">
1958            <xsl:text> (</xsl:text>
1959            <xsl:choose>
1960              <xsl:when test="$href!=''">
1961                <a href="{$href}"><xsl:value-of select="$secterm"/><xsl:text> </xsl:text><xsl:value-of select="$sec"/></a>
1962              </xsl:when>
1963              <xsl:otherwise><xsl:value-of select="$secterm"/><xsl:text> </xsl:text><xsl:value-of select="$sec"/></xsl:otherwise>
1964            </xsl:choose>
1965            <xsl:text>)</xsl:text>
1966          </xsl:when>
1967          <xsl:when test="$fmt=','">
1968            <xsl:text>, </xsl:text>
1969            <xsl:choose>
1970              <xsl:when test="$href!=''">
1971                <a href="{$href}">
1972                  <xsl:if test="$title!=''">
1973                    <xsl:attribute name="title"><xsl:value-of select="$title"/></xsl:attribute>
1974                  </xsl:if>
1975                  <xsl:value-of select="$secterm"/>
1976                  <xsl:text> </xsl:text>
1977                  <xsl:value-of select="$sec"/>
1978                </a>
1979              </xsl:when>
1980              <xsl:otherwise><xsl:value-of select="$secterm"/><xsl:text> </xsl:text><xsl:value-of select="$sec"/></xsl:otherwise>
1981            </xsl:choose>
1982          </xsl:when>
1983          <xsl:otherwise/>
1984        </xsl:choose>
1985      </xsl:if>
1986    </xsl:when>
1987   
1988    <xsl:otherwise>
1989      <xsl:call-template name="error">
1990        <xsl:with-param name="msg" select="concat('xref to unknown element: ',name($node))"/>
1991      </xsl:call-template>
1992    </xsl:otherwise>
1993  </xsl:choose>
1994</xsl:template>
1995
1996
1997<!-- mark unmatched elements red -->
1998
1999<xsl:template match="*">
2000  <xsl:message>ERROR: no XSLT template for element: &lt;<xsl:value-of select="name()"/>&gt;</xsl:message>   
2001  <tt class="error">&lt;<xsl:value-of select="name()" />&gt;</tt>
2002  <xsl:copy><xsl:apply-templates select="node()|@*" /></xsl:copy>
2003  <tt class="error">&lt;/<xsl:value-of select="name()" />&gt;</tt>
2004</xsl:template>
2005
2006<xsl:template match="/">
2007  <xsl:apply-templates select="*" />
2008</xsl:template>
2009
2010<!-- utility templates -->
2011
2012<xsl:template name="collectLeftHeaderColumn">
2013  <xsl:param name="mode" />
2014  <!-- default case -->
2015  <xsl:if test="not($xml2rfc-private)">
2016    <myns:item>Network Working Group</myns:item>
2017    <myns:item>
2018       <xsl:choose>
2019        <xsl:when test="/rfc/@ipr and not(/rfc/@number)">Internet Draft</xsl:when>
2020        <xsl:otherwise>Request for Comments: <xsl:value-of select="/rfc/@number"/></xsl:otherwise>
2021      </xsl:choose>
2022    </myns:item>
2023    <xsl:if test="/rfc/@docName and $mode!='nroff'">
2024      <myns:item>
2025        &lt;<xsl:value-of select="/rfc/@docName" />&gt;
2026      </myns:item>
2027    </xsl:if>
2028    <xsl:if test="/rfc/@obsoletes and /rfc/@obsoletes!=''">
2029      <myns:item>
2030        <xsl:text>Obsoletes: </xsl:text>
2031        <xsl:call-template name="rfclist">
2032          <xsl:with-param name="list" select="normalize-space(/rfc/@obsoletes)" />
2033        </xsl:call-template>
2034        <xsl:if test="not(/rfc/@number)"> (if approved)</xsl:if>
2035      </myns:item>
2036    </xsl:if>
2037    <xsl:if test="/rfc/@seriesNo">
2038       <myns:item>
2039        <xsl:choose>
2040          <xsl:when test="/rfc/@category='bcp'">BCP: <xsl:value-of select="/rfc/@seriesNo" /></xsl:when>
2041          <xsl:when test="/rfc/@category='info'">FYI: <xsl:value-of select="/rfc/@seriesNo" /></xsl:when>
2042          <xsl:when test="/rfc/@category='std'">STD: <xsl:value-of select="/rfc/@seriesNo" /></xsl:when>
2043          <xsl:otherwise><xsl:value-of select="concat(/rfc/@category,': ',/rfc/@seriesNo)" /></xsl:otherwise>
2044        </xsl:choose>
2045      </myns:item>
2046    </xsl:if>
2047    <xsl:if test="/rfc/@updates and /rfc/@updates!=''">
2048      <myns:item>
2049        <xsl:text>Updates: </xsl:text>
2050          <xsl:call-template name="rfclist">
2051             <xsl:with-param name="list" select="normalize-space(/rfc/@updates)" />
2052          </xsl:call-template>
2053          <xsl:if test="not(/rfc/@number)"> (if approved)</xsl:if>
2054      </myns:item>
2055    </xsl:if>
2056    <xsl:if test="$mode!='nroff'">
2057      <myns:item>
2058        <xsl:choose>
2059          <xsl:when test="/rfc/@number">
2060            <xsl:text>Category: </xsl:text>
2061          </xsl:when>
2062          <xsl:otherwise>
2063            <xsl:text>Intended status: </xsl:text>
2064          </xsl:otherwise>
2065        </xsl:choose>
2066        <xsl:call-template name="get-category-long" />
2067      </myns:item>
2068    </xsl:if>
2069    <xsl:if test="/rfc/@ipr and not(/rfc/@number)">
2070       <myns:item>Expires: <xsl:call-template name="expirydate" /></myns:item>
2071    </xsl:if>
2072  </xsl:if>
2073   
2074  <!-- private case -->
2075  <xsl:if test="$xml2rfc-private">
2076    <myns:item><xsl:value-of select="$xml2rfc-private" /></myns:item>
2077  </xsl:if>
2078</xsl:template>
2079
2080<xsl:template name="collectRightHeaderColumn">
2081  <xsl:for-each select="author">
2082    <xsl:variable name="initials">
2083      <xsl:call-template name="format-initials"/>
2084    </xsl:variable>
2085    <xsl:if test="@surname">
2086      <myns:item>
2087        <xsl:value-of select="concat($initials,' ',@surname)" />
2088        <xsl:if test="@role">
2089          <xsl:choose>
2090            <xsl:when test="@role='editor'">
2091              <xsl:text>, Editor</xsl:text>
2092            </xsl:when>
2093            <xsl:otherwise>
2094              <xsl:text>, </xsl:text><xsl:value-of select="@role" />
2095            </xsl:otherwise>
2096          </xsl:choose>
2097        </xsl:if>
2098      </myns:item>
2099    </xsl:if>
2100    <xsl:variable name="org">
2101      <xsl:choose>
2102        <xsl:when test="organization/@abbrev"><xsl:value-of select="organization/@abbrev" /></xsl:when>
2103        <xsl:otherwise><xsl:value-of select="organization" /></xsl:otherwise>
2104      </xsl:choose>
2105    </xsl:variable>
2106    <xsl:variable name="orgOfFollowing">
2107      <xsl:choose>
2108        <xsl:when test="following-sibling::*[1]/organization/@abbrev"><xsl:value-of select="following-sibling::*[1]/organization/@abbrev" /></xsl:when>
2109        <xsl:otherwise><xsl:value-of select="following-sibling::*/organization" /></xsl:otherwise>
2110      </xsl:choose>
2111    </xsl:variable>
2112    <xsl:if test="$org != $orgOfFollowing and $org != ''">
2113      <myns:item><xsl:value-of select="$org" /></myns:item>
2114    </xsl:if>
2115  </xsl:for-each>
2116  <myns:item>
2117    <xsl:value-of select="concat(date/@month,' ',date/@year)" />
2118  </myns:item>
2119</xsl:template>
2120
2121
2122<xsl:template name="emitheader">
2123  <xsl:param name="lc" />
2124  <xsl:param name="rc" />
2125
2126  <xsl:for-each select="$lc/myns:item | $rc/myns:item">
2127    <xsl:variable name="pos" select="position()" />
2128    <xsl:if test="$pos &lt; count($lc/myns:item) + 1 or $pos &lt; count($rc/myns:item) + 1"> 
2129      <tr>
2130        <td class="header left"><xsl:call-template name="copynodes"><xsl:with-param name="nodes" select="$lc/myns:item[$pos]/node()" /></xsl:call-template></td>
2131        <td class="header right"><xsl:call-template name="copynodes"><xsl:with-param name="nodes" select="$rc/myns:item[$pos]/node()" /></xsl:call-template></td>
2132      </tr>
2133    </xsl:if>
2134  </xsl:for-each>
2135</xsl:template>
2136
2137<!-- convenience template that avoids copying namespace nodes we don't want -->
2138<xsl:template name="copynodes">
2139  <xsl:param name="nodes" />
2140  <xsl:for-each select="$nodes">
2141    <xsl:choose>
2142      <xsl:when test="namespace-uri()='http://www.w3.org/1999/xhtml'">
2143        <xsl:element name="{name()}" namespace="{namespace-uri()}">
2144          <xsl:copy-of select="@*|node()" />
2145        </xsl:element>
2146      </xsl:when>
2147      <xsl:when test="self::*">
2148        <xsl:element name="{name()}">
2149          <xsl:copy-of select="@*|node()" />
2150        </xsl:element>
2151      </xsl:when>
2152      <!-- workaround for opera, remove when Opera > 9.0.x comes out -->
2153      <xsl:when test="self::text()">
2154        <xsl:value-of select="."/>
2155      </xsl:when>
2156      <xsl:otherwise>
2157        <xsl:copy-of select="." />
2158      </xsl:otherwise>
2159    </xsl:choose>
2160  </xsl:for-each>
2161</xsl:template>
2162
2163
2164<xsl:template name="expirydate">
2165  <xsl:variable name="date" select="/rfc/front/date" />
2166  <xsl:choose>
2167      <xsl:when test="$date/@month='January'">July <xsl:value-of select="$date/@year" /></xsl:when>
2168      <xsl:when test="$date/@month='February'">August <xsl:value-of select="$date/@year" /></xsl:when>
2169      <xsl:when test="$date/@month='March'">September <xsl:value-of select="$date/@year" /></xsl:when>
2170      <xsl:when test="$date/@month='April'">October <xsl:value-of select="$date/@year" /></xsl:when>
2171      <xsl:when test="$date/@month='May'">November <xsl:value-of select="$date/@year" /></xsl:when>
2172      <xsl:when test="$date/@month='June'">December <xsl:value-of select="$date/@year" /></xsl:when>
2173      <xsl:when test="$date/@month='July'">January <xsl:value-of select="$date/@year + 1" /></xsl:when>
2174      <xsl:when test="$date/@month='August'">February <xsl:value-of select="$date/@year + 1" /></xsl:when>
2175      <xsl:when test="$date/@month='September'">March <xsl:value-of select="$date/@year + 1" /></xsl:when>
2176      <xsl:when test="$date/@month='October'">April <xsl:value-of select="$date/@year + 1" /></xsl:when>
2177      <xsl:when test="$date/@month='November'">May <xsl:value-of select="$date/@year + 1" /></xsl:when>
2178      <xsl:when test="$date/@month='December'">June <xsl:value-of select="$date/@year + 1" /></xsl:when>
2179        <xsl:otherwise>WRONG SYNTAX FOR MONTH</xsl:otherwise>
2180     </xsl:choose>
2181</xsl:template>
2182
2183<xsl:template name="get-month-as-num">
2184  <xsl:variable name="date" select="/rfc/front/date" />
2185  <xsl:choose>
2186      <xsl:when test="$date/@month='January'">01</xsl:when>
2187      <xsl:when test="$date/@month='February'">02</xsl:when>
2188      <xsl:when test="$date/@month='March'">03</xsl:when>
2189      <xsl:when test="$date/@month='April'">04</xsl:when>
2190      <xsl:when test="$date/@month='May'">05</xsl:when>
2191      <xsl:when test="$date/@month='June'">06</xsl:when>
2192      <xsl:when test="$date/@month='July'">07</xsl:when>
2193      <xsl:when test="$date/@month='August'">08</xsl:when>
2194      <xsl:when test="$date/@month='September'">09</xsl:when>
2195      <xsl:when test="$date/@month='October'">10</xsl:when>
2196      <xsl:when test="$date/@month='November'">11</xsl:when>
2197      <xsl:when test="$date/@month='December'">12</xsl:when>
2198        <xsl:otherwise>WRONG SYNTAX FOR MONTH</xsl:otherwise>
2199     </xsl:choose>
2200</xsl:template>
2201
2202<!-- produce back section with author information -->
2203<xsl:template name="get-authors-section-title">
2204  <xsl:choose>
2205    <xsl:when test="count(/rfc/front/author)=1">Author's Address</xsl:when>
2206    <xsl:otherwise>Authors' Addresses</xsl:otherwise>
2207  </xsl:choose>
2208</xsl:template>
2209
2210<xsl:template name="get-authors-section-number">
2211  <xsl:if test="/*/x:assign-section-number[@builtin-target='authors']">
2212    <xsl:value-of select="/*/x:assign-section-number[@builtin-target='authors']/@number"/>
2213  </xsl:if>
2214</xsl:template>
2215
2216<xsl:template name="insertAuthors">
2217
2218  <xsl:call-template name="insert-conditional-hrule"/>
2219 
2220  <xsl:variable name="number">
2221    <xsl:call-template name="get-authors-section-number"/>
2222  </xsl:variable>
2223   
2224  <h1 id="{$anchor-prefix}.authors">
2225    <xsl:call-template name="insert-conditional-pagebreak"/>
2226    <xsl:if test="$number != ''">
2227      <a href="#{$anchor-prefix}.section.{$number}" id="{$anchor-prefix}.section.{$number}"><xsl:value-of select="$number"/>.</a>
2228      <xsl:text> </xsl:text>
2229    </xsl:if>
2230    <a href="#{$anchor-prefix}.authors"><xsl:call-template name="get-authors-section-title"/></a>
2231  </h1>
2232
2233  <xsl:apply-templates select="/rfc/front/author" />
2234</xsl:template>
2235
2236
2237
2238<!-- insert copyright statement -->
2239
2240<xsl:template name="insertCopyright" myns:namespaceless-elements="xml2rfc">
2241
2242  <xsl:choose>
2243    <xsl:when test="$ipr-rfc3667">
2244      <section title="Full Copyright Statement" anchor="{$anchor-prefix}.copyright" myns:unnumbered="unnumbered" myns:notoclink="notoclink">
2245        <t>
2246          <xsl:choose>
2247            <xsl:when test="$ipr-rfc4748">
2248              Copyright &#169; The IETF Trust (<xsl:value-of select="/rfc/front/date/@year" />).
2249            </xsl:when>
2250            <xsl:otherwise>
2251              Copyright &#169; The Internet Society (<xsl:value-of select="/rfc/front/date/@year" />).
2252            </xsl:otherwise>
2253          </xsl:choose>
2254        </t>
2255        <t>
2256          This document is subject to the rights, licenses and restrictions
2257          contained in BCP 78<xsl:if test="/rfc/@submissionType='independent'"> and at <eref target="http://www.rfc-editor.org/copyright.html"/></xsl:if>, and except as set forth therein, the authors
2258          retain all their rights.
2259        </t>
2260        <t>
2261          <xsl:choose>
2262            <xsl:when test="$ipr-rfc4748">
2263              This document and the information contained herein are provided
2264              on an &#8220;AS IS&#8221; basis and THE CONTRIBUTOR,
2265              THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY),
2266              THE INTERNET SOCIETY, THE IETF TRUST AND THE INTERNET ENGINEERING
2267              TASK FORCE DISCLAIM ALL WARRANTIES,
2268              EXPRESS OR IMPLIED,
2269              INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
2270              INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
2271              WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
2272            </xsl:when>
2273            <xsl:otherwise>
2274              This document and the information contained herein are provided
2275              on an &#8220;AS IS&#8221; basis and THE CONTRIBUTOR,
2276              THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY),
2277              THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIM
2278              ALL WARRANTIES,
2279              EXPRESS OR IMPLIED,
2280              INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
2281              INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
2282              WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
2283            </xsl:otherwise>
2284          </xsl:choose>
2285        </t>
2286      </section>   
2287    </xsl:when>
2288    <xsl:otherwise>
2289      <!-- <http://tools.ietf.org/html/rfc2026#section-10.4> -->
2290      <section title="Full Copyright Statement" anchor="{$anchor-prefix}.copyright" myns:unnumbered="unnumbered" myns:notoclink="notoclink">
2291        <t>
2292          Copyright &#169; The Internet Society (<xsl:value-of select="/rfc/front/date/@year" />). All Rights Reserved.
2293        </t>
2294        <t>
2295          This document and translations of it may be copied and furnished to
2296          others, and derivative works that comment on or otherwise explain it
2297          or assist in its implementation may be prepared, copied, published and
2298          distributed, in whole or in part, without restriction of any kind,
2299          provided that the above copyright notice and this paragraph are
2300          included on all such copies and derivative works. However, this
2301          document itself may not be modified in any way, such as by removing
2302          the copyright notice or references to the Internet Society or other
2303          Internet organizations, except as needed for the purpose of
2304          developing Internet standards in which case the procedures for
2305          copyrights defined in the Internet Standards process must be
2306          followed, or as required to translate it into languages other than
2307          English.
2308        </t>
2309        <t>
2310          The limited permissions granted above are perpetual and will not be
2311          revoked by the Internet Society or its successors or assignees.
2312        </t>
2313        <t>
2314          This document and the information contained herein is provided on an
2315          &#8220;;AS IS&#8221; basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
2316          TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
2317          BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
2318          HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
2319          MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
2320        </t>
2321      </section>
2322    </xsl:otherwise>
2323  </xsl:choose>
2324
2325  <section title="Intellectual Property" anchor="{$anchor-prefix}.ipr" myns:unnumbered="unnumbered">
2326    <xsl:choose>
2327      <xsl:when test="$ipr-rfc3667">
2328        <t>
2329          The IETF takes no position regarding the validity or scope of any
2330          Intellectual Property Rights or other rights that might be claimed to
2331          pertain to the implementation or use of the technology described in
2332          this document or the extent to which any license under such rights
2333          might or might not be available; nor does it represent that it has
2334          made any independent effort to identify any such rights.  Information
2335          on the procedures with respect to rights in RFC documents
2336          can be found in BCP 78 and BCP 79.
2337        </t>       
2338        <t>
2339          Copies of IPR disclosures made to the IETF Secretariat and any
2340          assurances of licenses to be made available, or the result of an
2341          attempt made to obtain a general license or permission for the use
2342          of such proprietary rights by implementers or users of this
2343          specification can be obtained from the IETF on-line IPR repository
2344          at <eref target="http://www.ietf.org/ipr"/>.
2345        </t>       
2346        <t>
2347          The IETF invites any interested party to bring to its attention any
2348          copyrights, patents or patent applications, or other proprietary
2349          rights that may cover technology that may be required to implement
2350          this standard. Please address the information to the IETF at
2351          <eref target="mailto:ietf-ipr@ietf.org">ietf-ipr@ietf.org</eref>.
2352        </t>       
2353      </xsl:when>
2354      <xsl:otherwise>
2355        <t>
2356          The IETF takes no position regarding the validity or scope of
2357          any intellectual property or other rights that might be claimed
2358          to  pertain to the implementation or use of the technology
2359          described in this document or the extent to which any license
2360          under such rights might or might not be available; neither does
2361          it represent that it has made any effort to identify any such
2362          rights. Information on the IETF's procedures with respect to
2363          rights in standards-track and standards-related documentation
2364          can be found in BCP-11. Copies of claims of rights made
2365          available for publication and any assurances of licenses to
2366          be made available, or the result of an attempt made
2367          to obtain a general license or permission for the use of such
2368          proprietary rights by implementors or users of this
2369          specification can be obtained from the IETF Secretariat.
2370        </t>
2371        <t>
2372          The IETF invites any interested party to bring to its
2373          attention any copyrights, patents or patent applications, or
2374          other proprietary rights which may cover technology that may be
2375          required to practice this standard. Please address the
2376          information to the IETF Executive Director.
2377        </t>
2378        <xsl:if test="$xml2rfc-iprnotified='yes'">
2379          <t>
2380            The IETF has been notified of intellectual property rights
2381            claimed in regard to some or all of the specification contained
2382            in this document. For more information consult the online list
2383            of claimed rights.
2384          </t>
2385        </xsl:if>
2386      </xsl:otherwise>
2387    </xsl:choose>
2388  </section>
2389 
2390  <section title="Acknowledgement" myns:unnumbered="unnumbered" myns:notoclink="notoclink">
2391    <t>
2392      Funding for the RFC Editor function is provided by the IETF
2393      Administrative Support Activity (IASA).
2394    </t>
2395  </section>
2396
2397</xsl:template>
2398
2399
2400<!-- insert CSS style info -->
2401
2402<xsl:template name="insertCss">
2403a {
2404  text-decoration: none;
2405}
2406a.smpl {
2407  color: black;
2408}
2409a:hover {
2410  text-decoration: underline;
2411}
2412a:active {
2413  text-decoration: underline;
2414}
2415address {
2416  margin-top: 1em;
2417  margin-left: 2em;
2418  font-style: normal;
2419}<xsl:if test="//x:blockquote">
2420blockquote {
2421  border-style: solid;
2422  border-color: gray;
2423  border-width: 0 0 0 .25em;
2424  font-style: italic;
2425  padding-left: 0.5em;
2426}</xsl:if>
2427body {<xsl:if test="$xml2rfc-background!=''">
2428  background: url(<xsl:value-of select="$xml2rfc-background" />) #ffffff left top;</xsl:if>
2429  color: black;
2430  font-family: verdana, helvetica, arial, sans-serif;
2431  font-size: 10pt;
2432}<xsl:if test="//xhtml:p">
2433br.p {
2434  line-height: 150%;
2435}</xsl:if>
2436cite {
2437  font-style: normal;
2438}
2439dd {
2440  margin-right: 2em;<xsl:if test="$xml2rfc-ext-justification='always'">
2441  text-align: justify;</xsl:if>
2442}
2443dl {
2444  margin-left: 2em;
2445}
2446<!-- spacing between two entries in definition lists -->
2447dl.empty dd {
2448  margin-top: .5em;
2449}
2450dl p {
2451  margin-left: 0em;
2452}
2453dt {
2454  margin-top: .5em;
2455}
2456h1 {
2457  font-size: 14pt;
2458  line-height: 21pt;
2459  page-break-after: avoid;
2460}
2461h1.np {
2462  page-break-before: always;
2463}
2464h1 a {
2465  color: #333333;
2466}
2467h2 {
2468  font-size: 12pt;
2469  line-height: 15pt;
2470  page-break-after: avoid;
2471}
2472h2 a {
2473  color: black;
2474}
2475h3 {
2476  font-size: 10pt;
2477  page-break-after: avoid;
2478}
2479h3 a {
2480  color: black;
2481}
2482h4 {
2483  font-size: 10pt;
2484  page-break-after: avoid;
2485}
2486h4 a {
2487  color: black;
2488}
2489h5 {
2490  font-size: 10pt;
2491  page-break-after: avoid;
2492}
2493h5 a {
2494  color: black;
2495}
2496img {
2497  margin-left: 3em;
2498}
2499li {
2500  margin-left: 2em;
2501  margin-right: 2em;<xsl:if test="$xml2rfc-ext-justification='always'">
2502  text-align: justify;</xsl:if>
2503}
2504ol {
2505  margin-left: 2em;
2506  margin-right: 2em;
2507}
2508ol p {
2509  margin-left: 0em;
2510}<xsl:if test="//xhtml:q">
2511q {
2512  font-style: italic;
2513}</xsl:if>
2514p {
2515  margin-left: 2em;
2516  margin-right: 2em;<xsl:if test="$xml2rfc-ext-justification='always'">
2517  text-align: justify;</xsl:if>
2518}
2519pre {
2520  margin-left: 3em;
2521  background-color: lightyellow;
2522  padding: .25em;
2523}
2524pre.text2 {
2525  border-style: dotted;
2526  border-width: 1px;
2527  background-color: #f0f0f0;
2528  width: 69em;
2529}
2530pre.inline {
2531  background-color: white;
2532  padding: 0em;
2533}
2534pre.text {
2535  border-style: dotted;
2536  border-width: 1px;
2537  background-color: #f8f8f8;
2538  width: 69em;
2539}
2540pre.drawing {
2541  border-style: solid;
2542  border-width: 1px;
2543  background-color: #f8f8f8;
2544  padding: 2em;
2545}<xsl:if test="//x:q">
2546q {
2547  font-style: italic;
2548}</xsl:if>
2549table {
2550  margin-left: 2em;
2551}<xsl:if test="//texttable">
2552table.tt {
2553  vertical-align: top;
2554}
2555table.full {
2556  border-style: outset;
2557  border-width: 1px;
2558}
2559table.headers {
2560  border-style: outset;
2561  border-width: 1px;
2562}
2563table.tt td {
2564  vertical-align: top;
2565}
2566table.full td {
2567  border-style: inset;
2568  border-width: 1px;
2569}
2570table.tt th {
2571  vertical-align: top;
2572}
2573table.full th {
2574  border-style: inset;
2575  border-width: 1px;
2576}
2577table.headers th {
2578  border-style: none none inset none;
2579  border-width: 1px;
2580}</xsl:if>
2581table.header {
2582  width: 95%;
2583  font-size: 10pt;
2584  color: white;
2585}
2586td.top {
2587  vertical-align: top;
2588}
2589td.topnowrap {
2590  vertical-align: top;
2591  white-space: nowrap;
2592}
2593td.header {
2594  background-color: gray;
2595  width: 50%;
2596}
2597td.reference {
2598  vertical-align: top;
2599  white-space: nowrap;
2600  padding-right: 1em;
2601}
2602thead {
2603  display:table-header-group;
2604}
2605ul.toc {
2606  list-style: none;
2607  margin-left: 1.5em;
2608  margin-right: 0em;
2609  padding-left: 0em;
2610}
2611li.tocline0 {
2612  line-height: 150%;
2613  font-weight: bold;
2614  font-size: 10pt;
2615  margin-left: 0em;
2616  margin-right: 0em;
2617}
2618li.tocline1 {
2619  line-height: normal;
2620  font-weight: normal;
2621  font-size: 9pt;
2622  margin-left: 0em;
2623  margin-right: 0em;
2624}
2625li.tocline2 {
2626  font-size: 0pt;
2627}
2628ul p {
2629  margin-left: 0em;
2630}
2631ul.ind {
2632  list-style: none;
2633  margin-left: 1.5em;
2634  margin-right: 0em;
2635  padding-left: 0em;
2636}
2637li.indline0 {
2638  font-weight: bold;
2639  line-height: 200%;
2640  margin-left: 0em;
2641  margin-right: 0em;
2642}
2643li.indline1 {
2644  font-weight: normal;
2645  line-height: 150%;
2646  margin-left: 0em;
2647  margin-right: 0em;
2648}
2649<xsl:if test="//x:bcp14">.bcp14 {
2650  font-style: normal;
2651  text-transform: lowercase;
2652  font-variant: small-caps;
2653}</xsl:if><xsl:if test="//x:blockquote">
2654blockquote > * .bcp14 {
2655  font-style: italic;
2656}</xsl:if>
2657.comment {
2658  background-color: yellow;
2659}<xsl:if test="$xml2rfc-editing='yes'">
2660.editingmark {
2661  background-color: khaki;
2662}</xsl:if>
2663.center {
2664  text-align: center;
2665}
2666.error {
2667  color: red;
2668  font-style: italic;
2669  font-weight: bold;
2670}
2671.figure {
2672  font-weight: bold;
2673  text-align: center;
2674  font-size: 9pt;
2675}
2676.filename {
2677  color: #333333;
2678  font-weight: bold;
2679  font-size: 12pt;
2680  line-height: 21pt;
2681  text-align: center;
2682}
2683.fn {
2684  font-weight: bold;
2685}
2686.hidden {
2687  display: none;
2688}
2689.left {
2690  text-align: left;
2691}
2692.right {
2693  text-align: right;
2694}
2695.title {
2696  color: #990000;
2697  font-size: 18pt;
2698  line-height: 18pt;
2699  font-weight: bold;
2700  text-align: center;
2701  margin-top: 36pt;
2702}
2703.vcardline {
2704  display: block;
2705}
2706.warning {
2707  font-size: 14pt;
2708  background-color: yellow;
2709}
2710<xsl:if test="//ed:del|//ed:replace|//ed:ins">del {
2711  color: red;
2712  text-decoration: line-through;
2713}
2714.del {
2715  color: red;
2716  text-decoration: line-through;
2717}
2718ins {
2719  color: green;
2720  text-decoration: underline;
2721}
2722.ins {
2723  color: green;
2724  text-decoration: underline;
2725}
2726div.issuepointer {
2727  float: left;
2728}</xsl:if><xsl:if test="//ed:issue">
2729table.openissue {
2730  background-color: khaki;
2731  border-width: thin;
2732  border-style: solid;
2733  border-color: black;
2734}
2735table.closedissue {
2736  background-color: white;
2737  border-width: thin;
2738  border-style: solid;
2739  border-color: gray;
2740  color: gray;
2741}
2742thead th {
2743  text-align: left;
2744}
2745.bg-issue {
2746  border: solid;
2747  border-width: 1px;
2748  font-size: 7pt;
2749}
2750.closed-issue {
2751  border: solid;
2752  border-width: thin;
2753  background-color: lime;
2754  font-size: smaller;
2755  font-weight: bold;
2756}
2757.open-issue {
2758  border: solid;
2759  border-width: thin;
2760  background-color: red;
2761  font-size: smaller;
2762  font-weight: bold;
2763}
2764.editor-issue {
2765  border: solid;
2766  border-width: thin;
2767  background-color: yellow;
2768  font-size: smaller;
2769  font-weight: bold;
2770}</xsl:if>
2771
2772@media print {
2773  .noprint {
2774    display: none;
2775  }
2776 
2777  a {
2778    color: black;
2779    text-decoration: none;
2780  }
2781
2782  table.header {
2783    width: 90%;
2784  }
2785
2786  td.header {
2787    width: 50%;
2788    color: black;
2789    background-color: white;
2790    vertical-align: top;
2791    font-size: 12pt;
2792  }
2793
2794  ul.toc a::after {
2795    content: leader('.') target-counter(attr(href), page);
2796  }
2797 
2798  a.iref {
2799    content: target-counter(attr(href), page);
2800  }
2801 
2802  .print2col {
2803    column-count: 2;
2804    -moz-column-count: 2;<!-- for Firefox -->
2805    column-fill: auto;<!-- for PrinceXML -->
2806  }
2807<xsl:if test="$xml2rfc-ext-justification='print'">
2808  dd {
2809    text-align: justify;
2810  }
2811  li {
2812    text-align: justify;
2813  }
2814  p {
2815    text-align: justify;
2816  }
2817</xsl:if>}
2818
2819@page {
2820  @top-left {
2821       content: "<xsl:call-template name="get-header-left"/>";
2822  }
2823  @top-right {
2824       content: "<xsl:call-template name="get-header-right"/>";
2825  }
2826  @top-center {
2827       content: "<xsl:call-template name="get-header-center"/>";
2828  }
2829  @bottom-left {
2830       content: "<xsl:call-template name="get-author-summary"/>";
2831  }
2832  @bottom-center {
2833       content: "<xsl:call-template name="get-category-long"/>";
2834  }
2835  @bottom-right {
2836       content: "[Page " counter(page) "]";
2837  }
2838}
2839
2840@page:first {
2841    @top-left {
2842      content: normal;
2843    }
2844    @top-right {
2845      content: normal;
2846    }
2847    @top-center {
2848      content: normal;
2849    }
2850}
2851</xsl:template>
2852
2853
2854<!-- generate the index section -->
2855
2856<xsl:template name="insertSingleIref">
2857  <xsl:choose>
2858    <xsl:when test="@ed:xref">
2859      <!-- special index generator mode -->
2860      <xsl:text>[</xsl:text>
2861      <a href="#{@ed:xref}"><xsl:value-of select="@ed:xref"/></a>
2862      <xsl:text>, </xsl:text>
2863      <a>
2864        <xsl:variable name="htmluri" select="//reference[@anchor=current()/@ed:xref]/format[@type='HTML']/@target"/>
2865        <xsl:if test="$htmluri">
2866          <xsl:attribute name="href"><xsl:value-of select="concat($htmluri,'#',@ed:frag)"/></xsl:attribute>
2867        </xsl:if>       
2868        <xsl:choose>
2869          <xsl:when test="@primary='true'"><b><xsl:value-of select="@ed:label" /></b></xsl:when>
2870          <xsl:otherwise><xsl:value-of select="@ed:label" /></xsl:otherwise>
2871        </xsl:choose>
2872      </a>
2873      <xsl:text>]</xsl:text>
2874      <xsl:if test="position()!=last()">, </xsl:if>
2875    </xsl:when>
2876    <xsl:otherwise>
2877      <xsl:variable name="_n">
2878        <xsl:call-template name="get-section-number" />
2879      </xsl:variable>
2880      <xsl:variable name="n">
2881        <xsl:choose>
2882          <xsl:when test="$_n!=''">
2883            <xsl:value-of select="$_n"/>
2884          </xsl:when>
2885          <xsl:otherwise>&#167;</xsl:otherwise>
2886        </xsl:choose>
2887      </xsl:variable>
2888      <xsl:variable name="backlink">
2889        <xsl:choose>
2890          <xsl:when test="self::xref">
2891            <xsl:variable name="target" select="@target"/>
2892            <xsl:text>#</xsl:text>
2893            <xsl:value-of select="$anchor-prefix"/>
2894            <xsl:text>.xref.</xsl:text>
2895            <xsl:value-of select="@target"/>.<xsl:number level="any" count="xref[@target=$target]"/>
2896          </xsl:when>
2897          <xsl:when test="self::iref">
2898            <xsl:text>#</xsl:text>
2899            <xsl:call-template name="compute-iref-anchor"/>
2900          </xsl:when>
2901          <xsl:when test="self::x:ref">
2902            <xsl:text>#</xsl:text>
2903            <xsl:call-template name="compute-extref-anchor"/>
2904          </xsl:when>
2905          <xsl:otherwise>
2906            <xsl:message>Unsupported element type for insertSingleIref</xsl:message>
2907          </xsl:otherwise>
2908        </xsl:choose>
2909      </xsl:variable>
2910      <a class="iref" href="{$backlink}">
2911        <xsl:call-template name="insertInsDelClass"/>
2912        <xsl:choose>
2913          <xsl:when test="@primary='true'"><b><xsl:value-of select="$n"/></b></xsl:when>
2914          <xsl:otherwise><xsl:value-of select="$n"/></xsl:otherwise>
2915        </xsl:choose>
2916      </a>
2917      <xsl:if test="position()!=last()">, </xsl:if>
2918    </xsl:otherwise>
2919  </xsl:choose>
2920</xsl:template>
2921
2922<xsl:template name="insertSingleXref">
2923  <xsl:variable name="_n">
2924    <xsl:call-template name="get-section-number" />
2925  </xsl:variable>
2926  <xsl:variable name="n">
2927    <xsl:choose>
2928      <xsl:when test="$_n!=''">
2929        <xsl:value-of select="$_n"/>
2930      </xsl:when>
2931      <xsl:otherwise>&#167;</xsl:otherwise>
2932    </xsl:choose>
2933  </xsl:variable>
2934  <xsl:choose>
2935    <xsl:when test="self::reference">
2936      <a class="iref" href="#{@anchor}">
2937        <xsl:call-template name="insertInsDelClass"/>
2938        <b><xsl:value-of select="$n"/></b>
2939      </a>
2940    </xsl:when>
2941    <xsl:otherwise>
2942      <xsl:variable name="target" select="@target"/>
2943      <xsl:variable name="backlink">#<xsl:value-of select="$anchor-prefix"/>.xref.<xsl:value-of select="$target"/>.<xsl:number level="any" count="xref[@target=$target]"/></xsl:variable>
2944      <a class="iref" href="{$backlink}">
2945        <xsl:call-template name="insertInsDelClass"/>
2946        <xsl:value-of select="$n"/>
2947      </a>
2948    </xsl:otherwise>
2949  </xsl:choose>
2950  <xsl:if test="position()!=last()">, </xsl:if>
2951</xsl:template>
2952
2953<xsl:template name="insertIndex">
2954
2955  <xsl:call-template name="insert-conditional-hrule"/>
2956
2957  <h1 id="{$anchor-prefix}.index">
2958    <xsl:call-template name="insert-conditional-pagebreak"/>
2959    <a href="#{$anchor-prefix}.index">Index</a>
2960  </h1>
2961 
2962  <!-- generate navigation links to index subsections -->
2963  <p class="noprint">
2964    <xsl:variable name="irefs" select="//iref[generate-id(.) = generate-id(key('index-first-letter',translate(substring(@item,1,1),$lcase,$ucase)))]"/>
2965    <xsl:variable name="xrefs" select="//reference[not(starts-with(@anchor,'deleted-'))][generate-id(.) = generate-id(key('index-first-letter',translate(substring(@anchor,1,1),$lcase,$ucase)))]"/>
2966 
2967    <xsl:for-each select="$irefs | $xrefs">
2968   
2969      <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)" />
2970         
2971      <xsl:variable name="letter" select="translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase)"/>
2972
2973      <!-- character? -->
2974      <xsl:if test="translate($letter,concat($lcase,$ucase,'0123456789'),'')=''">
2975     
2976        <xsl:variable name="showit">
2977          <xsl:choose>
2978            <xsl:when test="$xml2rfc-ext-include-references-in-index!='yes'">
2979              <xsl:if test="$irefs[starts-with(translate(@item,$lcase,$ucase),$letter)]">
2980                <xsl:text>yes</xsl:text>
2981              </xsl:if>
2982            </xsl:when>
2983            <xsl:otherwise>
2984              <xsl:text>yes</xsl:text>
2985            </xsl:otherwise>
2986          </xsl:choose>
2987        </xsl:variable>
2988       
2989        <xsl:if test="$showit='yes'">
2990          <a href="#{$anchor-prefix}.index.{$letter}">
2991            <xsl:value-of select="$letter" />
2992          </a>
2993          <xsl:text> </xsl:text>
2994        </xsl:if>
2995     
2996      </xsl:if>
2997
2998    </xsl:for-each>
2999  </p>
3000
3001  <!-- for each index subsection -->
3002  <div class="print2col">
3003  <ul class="ind">
3004    <xsl:variable name="irefs2" select="//iref[generate-id(.) = generate-id(key('index-first-letter',translate(substring(@item,1,1),$lcase,$ucase)))]"/>
3005    <xsl:variable name="xrefs2" select="//reference[not(starts-with(@anchor,'deleted-'))][generate-id(.) = generate-id(key('index-first-letter',translate(substring(@anchor,1,1),$lcase,$ucase)))]"/>
3006 
3007    <xsl:for-each select="$irefs2 | $xrefs2">
3008      <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)" />
3009      <xsl:variable name="letter" select="translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase)"/>
3010           
3011      <xsl:variable name="showit">
3012        <xsl:choose>
3013          <xsl:when test="$xml2rfc-ext-include-references-in-index!='yes'">
3014            <xsl:if test="$irefs2[starts-with(translate(@item,$lcase,$ucase),$letter)]">
3015              <xsl:text>yes</xsl:text>
3016            </xsl:if>
3017          </xsl:when>
3018          <xsl:otherwise>
3019            <xsl:text>yes</xsl:text>
3020          </xsl:otherwise>
3021        </xsl:choose>
3022      </xsl:variable>
3023
3024      <xsl:if test="$showit='yes'">
3025        <li class="indline0">
3026         
3027          <!-- make letters and digits stand out -->
3028          <xsl:choose>
3029            <xsl:when test="translate($letter,concat($lcase,$ucase,'0123456789'),'')=''">
3030              <a id="{$anchor-prefix}.index.{$letter}" href="#{$anchor-prefix}.index.{$letter}">
3031                <b><xsl:value-of select="$letter" /></b>
3032              </a>
3033            </xsl:when>
3034            <xsl:otherwise>
3035              <b><xsl:value-of select="$letter" /></b>
3036            </xsl:otherwise>
3037          </xsl:choose>
3038       
3039          <ul class="ind"> 
3040            <xsl:for-each select="key('index-first-letter',translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase))">
3041       
3042              <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)" />
3043             
3044                <xsl:choose>
3045                  <xsl:when test="self::reference">
3046                    <xsl:if test="$xml2rfc-ext-include-references-in-index='yes' and not(starts-with(@anchor,'deleted-'))">
3047                      <li class="indline1">
3048                        <em>
3049                          <xsl:value-of select="@anchor"/>
3050                        </em>
3051                        <xsl:text>&#160;&#160;</xsl:text>
3052                       
3053                        <xsl:variable name="rs" select="//xref[@target=current()/@anchor] | . | //reference[@anchor=concat('deleted-',current()/@anchor)]"/>
3054                        <xsl:for-each select="$rs">
3055                          <xsl:call-template name="insertSingleXref" />
3056                        </xsl:for-each>
3057
3058                        <xsl:variable name="rs2" select="$rs[@x:sec]"/>
3059
3060                        <xsl:if test="$rs2">
3061                          <ul class="ind"> 
3062                            <xsl:for-each select="$rs2">
3063                              <xsl:sort select="substring-before(concat(@x:sec,'.'),'.')" data-type="number"/>
3064                              <xsl:sort select="substring(@x:sec,1+string-length(substring-before(@x:sec,'.')))" data-type="number"/>
3065                              <xsl:if test="generate-id(.) = generate-id(key('index-xref-by-sec',concat(@target,'..',@x:sec)))">
3066                                <li class="indline1">
3067                                  <em>
3068                                    <xsl:text>Section </xsl:text>
3069                                    <xsl:value-of select="@x:sec"/>
3070                                  </em>
3071                                  <xsl:text>&#160;&#160;</xsl:text>
3072                                  <xsl:for-each select="key('index-xref-by-sec',concat(@target,'..',@x:sec))">
3073                                    <xsl:call-template name="insertSingleXref" />
3074                                  </xsl:for-each>
3075                                </li>
3076                              </xsl:if>
3077                            </xsl:for-each>
3078                          </ul>
3079                        </xsl:if>
3080
3081                        <xsl:if test="current()/x:source/@href">
3082                          <xsl:variable name="rs3" select="$rs[not(@x:sec) and @x:rel]"/>
3083                          <xsl:variable name="doc" select="document(current()/x:source/@href)"/>
3084                          <xsl:if test="$rs3">
3085                            <ul class="ind"> 
3086                              <xsl:for-each select="$rs3">
3087                                <xsl:sort select="count($doc//*[@anchor and following::*/@anchor=substring-after(current()/@x:rel,'#')])" order="ascending" data-type="number"/>
3088                                <xsl:if test="generate-id(.) = generate-id(key('index-xref-by-anchor',concat(@target,'..',@x:rel)))">
3089                                  <li class="indline1">
3090                                    <em>
3091                                      <xsl:text>Section </xsl:text>
3092                                      <xsl:for-each select="$doc//*[@anchor=substring-after(current()/@x:rel,'#')]">
3093                                        <xsl:call-template name="get-section-number"/>
3094                                      </xsl:for-each>
3095                                    </em>
3096                                    <xsl:text>&#160;&#160;</xsl:text>
3097                                    <xsl:for-each select="key('index-xref-by-anchor',concat(@target,'..',@x:rel))">
3098                                      <xsl:call-template name="insertSingleXref" />
3099                                    </xsl:for-each>
3100                                  </li>
3101                                </xsl:if>
3102                              </xsl:for-each>
3103                            </ul>
3104                          </xsl:if>
3105                        </xsl:if>
3106                      </li>
3107                    </xsl:if>
3108                  </xsl:when>
3109                  <xsl:otherwise>
3110                    <!-- regular iref -->
3111                    <xsl:if test="generate-id(.) = generate-id(key('index-item',concat(@item,@anchor)))">
3112                      <xsl:variable name="item" select="@item"/>
3113                      <xsl:variable name="in-artwork" select="count(//iref[@item=$item and @primary='true' and ancestor::artwork])!=0"/>
3114                         
3115                      <li class="indline1">
3116                        <xsl:choose>
3117                          <xsl:when test="$in-artwork">
3118                            <tt><xsl:value-of select="@item" /></tt>
3119                          </xsl:when>
3120                          <xsl:otherwise>
3121                            <xsl:value-of select="@item" />
3122                          </xsl:otherwise>
3123                        </xsl:choose>
3124                        <xsl:text>&#160;&#160;</xsl:text>
3125                       
3126                        <xsl:variable name="irefs3" select="key('index-item',@item)[not(@subitem) or @subitem='']"/>
3127                        <xsl:variable name="xrefs3" select="//xref[@target=$irefs3[@x:for-anchor='']/../@anchor or @target=$irefs3/@x:for-anchor]"/>
3128                        <xsl:variable name="extrefs3" select="//x:ref[.=$irefs3[@x:for-anchor='']/../@anchor or .=$irefs3/@x:for-anchor]"/>
3129
3130                        <xsl:for-each select="$irefs3|$xrefs3|$extrefs3">
3131                          <!-- <xsl:sort select="translate(@item,$lcase,$ucase)" />  -->
3132                          <xsl:call-template name="insertSingleIref" />
3133                        </xsl:for-each>
3134         
3135                        <xsl:variable name="s2" select="key('index-item',@item)[@subitem and @subitem!='']"/>
3136                        <xsl:if test="$s2">
3137                          <ul class="ind"> 
3138                            <xsl:for-each select="$s2">
3139                              <xsl:sort select="translate(@subitem,$lcase,$ucase)" />
3140                             
3141                              <xsl:if test="generate-id(.) = generate-id(key('index-item-subitem',concat(@item,'..',@subitem)))">
3142                 
3143                                <xsl:variable name="itemsubitem" select="concat(@item,'..',@subitem)"/>
3144                                <xsl:variable name="in-artwork2" select="count(//iref[concat(@item,'..',@subitem)=$itemsubitem and @primary='true' and ancestor::artwork])!=0"/>
3145                 
3146                                <li class="indline1">
3147             
3148                                  <xsl:choose>
3149                                    <xsl:when test="$in-artwork2">
3150                                      <tt><xsl:value-of select="@subitem" /></tt>
3151                                    </xsl:when>
3152                                    <xsl:otherwise>
3153                                      <xsl:value-of select="@subitem" />
3154                                    </xsl:otherwise>
3155                                  </xsl:choose>
3156                                  <xsl:text>&#160;&#160;</xsl:text>
3157                                   
3158                                  <xsl:variable name="irefs4" select="key('index-item-subitem',concat(@item,'..',@subitem))"/>
3159                                  <xsl:variable name="xrefs4" select="//xref[@target=$irefs4[@x:for-anchor='']/../@anchor or @target=$irefs4/@x:for-anchor]"/>
3160                                  <xsl:variable name="extrefs4" select="//x:ref[.=$irefs4[@x:for-anchor='']/../@anchor or .=$irefs4/@x:for-anchor]"/>
3161
3162                                  <xsl:for-each select="$irefs4|$xrefs4|$extrefs4">
3163                                    <!--<xsl:sort select="translate(@item,$lcase,$ucase)" />-->                   
3164                                    <xsl:call-template name="insertSingleIref" />
3165                                  </xsl:for-each>
3166               
3167                                </li>
3168                              </xsl:if>
3169                            </xsl:for-each>
3170                          </ul>
3171                        </xsl:if>
3172                      </li>
3173                    </xsl:if>
3174                  </xsl:otherwise>
3175                </xsl:choose>
3176             
3177                     
3178            </xsl:for-each>           
3179          </ul>
3180        </li>
3181      </xsl:if>
3182     
3183    </xsl:for-each>
3184  </ul>
3185  </div>
3186 
3187</xsl:template>
3188
3189
3190
3191
3192<xsl:template name="insertPreamble" myns:namespaceless-elements="xml2rfc">
3193
3194  <section title="Status of this Memo" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.status">
3195
3196  <xsl:choose>
3197    <xsl:when test="/rfc/@ipr and not(/rfc/@number)">
3198      <t>
3199        <xsl:choose>
3200         
3201          <!-- RFC2026 -->
3202          <xsl:when test="/rfc/@ipr = 'full2026'">
3203            This document is an Internet-Draft and is
3204            in full conformance with all provisions of Section 10 of RFC2026.   
3205          </xsl:when>
3206          <xsl:when test="/rfc/@ipr = 'noDerivativeWorks2026'">
3207            This document is an Internet-Draft and is
3208            in full conformance with all provisions of Section 10 of RFC2026
3209            except that the right to produce derivative works is not granted.   
3210          </xsl:when>
3211          <xsl:when test="/rfc/@ipr = 'noDerivativeWorksNow'">
3212            This document is an Internet-Draft and is
3213            in full conformance with all provisions of Section 10 of RFC2026
3214            except that the right to produce derivative works is not granted.
3215            (If this document becomes part of an IETF working group activity,
3216            then it will be brought into full compliance with Section 10 of RFC2026.) 
3217          </xsl:when>
3218          <xsl:when test="/rfc/@ipr = 'none'">
3219            This document is an Internet-Draft and is
3220            NOT offered in accordance with Section 10 of RFC2026,
3221            and the author does not provide the IETF with any rights other
3222            than to publish as an Internet-Draft.
3223          </xsl:when>
3224         
3225          <!-- RFC3667 -->
3226          <xsl:when test="/rfc/@ipr = 'full3667'">
3227            This document is an Internet-Draft and is subject to all provisions
3228            of section 3 of RFC 3667.  By submitting this Internet-Draft, each
3229            author represents that any applicable patent or other IPR claims of
3230            which he or she is aware have been or will be disclosed, and any of
3231            which he or she become aware will be disclosed, in accordance with
3232            RFC 3668.
3233          </xsl:when>
3234          <xsl:when test="/rfc/@ipr = 'noModification3667'">
3235            This document is an Internet-Draft and is subject to all provisions
3236            of section 3 of RFC 3667.  By submitting this Internet-Draft, each
3237            author represents that any applicable patent or other IPR claims of
3238            which he or she is aware have been or will be disclosed, and any of
3239            which he or she become aware will be disclosed, in accordance with
3240            RFC 3668.  This document may not be modified, and derivative works of
3241            it may not be created, except to publish it as an RFC and to
3242            translate it into languages other than English<xsl:if test="/rfc/@iprExtract">,
3243            other than to extract <xref target="{/rfc/@iprExtract}"/> as-is
3244            for separate use.</xsl:if>.
3245          </xsl:when>
3246          <xsl:when test="/rfc/@ipr = 'noDerivatives3667'">
3247            This document is an Internet-Draft and is subject to all provisions
3248            of section 3 of RFC 3667 except for the right to produce derivative
3249            works.  By submitting this Internet-Draft, each author represents
3250            that any applicable patent or other IPR claims of which he or she
3251            is aware have been or will be disclosed, and any of which he or she
3252            become aware will be disclosed, in accordance with RFC 3668.  This
3253            document may not be modified, and derivative works of it may
3254            not be created<xsl:if test="/rfc/@iprExtract">, other than to extract
3255            <xref target="{/rfc/@iprExtract}"/> as-is for separate use.</xsl:if>.
3256          </xsl:when>
3257         
3258          <!-- RFC3978 -->
3259          <xsl:when test="/rfc/@ipr = 'full3978'">
3260            By submitting this Internet-Draft, each
3261            author represents that any applicable patent or other IPR claims of
3262            which he or she is aware have been or will be disclosed, and any of
3263            which he or she becomes aware will be disclosed, in accordance with
3264            Section 6 of BCP 79.
3265          </xsl:when>
3266          <xsl:when test="/rfc/@ipr = 'noModification3978'">
3267            By submitting this Internet-Draft, each
3268            author represents that any applicable patent or other IPR claims of
3269            which he or she is aware have been or will be disclosed, and any of
3270            which he or she becomes aware will be disclosed, in accordance with
3271            Section 6 of BCP 79.  This document may not be modified, and derivative works of
3272            it may not be created, except to publish it as an RFC and to
3273            translate it into languages other than English<xsl:if test="/rfc/@iprExtract">,
3274            other than to extract <xref target="{/rfc/@iprExtract}"/> as-is
3275            for separate use.</xsl:if>.
3276          </xsl:when>
3277          <xsl:when test="/rfc/@ipr = 'noDerivatives3978'">
3278            By submitting this Internet-Draft, each author represents
3279            that any applicable patent or other IPR claims of which he or she
3280            is aware have been or will be disclosed, and any of which he or she
3281            becomes aware will be disclosed, in accordance with Section 6 of BCP 79.  This
3282            document may not be modified, and derivative works of it may
3283            not be created<xsl:if test="/rfc/@iprExtract">, other than to extract
3284            <xref target="{/rfc/@iprExtract}"/> as-is for separate use.</xsl:if>.
3285          </xsl:when>
3286
3287          <xsl:otherwise>CONFORMANCE UNDEFINED.</xsl:otherwise>
3288        </xsl:choose>
3289      </t>
3290      <t>
3291        Internet-Drafts are working documents of the Internet Engineering
3292        Task Force (IETF), its areas, and its working groups.
3293        Note that other groups may also distribute working documents as
3294        Internet-Drafts.
3295      </t>
3296      <t>
3297        Internet-Drafts are draft documents valid for a maximum of six months
3298        and may be updated, replaced, or obsoleted by other documents at any time.
3299        It is inappropriate to use Internet-Drafts as reference material or to cite
3300        them other than as &#8220;work in progress&#8221;.
3301      </t>
3302      <t>
3303        The list of current Internet-Drafts can be accessed at
3304        <eref target='http://www.ietf.org/ietf/1id-abstracts.txt'/>.
3305      </t>
3306      <t>
3307        The list of Internet-Draft Shadow Directories can be accessed at
3308        <eref target='http://www.ietf.org/shadow.html'/>.
3309      </t>
3310      <t>
3311        This Internet-Draft will expire in <xsl:call-template name="expirydate" />.
3312      </t>
3313    </xsl:when>
3314
3315    <xsl:when test="/rfc/@category='bcp'">
3316      <t>
3317        This document specifies an Internet Best Current Practices for the Internet
3318        Community, and requests discussion and suggestions for improvements.
3319        Distribution of this memo is unlimited.
3320      </t>
3321    </xsl:when>
3322    <xsl:when test="/rfc/@category='exp'">
3323      <t>
3324        This memo defines an Experimental Protocol for the Internet community.
3325        It does not specify an Internet standard of any kind.
3326        Discussion and suggestions for improvement are requested.
3327        Distribution of this memo is unlimited.
3328      </t>
3329    </xsl:when>
3330    <xsl:when test="/rfc/@category='historic'">
3331      <t>
3332        This memo describes a historic protocol for the Internet community.
3333        It does not specify an Internet standard of any kind.
3334        Distribution of this memo is unlimited.
3335      </t>
3336    </xsl:when>
3337    <xsl:when test="/rfc/@category='info' or not(/rfc/@category)">
3338      <t>
3339        This memo provides information for the Internet community.
3340        It does not specify an Internet standard of any kind.
3341        Distribution of this memo is unlimited.
3342      </t>
3343    </xsl:when>
3344    <xsl:when test="/rfc/@category='std'">
3345      <t>
3346        This document specifies an Internet standards track protocol for the Internet
3347        community, and requests discussion and suggestions for improvements.
3348        Please refer to the current edition of the &#8220;Internet Official Protocol
3349        Standards&#8221; (STD 1) for the standardization state and status of this
3350        protocol. Distribution of this memo is unlimited.
3351      </t>
3352    </xsl:when>
3353    <xsl:otherwise>
3354      <t>UNSUPPORTED CATEGORY.</t>
3355    </xsl:otherwise>
3356  </xsl:choose>
3357 
3358  </section>
3359
3360  <section title="Copyright Notice" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.copyrightnotice">
3361  <t>
3362    <xsl:choose>
3363      <xsl:when test="$ipr-rfc4748">
3364        Copyright &#169; The IETF Trust (<xsl:value-of select="/rfc/front/date/@year" />).  All Rights Reserved.
3365      </xsl:when>
3366      <xsl:otherwise>
3367        Copyright &#169; The Internet Society (<xsl:value-of select="/rfc/front/date/@year" />).  All Rights Reserved.
3368      </xsl:otherwise>
3369    </xsl:choose>
3370  </t>
3371  </section>
3372 
3373</xsl:template>
3374
3375<!-- TOC generation -->
3376
3377<xsl:template match="/" mode="toc">
3378  <hr class="noprint"/>
3379
3380  <h1 class="np" id="{$anchor-prefix}.toc"> <!-- this pagebreak occurs always -->
3381    <a href="#{$anchor-prefix}.toc">Table of Contents</a>
3382  </h1>
3383
3384  <ul class="toc">
3385    <xsl:apply-templates mode="toc" />
3386  </ul>
3387</xsl:template>
3388
3389<xsl:template name="insert-toc-line">
3390  <xsl:param name="number" />
3391  <xsl:param name="target" />
3392  <xsl:param name="title" />
3393  <xsl:param name="tocparam" />
3394  <xsl:param name="oldtitle" />
3395  <xsl:param name="waschanged" />
3396
3397  <!-- handle tocdepth parameter -->
3398  <xsl:choose>
3399    <xsl:when test="($tocparam='' or $tocparam='default') and string-length(translate($number,'.ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890&#167;','.')) &gt;= $parsedTocDepth">
3400      <!-- dropped entry because excluded -->
3401      <xsl:attribute name="class">tocline2</xsl:attribute>
3402    </xsl:when>
3403    <xsl:when test="$tocparam='exclude'">
3404      <!-- dropped entry because excluded -->
3405      <xsl:attribute name="class">tocline2</xsl:attribute>
3406    </xsl:when>
3407    <xsl:otherwise>
3408      <xsl:choose>
3409        <xsl:when test="starts-with($number,'del-')">
3410          <del>
3411            <xsl:value-of select="$number" />
3412            <a href="#{$target}"><xsl:value-of select="$title"/></a>
3413          </del>
3414        </xsl:when>
3415        <xsl:otherwise>
3416          <xsl:choose>
3417            <xsl:when test="not(contains($number,'.'))">
3418              <xsl:attribute name="class">tocline0</xsl:attribute>
3419            </xsl:when>
3420            <xsl:otherwise>
3421              <xsl:attribute name="class">tocline1</xsl:attribute>
3422            </xsl:otherwise>
3423          </xsl:choose>
3424          <xsl:if test="$number != ''">
3425            <xsl:call-template name="emit-section-number">
3426              <xsl:with-param name="no" select="$number"/>
3427            </xsl:call-template>
3428            <xsl:text>&#160;&#160;&#160;</xsl:text>
3429          </xsl:if>
3430          <a href="#{$target}">
3431            <xsl:choose>
3432              <xsl:when test="$waschanged!=''">
3433                <ins><xsl:value-of select="$title"/></ins>
3434                <del><xsl:value-of select="$oldtitle"/></del>
3435              </xsl:when>
3436              <xsl:otherwise>
3437                <xsl:value-of select="$title"/>
3438              </xsl:otherwise>
3439            </xsl:choose>
3440          </a>
3441        </xsl:otherwise>
3442      </xsl:choose>
3443    </xsl:otherwise>
3444  </xsl:choose>
3445</xsl:template>
3446
3447<xsl:template match="back" mode="toc">
3448
3449  <!-- <xsl:apply-templates select="references" mode="toc" /> -->
3450
3451  <xsl:if test="//cref and $xml2rfc-comments='yes' and $xml2rfc-inline!='yes'">
3452    <li>
3453      <xsl:call-template name="insert-toc-line">
3454        <xsl:with-param name="target" select="concat($anchor-prefix,'.comments')"/>
3455        <xsl:with-param name="title" select="'Editorial Comments'"/>
3456      </xsl:call-template>
3457    </li>
3458  </xsl:if>
3459
3460  <xsl:if test="$xml2rfc-ext-authors-section!='end'">
3461    <xsl:apply-templates select="/rfc/front" mode="toc" />
3462  </xsl:if>
3463  <xsl:apply-templates select="*[not(self::references)]" mode="toc" />
3464
3465  <xsl:if test="$xml2rfc-ext-authors-section='end'">
3466    <xsl:apply-templates select="/rfc/front" mode="toc" />
3467  </xsl:if>
3468
3469  <!-- copyright statements -->
3470  <xsl:if test="not($xml2rfc-private)">
3471    <li>
3472      <xsl:call-template name="insert-toc-line">
3473        <xsl:with-param name="target" select="concat($anchor-prefix,'.ipr')"/>
3474        <xsl:with-param name="title" select="'Intellectual Property and Copyright Statements'"/>
3475      </xsl:call-template>
3476    </li>
3477  </xsl:if>
3478 
3479  <!-- insert the index if index entries exist -->
3480  <xsl:if test="//iref">
3481    <li>
3482      <xsl:call-template name="insert-toc-line">
3483        <xsl:with-param name="target" select="concat($anchor-prefix,'.index')"/>
3484        <xsl:with-param name="title" select="'Index'"/>
3485      </xsl:call-template>
3486    </li>
3487  </xsl:if>
3488
3489</xsl:template>
3490
3491<xsl:template match="front" mode="toc">
3492 
3493  <li>
3494    <xsl:variable name="authors-title">
3495      <xsl:call-template name="get-authors-section-title"/>
3496    </xsl:variable>
3497    <xsl:variable name="authors-number">
3498      <xsl:call-template name="get-authors-section-number"/>
3499    </xsl:variable>
3500    <xsl:call-template name="insert-toc-line">
3501      <xsl:with-param name="target" select="concat($anchor-prefix,'.authors')"/>
3502      <xsl:with-param name="title" select="$authors-title"/>
3503      <xsl:with-param name="number" select="$authors-number"/>
3504    </xsl:call-template>
3505  </li>
3506
3507</xsl:template>
3508
3509<xsl:template name="references-toc">
3510
3511  <!-- distinguish two cases: (a) single references element (process
3512  as toplevel section; (b) multiple references sections (add one toplevel
3513  container with subsection) -->
3514
3515  <xsl:variable name="refsecs" select="/rfc/back/references|/rfc/back/ed:replace/ed:ins/references"/>
3516   
3517  <xsl:choose>
3518    <xsl:when test="count($refsecs) = 0">
3519      <!-- nop -->
3520    </xsl:when>
3521    <xsl:when test="count($refsecs) = 1">
3522      <xsl:for-each select="$refsecs">
3523        <xsl:variable name="title">
3524          <xsl:choose>
3525            <xsl:when test="@title!=''"><xsl:value-of select="@title" /></xsl:when>
3526            <xsl:otherwise>References</xsl:otherwise>
3527          </xsl:choose>
3528        </xsl:variable>
3529     
3530        <li>
3531          <xsl:call-template name="insert-toc-line">
3532            <xsl:with-param name="number">
3533              <xsl:call-template name="get-references-section-number"/>
3534            </xsl:with-param>
3535            <xsl:with-param name="target" select="concat($anchor-prefix,'.references')"/>
3536            <xsl:with-param name="title" select="$title"/>
3537          </xsl:call-template>
3538        </li>
3539      </xsl:for-each>
3540    </xsl:when>
3541    <xsl:otherwise>
3542      <li>
3543        <!-- insert pseudo container -->   
3544        <xsl:call-template name="insert-toc-line">
3545          <xsl:with-param name="number">
3546            <xsl:call-template name="get-references-section-number"/>
3547          </xsl:with-param>
3548          <xsl:with-param name="target" select="concat($anchor-prefix,'.references')"/>
3549          <xsl:with-param name="title" select="'References'"/>
3550        </xsl:call-template>
3551 
3552        <ul class="toc">
3553          <!-- ...with subsections... -->   
3554          <xsl:for-each select="$refsecs">
3555            <xsl:variable name="title">
3556              <xsl:choose>
3557                <xsl:when test="@title!=''"><xsl:value-of select="@title" /></xsl:when>
3558                <xsl:otherwise>References</xsl:otherwise>
3559              </xsl:choose>
3560            </xsl:variable>
3561         
3562            <xsl:variable name="sectionNumber">
3563              <xsl:call-template name="get-section-number" />
3564            </xsl:variable>
3565   
3566            <xsl:variable name="num">
3567              <xsl:number level="any"/>
3568            </xsl:variable>
3569   
3570            <li>
3571              <xsl:call-template name="insert-toc-line">
3572                <xsl:with-param name="number" select="$sectionNumber"/>
3573                <xsl:with-param name="target" select="concat($anchor-prefix,'.references','.',$num)"/>
3574                <xsl:with-param name="title" select="$title"/>
3575              </xsl:call-template>
3576            </li>
3577          </xsl:for-each>
3578        </ul>
3579      </li>
3580    </xsl:otherwise>
3581  </xsl:choose>
3582</xsl:template>
3583
3584<xsl:template match="section|appendix" mode="toc">
3585  <xsl:variable name="sectionNumber">
3586    <xsl:call-template name="get-section-number" />
3587  </xsl:variable>
3588
3589  <xsl:variable name="target">
3590    <xsl:choose>
3591      <xsl:when test="@anchor"><xsl:value-of select="@anchor" /></xsl:when>
3592       <xsl:otherwise><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$sectionNumber" /></xsl:otherwise>
3593    </xsl:choose>
3594  </xsl:variable>
3595
3596  <!-- obtain content, just to check whether we need to recurse at all -->
3597  <xsl:variable name="content">
3598    <li>
3599      <xsl:call-template name="insert-toc-line">
3600        <xsl:with-param name="number" select="$sectionNumber"/>
3601        <xsl:with-param name="target" select="$target"/>
3602        <xsl:with-param name="title" select="@title"/>
3603        <xsl:with-param name="tocparam" select="@toc"/>
3604        <xsl:with-param name="oldtitle" select="@ed:old-title"/>
3605        <xsl:with-param name="waschanged" select="@ed:resolves"/>
3606      </xsl:call-template>
3607   
3608      <ul class="toc">
3609        <xsl:apply-templates mode="toc" />
3610      </ul>
3611    </li>
3612  </xsl:variable>
3613 
3614  <xsl:if test="$content!=''">
3615    <li>
3616      <xsl:call-template name="insert-toc-line">
3617        <xsl:with-param name="number" select="$sectionNumber"/>
3618        <xsl:with-param name="target" select="$target"/>
3619        <xsl:with-param name="title" select="@title"/>
3620        <xsl:with-param name="tocparam" select="@toc"/>
3621        <xsl:with-param name="oldtitle" select="@ed:old-title"/>
3622        <xsl:with-param name="waschanged" select="@ed:resolves"/>
3623      </xsl:call-template>
3624   
3625      <!-- obtain nested content, just to check whether we need to recurse at all -->
3626      <xsl:variable name="nested-content">
3627        <ul class="toc">
3628          <xsl:apply-templates mode="toc" />
3629        </ul>
3630      </xsl:variable>
3631     
3632      <!-- only recurse if we need to (do not produce useless list container) -->     
3633      <xsl:if test="$nested-content!=''">
3634        <ul class="toc">
3635          <xsl:apply-templates mode="toc" />
3636        </ul>
3637      </xsl:if>
3638    </li>
3639  </xsl:if>
3640</xsl:template>
3641
3642<xsl:template match="middle" mode="toc">
3643  <xsl:apply-templates mode="toc" />
3644  <xsl:call-template name="references-toc" />
3645</xsl:template>
3646
3647<xsl:template match="rfc" mode="toc">
3648  <xsl:apply-templates select="middle|back" mode="toc" />
3649</xsl:template>
3650
3651<xsl:template match="ed:del|ed:ins|ed:replace" mode="toc">
3652  <xsl:apply-templates mode="toc" />
3653</xsl:template>
3654
3655<xsl:template match="*|text()" mode="toc" />
3656
3657
3658<xsl:template name="insertTocAppendix">
3659 
3660  <xsl:if test="//figure[@title!='' or @anchor!='']">
3661    <ul class="toc">
3662      <xsl:for-each select="//figure[@title!='' or @anchor!='']">
3663        <xsl:variable name="title">Figure <xsl:value-of select="position()"/><xsl:if test="@title">: <xsl:value-of select="@title"/></xsl:if>
3664        </xsl:variable>
3665        <li>
3666          <xsl:call-template name="insert-toc-line">
3667            <xsl:with-param name="target" select="concat($anchor-prefix,'.figure.',position())" />
3668            <xsl:with-param name="title" select="$title" />
3669          </xsl:call-template>
3670        </li>
3671      </xsl:for-each>
3672    </ul>
3673  </xsl:if>
3674 
3675  <!-- experimental -->
3676  <xsl:if test="//ed:issue">
3677    <xsl:call-template name="insertIssuesList" />
3678  </xsl:if>
3679
3680</xsl:template>
3681
3682<xsl:template name="referencename">
3683  <xsl:param name="node" />
3684 
3685  <xsl:for-each select="$node">
3686    <xsl:choose>
3687      <xsl:when test="$xml2rfc-symrefs!='no' and ancestor::ed:del">
3688        <xsl:variable name="unprefixed" select="substring-after(@anchor,'deleted-')"/>
3689        <xsl:choose>
3690          <xsl:when test="$unprefixed!=''">
3691            <xsl:value-of select="concat('[',$unprefixed,']')"/>
3692          </xsl:when>
3693          <xsl:otherwise>
3694            <xsl:if test="count(//reference[@anchor=current()/@anchor])!=1">
3695              <xsl:message>Deleted duplicate anchors should have the prefix "deleted-": <xsl:value-of select="@anchor"/></xsl:message>
3696            </xsl:if>
3697            <xsl:value-of select="concat('[',@anchor,']')"/>
3698          </xsl:otherwise>
3699        </xsl:choose>
3700      </xsl:when>
3701      <xsl:when test="$xml2rfc-symrefs!='no'">[<xsl:value-of select="@anchor" />]</xsl:when>
3702      <xsl:when test="ancestor::ed:del">
3703        <xsl:text>[del]</xsl:text>
3704      </xsl:when>
3705      <xsl:otherwise>[<xsl:number level="any" count="reference[not(ancestor::ed:del)]"/>]</xsl:otherwise>
3706    </xsl:choose>
3707  </xsl:for-each> 
3708</xsl:template>
3709
3710
3711
3712<xsl:template name="replace-substring">
3713
3714  <xsl:param name="string" />
3715  <xsl:param name="replace" />
3716  <xsl:param name="by" />
3717
3718  <xsl:choose>
3719    <xsl:when test="contains($string,$replace)">
3720      <xsl:value-of select="concat(substring-before($string, $replace),$by)" />
3721      <xsl:call-template name="replace-substring">
3722        <xsl:with-param name="string" select="substring-after($string,$replace)" />
3723        <xsl:with-param name="replace" select="$replace" />
3724        <xsl:with-param name="by" select="$by" />
3725      </xsl:call-template>
3726    </xsl:when>
3727    <xsl:otherwise><xsl:value-of select="$string" /></xsl:otherwise>
3728  </xsl:choose>
3729
3730</xsl:template>
3731
3732
3733<xsl:template name="rfclist">
3734  <xsl:param name="list" />
3735  <xsl:choose>
3736    <xsl:when test="contains($list,',')">
3737      <xsl:variable name="rfcNo" select="substring-before($list,',')" />
3738      <xsl:if test="count(//references//reference/seriesInfo[@name='RFC' and @value=$rfcNo])=0">
3739        <xsl:call-template name="warning">
3740          <xsl:with-param name="inline" select="'no'"/>
3741          <xsl:with-param name="msg" select="concat('front matter mentions RFC',$rfcNo,' for which there is no reference element')"/>
3742        </xsl:call-template>
3743      </xsl:if>
3744      <a href="{concat($rfcUrlPrefix,$rfcNo,$rfcUrlPostfix)}"><xsl:value-of select="$rfcNo" /></a>,
3745      <xsl:call-template name="rfclist">
3746        <xsl:with-param name="list" select="normalize-space(substring-after($list,','))" />
3747      </xsl:call-template>
3748    </xsl:when>
3749    <xsl:otherwise>
3750      <xsl:variable name="rfcNo" select="$list" />
3751      <xsl:if test="count(//references//reference/seriesInfo[@name='RFC' and @value=$rfcNo])=0">
3752        <xsl:call-template name="warning">
3753          <xsl:with-param name="inline" select="'no'"/>
3754          <xsl:with-param name="msg" select="concat('front matter mentions RFC',$rfcNo,' for which there is no reference element')"/>
3755        </xsl:call-template>
3756      </xsl:if>
3757      <a href="{concat($rfcUrlPrefix,$rfcNo,$rfcUrlPostfix)}"><xsl:value-of select="$rfcNo" /></a>
3758    </xsl:otherwise>
3759  </xsl:choose>
3760</xsl:template>
3761
3762<xsl:template name="rfclist-for-dcmeta">
3763  <xsl:param name="list" />
3764  <xsl:choose>
3765    <xsl:when test="contains($list,',')">
3766      <xsl:variable name="rfcNo" select="substring-before($list,',')" />
3767      <meta name="DC.Relation.Replaces" content="urn:ietf:rfc:{$rfcNo}" />
3768      <xsl:call-template name="rfclist-for-dcmeta">
3769        <xsl:with-param name="list" select="normalize-space(substring-after($list,','))" />
3770      </xsl:call-template>
3771    </xsl:when>
3772    <xsl:otherwise>
3773      <xsl:variable name="rfcNo" select="$list" />
3774      <meta name="DC.Relation.Replaces" content="urn:ietf:rfc:{$rfcNo}" />
3775    </xsl:otherwise>
3776  </xsl:choose>
3777</xsl:template>
3778
3779<xsl:template name="get-paragraph-number">
3780  <!-- get section number of ancestor section element, then add t or figure number -->
3781  <xsl:if test="ancestor::section and not(ancestor::section[@myns:unnumbered='unnumbered']) and not(ancestor::x:blockquote)">
3782    <xsl:for-each select="ancestor::section[1]"><xsl:call-template name="get-section-number" />.p.</xsl:for-each><xsl:number count="t|figure|x:blockquote" />
3783  </xsl:if>
3784</xsl:template>
3785
3786<xsl:template name="editingMark">
3787  <xsl:if test="$xml2rfc-editing='yes' and ancestor::rfc">
3788    <sup class="editingmark"><span><xsl:number level="any" count="postamble|preamble|t"/></span>&#0160;</sup>
3789  </xsl:if>
3790</xsl:template>
3791
3792<!-- internal ref support -->
3793<xsl:template match="x:ref">
3794  <xsl:variable name="val" select="."/>
3795  <xsl:variable name="target" select="//*[(@anchor and x:anchor-alias/@value=$val) or (@anchor and ed:replace/ed:ins/x:anchor-alias/@value=$val) or (@anchor=$val)]"/>
3796  <xsl:variable name="irefs" select="//iref[@x:for-anchor=$val]"/>
3797  <xsl:choose>
3798    <xsl:when test="$target">
3799      <a href="#{$target/@anchor}" class="smpl">
3800        <!-- to be indexed? -->
3801        <xsl:if test="$irefs">
3802          <xsl:attribute name="id"><xsl:call-template name="compute-extref-anchor"/></xsl:attribute>
3803        </xsl:if>
3804        <xsl:value-of select="."/>
3805      </a>
3806    </xsl:when>
3807    <xsl:otherwise>
3808      <xsl:message>WARNING: internal link target for '<xsl:value-of select="."/>' does not exist.<xsl:call-template name="lineno"/></xsl:message>
3809      <xsl:value-of select="."/>
3810    </xsl:otherwise>
3811  </xsl:choose>
3812</xsl:template>
3813
3814<!-- Nothing to do here -->
3815<xsl:template match="x:anchor-alias" />
3816
3817<!-- Quotes -->
3818<xsl:template match="x:q">
3819  <q>
3820    <xsl:copy-of select="@cite"/>
3821    <xsl:apply-templates/>
3822  </q>
3823</xsl:template>
3824
3825<xsl:template match="x:bcp14">
3826  <!-- check valid BCP14 keywords, then emphasize them -->
3827  <xsl:variable name="c" select="normalize-space(.)"/>
3828  <xsl:choose>
3829    <xsl:when test="$c='MUST' or $c='REQUIRED' or $c='SHALL'">
3830      <em class="bcp14"><xsl:value-of select="."/></em>
3831    </xsl:when>
3832    <xsl:when test="$c='MUST NOT' or $c='SHALL NOT'">
3833      <em class="bcp14"><xsl:value-of select="."/></em>
3834    </xsl:when>
3835    <xsl:when test="$c='SHOULD' or $c='RECOMMENDED'">
3836      <em class="bcp14"><xsl:value-of select="."/></em>
3837    </xsl:when>
3838    <xsl:when test="$c='SHOULD NOT' or $c='NOT RECOMMENDED'">
3839      <em class="bcp14"><xsl:value-of select="."/></em>
3840    </xsl:when>
3841    <xsl:when test="$c='MAY' or $c='OPTIONAL'">
3842      <em class="bcp14"><xsl:value-of select="."/></em>
3843    </xsl:when>
3844    <xsl:otherwise>
3845      <xsl:value-of select="."/>
3846      <xsl:message>ERROR: unknown BCP14 keyword: <xsl:value-of select="."/></xsl:message>
3847    </xsl:otherwise>
3848  </xsl:choose>
3849</xsl:template>
3850
3851<xsl:template match="x:blockquote">
3852  <xsl:variable name="p">
3853    <xsl:call-template name="get-paragraph-number" />
3854  </xsl:variable>
3855
3856  <blockquote>
3857    <xsl:if test="string-length($p) &gt; 0 and not(ancestor::ed:del) and not(ancestor::ed:ins)">
3858      <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$p"/></xsl:attribute>
3859    </xsl:if>
3860    <xsl:call-template name="insertInsDelClass"/>
3861    <xsl:call-template name="editingMark" />
3862    <xsl:copy-of select="@cite"/>
3863    <xsl:apply-templates/>
3864  </blockquote>
3865</xsl:template>
3866
3867<!-- Definitions -->
3868<xsl:template match="x:dfn">
3869  <dfn>
3870    <xsl:apply-templates/>
3871  </dfn>
3872</xsl:template>
3873
3874<!-- headings -->
3875<xsl:template match="x:h">
3876  <b>
3877    <xsl:apply-templates/>
3878  </b>
3879</xsl:template>
3880
3881<!-- box drawing -->
3882
3883<!-- nop for alignment -->
3884<xsl:template match="x:x"/>
3885
3886<!-- box (top) -->
3887<xsl:template match="x:bt">
3888  <xsl:text>&#x250c;</xsl:text>
3889  <xsl:value-of select="translate(substring(.,2,string-length(.)-2),'-','&#x2500;')"/>
3890  <xsl:text>&#x2510;</xsl:text>
3891</xsl:template>
3892
3893<!-- box (center) -->
3894<xsl:template match="x:bc">
3895  <xsl:variable name="first" select="substring(.,1)"/>
3896  <xsl:variable name="last" select="substring(.,string-length(.)-1)"/>
3897  <xsl:variable name="content" select="substring(.,2,string-length(.)-2)"/>
3898  <xsl:variable name="is-delimiter" select="translate($content,'-','')=''"/>
3899 
3900  <xsl:choose>
3901    <xsl:when test="$is-delimiter">
3902      <xsl:text>&#x251c;</xsl:text>
3903      <xsl:value-of select="translate($content,'-','&#x2500;')"/>
3904      <xsl:text>&#x2524;</xsl:text>
3905    </xsl:when>
3906    <xsl:when test="*">
3907      <xsl:for-each select="node()">
3908        <xsl:choose>
3909          <xsl:when test="position()=1">
3910            <xsl:text>&#x2502;</xsl:text>
3911            <xsl:value-of select="substring(.,2)"/>
3912          </xsl:when>
3913          <xsl:when test="position()=last()">
3914            <xsl:value-of select="substring(.,1,string-length(.)-1)"/>
3915            <xsl:text>&#x2502;</xsl:text>
3916          </xsl:when>
3917          <xsl:otherwise>
3918            <xsl:apply-templates select="."/>
3919          </xsl:otherwise>
3920        </xsl:choose>
3921      </xsl:for-each>
3922    </xsl:when>
3923    <xsl:otherwise>
3924      <xsl:text>&#x2502;</xsl:text>
3925      <xsl:value-of select="$content"/>
3926      <xsl:text>&#x2502;</xsl:text>
3927    </xsl:otherwise>
3928  </xsl:choose>
3929 
3930</xsl:template>
3931
3932<!-- box (bottom) -->
3933<xsl:template match="x:bb">
3934  <xsl:text>&#x2514;</xsl:text>
3935  <xsl:value-of select="translate(substring(.,2,string-length(.)-2),'-','&#x2500;')"/>
3936  <xsl:text>&#x2518;</xsl:text>
3937</xsl:template>
3938
3939<!-- experimental annotation support -->
3940
3941<xsl:template match="ed:issueref">
3942  <xsl:choose>
3943    <xsl:when test=".=//ed:issue/@name">
3944      <a href="#{$anchor-prefix}.issue.{.}">
3945        <xsl:apply-templates/>
3946      </a>
3947    </xsl:when>
3948    <xsl:otherwise>
3949      <xsl:call-template name="warning">
3950        <xsl:with-param name="msg">Dangling ed:issueref: <xsl:value-of select="."/></xsl:with-param>
3951      </xsl:call-template>
3952      <xsl:apply-templates/>
3953    </xsl:otherwise>
3954  </xsl:choose>
3955</xsl:template>
3956
3957<xsl:template match="ed:issue">
3958  <xsl:variable name="class">
3959    <xsl:choose>
3960      <xsl:when test="@status='closed'">closedissue</xsl:when>
3961      <xsl:otherwise>openissue</xsl:otherwise>
3962    </xsl:choose>
3963  </xsl:variable>
3964 
3965  <table summary="issue {@name}" class="{$class}">
3966    <tr>
3967      <td colspan="3">
3968        <a id="{$anchor-prefix}.issue.{@name}">
3969          <xsl:choose>
3970            <xsl:when test="@status='closed'">
3971              <xsl:attribute name="class">closed-issue</xsl:attribute>
3972            </xsl:when>
3973            <xsl:when test="@status='editor'">
3974              <xsl:attribute name="class">editor-issue</xsl:attribute>
3975            </xsl:when>
3976            <xsl:otherwise>
3977              <xsl:attribute name="class">open-issue</xsl:attribute>
3978            </xsl:otherwise>
3979          </xsl:choose>
3980          <xsl:text>&#160;I&#160;</xsl:text>
3981        </a>
3982        <xsl:text>&#160;</xsl:text>
3983        <xsl:choose>
3984          <xsl:when test="@href">
3985            <em><a href="{@href}"><xsl:value-of select="@name" /></a></em>
3986          </xsl:when>
3987          <xsl:when test="@alternate-href">
3988            <em>[<a href="{@alternate-href}">alternate link</a>]</em>
3989          </xsl:when>
3990          <xsl:otherwise>
3991            <em><xsl:value-of select="@name" /></em>
3992          </xsl:otherwise>
3993        </xsl:choose>
3994        &#0160;
3995        (type: <xsl:value-of select="@type"/>, status: <xsl:value-of select="@status"/>)
3996      </td>
3997    </tr>
3998
3999    <xsl:apply-templates select="ed:item"/>
4000    <xsl:apply-templates select="ed:resolution"/>
4001
4002    <xsl:variable name="changes" select="//*[@ed:resolves=current()/@name or ed:resolves=current()/@name]" />
4003    <xsl:if test="$changes">
4004      <tr>
4005        <td class="top" colspan="3">
4006          Associated changes in this document:
4007          <xsl:variable name="issue" select="@name"/>
4008          <xsl:for-each select="$changes">
4009            <a href="#{$anchor-prefix}.change.{$issue}.{position()}">
4010              <xsl:variable name="label">
4011                <xsl:call-template name="get-section-number"/>
4012              </xsl:variable>
4013              <xsl:choose>
4014                <xsl:when test="$label!=''"><xsl:value-of select="$label"/></xsl:when>
4015                <xsl:otherwise>&lt;<xsl:value-of select="concat('#',$anchor-prefix,'.change.',$issue,'.',position())"/>&gt;</xsl:otherwise>
4016              </xsl:choose>
4017            </a>
4018            <xsl:if test="position()!=last()">, </xsl:if>
4019          </xsl:for-each>
4020          <xsl:text>.</xsl:text>
4021        </td>
4022      </tr>
4023    </xsl:if>
4024  </table>
4025   
4026</xsl:template>
4027
4028<xsl:template match="ed:item">
4029  <tr>
4030    <td class="top">
4031      <xsl:if test="@entered-by">
4032        <a href="mailto:{@entered-by}?subject={/rfc/@docName},%20{../@name}">
4033          <i><xsl:value-of select="@entered-by"/></i>
4034        </a>
4035      </xsl:if>
4036    </td>
4037    <td class="topnowrap">
4038      <xsl:value-of select="@date"/>
4039    </td>
4040    <td class="top">
4041      <xsl:apply-templates select="node()" mode="issuehtml"/>
4042    </td>
4043  </tr>
4044</xsl:template>
4045
4046<xsl:template match="ed:resolution">
4047  <tr>
4048    <td class="top">
4049      <xsl:if test="@entered-by">
4050        <a href="mailto:{@entered-by}?subject={/rfc/@docName},%20{../@name}"><i><xsl:value-of select="@entered-by"/></i></a>
4051      </xsl:if>
4052    </td>
4053    <td class="topnowrap">
4054      <xsl:value-of select="@datetime"/>
4055    </td>
4056    <td class="top">
4057      <em>Resolution:</em>
4058      <xsl:apply-templates select="node()" mode="issuehtml"/>
4059    </td>
4060  </tr>
4061</xsl:template>
4062
4063<xsl:template match="ed:annotation">
4064  <em>
4065    <xsl:apply-templates/>
4066  </em>
4067</xsl:template>
4068
4069<!-- special templates for handling XHTML in issues -->
4070<xsl:template match="text()" mode="issuehtml">
4071  <xsl:value-of select="."/>
4072</xsl:template>
4073
4074<xsl:template match="*|@*" mode="issuehtml">
4075  <xsl:message terminate="yes">Unexpected node in issue HTML: <xsl:value-of select="local-name(.)"/></xsl:message>
4076</xsl:template>
4077
4078<xsl:template match="xhtml:a|xhtml:b|xhtml:br|xhtml:cite|xhtml:del|xhtml:em|xhtml:i|xhtml:ins|xhtml:q|xhtml:pre|xhtml:tt" mode="issuehtml">
4079  <xsl:element name="{local-name()}">
4080    <xsl:apply-templates select="@*|node()" mode="issuehtml"/>
4081  </xsl:element>
4082</xsl:template>
4083
4084<xsl:template match="xhtml:p" mode="issuehtml">
4085  <xsl:apply-templates select="node()" mode="issuehtml"/>
4086  <br class="p"/>
4087</xsl:template>
4088
4089<xsl:template match="xhtml:a/@href|xhtml:q/@cite" mode="issuehtml">
4090  <xsl:attribute name="{local-name(.)}">
4091    <xsl:value-of select="."/>
4092  </xsl:attribute>
4093</xsl:template>
4094
4095<xsl:template match="ed:issueref" mode="issuehtml">
4096  <xsl:apply-templates select="."/>
4097</xsl:template>
4098
4099<xsl:template match="ed:eref" mode="issuehtml">
4100  <xsl:text>&lt;</xsl:text>
4101  <a href="{.}"><xsl:value-of select="."/></a>
4102  <xsl:text>&gt;</xsl:text>
4103</xsl:template>
4104
4105<xsl:template name="insertIssuesList">
4106
4107  <h2 id="{$anchor-prefix}.issues-list" ><a href="#{$anchor-prefix}.issues-list">Issues list</a></h2>
4108  <table summary="Issues list">
4109    <thead>
4110      <tr>
4111        <th>Id</th>
4112        <th>Type</th>
4113        <th>Status</th>
4114        <th>Date</th>
4115        <th>Raised By</th>
4116      </tr>
4117    </thead>
4118    <tbody>
4119      <xsl:for-each select="//ed:issue">
4120        <xsl:sort select="@status" />
4121        <xsl:sort select="@name" />
4122        <tr>
4123          <td><a href="#{$anchor-prefix}.issue.{@name}"><xsl:value-of select="@name" /></a></td>
4124          <td><xsl:value-of select="@type" /></td>
4125          <td><xsl:value-of select="@status" /></td>
4126          <td><xsl:value-of select="ed:item[1]/@date" /></td>
4127          <td><a href="mailto:{ed:item[1]/@entered-by}?subject={/rfc/@docName},%20{@name}"><xsl:value-of select="ed:item[1]/@entered-by" /></a></td>
4128        </tr>
4129      </xsl:for-each>
4130    </tbody>
4131  </table>
4132 
4133</xsl:template>
4134
4135<xsl:template name="formatTitle">
4136  <xsl:if test="@who">
4137    <xsl:value-of select="@who" />
4138  </xsl:if>
4139  <xsl:if test="@datetime">
4140    <xsl:value-of select="concat(' (',@datetime,')')" />
4141  </xsl:if>
4142  <xsl:if test="@reason">
4143    <xsl:value-of select="concat(': ',@reason)" />
4144  </xsl:if>
4145  <xsl:if test="@cite">
4146    <xsl:value-of select="concat(' &lt;',@cite,'&gt;')" />
4147  </xsl:if>
4148</xsl:template>
4149
4150<xsl:template name="insert-diagnostics">
4151 
4152  <!-- check anchor names -->
4153  <xsl:variable name="badAnchors" select="//*[starts-with(@anchor,concat($anchor-prefix,'.'))]" />
4154  <xsl:if test="$badAnchors">
4155    <p class="warning">
4156      The following anchor names may collide with internally generated anchors because of their prefix "<xsl:value-of select="$anchor-prefix" />":
4157      <xsl:for-each select="$badAnchors">
4158        <xsl:value-of select="@anchor"/><xsl:if test="position()!=last()">, </xsl:if>
4159      </xsl:for-each>
4160    </p>
4161    <xsl:message>
4162      The following anchor names may collide with internally generated anchors because of their prefix "<xsl:value-of select="$anchor-prefix" />":
4163      <xsl:for-each select="$badAnchors">
4164        <xsl:value-of select="@anchor"/><xsl:if test="position()!=last()">, </xsl:if>
4165      </xsl:for-each>
4166    </xsl:message>
4167  </xsl:if>
4168 
4169  <!-- check IDs -->
4170  <xsl:variable name="badTargets" select="//xref[not(@target=//@anchor) and not(ancestor::ed:del)]" />
4171  <xsl:if test="$badTargets">
4172    <p class="error">
4173      The following target names do not exist:
4174      <xsl:for-each select="$badTargets">
4175        <xsl:value-of select="@target"/><xsl:if test="position()!=last()">, </xsl:if>
4176      </xsl:for-each>
4177    </p>
4178    <xsl:message>
4179      The following target names do not exist:
4180      <xsl:for-each select="$badTargets">
4181        <xsl:value-of select="@target"/><xsl:if test="position()!=last()">, </xsl:if>
4182      </xsl:for-each>
4183    </xsl:message>
4184  </xsl:if>
4185 
4186 
4187</xsl:template>
4188
4189<!-- special change mark support, not supported by RFC2629 yet -->
4190
4191<xsl:template match="@ed:*" />
4192
4193<xsl:template match="ed:del">
4194  <xsl:call-template name="insert-issue-pointer"/>
4195  <del>
4196    <xsl:copy-of select="@*[namespace-uri()='']"/>
4197    <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
4198      <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4199    </xsl:if>
4200    <xsl:apply-templates />
4201  </del>
4202</xsl:template>
4203
4204<xsl:template match="ed:ins">
4205  <xsl:call-template name="insert-issue-pointer"/>
4206  <ins>
4207    <xsl:copy-of select="@*[namespace-uri()='']"/>
4208    <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
4209      <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4210    </xsl:if>
4211    <xsl:apply-templates />
4212  </ins>
4213</xsl:template>
4214
4215<xsl:template name="insert-issue-pointer">
4216  <xsl:param name="deleted-anchor"/>
4217  <xsl:variable name="change" select="."/>
4218  <xsl:for-each select="@ed:resolves|ed:resolves">
4219    <xsl:variable name="resolves" select="."/>
4220    <!-- need the right context node for proper numbering -->
4221    <xsl:variable name="count"><xsl:for-each select=".."><xsl:number level="any" count="*[@ed:resolves=$resolves or ed:resolves=$resolves]" /></xsl:for-each></xsl:variable>
4222    <xsl:variable name="total" select="count(//*[@ed:resolves=$resolves or ed:resolves=$resolves])" />
4223    <xsl:variable name="id">
4224      <xsl:value-of select="$anchor-prefix"/>.change.<xsl:value-of select="$resolves"/>.<xsl:value-of select="$count" />
4225    </xsl:variable>
4226    <xsl:choose>
4227      <!-- block level? -->
4228      <xsl:when test="not(ancestor::t) and not(ancestor::title) and not(ancestor::figure) and not($change/@ed:old-title)">
4229        <div class="issuepointer noprint">
4230          <xsl:if test="not($deleted-anchor)">
4231            <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
4232          </xsl:if>
4233          <xsl:if test="$count > 1">
4234            <a class="bg-issue" title="previous change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count - 1}">&#x2191;</a>
4235          </xsl:if>
4236          <a class="open-issue" href="#{$anchor-prefix}.issue.{$resolves}" title="resolves: {$resolves}">
4237            <xsl:choose>
4238              <xsl:when test="//ed:issue[@name=$resolves and @status='closed']">
4239                <xsl:attribute name="class">closed-issue</xsl:attribute>
4240              </xsl:when>
4241              <xsl:when test="//ed:issue[@name=$resolves and @status='editor']">
4242                <xsl:attribute name="class">editor-issue</xsl:attribute>
4243              </xsl:when>
4244              <xsl:otherwise>
4245                <xsl:attribute name="class">open-issue</xsl:attribute>
4246              </xsl:otherwise>
4247            </xsl:choose>
4248            <xsl:text>&#160;I&#160;</xsl:text>
4249          </a>
4250          <xsl:if test="$count &lt; $total">
4251            <a class="bg-issue" title="next change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count + 1}">&#x2193;</a>
4252          </xsl:if>
4253          <xsl:text>&#160;</xsl:text>
4254        </div>
4255      </xsl:when>
4256      <xsl:otherwise>
4257        <xsl:if test="$count > 1">
4258          <a class="bg-issue" title="previous change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count - 1}">&#x2191;</a>
4259        </xsl:if>
4260        <a title="resolves: {$resolves}" href="#{$anchor-prefix}.issue.{$resolves}">
4261          <xsl:if test="not($deleted-anchor)">
4262            <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
4263          </xsl:if>
4264          <xsl:choose>
4265            <xsl:when test="//ed:issue[@name=$resolves and @status='closed']">
4266              <xsl:attribute name="class">closed-issue noprint</xsl:attribute>
4267            </xsl:when>
4268            <xsl:when test="//ed:issue[@name=$resolves and @status='editor']">
4269              <xsl:attribute name="class">editor-issue noprint</xsl:attribute>
4270            </xsl:when>
4271            <xsl:otherwise>
4272              <xsl:attribute name="class">open-issue noprint</xsl:attribute>
4273            </xsl:otherwise>
4274          </xsl:choose>
4275          <xsl:text>&#160;I&#160;</xsl:text>
4276        </a>
4277        <xsl:if test="$count &lt; $total">
4278          <a class="bg-issue" title="next change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count + 1}">&#x2193;</a>
4279        </xsl:if>
4280      </xsl:otherwise>
4281    </xsl:choose>
4282  </xsl:for-each>
4283</xsl:template>
4284
4285<xsl:template match="ed:replace">
4286  <!-- we need to special-case things like lists and tables -->
4287  <xsl:choose>
4288    <xsl:when test="parent::list">
4289      <xsl:apply-templates select="ed:del/node()" />
4290      <xsl:apply-templates select="ed:ins/node()" />
4291    </xsl:when>
4292    <xsl:when test="ancestor::references">
4293      <xsl:apply-templates select="ed:del/node()" />
4294      <xsl:apply-templates select="ed:ins/node()" />
4295    </xsl:when>
4296    <xsl:otherwise>
4297      <xsl:if test="@cite">
4298        <a class="editor-issue" href="{@cite}" target="_blank" title="see {@cite}">
4299          <xsl:text>&#160;i&#160;</xsl:text>
4300        </a>
4301      </xsl:if>
4302      <xsl:call-template name="insert-issue-pointer"/>
4303      <xsl:if test="ed:del">
4304        <del>
4305          <xsl:copy-of select="@*[namespace-uri()='']"/>
4306          <xsl:if test="not(@title) and ancestor-or-self::xsl:template[@ed:entered-by] and @datetime">
4307            <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4308          </xsl:if>
4309          <xsl:apply-templates select="ed:del/node()" />
4310        </del>
4311      </xsl:if>
4312      <xsl:if test="ed:ins">
4313        <ins>
4314          <xsl:copy-of select="@*[namespace-uri()='']"/>
4315          <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
4316            <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4317          </xsl:if>
4318          <xsl:apply-templates select="ed:ins/node()" />
4319        </ins>
4320      </xsl:if>
4321    </xsl:otherwise>
4322  </xsl:choose>
4323</xsl:template>
4324
4325<!-- convenience template for helping Mozilla (pre/ins inheritance problem) -->
4326<xsl:template name="insertInsDelClass">
4327  <xsl:if test="ancestor::ed:del">
4328    <xsl:attribute name="class">del</xsl:attribute>
4329  </xsl:if>
4330  <xsl:if test="ancestor::ed:ins">
4331    <xsl:attribute name="class">ins</xsl:attribute>
4332  </xsl:if>
4333</xsl:template>
4334
4335
4336<xsl:template name="sectionnumberAndEdits">
4337  <xsl:choose>
4338    <xsl:when test="ancestor::ed:del">del-<xsl:number count="ed:del//section" level="any"/></xsl:when>
4339    <xsl:when test="@x:fixed-section-number">
4340      <xsl:value-of select="@x:fixed-section-number"/>
4341    </xsl:when>
4342    <xsl:when test="self::section and parent::ed:ins and local-name(../..)='replace'">
4343      <xsl:for-each select="../.."><xsl:call-template name="sectionnumberAndEdits" /></xsl:for-each>
4344      <xsl:for-each select="..">
4345        <xsl:if test="parent::ed:replace">
4346          <xsl:for-each select="..">
4347            <xsl:if test="parent::section">.</xsl:if>
4348            <xsl:variable name="cnt" select="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)" />
4349            <xsl:choose>
4350              <xsl:when test="ancestor::back and not(ancestor::section)"><xsl:number format="A" value="$cnt"/></xsl:when>
4351              <xsl:otherwise><xsl:value-of select="$cnt"/></xsl:otherwise>
4352            </xsl:choose>
4353          </xsl:for-each>
4354        </xsl:if>
4355      </xsl:for-each>
4356    </xsl:when>
4357    <xsl:when test="self::section[parent::ed:ins]">
4358      <xsl:for-each select="../.."><xsl:call-template name="sectionnumberAndEdits" /></xsl:for-each>
4359      <xsl:for-each select="..">
4360        <xsl:if test="parent::section">.</xsl:if><xsl:value-of select="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)" />
4361      </xsl:for-each>
4362    </xsl:when>
4363    <xsl:when test="self::section">
4364      <xsl:for-each select=".."><xsl:call-template name="sectionnumberAndEdits" /></xsl:for-each>
4365      <xsl:if test="parent::section">.</xsl:if>
4366      <xsl:choose>
4367        <xsl:when test="parent::back">
4368          <xsl:number format="A" value="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)" />
4369        </xsl:when>
4370        <xsl:otherwise>
4371          <xsl:number value="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)" />
4372        </xsl:otherwise>
4373      </xsl:choose>
4374    </xsl:when>
4375    <xsl:when test="self::references">
4376      <xsl:choose>
4377        <xsl:when test="count(/*/back/references)+count(/*/back/ed:replace/ed:ins/references)=1"><xsl:call-template name="get-references-section-number"/></xsl:when>
4378        <xsl:otherwise><xsl:call-template name="get-references-section-number"/>.<xsl:number level="any"/></xsl:otherwise>
4379      </xsl:choose>
4380    </xsl:when>
4381    <xsl:when test="self::middle or self::back"><!-- done --></xsl:when>
4382    <xsl:otherwise>
4383      <!-- go up one level -->
4384      <xsl:for-each select=".."><xsl:call-template name="sectionnumberAndEdits" /></xsl:for-each>
4385    </xsl:otherwise>
4386  </xsl:choose>
4387</xsl:template>
4388
4389<!-- utilities for warnings -->
4390
4391<xsl:template name="warning">
4392  <xsl:param name="msg"/>
4393  <xsl:param name="msg2"/>
4394  <xsl:param name="inline"/>
4395  <xsl:if test="$inline!='no'">
4396    <div class="error">WARNING: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/></div>
4397  </xsl:if>
4398  <xsl:message>WARNING: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/><xsl:call-template name="lineno"/></xsl:message>
4399</xsl:template>
4400
4401<xsl:template name="error">
4402  <xsl:param name="msg"/>
4403  <xsl:param name="msg2"/>
4404  <xsl:param name="inline"/>
4405  <xsl:if test="$inline='no'">
4406    <div class="error">ERROR: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/></div>
4407  </xsl:if>
4408  <xsl:message>ERROR: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/><xsl:call-template name="lineno"/></xsl:message>
4409</xsl:template>
4410
4411<!-- table formatting -->
4412
4413<xsl:template match="texttable">
4414
4415  <xsl:variable name="anch">
4416    <xsl:call-template name="get-table-anchor"/>
4417  </xsl:variable>
4418
4419  <div id="{$anch}">
4420    <xsl:if test="@anchor!=''">
4421      <div id="{@anchor}"/>
4422    </xsl:if>
4423    <xsl:apply-templates select="preamble" />
4424    <xsl:variable name="style">
4425      <xsl:text>tt </xsl:text>
4426      <xsl:choose>
4427        <xsl:when test="@style!=''">
4428          <xsl:value-of select="@style"/>
4429        </xsl:when>
4430        <xsl:otherwise>full</xsl:otherwise>
4431      </xsl:choose>
4432    </xsl:variable>
4433    <table summary="{preamble}" class="{$style}" cellpadding="3" cellspacing="0">
4434      <thead>
4435        <tr>
4436          <xsl:apply-templates select="ttcol" />
4437        </tr>
4438      </thead>
4439      <tbody>
4440        <xsl:variable name="columns" select="count(ttcol)" />
4441        <xsl:variable name="fields" select="c | ed:replace/ed:ins/c | ed:replace/ed:del/c" />
4442        <xsl:for-each select="$fields[(position() mod $columns) = 1]">
4443          <tr>
4444            <xsl:for-each select=". | following-sibling::c[position() &lt; $columns]">
4445              <td>
4446                <xsl:call-template name="insertInsDelClass"/>
4447                <xsl:variable name="pos" select="position()" />
4448                <xsl:variable name="col" select="../ttcol[position() = $pos]" />
4449                <xsl:choose>
4450                  <xsl:when test="$col/@align='right' or $col/@align='center'">
4451                    <xsl:attribute name="class"><xsl:value-of select="$col/@align"/></xsl:attribute>
4452                  </xsl:when>
4453                  <xsl:when test="$col/@align='left' or not($col/@align)">
4454                    <!-- that's the default, nothing to do here -->
4455                  </xsl:when>
4456                  <xsl:otherwise>
4457                    <xsl:message>Unknown align attribute on ttcol: <xsl:value-of select="$col/@align"/></xsl:message>
4458                  </xsl:otherwise>
4459                </xsl:choose>
4460                <xsl:apply-templates select="node()" />
4461              </td>
4462            </xsl:for-each>
4463          </tr>
4464        </xsl:for-each>
4465      </tbody>
4466    </table>
4467    <xsl:apply-templates select="postamble" />
4468
4469    <xsl:if test="(@title!='' or @anchor!='') and not(@suppress-title='true')">
4470      <xsl:variable name="n"><xsl:number level="any" count="texttable[(@title!='' or @anchor!='') and not(@suppress-title='true')]" /></xsl:variable>
4471      <p class="figure">Table <xsl:value-of select="$n"/><xsl:if test="@title!=''">: <xsl:value-of select="@title" /></xsl:if></p>
4472    </xsl:if>
4473  </div>
4474 
4475</xsl:template>
4476
4477<xsl:template match="ttcol">
4478  <th>
4479   
4480    <xsl:choose>
4481      <xsl:when test="@align='right' or @align='center' or @align='left'">
4482        <xsl:attribute name="class"><xsl:value-of select="@align"/></xsl:attribute>
4483      </xsl:when>
4484      <xsl:when test="not(@align)">
4485        <!-- that's the default, nothing to do here -->
4486      </xsl:when>
4487      <xsl:otherwise>
4488        <xsl:message>Unknown align attribute on ttcol: <xsl:value-of select="@align"/></xsl:message>
4489      </xsl:otherwise>
4490    </xsl:choose>
4491   
4492    <xsl:if test="@width">
4493      <xsl:attribute name="style">width: <xsl:value-of select="@width" />;</xsl:attribute>
4494    </xsl:if>
4495
4496    <xsl:apply-templates />
4497  </th>
4498</xsl:template>
4499
4500<!-- cref support -->
4501
4502<xsl:template match="cref">
4503  <xsl:if test="$xml2rfc-comments!='no'">
4504    <xsl:variable name="cid">
4505      <xsl:choose>
4506        <xsl:when test="@anchor">
4507          <xsl:value-of select="@anchor"/>
4508        </xsl:when>
4509        <xsl:otherwise>
4510          <xsl:value-of select="$anchor-prefix"/>
4511          <xsl:text>.comment.</xsl:text>
4512          <xsl:number count="cref[not(@anchor)]" level="any"/>
4513        </xsl:otherwise>
4514      </xsl:choose>
4515    </xsl:variable>
4516   
4517    <span class="comment">
4518      <xsl:if test="$xml2rfc-inline!='yes'">
4519        <xsl:attribute name="title">
4520          <xsl:if test="@source"><xsl:value-of select="@source"/>: </xsl:if>
4521          <xsl:value-of select="."/>
4522        </xsl:attribute>
4523      </xsl:if>
4524      <xsl:text>[</xsl:text>
4525      <xsl:choose>
4526        <xsl:when test="$xml2rfc-inline='yes'">
4527          <xsl:value-of select="$cid"/>
4528          <xsl:text>: </xsl:text>
4529          <xsl:value-of select="."/>
4530          <xsl:if test="@source"> --<xsl:value-of select="@source"/></xsl:if>
4531        </xsl:when>
4532        <xsl:otherwise>
4533          <a href="#{$cid}">
4534            <xsl:value-of select="$cid"/>
4535          </a>
4536        </xsl:otherwise>
4537      </xsl:choose>
4538      <xsl:text>]</xsl:text>
4539    </span>
4540  </xsl:if>
4541</xsl:template>
4542
4543<xsl:template name="insertComments">
4544
4545  <xsl:call-template name="insert-conditional-hrule"/>
4546   
4547  <h1>
4548    <xsl:call-template name="insert-conditional-pagebreak"/>
4549    <a id="{$anchor-prefix}.comments" href="#{$anchor-prefix}.comments">Editorial Comments</a>
4550  </h1>
4551
4552  <dl>
4553    <xsl:for-each select="//cref">
4554      <xsl:variable name="cid">
4555        <xsl:choose>
4556          <xsl:when test="@anchor">
4557            <xsl:value-of select="@anchor"/>
4558          </xsl:when>
4559          <xsl:otherwise>
4560            <xsl:value-of select="$anchor-prefix"/>
4561            <xsl:text>.comment.</xsl:text>
4562            <xsl:number count="cref[not(@anchor)]" level="any"/>
4563          </xsl:otherwise>
4564        </xsl:choose>
4565      </xsl:variable>
4566      <dt id="{$cid}">
4567        [<xsl:value-of select="$cid"/>]
4568      </dt>
4569      <dd>
4570        <xsl:value-of select="."/>
4571        <xsl:if test="@source"> --<xsl:value-of select="@source"/></xsl:if>
4572      </dd>
4573    </xsl:for-each>
4574  </dl>
4575</xsl:template>
4576
4577
4578<!-- Chapter Link Generation -->
4579
4580<xsl:template match="*" mode="links"><xsl:apply-templates mode="links"/></xsl:template>
4581<xsl:template match="text()" mode="links" />
4582
4583<xsl:template match="/*/middle//section[not(myns:unnumbered) and not(ancestor::section)]" mode="links">
4584  <xsl:variable name="sectionNumber"><xsl:call-template name="get-section-number" /></xsl:variable>
4585  <link rel="Chapter" title="{$sectionNumber} {@title}" href="#{$anchor-prefix}.section.{$sectionNumber}" />
4586  <xsl:apply-templates mode="links" />
4587</xsl:template>
4588
4589<xsl:template match="/*/back//section[not(myns:unnumbered) and not(ancestor::section)]" mode="links">
4590  <xsl:variable name="sectionNumber"><xsl:call-template name="get-section-number" /></xsl:variable>
4591  <link rel="Appendix" title="{$sectionNumber} {@title}" href="#{$anchor-prefix}.section.{$sectionNumber}" />
4592  <xsl:apply-templates mode="links" />
4593</xsl:template>
4594
4595<xsl:template match="/*/back/references[position()=1]" mode="links">
4596  <xsl:variable name="sectionNumber"><xsl:call-template name="get-references-section-number" /></xsl:variable>
4597  <link rel="Chapter" href="#{$anchor-prefix}.section.{$sectionNumber}">
4598    <xsl:choose>
4599      <xsl:when test="@title and count(/*/back/references)=1">
4600        <xsl:attribute name="title">
4601          <xsl:call-template name="get-references-section-number"/>
4602          <xsl:text> </xsl:text>
4603          <xsl:value-of select="@title"/>
4604        </xsl:attribute>
4605      </xsl:when>
4606      <xsl:otherwise>
4607        <xsl:attribute name="title">
4608          <xsl:call-template name="get-references-section-number"/>
4609          <xsl:text> References</xsl:text>
4610        </xsl:attribute>
4611      </xsl:otherwise>
4612    </xsl:choose>
4613  </link>
4614</xsl:template>
4615
4616<!-- convenience templates -->
4617
4618<xsl:template name="get-author-summary">
4619  <xsl:choose>
4620    <xsl:when test="count(/rfc/front/author)=1">
4621      <xsl:value-of select="/rfc/front/author[1]/@surname" />
4622    </xsl:when>
4623    <xsl:when test="count(/rfc/front/author)=2">
4624      <xsl:value-of select="concat(/rfc/front/author[1]/@surname,' &amp; ',/rfc/front/author[2]/@surname)" />
4625    </xsl:when>
4626    <xsl:otherwise>
4627      <xsl:value-of select="concat(/rfc/front/author[1]/@surname,', et al.')" />
4628    </xsl:otherwise>
4629  </xsl:choose>
4630</xsl:template>
4631
4632<xsl:template name="get-authors">
4633  <xsl:for-each select="/rfc/front/author">
4634    <xsl:value-of select="@fullname" />
4635    <xsl:if test="position()!=last()">, </xsl:if>
4636  </xsl:for-each>
4637</xsl:template>
4638
4639<xsl:template name="get-category-long">
4640  <xsl:choose>
4641    <xsl:when test="$xml2rfc-footer"><xsl:value-of select="$xml2rfc-footer" /></xsl:when>
4642    <xsl:when test="$xml2rfc-private"/> <!-- private draft, footer not set -->
4643    <xsl:when test="/rfc/@category='bcp'">Best Current Practice</xsl:when>
4644    <xsl:when test="/rfc/@category='historic'">Historic</xsl:when>
4645    <xsl:when test="/rfc/@category='info' or not(/rfc/@category)">Informational</xsl:when>
4646    <xsl:when test="/rfc/@category='std'">Standards Track</xsl:when>
4647    <xsl:when test="/rfc/@category='exp'">Experimental</xsl:when>
4648    <xsl:otherwise>(category unknown)</xsl:otherwise>
4649  </xsl:choose>
4650</xsl:template>
4651
4652<xsl:template name="get-header-center">
4653  <xsl:choose>
4654    <xsl:when test="string-length(/rfc/front/title/@abbrev) &gt; 0">
4655      <xsl:value-of select="/rfc/front/title/@abbrev" />
4656    </xsl:when>
4657    <xsl:otherwise>
4658      <xsl:apply-templates select="/rfc/front/title" mode="get-text-content" />
4659    </xsl:otherwise>
4660  </xsl:choose>
4661</xsl:template>
4662
4663<xsl:template name="get-header-left">
4664  <xsl:choose>
4665    <xsl:when test="$xml2rfc-header"><xsl:value-of select="$xml2rfc-header" /></xsl:when>
4666    <xsl:when test="$xml2rfc-private"/> <!-- private draft, header not set -->
4667    <xsl:when test="/rfc/@ipr and not(/rfc/@number)">INTERNET DRAFT</xsl:when>
4668    <xsl:otherwise>RFC <xsl:value-of select="/rfc/@number"/></xsl:otherwise>
4669  </xsl:choose>
4670</xsl:template>
4671
4672<xsl:template name="get-generator">
4673  <xsl:variable name="gen">
4674    <xsl:text>http://greenbytes.de/tech/webdav/rfc2629.xslt, </xsl:text>
4675    <!-- when RCS keyword substitution in place, add version info -->
4676    <xsl:if test="contains('$Revision: 1.356 $',':')">
4677      <xsl:value-of select="concat('Revision ',normalize-space(translate(substring-after('$Revision: 1.356 $', 'Revision: '),'$','')),', ')" />
4678    </xsl:if>
4679    <xsl:if test="contains('$Date: 2008/02/03 13:29:11 $',':')">
4680      <xsl:value-of select="concat(normalize-space(translate(substring-after('$Date: 2008/02/03 13:29:11 $', 'Date: '),'$','')),', ')" />
4681    </xsl:if>
4682    <xsl:value-of select="concat('XSLT vendor: ',system-property('xsl:vendor'),' ',system-property('xsl:vendor-url'))" />
4683  </xsl:variable>
4684  <xsl:value-of select="$gen" />
4685</xsl:template>
4686
4687<xsl:template name="get-header-right">
4688  <xsl:value-of select="concat(/rfc/front/date/@month,' ',/rfc/front/date/@year)" />
4689</xsl:template>
4690
4691<xsl:template name="get-keywords">
4692  <xsl:variable name="keyw">
4693    <xsl:for-each select="/rfc/front/keyword">
4694      <xsl:value-of select="translate(.,',',' ')" />
4695      <xsl:if test="position()!=last()">, </xsl:if>
4696    </xsl:for-each>
4697  </xsl:variable>
4698  <xsl:value-of select="normalize-space($keyw)" />
4699</xsl:template>
4700
4701<!-- get language from context node. nearest ancestor or return the default of "en" -->
4702<xsl:template name="get-lang">
4703  <xsl:choose>
4704    <xsl:when test="ancestor-or-self::*[@xml:lang]"><xsl:value-of select="ancestor-or-self::*/@xml:lang" /></xsl:when>
4705    <xsl:otherwise>en</xsl:otherwise>
4706  </xsl:choose>
4707</xsl:template>
4708
4709<xsl:template name="get-section-number">
4710  <xsl:variable name="hasEdits" select="count(//ed:del|//ed:ins)!=0" />
4711  <xsl:variable name="anchor" select="@anchor"/>
4712  <xsl:choose>
4713    <xsl:when test="@x:fixed-section-number">
4714      <xsl:value-of select="@x:fixed-section-number"/>
4715    </xsl:when>
4716    <xsl:when test="$hasEdits or ancestor::*/@x:fixed-section-number">
4717      <xsl:call-template name="sectionnumberAndEdits" />
4718    </xsl:when>
4719    <xsl:otherwise>
4720      <xsl:choose>
4721        <xsl:when test="self::references">
4722          <xsl:choose>
4723            <xsl:when test="count(/*/back/references)=1">
4724              <xsl:call-template name="get-references-section-number"/>
4725            </xsl:when>
4726            <xsl:otherwise>
4727              <xsl:call-template name="get-references-section-number"/>.<xsl:number count="references"/>
4728            </xsl:otherwise>
4729          </xsl:choose>
4730        </xsl:when>
4731        <xsl:when test="self::reference">
4732          <xsl:for-each select="parent::references">
4733            <xsl:choose>
4734              <xsl:when test="count(/*/back/references)=1">
4735                <xsl:call-template name="get-references-section-number"/>
4736              </xsl:when>
4737              <xsl:otherwise>
4738                <xsl:call-template name="get-references-section-number"/>.<xsl:number count="references"/>
4739              </xsl:otherwise>
4740            </xsl:choose>
4741          </xsl:for-each>
4742        </xsl:when>
4743        <xsl:when test="ancestor::back"><xsl:number count="section|appendix" level="multiple" format="A.1.1.1.1.1.1.1" /></xsl:when>
4744        <xsl:when test="self::appendix"><xsl:number count="appendix" level="multiple" format="A.1.1.1.1.1.1.1" /></xsl:when>
4745        <xsl:otherwise><xsl:number count="section" level="multiple"/></xsl:otherwise>
4746      </xsl:choose>
4747    </xsl:otherwise>
4748  </xsl:choose>
4749</xsl:template>
4750
4751<!-- get the section number for the references section -->
4752<xsl:template name="get-references-section-number">
4753  <xsl:value-of select="count(/rfc/middle/section) + count(/rfc/middle/ed:replace/ed:ins/section) + 1"/>
4754</xsl:template>
4755
4756<xsl:template name="emit-section-number">
4757  <xsl:param name="no"/>
4758  <xsl:value-of select="$no"/><xsl:if test="not(contains($no,'.')) or $xml2rfc-ext-sec-no-trailing-dots='yes'">.</xsl:if>
4759</xsl:template>
4760
4761<xsl:template name="get-section-type">
4762  <xsl:param name="prec" />
4763  <xsl:choose>
4764    <xsl:when test="ancestor::back">Appendix</xsl:when>
4765    <xsl:otherwise>Section</xsl:otherwise>
4766  </xsl:choose>
4767</xsl:template>
4768
4769<xsl:template name="get-table-anchor">
4770  <xsl:value-of select="$anchor-prefix"/>
4771  <xsl:text>.table.</xsl:text>
4772  <xsl:choose>
4773    <xsl:when test="@title!='' or @anchor!=''">
4774      <xsl:number level="any" count="texttable[@title!='' or @anchor!='']" />
4775    </xsl:when>
4776    <xsl:otherwise>
4777      <xsl:text>u.</xsl:text>
4778      <xsl:number level="any" count="texttable[not(@title!='' or @anchor!='')]" />
4779    </xsl:otherwise>
4780  </xsl:choose>
4781</xsl:template>
4782
4783<xsl:template name="get-figure-anchor">
4784  <xsl:value-of select="$anchor-prefix"/>
4785  <xsl:text>.figure.</xsl:text>
4786  <xsl:choose>
4787    <xsl:when test="@title!='' or @anchor!=''">
4788      <xsl:number level="any" count="figure[@title!='' or @anchor!='']" />
4789    </xsl:when>
4790    <xsl:otherwise>
4791      <xsl:text>u.</xsl:text>
4792      <xsl:number level="any" count="figure[not(@title!='' or @anchor!='')]" />
4793    </xsl:otherwise>
4794  </xsl:choose>
4795</xsl:template>
4796
4797<!-- reformat contents of author/@initials -->
4798<xsl:template name="format-initials">
4799  <xsl:choose>
4800    <xsl:when test="string-length(@initials)=1">
4801      <xsl:value-of select="concat(@initials,'.')"/>
4802    </xsl:when>
4803    <xsl:otherwise>
4804      <xsl:value-of select="@initials"/>
4805    </xsl:otherwise>
4806  </xsl:choose>
4807</xsl:template>
4808
4809<xsl:template name="insert-conditional-pagebreak">
4810  <xsl:if test="$xml2rfc-compact!='yes'">
4811    <xsl:attribute name="class">np</xsl:attribute>
4812  </xsl:if>
4813</xsl:template>
4814
4815<xsl:template name="insert-conditional-hrule">
4816  <xsl:if test="$xml2rfc-compact!='yes'">
4817    <hr class="noprint" />
4818  </xsl:if>
4819</xsl:template>
4820
4821<!-- get text content from marked-up text -->
4822
4823<xsl:template match="text()" mode="get-text-content">
4824  <xsl:value-of select="."/>
4825</xsl:template>
4826
4827<xsl:template match="*" mode="get-text-content">
4828  <xsl:apply-templates mode="get-text-content"/>
4829</xsl:template>
4830
4831<xsl:template match="ed:del" mode="get-text-content">
4832</xsl:template>
4833
4834<!-- diag support -->
4835<xsl:template name="lineno">
4836  <xsl:if test="function-available('saxon:line-number')">
4837    <xsl:if test="saxon:line-number() > 0">
4838      <xsl:text> (at line </xsl:text>
4839      <xsl:value-of select="saxon:line-number()"/>
4840      <xsl:text>)</xsl:text>
4841    </xsl:if>
4842  </xsl:if>
4843</xsl:template>
4844
4845</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.