source: rfc2629xslt/rfc2629.xslt @ 32

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

rfc2629.xslt fix: for cross-document references, distinguish between Section and Appendix

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