source: rfc2629xslt/rfc2629.xslt @ 24

Last change on this file since 24 was 6, checked in by fielding@…, 15 years ago

XSLT stylesheet for enhanced RFC2629 xml2rfc output as HTML.
By Julian Reschke

Obtained from: wget -N http://www.greenbytes.de/tech/webdav/rfc2629xslt.zip

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