source: rfc2629xslt/rfc2629.xslt @ 230

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

Update to xml2rfc 1.33 (only affects Makefiles), update to latest version of rfc2629.xslt, change Makefile to allow Saxon to keep line numbers from source files.

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