source: rfc2629xslt/rfc2629.xslt @ 120

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

Update to latest version of rfc2629.xslt.

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