source: rfc2629xslt/rfc2629.xslt @ 260

Last change on this file since 260 was 246, checked in by julian.reschke@…, 13 years ago

Update to latest version of rfc2629xslt.

  • Property svn:eol-style set to native
File size: 184.4 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>
2631<xsl:if test="//x:sup">
2632sup {
2633  font-size: 60%;
2634}</xsl:if>
2635table {
2636  margin-left: 2em;
2637}<xsl:if test="//texttable">
2638table.tt {
2639  vertical-align: top;
2640}
2641table.full {
2642  border-style: outset;
2643  border-width: 1px;
2644}
2645table.headers {
2646  border-style: outset;
2647  border-width: 1px;
2648}
2649table.tt td {
2650  vertical-align: top;
2651}
2652table.full td {
2653  border-style: inset;
2654  border-width: 1px;
2655}
2656table.tt th {
2657  vertical-align: top;
2658}
2659table.full th {
2660  border-style: inset;
2661  border-width: 1px;
2662}
2663table.headers th {
2664  border-style: none none inset none;
2665  border-width: 1px;
2666}</xsl:if>
2667table.header {
2668  width: 95%;
2669  font-size: 10pt;
2670  color: white;
2671}
2672td.top {
2673  vertical-align: top;
2674}
2675td.topnowrap {
2676  vertical-align: top;
2677  white-space: nowrap;
2678}
2679td.header {
2680  background-color: gray;
2681  width: 50%;
2682}<xsl:if test="/rfc/@obsoletes | /rfc/@updates">
2683td.header a {
2684  color: white;
2685}</xsl:if>
2686td.reference {
2687  vertical-align: top;
2688  white-space: nowrap;
2689  padding-right: 1em;
2690}
2691thead {
2692  display:table-header-group;
2693}
2694ul.toc {
2695  list-style: none;
2696  margin-left: 1.5em;
2697  margin-right: 0em;
2698  padding-left: 0em;
2699}
2700li.tocline0 {
2701  line-height: 150%;
2702  font-weight: bold;
2703  font-size: 10pt;
2704  margin-left: 0em;
2705  margin-right: 0em;
2706}
2707li.tocline1 {
2708  line-height: normal;
2709  font-weight: normal;
2710  font-size: 9pt;
2711  margin-left: 0em;
2712  margin-right: 0em;
2713}
2714li.tocline2 {
2715  font-size: 0pt;
2716}
2717ul p {
2718  margin-left: 0em;
2719}
2720ul.ind {
2721  list-style: none;
2722  margin-left: 1.5em;
2723  margin-right: 0em;
2724  padding-left: 0em;
2725}
2726li.indline0 {
2727  font-weight: bold;
2728  line-height: 200%;
2729  margin-left: 0em;
2730  margin-right: 0em;
2731}
2732li.indline1 {
2733  font-weight: normal;
2734  line-height: 150%;
2735  margin-left: 0em;
2736  margin-right: 0em;
2737}
2738<xsl:if test="//x:bcp14">.bcp14 {
2739  font-style: normal;
2740  text-transform: lowercase;
2741  font-variant: small-caps;
2742}</xsl:if><xsl:if test="//x:blockquote">
2743blockquote > * .bcp14 {
2744  font-style: italic;
2745}</xsl:if>
2746.comment {
2747  background-color: yellow;
2748}<xsl:if test="$xml2rfc-editing='yes'">
2749.editingmark {
2750  background-color: khaki;
2751}</xsl:if>
2752.center {
2753  text-align: center;
2754}
2755.error {
2756  color: red;
2757  font-style: italic;
2758  font-weight: bold;
2759}
2760.figure {
2761  font-weight: bold;
2762  text-align: center;
2763  font-size: 9pt;
2764}
2765.filename {
2766  color: #333333;
2767  font-weight: bold;
2768  font-size: 12pt;
2769  line-height: 21pt;
2770  text-align: center;
2771}
2772.fn {
2773  font-weight: bold;
2774}
2775.hidden {
2776  display: none;
2777}
2778.left {
2779  text-align: left;
2780}
2781.right {
2782  text-align: right;
2783}
2784.title {
2785  color: #990000;
2786  font-size: 18pt;
2787  line-height: 18pt;
2788  font-weight: bold;
2789  text-align: center;
2790  margin-top: 36pt;
2791}
2792.vcardline {
2793  display: block;
2794}
2795.warning {
2796  font-size: 14pt;
2797  background-color: yellow;
2798}
2799<xsl:if test="//ed:del|//ed:replace|//ed:ins">del {
2800  color: red;
2801  text-decoration: line-through;
2802}
2803.del {
2804  color: red;
2805  text-decoration: line-through;
2806}
2807ins {
2808  color: green;
2809  text-decoration: underline;
2810}
2811.ins {
2812  color: green;
2813  text-decoration: underline;
2814}
2815div.issuepointer {
2816  float: left;
2817}</xsl:if><xsl:if test="//ed:issue">
2818table.openissue {
2819  background-color: khaki;
2820  border-width: thin;
2821  border-style: solid;
2822  border-color: black;
2823}
2824table.closedissue {
2825  background-color: white;
2826  border-width: thin;
2827  border-style: solid;
2828  border-color: gray;
2829  color: gray;
2830}
2831thead th {
2832  text-align: left;
2833}
2834.bg-issue {
2835  border: solid;
2836  border-width: 1px;
2837  font-size: 7pt;
2838}
2839.closed-issue {
2840  border: solid;
2841  border-width: thin;
2842  background-color: lime;
2843  font-size: smaller;
2844  font-weight: bold;
2845}
2846.open-issue {
2847  border: solid;
2848  border-width: thin;
2849  background-color: red;
2850  font-size: smaller;
2851  font-weight: bold;
2852}
2853.editor-issue {
2854  border: solid;
2855  border-width: thin;
2856  background-color: yellow;
2857  font-size: smaller;
2858  font-weight: bold;
2859}</xsl:if>
2860
2861@media print {
2862  .noprint {
2863    display: none;
2864  }
2865 
2866  a {
2867    color: black;
2868    text-decoration: none;
2869  }
2870
2871  table.header {
2872    width: 90%;
2873  }
2874
2875  td.header {
2876    width: 50%;
2877    color: black;
2878    background-color: white;
2879    vertical-align: top;
2880    font-size: 12pt;
2881  }
2882
2883  ul.toc a::after {
2884    content: leader('.') target-counter(attr(href), page);
2885  }
2886 
2887  a.iref {
2888    content: target-counter(attr(href), page);
2889  }
2890 
2891  .print2col {
2892    column-count: 2;
2893    -moz-column-count: 2;<!-- for Firefox -->
2894    column-fill: auto;<!-- for PrinceXML -->
2895  }
2896<xsl:if test="$xml2rfc-ext-justification='print'">
2897  dd {
2898    text-align: justify;
2899  }
2900  li {
2901    text-align: justify;
2902  }
2903  p {
2904    text-align: justify;
2905  }
2906</xsl:if>}
2907
2908@page {
2909  @top-left {
2910       content: "<xsl:call-template name="get-header-left"/>";
2911  }
2912  @top-right {
2913       content: "<xsl:call-template name="get-header-right"/>";
2914  }
2915  @top-center {
2916       content: "<xsl:call-template name="get-header-center"/>";
2917  }
2918  @bottom-left {
2919       content: "<xsl:call-template name="get-author-summary"/>";
2920  }
2921  @bottom-center {
2922       content: "<xsl:call-template name="get-category-long"/>";
2923  }
2924  @bottom-right {
2925       content: "[Page " counter(page) "]";
2926  }
2927}
2928
2929@page:first {
2930    @top-left {
2931      content: normal;
2932    }
2933    @top-right {
2934      content: normal;
2935    }
2936    @top-center {
2937      content: normal;
2938    }
2939}
2940</xsl:template>
2941
2942
2943<!-- generate the index section -->
2944
2945<xsl:template name="insertSingleIref">
2946  <xsl:choose>
2947    <xsl:when test="@ed:xref">
2948      <!-- special index generator mode -->
2949      <xsl:text>[</xsl:text>
2950      <a href="#{@ed:xref}"><xsl:value-of select="@ed:xref"/></a>
2951      <xsl:text>, </xsl:text>
2952      <a>
2953        <xsl:variable name="htmluri" select="//reference[@anchor=current()/@ed:xref]/format[@type='HTML']/@target"/>
2954        <xsl:if test="$htmluri">
2955          <xsl:attribute name="href"><xsl:value-of select="concat($htmluri,'#',@ed:frag)"/></xsl:attribute>
2956        </xsl:if>       
2957        <xsl:choose>
2958          <xsl:when test="@primary='true'"><b><xsl:value-of select="@ed:label" /></b></xsl:when>
2959          <xsl:otherwise><xsl:value-of select="@ed:label" /></xsl:otherwise>
2960        </xsl:choose>
2961      </a>
2962      <xsl:text>]</xsl:text>
2963      <xsl:if test="position()!=last()">, </xsl:if>
2964    </xsl:when>
2965    <xsl:otherwise>
2966      <xsl:variable name="_n">
2967        <xsl:call-template name="get-section-number" />
2968      </xsl:variable>
2969      <xsl:variable name="n">
2970        <xsl:choose>
2971          <xsl:when test="$_n!=''">
2972            <xsl:value-of select="$_n"/>
2973          </xsl:when>
2974          <xsl:otherwise>&#167;</xsl:otherwise>
2975        </xsl:choose>
2976      </xsl:variable>
2977      <xsl:variable name="backlink">
2978        <xsl:choose>
2979          <xsl:when test="self::xref">
2980            <xsl:variable name="target" select="@target"/>
2981            <xsl:text>#</xsl:text>
2982            <xsl:value-of select="$anchor-prefix"/>
2983            <xsl:text>.xref.</xsl:text>
2984            <xsl:value-of select="@target"/>.<xsl:number level="any" count="xref[@target=$target]"/>
2985          </xsl:when>
2986          <xsl:when test="self::iref">
2987            <xsl:text>#</xsl:text>
2988            <xsl:call-template name="compute-iref-anchor"/>
2989          </xsl:when>
2990          <xsl:when test="self::x:ref">
2991            <xsl:text>#</xsl:text>
2992            <xsl:call-template name="compute-extref-anchor"/>
2993          </xsl:when>
2994          <xsl:otherwise>
2995            <xsl:message>Unsupported element type for insertSingleIref</xsl:message>
2996          </xsl:otherwise>
2997        </xsl:choose>
2998      </xsl:variable>
2999      <a class="iref" href="{$backlink}">
3000        <xsl:call-template name="insertInsDelClass"/>
3001        <xsl:choose>
3002          <xsl:when test="@primary='true'"><b><xsl:value-of select="$n"/></b></xsl:when>
3003          <xsl:otherwise><xsl:value-of select="$n"/></xsl:otherwise>
3004        </xsl:choose>
3005      </a>
3006      <xsl:if test="position()!=last()">, </xsl:if>
3007    </xsl:otherwise>
3008  </xsl:choose>
3009</xsl:template>
3010
3011<xsl:template name="insertSingleXref">
3012  <xsl:variable name="_n">
3013    <xsl:call-template name="get-section-number" />
3014  </xsl:variable>
3015  <xsl:variable name="n">
3016    <xsl:choose>
3017      <xsl:when test="$_n!=''">
3018        <xsl:value-of select="$_n"/>
3019      </xsl:when>
3020      <xsl:otherwise>&#167;</xsl:otherwise>
3021    </xsl:choose>
3022  </xsl:variable>
3023  <xsl:choose>
3024    <xsl:when test="self::reference">
3025      <a class="iref" href="#{@anchor}">
3026        <xsl:call-template name="insertInsDelClass"/>
3027        <b><xsl:value-of select="$n"/></b>
3028      </a>
3029    </xsl:when>
3030    <xsl:otherwise>
3031      <xsl:variable name="target" select="@target"/>
3032      <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>
3033      <a class="iref" href="{$backlink}">
3034        <xsl:call-template name="insertInsDelClass"/>
3035        <xsl:value-of select="$n"/>
3036      </a>
3037    </xsl:otherwise>
3038  </xsl:choose>
3039  <xsl:if test="position()!=last()">, </xsl:if>
3040</xsl:template>
3041
3042<xsl:template name="insertIndex">
3043
3044  <xsl:call-template name="insert-conditional-hrule"/>
3045
3046  <h1 id="{$anchor-prefix}.index">
3047    <xsl:call-template name="insert-conditional-pagebreak"/>
3048    <a href="#{$anchor-prefix}.index">Index</a>
3049  </h1>
3050 
3051  <!-- generate navigation links to index subsections -->
3052  <p class="noprint">
3053    <xsl:variable name="irefs" select="//iref[generate-id(.) = generate-id(key('index-first-letter',translate(substring(@item,1,1),$lcase,$ucase)))]"/>
3054    <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)))]"/>
3055 
3056    <xsl:for-each select="$irefs | $xrefs">
3057   
3058      <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)" />
3059         
3060      <xsl:variable name="letter" select="translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase)"/>
3061
3062      <!-- character? -->
3063      <xsl:if test="translate($letter,concat($lcase,$ucase,'0123456789'),'')=''">
3064     
3065        <xsl:variable name="showit">
3066          <xsl:choose>
3067            <xsl:when test="$xml2rfc-ext-include-references-in-index!='yes'">
3068              <xsl:if test="$irefs[starts-with(translate(@item,$lcase,$ucase),$letter)]">
3069                <xsl:text>yes</xsl:text>
3070              </xsl:if>
3071            </xsl:when>
3072            <xsl:otherwise>
3073              <xsl:text>yes</xsl:text>
3074            </xsl:otherwise>
3075          </xsl:choose>
3076        </xsl:variable>
3077       
3078        <xsl:if test="$showit='yes'">
3079          <a href="#{$anchor-prefix}.index.{$letter}">
3080            <xsl:value-of select="$letter" />
3081          </a>
3082          <xsl:text> </xsl:text>
3083        </xsl:if>
3084     
3085      </xsl:if>
3086
3087    </xsl:for-each>
3088  </p>
3089
3090  <!-- for each index subsection -->
3091  <div class="print2col">
3092  <ul class="ind">
3093    <xsl:variable name="irefs2" select="//iref[generate-id(.) = generate-id(key('index-first-letter',translate(substring(@item,1,1),$lcase,$ucase)))]"/>
3094    <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)))]"/>
3095 
3096    <xsl:for-each select="$irefs2 | $xrefs2">
3097      <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)" />
3098      <xsl:variable name="letter" select="translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase)"/>
3099           
3100      <xsl:variable name="showit">
3101        <xsl:choose>
3102          <xsl:when test="$xml2rfc-ext-include-references-in-index!='yes'">
3103            <xsl:if test="$irefs2[starts-with(translate(@item,$lcase,$ucase),$letter)]">
3104              <xsl:text>yes</xsl:text>
3105            </xsl:if>
3106          </xsl:when>
3107          <xsl:otherwise>
3108            <xsl:text>yes</xsl:text>
3109          </xsl:otherwise>
3110        </xsl:choose>
3111      </xsl:variable>
3112
3113      <xsl:if test="$showit='yes'">
3114        <li class="indline0">
3115         
3116          <!-- make letters and digits stand out -->
3117          <xsl:choose>
3118            <xsl:when test="translate($letter,concat($lcase,$ucase,'0123456789'),'')=''">
3119              <a id="{$anchor-prefix}.index.{$letter}" href="#{$anchor-prefix}.index.{$letter}">
3120                <b><xsl:value-of select="$letter" /></b>
3121              </a>
3122            </xsl:when>
3123            <xsl:otherwise>
3124              <b><xsl:value-of select="$letter" /></b>
3125            </xsl:otherwise>
3126          </xsl:choose>
3127       
3128          <ul class="ind"> 
3129            <xsl:for-each select="key('index-first-letter',translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase))">
3130       
3131              <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)" />
3132             
3133                <xsl:choose>
3134                  <xsl:when test="self::reference">
3135                    <xsl:if test="$xml2rfc-ext-include-references-in-index='yes' and not(starts-with(@anchor,'deleted-'))">
3136                      <li class="indline1">
3137                        <em>
3138                          <xsl:value-of select="@anchor"/>
3139                        </em>
3140                        <xsl:text>&#160;&#160;</xsl:text>
3141                       
3142                        <xsl:variable name="rs" select="//xref[@target=current()/@anchor] | . | //reference[@anchor=concat('deleted-',current()/@anchor)]"/>
3143                        <xsl:for-each select="$rs">
3144                          <xsl:call-template name="insertSingleXref" />
3145                        </xsl:for-each>
3146
3147                        <xsl:variable name="rs2" select="$rs[@x:sec]"/>
3148
3149                        <xsl:if test="$rs2">
3150                          <ul class="ind"> 
3151                            <xsl:for-each select="$rs2">
3152                              <xsl:sort select="substring-before(concat(@x:sec,'.'),'.')" data-type="number"/>
3153                              <xsl:sort select="substring(@x:sec,1+string-length(substring-before(@x:sec,'.')))" data-type="number"/>
3154                              <xsl:if test="generate-id(.) = generate-id(key('index-xref-by-sec',concat(@target,'..',@x:sec)))">
3155                                <li class="indline1">
3156                                  <em>
3157                                    <xsl:text>Section </xsl:text>
3158                                    <xsl:value-of select="@x:sec"/>
3159                                  </em>
3160                                  <xsl:text>&#160;&#160;</xsl:text>
3161                                  <xsl:for-each select="key('index-xref-by-sec',concat(@target,'..',@x:sec))">
3162                                    <xsl:call-template name="insertSingleXref" />
3163                                  </xsl:for-each>
3164                                </li>
3165                              </xsl:if>
3166                            </xsl:for-each>
3167                          </ul>
3168                        </xsl:if>
3169
3170                        <xsl:if test="current()/x:source/@href">
3171                          <xsl:variable name="rs3" select="$rs[not(@x:sec) and @x:rel]"/>
3172                          <xsl:variable name="doc" select="document(current()/x:source/@href)"/>
3173                          <xsl:if test="$rs3">
3174                            <ul class="ind"> 
3175                              <xsl:for-each select="$rs3">
3176                                <xsl:sort select="count($doc//*[@anchor and following::*/@anchor=substring-after(current()/@x:rel,'#')])" order="ascending" data-type="number"/>
3177                                <xsl:if test="generate-id(.) = generate-id(key('index-xref-by-anchor',concat(@target,'..',@x:rel)))">
3178                                  <li class="indline1">
3179                                    <em>
3180                                      <xsl:text>Section </xsl:text>
3181                                      <xsl:for-each select="$doc//*[@anchor=substring-after(current()/@x:rel,'#')]">
3182                                        <xsl:call-template name="get-section-number"/>
3183                                      </xsl:for-each>
3184                                    </em>
3185                                    <xsl:text>&#160;&#160;</xsl:text>
3186                                    <xsl:for-each select="key('index-xref-by-anchor',concat(@target,'..',@x:rel))">
3187                                      <xsl:call-template name="insertSingleXref" />
3188                                    </xsl:for-each>
3189                                  </li>
3190                                </xsl:if>
3191                              </xsl:for-each>
3192                            </ul>
3193                          </xsl:if>
3194                        </xsl:if>
3195                      </li>
3196                    </xsl:if>
3197                  </xsl:when>
3198                  <xsl:otherwise>
3199                    <!-- regular iref -->
3200                    <xsl:if test="generate-id(.) = generate-id(key('index-item',concat(@item,@anchor)))">
3201                      <xsl:variable name="item" select="@item"/>
3202                      <xsl:variable name="in-artwork" select="count(//iref[@item=$item and @primary='true' and ancestor::artwork])!=0"/>
3203                         
3204                      <li class="indline1">
3205                        <xsl:choose>
3206                          <xsl:when test="$in-artwork">
3207                            <tt><xsl:value-of select="@item" /></tt>
3208                          </xsl:when>
3209                          <xsl:otherwise>
3210                            <xsl:value-of select="@item" />
3211                          </xsl:otherwise>
3212                        </xsl:choose>
3213                        <xsl:text>&#160;&#160;</xsl:text>
3214                       
3215                        <xsl:variable name="irefs3" select="key('index-item',@item)[not(@subitem) or @subitem='']"/>
3216                        <xsl:variable name="xrefs3" select="//xref[@target=$irefs3[@x:for-anchor='']/../@anchor or @target=$irefs3/@x:for-anchor]"/>
3217                        <xsl:variable name="extrefs3" select="//x:ref[.=$irefs3[@x:for-anchor='']/../@anchor or .=$irefs3/@x:for-anchor]"/>
3218
3219                        <xsl:for-each select="$irefs3|$xrefs3|$extrefs3">
3220                          <!-- <xsl:sort select="translate(@item,$lcase,$ucase)" />  -->
3221                          <xsl:call-template name="insertSingleIref" />
3222                        </xsl:for-each>
3223         
3224                        <xsl:variable name="s2" select="key('index-item',@item)[@subitem and @subitem!='']"/>
3225                        <xsl:if test="$s2">
3226                          <ul class="ind"> 
3227                            <xsl:for-each select="$s2">
3228                              <xsl:sort select="translate(@subitem,$lcase,$ucase)" />
3229                             
3230                              <xsl:if test="generate-id(.) = generate-id(key('index-item-subitem',concat(@item,'..',@subitem)))">
3231                 
3232                                <xsl:variable name="itemsubitem" select="concat(@item,'..',@subitem)"/>
3233                                <xsl:variable name="in-artwork2" select="count(//iref[concat(@item,'..',@subitem)=$itemsubitem and @primary='true' and ancestor::artwork])!=0"/>
3234                 
3235                                <li class="indline1">
3236             
3237                                  <xsl:choose>
3238                                    <xsl:when test="$in-artwork2">
3239                                      <tt><xsl:value-of select="@subitem" /></tt>
3240                                    </xsl:when>
3241                                    <xsl:otherwise>
3242                                      <xsl:value-of select="@subitem" />
3243                                    </xsl:otherwise>
3244                                  </xsl:choose>
3245                                  <xsl:text>&#160;&#160;</xsl:text>
3246                                   
3247                                  <xsl:variable name="irefs4" select="key('index-item-subitem',concat(@item,'..',@subitem))"/>
3248                                  <xsl:variable name="xrefs4" select="//xref[@target=$irefs4[@x:for-anchor='']/../@anchor or @target=$irefs4/@x:for-anchor]"/>
3249                                  <xsl:variable name="extrefs4" select="//x:ref[.=$irefs4[@x:for-anchor='']/../@anchor or .=$irefs4/@x:for-anchor]"/>
3250
3251                                  <xsl:for-each select="$irefs4|$xrefs4|$extrefs4">
3252                                    <!--<xsl:sort select="translate(@item,$lcase,$ucase)" />-->                   
3253                                    <xsl:call-template name="insertSingleIref" />
3254                                  </xsl:for-each>
3255               
3256                                </li>
3257                              </xsl:if>
3258                            </xsl:for-each>
3259                          </ul>
3260                        </xsl:if>
3261                      </li>
3262                    </xsl:if>
3263                  </xsl:otherwise>
3264                </xsl:choose>
3265             
3266                     
3267            </xsl:for-each>           
3268          </ul>
3269        </li>
3270      </xsl:if>
3271     
3272    </xsl:for-each>
3273  </ul>
3274  </div>
3275 
3276</xsl:template>
3277
3278
3279
3280
3281<xsl:template name="insertPreamble" myns:namespaceless-elements="xml2rfc">
3282
3283  <section title="Status of this Memo" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.status">
3284
3285  <xsl:choose>
3286    <xsl:when test="/rfc/@ipr and not(/rfc/@number)">
3287      <t>
3288        <xsl:choose>
3289         
3290          <!-- RFC2026 -->
3291          <xsl:when test="/rfc/@ipr = 'full2026'">
3292            This document is an Internet-Draft and is
3293            in full conformance with all provisions of Section 10 of RFC2026.   
3294          </xsl:when>
3295          <xsl:when test="/rfc/@ipr = 'noDerivativeWorks2026'">
3296            This document is an Internet-Draft and is
3297            in full conformance with all provisions of Section 10 of RFC2026
3298            except that the right to produce derivative works is not granted.   
3299          </xsl:when>
3300          <xsl:when test="/rfc/@ipr = 'noDerivativeWorksNow'">
3301            This document is an Internet-Draft and is
3302            in full conformance with all provisions of Section 10 of RFC2026
3303            except that the right to produce derivative works is not granted.
3304            (If this document becomes part of an IETF working group activity,
3305            then it will be brought into full compliance with Section 10 of RFC2026.) 
3306          </xsl:when>
3307          <xsl:when test="/rfc/@ipr = 'none'">
3308            This document is an Internet-Draft and is
3309            NOT offered in accordance with Section 10 of RFC2026,
3310            and the author does not provide the IETF with any rights other
3311            than to publish as an Internet-Draft.
3312          </xsl:when>
3313         
3314          <!-- RFC3667 -->
3315          <xsl:when test="/rfc/@ipr = 'full3667'">
3316            This document is an Internet-Draft and is subject to all provisions
3317            of section 3 of RFC 3667.  By submitting this Internet-Draft, each
3318            author represents that any applicable patent or other IPR claims of
3319            which he or she is aware have been or will be disclosed, and any of
3320            which he or she become aware will be disclosed, in accordance with
3321            RFC 3668.
3322          </xsl:when>
3323          <xsl:when test="/rfc/@ipr = 'noModification3667'">
3324            This document is an Internet-Draft and is subject to all provisions
3325            of section 3 of RFC 3667.  By submitting this Internet-Draft, each
3326            author represents that any applicable patent or other IPR claims of
3327            which he or she is aware have been or will be disclosed, and any of
3328            which he or she become aware will be disclosed, in accordance with
3329            RFC 3668.  This document may not be modified, and derivative works of
3330            it may not be created, except to publish it as an RFC and to
3331            translate it into languages other than English<xsl:if test="/rfc/@iprExtract">,
3332            other than to extract <xref target="{/rfc/@iprExtract}"/> as-is
3333            for separate use.</xsl:if>.
3334          </xsl:when>
3335          <xsl:when test="/rfc/@ipr = 'noDerivatives3667'">
3336            This document is an Internet-Draft and is subject to all provisions
3337            of section 3 of RFC 3667 except for the right to produce derivative
3338            works.  By submitting this Internet-Draft, each author represents
3339            that any applicable patent or other IPR claims of which he or she
3340            is aware have been or will be disclosed, and any of which he or she
3341            become aware will be disclosed, in accordance with RFC 3668.  This
3342            document may not be modified, and derivative works of it may
3343            not be created<xsl:if test="/rfc/@iprExtract">, other than to extract
3344            <xref target="{/rfc/@iprExtract}"/> as-is for separate use.</xsl:if>.
3345          </xsl:when>
3346         
3347          <!-- RFC3978 -->
3348          <xsl:when test="/rfc/@ipr = 'full3978'">
3349            By submitting this Internet-Draft, each
3350            author represents that any applicable patent or other IPR claims of
3351            which he or she is aware have been or will be disclosed, and any of
3352            which he or she becomes aware will be disclosed, in accordance with
3353            Section 6 of BCP 79.
3354          </xsl:when>
3355          <xsl:when test="/rfc/@ipr = 'noModification3978'">
3356            By submitting this Internet-Draft, each
3357            author represents that any applicable patent or other IPR claims of
3358            which he or she is aware have been or will be disclosed, and any of
3359            which he or she becomes aware will be disclosed, in accordance with
3360            Section 6 of BCP 79.  This document may not be modified, and derivative works of
3361            it may not be created, except to publish it as an RFC and to
3362            translate it into languages other than English<xsl:if test="/rfc/@iprExtract">,
3363            other than to extract <xref target="{/rfc/@iprExtract}"/> as-is
3364            for separate use.</xsl:if>.
3365          </xsl:when>
3366          <xsl:when test="/rfc/@ipr = 'noDerivatives3978'">
3367            By submitting this Internet-Draft, each author represents
3368            that any applicable patent or other IPR claims of which he or she
3369            is aware have been or will be disclosed, and any of which he or she
3370            becomes aware will be disclosed, in accordance with Section 6 of BCP 79.  This
3371            document may not be modified, and derivative works of it may
3372            not be created<xsl:if test="/rfc/@iprExtract">, other than to extract
3373            <xref target="{/rfc/@iprExtract}"/> as-is for separate use.</xsl:if>.
3374          </xsl:when>
3375
3376          <xsl:otherwise>CONFORMANCE UNDEFINED.</xsl:otherwise>
3377        </xsl:choose>
3378      </t>
3379      <t>
3380        Internet-Drafts are working documents of the Internet Engineering
3381        Task Force (IETF), its areas, and its working groups.
3382        Note that other groups may also distribute working documents as
3383        Internet-Drafts.
3384      </t>
3385      <t>
3386        Internet-Drafts are draft documents valid for a maximum of six months
3387        and may be updated, replaced, or obsoleted by other documents at any time.
3388        It is inappropriate to use Internet-Drafts as reference material or to cite
3389        them other than as &#8220;work in progress&#8221;.
3390      </t>
3391      <t>
3392        The list of current Internet-Drafts can be accessed at
3393        <eref target='http://www.ietf.org/ietf/1id-abstracts.txt'/>.
3394      </t>
3395      <t>
3396        The list of Internet-Draft Shadow Directories can be accessed at
3397        <eref target='http://www.ietf.org/shadow.html'/>.
3398      </t>
3399      <t>
3400        This Internet-Draft will expire in <xsl:call-template name="expirydate" />.
3401      </t>
3402    </xsl:when>
3403
3404    <xsl:when test="/rfc/@category='bcp'">
3405      <t>
3406        This document specifies an Internet Best Current Practices for the Internet
3407        Community, and requests discussion and suggestions for improvements.
3408        Distribution of this memo is unlimited.
3409      </t>
3410    </xsl:when>
3411    <xsl:when test="/rfc/@category='exp'">
3412      <t>
3413        This memo defines an Experimental Protocol for the Internet community.
3414        It does not specify an Internet standard of any kind.
3415        Discussion and suggestions for improvement are requested.
3416        Distribution of this memo is unlimited.
3417      </t>
3418    </xsl:when>
3419    <xsl:when test="/rfc/@category='historic'">
3420      <t>
3421        This memo describes a historic protocol for the Internet community.
3422        It does not specify an Internet standard of any kind.
3423        Distribution of this memo is unlimited.
3424      </t>
3425    </xsl:when>
3426    <xsl:when test="/rfc/@category='info' or not(/rfc/@category)">
3427      <t>
3428        This memo provides information for the Internet community.
3429        It does not specify an Internet standard of any kind.
3430        Distribution of this memo is unlimited.
3431      </t>
3432    </xsl:when>
3433    <xsl:when test="/rfc/@category='std'">
3434      <t>
3435        This document specifies an Internet standards track protocol for the Internet
3436        community, and requests discussion and suggestions for improvements.
3437        Please refer to the current edition of the &#8220;Internet Official Protocol
3438        Standards&#8221; (STD 1) for the standardization state and status of this
3439        protocol. Distribution of this memo is unlimited.
3440      </t>
3441    </xsl:when>
3442    <xsl:otherwise>
3443      <t>UNSUPPORTED CATEGORY.</t>
3444    </xsl:otherwise>
3445  </xsl:choose>
3446 
3447  </section>
3448
3449  <xsl:choose>
3450    <xsl:when test="$ipr-2007-08"/>
3451    <xsl:when test="$ipr-rfc4748">
3452      <section title="Copyright Notice" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.copyrightnotice">
3453        <t>
3454          Copyright &#169; The IETF Trust (<xsl:value-of select="$xml2rfc-ext-pub-year" />).  All Rights Reserved.
3455        </t>
3456      </section>
3457    </xsl:when>
3458    <xsl:otherwise>
3459      <section title="Copyright Notice" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.copyrightnotice">
3460        <t>
3461          Copyright &#169; The Internet Society (<xsl:value-of select="$xml2rfc-ext-pub-year" />).  All Rights Reserved.
3462      </t>
3463      </section>
3464    </xsl:otherwise>
3465  </xsl:choose>
3466 
3467</xsl:template>
3468
3469<!-- TOC generation -->
3470
3471<xsl:template match="/" mode="toc">
3472  <hr class="noprint"/>
3473
3474  <h1 class="np" id="{$anchor-prefix}.toc"> <!-- this pagebreak occurs always -->
3475    <a href="#{$anchor-prefix}.toc">Table of Contents</a>
3476  </h1>
3477
3478  <ul class="toc">
3479    <xsl:apply-templates mode="toc" />
3480  </ul>
3481</xsl:template>
3482
3483<xsl:template name="insert-toc-line">
3484  <xsl:param name="number" />
3485  <xsl:param name="target" />
3486  <xsl:param name="title" />
3487  <xsl:param name="tocparam" />
3488  <xsl:param name="oldtitle" />
3489  <xsl:param name="waschanged" />
3490
3491  <!-- handle tocdepth parameter -->
3492  <xsl:choose>
3493    <xsl:when test="($tocparam='' or $tocparam='default') and string-length(translate($number,'.ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890&#167;','.')) &gt;= $parsedTocDepth">
3494      <!-- dropped entry because excluded -->
3495      <xsl:attribute name="class">tocline2</xsl:attribute>
3496    </xsl:when>
3497    <xsl:when test="$tocparam='exclude'">
3498      <!-- dropped entry because excluded -->
3499      <xsl:attribute name="class">tocline2</xsl:attribute>
3500    </xsl:when>
3501    <xsl:otherwise>
3502      <xsl:choose>
3503        <xsl:when test="starts-with($number,'del-')">
3504          <del>
3505            <xsl:value-of select="$number" />
3506            <a href="#{$target}"><xsl:value-of select="$title"/></a>
3507          </del>
3508        </xsl:when>
3509        <xsl:otherwise>
3510          <xsl:choose>
3511            <xsl:when test="not(contains($number,'.'))">
3512              <xsl:attribute name="class">tocline0</xsl:attribute>
3513            </xsl:when>
3514            <xsl:otherwise>
3515              <xsl:attribute name="class">tocline1</xsl:attribute>
3516            </xsl:otherwise>
3517          </xsl:choose>
3518          <xsl:if test="$number != ''">
3519            <xsl:call-template name="emit-section-number">
3520              <xsl:with-param name="no" select="$number"/>
3521            </xsl:call-template>
3522            <xsl:text>&#160;&#160;&#160;</xsl:text>
3523          </xsl:if>
3524          <a href="#{$target}">
3525            <xsl:choose>
3526              <xsl:when test="$waschanged!=''">
3527                <ins><xsl:value-of select="$title"/></ins>
3528                <del><xsl:value-of select="$oldtitle"/></del>
3529              </xsl:when>
3530              <xsl:otherwise>
3531                <xsl:value-of select="$title"/>
3532              </xsl:otherwise>
3533            </xsl:choose>
3534          </a>
3535        </xsl:otherwise>
3536      </xsl:choose>
3537    </xsl:otherwise>
3538  </xsl:choose>
3539</xsl:template>
3540
3541<xsl:template match="back" mode="toc">
3542
3543  <!-- <xsl:apply-templates select="references" mode="toc" /> -->
3544
3545  <xsl:if test="//cref and $xml2rfc-comments='yes' and $xml2rfc-inline!='yes'">
3546    <li>
3547      <xsl:call-template name="insert-toc-line">
3548        <xsl:with-param name="target" select="concat($anchor-prefix,'.comments')"/>
3549        <xsl:with-param name="title" select="'Editorial Comments'"/>
3550      </xsl:call-template>
3551    </li>
3552  </xsl:if>
3553
3554  <xsl:if test="$xml2rfc-ext-authors-section!='end'">
3555    <xsl:apply-templates select="/rfc/front" mode="toc" />
3556  </xsl:if>
3557  <xsl:apply-templates select="*[not(self::references)]" mode="toc" />
3558
3559  <xsl:if test="$xml2rfc-ext-authors-section='end'">
3560    <xsl:apply-templates select="/rfc/front" mode="toc" />
3561  </xsl:if>
3562
3563  <!-- copyright statements -->
3564  <xsl:if test="not($xml2rfc-private)">
3565    <li>
3566      <xsl:call-template name="insert-toc-line">
3567        <xsl:with-param name="target" select="concat($anchor-prefix,'.ipr')"/>
3568        <xsl:with-param name="title" select="'Intellectual Property and Copyright Statements'"/>
3569      </xsl:call-template>
3570    </li>
3571  </xsl:if>
3572 
3573  <!-- insert the index if index entries exist -->
3574  <xsl:if test="//iref">
3575    <li>
3576      <xsl:call-template name="insert-toc-line">
3577        <xsl:with-param name="target" select="concat($anchor-prefix,'.index')"/>
3578        <xsl:with-param name="title" select="'Index'"/>
3579      </xsl:call-template>
3580    </li>
3581  </xsl:if>
3582
3583</xsl:template>
3584
3585<xsl:template match="front" mode="toc">
3586 
3587  <li>
3588    <xsl:variable name="authors-title">
3589      <xsl:call-template name="get-authors-section-title"/>
3590    </xsl:variable>
3591    <xsl:variable name="authors-number">
3592      <xsl:call-template name="get-authors-section-number"/>
3593    </xsl:variable>
3594    <xsl:call-template name="insert-toc-line">
3595      <xsl:with-param name="target" select="concat($anchor-prefix,'.authors')"/>
3596      <xsl:with-param name="title" select="$authors-title"/>
3597      <xsl:with-param name="number" select="$authors-number"/>
3598    </xsl:call-template>
3599  </li>
3600
3601</xsl:template>
3602
3603<xsl:template name="references-toc">
3604
3605  <!-- distinguish two cases: (a) single references element (process
3606  as toplevel section; (b) multiple references sections (add one toplevel
3607  container with subsection) -->
3608
3609  <xsl:variable name="refsecs" select="/rfc/back/references|/rfc/back/ed:replace/ed:ins/references"/>
3610   
3611  <xsl:choose>
3612    <xsl:when test="count($refsecs) = 0">
3613      <!-- nop -->
3614    </xsl:when>
3615    <xsl:when test="count($refsecs) = 1">
3616      <xsl:for-each select="$refsecs">
3617        <xsl:variable name="title">
3618          <xsl:choose>
3619            <xsl:when test="@title!=''"><xsl:value-of select="@title" /></xsl:when>
3620            <xsl:otherwise>References</xsl:otherwise>
3621          </xsl:choose>
3622        </xsl:variable>
3623     
3624        <li>
3625          <xsl:call-template name="insert-toc-line">
3626            <xsl:with-param name="number">
3627              <xsl:call-template name="get-references-section-number"/>
3628            </xsl:with-param>
3629            <xsl:with-param name="target" select="concat($anchor-prefix,'.references')"/>
3630            <xsl:with-param name="title" select="$title"/>
3631          </xsl:call-template>
3632        </li>
3633      </xsl:for-each>
3634    </xsl:when>
3635    <xsl:otherwise>
3636      <li>
3637        <!-- insert pseudo container -->   
3638        <xsl:call-template name="insert-toc-line">
3639          <xsl:with-param name="number">
3640            <xsl:call-template name="get-references-section-number"/>
3641          </xsl:with-param>
3642          <xsl:with-param name="target" select="concat($anchor-prefix,'.references')"/>
3643          <xsl:with-param name="title" select="'References'"/>
3644        </xsl:call-template>
3645 
3646        <ul class="toc">
3647          <!-- ...with subsections... -->   
3648          <xsl:for-each select="$refsecs">
3649            <xsl:variable name="title">
3650              <xsl:choose>
3651                <xsl:when test="@title!=''"><xsl:value-of select="@title" /></xsl:when>
3652                <xsl:otherwise>References</xsl:otherwise>
3653              </xsl:choose>
3654            </xsl:variable>
3655         
3656            <xsl:variable name="sectionNumber">
3657              <xsl:call-template name="get-section-number" />
3658            </xsl:variable>
3659   
3660            <xsl:variable name="num">
3661              <xsl:number level="any"/>
3662            </xsl:variable>
3663   
3664            <li>
3665              <xsl:call-template name="insert-toc-line">
3666                <xsl:with-param name="number" select="$sectionNumber"/>
3667                <xsl:with-param name="target" select="concat($anchor-prefix,'.references','.',$num)"/>
3668                <xsl:with-param name="title" select="$title"/>
3669              </xsl:call-template>
3670            </li>
3671          </xsl:for-each>
3672        </ul>
3673      </li>
3674    </xsl:otherwise>
3675  </xsl:choose>
3676</xsl:template>
3677
3678<xsl:template match="section|appendix" mode="toc">
3679  <xsl:variable name="sectionNumber">
3680    <xsl:call-template name="get-section-number" />
3681  </xsl:variable>
3682
3683  <xsl:variable name="target">
3684    <xsl:choose>
3685      <xsl:when test="@anchor"><xsl:value-of select="@anchor" /></xsl:when>
3686       <xsl:otherwise><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$sectionNumber" /></xsl:otherwise>
3687    </xsl:choose>
3688  </xsl:variable>
3689
3690  <!-- obtain content, just to check whether we need to recurse at all -->
3691  <xsl:variable name="content">
3692    <li>
3693      <xsl:call-template name="insert-toc-line">
3694        <xsl:with-param name="number" select="$sectionNumber"/>
3695        <xsl:with-param name="target" select="$target"/>
3696        <xsl:with-param name="title" select="@title"/>
3697        <xsl:with-param name="tocparam" select="@toc"/>
3698        <xsl:with-param name="oldtitle" select="@ed:old-title"/>
3699        <xsl:with-param name="waschanged" select="@ed:resolves"/>
3700      </xsl:call-template>
3701   
3702      <ul class="toc">
3703        <xsl:apply-templates mode="toc" />
3704      </ul>
3705    </li>
3706  </xsl:variable>
3707 
3708  <xsl:if test="$content!=''">
3709    <li>
3710      <xsl:call-template name="insert-toc-line">
3711        <xsl:with-param name="number" select="$sectionNumber"/>
3712        <xsl:with-param name="target" select="$target"/>
3713        <xsl:with-param name="title" select="@title"/>
3714        <xsl:with-param name="tocparam" select="@toc"/>
3715        <xsl:with-param name="oldtitle" select="@ed:old-title"/>
3716        <xsl:with-param name="waschanged" select="@ed:resolves"/>
3717      </xsl:call-template>
3718   
3719      <!-- obtain nested content, just to check whether we need to recurse at all -->
3720      <xsl:variable name="nested-content">
3721        <ul class="toc">
3722          <xsl:apply-templates mode="toc" />
3723        </ul>
3724      </xsl:variable>
3725     
3726      <!-- only recurse if we need to (do not produce useless list container) -->     
3727      <xsl:if test="$nested-content!=''">
3728        <ul class="toc">
3729          <xsl:apply-templates mode="toc" />
3730        </ul>
3731      </xsl:if>
3732    </li>
3733  </xsl:if>
3734</xsl:template>
3735
3736<xsl:template match="middle" mode="toc">
3737  <xsl:apply-templates mode="toc" />
3738  <xsl:call-template name="references-toc" />
3739</xsl:template>
3740
3741<xsl:template match="rfc" mode="toc">
3742  <xsl:apply-templates select="middle|back" mode="toc" />
3743</xsl:template>
3744
3745<xsl:template match="ed:del|ed:ins|ed:replace" mode="toc">
3746  <xsl:apply-templates mode="toc" />
3747</xsl:template>
3748
3749<xsl:template match="*|text()" mode="toc" />
3750
3751
3752<xsl:template name="insertTocAppendix">
3753 
3754  <xsl:if test="//figure[@title!='' or @anchor!='']">
3755    <ul class="toc">
3756      <xsl:for-each select="//figure[@title!='' or @anchor!='']">
3757        <xsl:variable name="title">Figure <xsl:value-of select="position()"/><xsl:if test="@title">: <xsl:value-of select="@title"/></xsl:if>
3758        </xsl:variable>
3759        <li>
3760          <xsl:call-template name="insert-toc-line">
3761            <xsl:with-param name="target" select="concat($anchor-prefix,'.figure.',position())" />
3762            <xsl:with-param name="title" select="$title" />
3763          </xsl:call-template>
3764        </li>
3765      </xsl:for-each>
3766    </ul>
3767  </xsl:if>
3768 
3769  <!-- experimental -->
3770  <xsl:if test="//ed:issue">
3771    <xsl:call-template name="insertIssuesList" />
3772  </xsl:if>
3773
3774</xsl:template>
3775
3776<xsl:template name="referencename">
3777  <xsl:param name="node" />
3778 
3779  <xsl:for-each select="$node">
3780    <xsl:choose>
3781      <xsl:when test="$xml2rfc-symrefs!='no' and ancestor::ed:del">
3782        <xsl:variable name="unprefixed" select="substring-after(@anchor,'deleted-')"/>
3783        <xsl:choose>
3784          <xsl:when test="$unprefixed!=''">
3785            <xsl:value-of select="concat('[',$unprefixed,']')"/>
3786          </xsl:when>
3787          <xsl:otherwise>
3788            <xsl:if test="count(//reference[@anchor=current()/@anchor])!=1">
3789              <xsl:message>Deleted duplicate anchors should have the prefix "deleted-": <xsl:value-of select="@anchor"/></xsl:message>
3790            </xsl:if>
3791            <xsl:value-of select="concat('[',@anchor,']')"/>
3792          </xsl:otherwise>
3793        </xsl:choose>
3794      </xsl:when>
3795      <xsl:when test="$xml2rfc-symrefs!='no'">[<xsl:value-of select="@anchor" />]</xsl:when>
3796      <xsl:when test="ancestor::ed:del">
3797        <xsl:text>[del]</xsl:text>
3798      </xsl:when>
3799      <xsl:otherwise>[<xsl:number level="any" count="reference[not(ancestor::ed:del)]"/>]</xsl:otherwise>
3800    </xsl:choose>
3801  </xsl:for-each> 
3802</xsl:template>
3803
3804
3805
3806<xsl:template name="replace-substring">
3807
3808  <xsl:param name="string" />
3809  <xsl:param name="replace" />
3810  <xsl:param name="by" />
3811
3812  <xsl:choose>
3813    <xsl:when test="contains($string,$replace)">
3814      <xsl:value-of select="concat(substring-before($string, $replace),$by)" />
3815      <xsl:call-template name="replace-substring">
3816        <xsl:with-param name="string" select="substring-after($string,$replace)" />
3817        <xsl:with-param name="replace" select="$replace" />
3818        <xsl:with-param name="by" select="$by" />
3819      </xsl:call-template>
3820    </xsl:when>
3821    <xsl:otherwise><xsl:value-of select="$string" /></xsl:otherwise>
3822  </xsl:choose>
3823
3824</xsl:template>
3825
3826
3827<xsl:template name="rfclist">
3828  <xsl:param name="list" />
3829  <xsl:choose>
3830    <xsl:when test="contains($list,',')">
3831      <xsl:variable name="rfcNo" select="substring-before($list,',')" />
3832      <xsl:if test="count(//references//reference/seriesInfo[@name='RFC' and @value=$rfcNo])=0">
3833        <xsl:call-template name="warning">
3834          <xsl:with-param name="inline" select="'no'"/>
3835          <xsl:with-param name="msg" select="concat('front matter mentions RFC ',$rfcNo,' for which there is no reference element')"/>
3836        </xsl:call-template>
3837      </xsl:if>
3838      <a href="{concat($rfcUrlPrefix,$rfcNo,$rfcUrlPostfix)}"><xsl:value-of select="$rfcNo" /></a>,
3839      <xsl:call-template name="rfclist">
3840        <xsl:with-param name="list" select="normalize-space(substring-after($list,','))" />
3841      </xsl:call-template>
3842    </xsl:when>
3843    <xsl:otherwise>
3844      <xsl:variable name="rfcNo" select="$list" />
3845      <xsl:if test="count(//references//reference/seriesInfo[@name='RFC' and @value=$rfcNo])=0">
3846        <xsl:call-template name="warning">
3847          <xsl:with-param name="inline" select="'no'"/>
3848          <xsl:with-param name="msg" select="concat('front matter mentions RFC',$rfcNo,' for which there is no reference element')"/>
3849        </xsl:call-template>
3850      </xsl:if>
3851      <a href="{concat($rfcUrlPrefix,$rfcNo,$rfcUrlPostfix)}"><xsl:value-of select="$rfcNo" /></a>
3852    </xsl:otherwise>
3853  </xsl:choose>
3854</xsl:template>
3855
3856<xsl:template name="rfclist-for-dcmeta">
3857  <xsl:param name="list" />
3858  <xsl:choose>
3859    <xsl:when test="contains($list,',')">
3860      <xsl:variable name="rfcNo" select="substring-before($list,',')" />
3861      <meta name="DC.Relation.Replaces" content="urn:ietf:rfc:{$rfcNo}" />
3862      <xsl:call-template name="rfclist-for-dcmeta">
3863        <xsl:with-param name="list" select="normalize-space(substring-after($list,','))" />
3864      </xsl:call-template>
3865    </xsl:when>
3866    <xsl:otherwise>
3867      <xsl:variable name="rfcNo" select="$list" />
3868      <meta name="DC.Relation.Replaces" content="urn:ietf:rfc:{$rfcNo}" />
3869    </xsl:otherwise>
3870  </xsl:choose>
3871</xsl:template>
3872
3873<xsl:template name="get-paragraph-number">
3874  <!-- get section number of ancestor section element, then add t or figure number -->
3875  <xsl:if test="ancestor::section and not(ancestor::section[@myns:unnumbered='unnumbered']) and not(ancestor::x:blockquote)">
3876    <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" />
3877  </xsl:if>
3878</xsl:template>
3879
3880<xsl:template name="editingMark">
3881  <xsl:if test="$xml2rfc-editing='yes' and ancestor::rfc">
3882    <sup class="editingmark"><span><xsl:number level="any" count="postamble|preamble|t"/></span>&#0160;</sup>
3883  </xsl:if>
3884</xsl:template>
3885
3886<!-- internal ref support -->
3887<xsl:template match="x:ref">
3888  <xsl:variable name="val" select="."/>
3889  <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)]"/>
3890  <xsl:variable name="irefs" select="//iref[@x:for-anchor=$val]"/>
3891  <xsl:choose>
3892    <xsl:when test="$target">
3893      <a href="#{$target/@anchor}" class="smpl">
3894        <!-- to be indexed? -->
3895        <xsl:if test="$irefs">
3896          <xsl:attribute name="id"><xsl:call-template name="compute-extref-anchor"/></xsl:attribute>
3897        </xsl:if>
3898        <xsl:value-of select="."/>
3899      </a>
3900    </xsl:when>
3901    <xsl:otherwise>
3902      <xsl:message>WARNING: internal link target for '<xsl:value-of select="."/>' does not exist.<xsl:call-template name="lineno"/></xsl:message>
3903      <xsl:value-of select="."/>
3904    </xsl:otherwise>
3905  </xsl:choose>
3906</xsl:template>
3907
3908<!-- Nothing to do here -->
3909<xsl:template match="x:anchor-alias" />
3910
3911<!-- Quotes -->
3912<xsl:template match="x:q">
3913  <q>
3914    <xsl:copy-of select="@cite"/>
3915    <xsl:apply-templates/>
3916  </q>
3917</xsl:template>
3918
3919<xsl:template match="x:bcp14">
3920  <!-- check valid BCP14 keywords, then emphasize them -->
3921  <xsl:variable name="c" select="normalize-space(.)"/>
3922  <xsl:choose>
3923    <xsl:when test="$c='MUST' or $c='REQUIRED' or $c='SHALL'">
3924      <em class="bcp14"><xsl:value-of select="."/></em>
3925    </xsl:when>
3926    <xsl:when test="$c='MUST NOT' or $c='SHALL NOT'">
3927      <em class="bcp14"><xsl:value-of select="."/></em>
3928    </xsl:when>
3929    <xsl:when test="$c='SHOULD' or $c='RECOMMENDED'">
3930      <em class="bcp14"><xsl:value-of select="."/></em>
3931    </xsl:when>
3932    <xsl:when test="$c='SHOULD NOT' or $c='NOT RECOMMENDED'">
3933      <em class="bcp14"><xsl:value-of select="."/></em>
3934    </xsl:when>
3935    <xsl:when test="$c='MAY' or $c='OPTIONAL'">
3936      <em class="bcp14"><xsl:value-of select="."/></em>
3937    </xsl:when>
3938    <xsl:otherwise>
3939      <xsl:value-of select="."/>
3940      <xsl:message>ERROR: unknown BCP14 keyword: <xsl:value-of select="."/></xsl:message>
3941    </xsl:otherwise>
3942  </xsl:choose>
3943</xsl:template>
3944
3945<xsl:template match="x:blockquote">
3946  <xsl:variable name="p">
3947    <xsl:call-template name="get-paragraph-number" />
3948  </xsl:variable>
3949
3950  <blockquote>
3951    <xsl:if test="string-length($p) &gt; 0 and not(ancestor::ed:del) and not(ancestor::ed:ins)">
3952      <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$p"/></xsl:attribute>
3953    </xsl:if>
3954    <xsl:call-template name="insertInsDelClass"/>
3955    <xsl:call-template name="editingMark" />
3956    <xsl:copy-of select="@cite"/>
3957    <xsl:apply-templates/>
3958  </blockquote>
3959</xsl:template>
3960
3961<!-- Definitions -->
3962<xsl:template match="x:dfn">
3963  <dfn>
3964    <xsl:apply-templates/>
3965  </dfn>
3966</xsl:template>
3967
3968<!-- headings -->
3969<xsl:template match="x:h">
3970  <b>
3971    <xsl:apply-templates/>
3972  </b>
3973</xsl:template>
3974
3975<!-- superscripts -->
3976<xsl:template match="x:sup">
3977  <sup>
3978    <xsl:apply-templates/>
3979  </sup>
3980</xsl:template>
3981
3982<!-- measuring lengths -->
3983<xsl:template match="x:length-of">
3984  <xsl:variable name="target" select="//*[@anchor=current()/@target]"/>
3985  <xsl:if test="count($target)!=1">
3986    <xsl:call-template name="error">
3987      <xsl:with-param name="msg" select="concat('@target ',@target,' defined ',count($target),' times.')"/>
3988    </xsl:call-template>
3989  </xsl:if>
3990  <xsl:variable name="content">
3991    <xsl:apply-templates select="$target"/>
3992  </xsl:variable>
3993  <xsl:variable name="lineends" select="string-length($content) - string-length(translate($content,'&#10;',''))"/>
3994  <xsl:variable name="indents">
3995    <xsl:choose>
3996      <xsl:when test="@indented">
3997        <xsl:value-of select="number(@indented) * $lineends"/>
3998      </xsl:when>
3999      <xsl:otherwise>0</xsl:otherwise>
4000    </xsl:choose>
4001  </xsl:variable>
4002  <xsl:value-of select="string-length($content) + $lineends - $indents"/>
4003</xsl:template>
4004
4005<!-- Nop -->
4006<xsl:template match="x:span">
4007  <xsl:apply-templates/>
4008</xsl:template>
4009
4010<!-- box drawing -->
4011
4012<!-- nop for alignment -->
4013<xsl:template match="x:x"/>
4014
4015<!-- box (top) -->
4016<xsl:template match="x:bt">
4017  <xsl:text>&#x250c;</xsl:text>
4018  <xsl:value-of select="translate(substring(.,2,string-length(.)-2),'-','&#x2500;')"/>
4019  <xsl:text>&#x2510;</xsl:text>
4020</xsl:template>
4021
4022<!-- box (center) -->
4023<xsl:template match="x:bc">
4024  <xsl:variable name="first" select="substring(.,1)"/>
4025  <xsl:variable name="last" select="substring(.,string-length(.)-1)"/>
4026  <xsl:variable name="content" select="substring(.,2,string-length(.)-2)"/>
4027  <xsl:variable name="is-delimiter" select="translate($content,'-','')=''"/>
4028 
4029  <xsl:choose>
4030    <xsl:when test="$is-delimiter">
4031      <xsl:text>&#x251c;</xsl:text>
4032      <xsl:value-of select="translate($content,'-','&#x2500;')"/>
4033      <xsl:text>&#x2524;</xsl:text>
4034    </xsl:when>
4035    <xsl:when test="*">
4036      <xsl:for-each select="node()">
4037        <xsl:choose>
4038          <xsl:when test="position()=1">
4039            <xsl:text>&#x2502;</xsl:text>
4040            <xsl:value-of select="substring(.,2)"/>
4041          </xsl:when>
4042          <xsl:when test="position()=last()">
4043            <xsl:value-of select="substring(.,1,string-length(.)-1)"/>
4044            <xsl:text>&#x2502;</xsl:text>
4045          </xsl:when>
4046          <xsl:otherwise>
4047            <xsl:apply-templates select="."/>
4048          </xsl:otherwise>
4049        </xsl:choose>
4050      </xsl:for-each>
4051    </xsl:when>
4052    <xsl:otherwise>
4053      <xsl:text>&#x2502;</xsl:text>
4054      <xsl:value-of select="$content"/>
4055      <xsl:text>&#x2502;</xsl:text>
4056    </xsl:otherwise>
4057  </xsl:choose>
4058 
4059</xsl:template>
4060
4061<!-- box (bottom) -->
4062<xsl:template match="x:bb">
4063  <xsl:text>&#x2514;</xsl:text>
4064  <xsl:value-of select="translate(substring(.,2,string-length(.)-2),'-','&#x2500;')"/>
4065  <xsl:text>&#x2518;</xsl:text>
4066</xsl:template>
4067
4068<!-- experimental annotation support -->
4069
4070<xsl:template match="ed:issueref">
4071  <xsl:choose>
4072    <xsl:when test=".=//ed:issue/@name">
4073      <a href="#{$anchor-prefix}.issue.{.}">
4074        <xsl:apply-templates/>
4075      </a>
4076    </xsl:when>
4077    <xsl:otherwise>
4078      <xsl:call-template name="warning">
4079        <xsl:with-param name="msg">Dangling ed:issueref: <xsl:value-of select="."/></xsl:with-param>
4080      </xsl:call-template>
4081      <xsl:apply-templates/>
4082    </xsl:otherwise>
4083  </xsl:choose>
4084</xsl:template>
4085
4086<xsl:template match="ed:issue">
4087  <xsl:variable name="class">
4088    <xsl:choose>
4089      <xsl:when test="@status='closed'">closedissue</xsl:when>
4090      <xsl:otherwise>openissue</xsl:otherwise>
4091    </xsl:choose>
4092  </xsl:variable>
4093 
4094  <table summary="issue {@name}" class="{$class}">
4095    <tr>
4096      <td colspan="3">
4097        <a id="{$anchor-prefix}.issue.{@name}">
4098          <xsl:choose>
4099            <xsl:when test="@status='closed'">
4100              <xsl:attribute name="class">closed-issue</xsl:attribute>
4101            </xsl:when>
4102            <xsl:when test="@status='editor'">
4103              <xsl:attribute name="class">editor-issue</xsl:attribute>
4104            </xsl:when>
4105            <xsl:otherwise>
4106              <xsl:attribute name="class">open-issue</xsl:attribute>
4107            </xsl:otherwise>
4108          </xsl:choose>
4109          <xsl:text>&#160;I&#160;</xsl:text>
4110        </a>
4111        <xsl:text>&#160;</xsl:text>
4112        <xsl:choose>
4113          <xsl:when test="@href">
4114            <em><a href="{@href}"><xsl:value-of select="@name" /></a></em>
4115          </xsl:when>
4116          <xsl:when test="@alternate-href">
4117            <em>[<a href="{@alternate-href}">alternate link</a>]</em>
4118          </xsl:when>
4119          <xsl:otherwise>
4120            <em><xsl:value-of select="@name" /></em>
4121          </xsl:otherwise>
4122        </xsl:choose>
4123        &#0160;
4124        (type: <xsl:value-of select="@type"/>, status: <xsl:value-of select="@status"/>)
4125      </td>
4126    </tr>
4127
4128    <xsl:apply-templates select="ed:item"/>
4129    <xsl:apply-templates select="ed:resolution"/>
4130
4131    <xsl:variable name="changes" select="//*[@ed:resolves=current()/@name or ed:resolves=current()/@name]" />
4132    <xsl:if test="$changes">
4133      <tr>
4134        <td class="top" colspan="3">
4135          Associated changes in this document:
4136          <xsl:variable name="issue" select="@name"/>
4137          <xsl:for-each select="$changes">
4138            <a href="#{$anchor-prefix}.change.{$issue}.{position()}">
4139              <xsl:variable name="label">
4140                <xsl:call-template name="get-section-number"/>
4141              </xsl:variable>
4142              <xsl:choose>
4143                <xsl:when test="$label!=''"><xsl:value-of select="$label"/></xsl:when>
4144                <xsl:otherwise>&lt;<xsl:value-of select="concat('#',$anchor-prefix,'.change.',$issue,'.',position())"/>&gt;</xsl:otherwise>
4145              </xsl:choose>
4146            </a>
4147            <xsl:if test="position()!=last()">, </xsl:if>
4148          </xsl:for-each>
4149          <xsl:text>.</xsl:text>
4150        </td>
4151      </tr>
4152    </xsl:if>
4153  </table>
4154   
4155</xsl:template>
4156
4157<xsl:template match="ed:item">
4158  <tr>
4159    <td class="top">
4160      <xsl:if test="@entered-by">
4161        <a href="mailto:{@entered-by}?subject={/rfc/@docName},%20{../@name}">
4162          <i><xsl:value-of select="@entered-by"/></i>
4163        </a>
4164      </xsl:if>
4165    </td>
4166    <td class="topnowrap">
4167      <xsl:value-of select="@date"/>
4168    </td>
4169    <td class="top">
4170      <xsl:apply-templates select="node()" mode="issuehtml"/>
4171    </td>
4172  </tr>
4173</xsl:template>
4174
4175<xsl:template match="ed:resolution">
4176  <tr>
4177    <td class="top">
4178      <xsl:if test="@entered-by">
4179        <a href="mailto:{@entered-by}?subject={/rfc/@docName},%20{../@name}"><i><xsl:value-of select="@entered-by"/></i></a>
4180      </xsl:if>
4181    </td>
4182    <td class="topnowrap">
4183      <xsl:value-of select="@datetime"/>
4184    </td>
4185    <td class="top">
4186      <em>Resolution:</em>
4187      <xsl:apply-templates select="node()" mode="issuehtml"/>
4188    </td>
4189  </tr>
4190</xsl:template>
4191
4192<xsl:template match="ed:annotation">
4193  <em>
4194    <xsl:apply-templates/>
4195  </em>
4196</xsl:template>
4197
4198<!-- special templates for handling XHTML in issues -->
4199<xsl:template match="text()" mode="issuehtml">
4200  <xsl:value-of select="."/>
4201</xsl:template>
4202
4203<xsl:template match="*|@*" mode="issuehtml">
4204  <xsl:message terminate="yes">Unexpected node in issue HTML: <xsl:value-of select="local-name(.)"/></xsl:message>
4205</xsl:template>
4206
4207<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">
4208  <xsl:element name="{local-name()}">
4209    <xsl:apply-templates select="@*|node()" mode="issuehtml"/>
4210  </xsl:element>
4211</xsl:template>
4212
4213<xsl:template match="xhtml:p" mode="issuehtml">
4214  <xsl:apply-templates select="node()" mode="issuehtml"/>
4215  <br class="p"/>
4216</xsl:template>
4217
4218<xsl:template match="xhtml:a/@href|xhtml:q/@cite" mode="issuehtml">
4219  <xsl:attribute name="{local-name(.)}">
4220    <xsl:value-of select="."/>
4221  </xsl:attribute>
4222</xsl:template>
4223
4224<xsl:template match="ed:issueref" mode="issuehtml">
4225  <xsl:apply-templates select="."/>
4226</xsl:template>
4227
4228<xsl:template match="ed:eref" mode="issuehtml">
4229  <xsl:text>&lt;</xsl:text>
4230  <a href="{.}"><xsl:value-of select="."/></a>
4231  <xsl:text>&gt;</xsl:text>
4232</xsl:template>
4233
4234<xsl:template name="insertIssuesList">
4235
4236  <h2 id="{$anchor-prefix}.issues-list" ><a href="#{$anchor-prefix}.issues-list">Issues list</a></h2>
4237  <table summary="Issues list">
4238    <thead>
4239      <tr>
4240        <th>Id</th>
4241        <th>Type</th>
4242        <th>Status</th>
4243        <th>Date</th>
4244        <th>Raised By</th>
4245      </tr>
4246    </thead>
4247    <tbody>
4248      <xsl:for-each select="//ed:issue">
4249        <xsl:sort select="@status" />
4250        <xsl:sort select="@name" />
4251        <tr>
4252          <td><a href="#{$anchor-prefix}.issue.{@name}"><xsl:value-of select="@name" /></a></td>
4253          <td><xsl:value-of select="@type" /></td>
4254          <td><xsl:value-of select="@status" /></td>
4255          <td><xsl:value-of select="ed:item[1]/@date" /></td>
4256          <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>
4257        </tr>
4258      </xsl:for-each>
4259    </tbody>
4260  </table>
4261 
4262</xsl:template>
4263
4264<xsl:template name="formatTitle">
4265  <xsl:if test="@who">
4266    <xsl:value-of select="@who" />
4267  </xsl:if>
4268  <xsl:if test="@datetime">
4269    <xsl:value-of select="concat(' (',@datetime,')')" />
4270  </xsl:if>
4271  <xsl:if test="@reason">
4272    <xsl:value-of select="concat(': ',@reason)" />
4273  </xsl:if>
4274  <xsl:if test="@cite">
4275    <xsl:value-of select="concat(' &lt;',@cite,'&gt;')" />
4276  </xsl:if>
4277</xsl:template>
4278
4279<xsl:template name="insert-diagnostics">
4280 
4281  <!-- check anchor names -->
4282  <xsl:variable name="badAnchors" select="//*[starts-with(@anchor,concat($anchor-prefix,'.'))]" />
4283  <xsl:if test="$badAnchors">
4284    <p class="warning">
4285      The following anchor names may collide with internally generated anchors because of their prefix "<xsl:value-of select="$anchor-prefix" />":
4286      <xsl:for-each select="$badAnchors">
4287        <xsl:value-of select="@anchor"/><xsl:if test="position()!=last()">, </xsl:if>
4288      </xsl:for-each>
4289    </p>
4290    <xsl:message>
4291      The following anchor names may collide with internally generated anchors because of their prefix "<xsl:value-of select="$anchor-prefix" />":
4292      <xsl:for-each select="$badAnchors">
4293        <xsl:value-of select="@anchor"/><xsl:if test="position()!=last()">, </xsl:if>
4294      </xsl:for-each>
4295    </xsl:message>
4296  </xsl:if>
4297 
4298  <!-- check IDs -->
4299  <xsl:variable name="badTargets" select="//xref[not(@target=//@anchor) and not(ancestor::ed:del)]" />
4300  <xsl:if test="$badTargets">
4301    <p class="error">
4302      The following target names do not exist:
4303      <xsl:for-each select="$badTargets">
4304        <xsl:value-of select="@target"/><xsl:if test="position()!=last()">, </xsl:if>
4305      </xsl:for-each>
4306    </p>
4307    <xsl:message>
4308      The following target names do not exist:
4309      <xsl:for-each select="$badTargets">
4310        <xsl:value-of select="@target"/><xsl:if test="position()!=last()">, </xsl:if>
4311      </xsl:for-each>
4312    </xsl:message>
4313  </xsl:if>
4314 
4315 
4316</xsl:template>
4317
4318<!-- special change mark support, not supported by RFC2629 yet -->
4319
4320<xsl:template match="@ed:*" />
4321
4322<xsl:template match="ed:del">
4323  <xsl:call-template name="insert-issue-pointer"/>
4324  <del>
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  </del>
4331</xsl:template>
4332
4333<xsl:template match="ed:ins">
4334  <xsl:call-template name="insert-issue-pointer"/>
4335  <ins>
4336    <xsl:copy-of select="@*[namespace-uri()='']"/>
4337    <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
4338      <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4339    </xsl:if>
4340    <xsl:apply-templates />
4341  </ins>
4342</xsl:template>
4343
4344<xsl:template name="insert-issue-pointer">
4345  <xsl:param name="deleted-anchor"/>
4346  <xsl:variable name="change" select="."/>
4347  <xsl:for-each select="@ed:resolves|ed:resolves">
4348    <xsl:variable name="resolves" select="."/>
4349    <!-- need the right context node for proper numbering -->
4350    <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>
4351    <xsl:variable name="total" select="count(//*[@ed:resolves=$resolves or ed:resolves=$resolves])" />
4352    <xsl:variable name="id">
4353      <xsl:value-of select="$anchor-prefix"/>.change.<xsl:value-of select="$resolves"/>.<xsl:value-of select="$count" />
4354    </xsl:variable>
4355    <xsl:choose>
4356      <!-- block level? -->
4357      <xsl:when test="not(ancestor::t) and not(ancestor::title) and not(ancestor::figure) and not($change/@ed:old-title)">
4358        <div class="issuepointer noprint">
4359          <xsl:if test="not($deleted-anchor)">
4360            <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
4361          </xsl:if>
4362          <xsl:if test="$count > 1">
4363            <a class="bg-issue" title="previous change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count - 1}">&#x2191;</a>
4364          </xsl:if>
4365          <a class="open-issue" href="#{$anchor-prefix}.issue.{$resolves}" title="resolves: {$resolves}">
4366            <xsl:choose>
4367              <xsl:when test="//ed:issue[@name=$resolves and @status='closed']">
4368                <xsl:attribute name="class">closed-issue</xsl:attribute>
4369              </xsl:when>
4370              <xsl:when test="//ed:issue[@name=$resolves and @status='editor']">
4371                <xsl:attribute name="class">editor-issue</xsl:attribute>
4372              </xsl:when>
4373              <xsl:otherwise>
4374                <xsl:attribute name="class">open-issue</xsl:attribute>
4375              </xsl:otherwise>
4376            </xsl:choose>
4377            <xsl:text>&#160;I&#160;</xsl:text>
4378          </a>
4379          <xsl:if test="$count &lt; $total">
4380            <a class="bg-issue" title="next change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count + 1}">&#x2193;</a>
4381          </xsl:if>
4382          <xsl:text>&#160;</xsl:text>
4383        </div>
4384      </xsl:when>
4385      <xsl:otherwise>
4386        <xsl:if test="$count > 1">
4387          <a class="bg-issue" title="previous change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count - 1}">&#x2191;</a>
4388        </xsl:if>
4389        <a title="resolves: {$resolves}" href="#{$anchor-prefix}.issue.{$resolves}">
4390          <xsl:if test="not($deleted-anchor)">
4391            <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
4392          </xsl:if>
4393          <xsl:choose>
4394            <xsl:when test="//ed:issue[@name=$resolves and @status='closed']">
4395              <xsl:attribute name="class">closed-issue noprint</xsl:attribute>
4396            </xsl:when>
4397            <xsl:when test="//ed:issue[@name=$resolves and @status='editor']">
4398              <xsl:attribute name="class">editor-issue noprint</xsl:attribute>
4399            </xsl:when>
4400            <xsl:otherwise>
4401              <xsl:attribute name="class">open-issue noprint</xsl:attribute>
4402            </xsl:otherwise>
4403          </xsl:choose>
4404          <xsl:text>&#160;I&#160;</xsl:text>
4405        </a>
4406        <xsl:if test="$count &lt; $total">
4407          <a class="bg-issue" title="next change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count + 1}">&#x2193;</a>
4408        </xsl:if>
4409      </xsl:otherwise>
4410    </xsl:choose>
4411  </xsl:for-each>
4412</xsl:template>
4413
4414<xsl:template match="ed:replace">
4415  <!-- we need to special-case things like lists and tables -->
4416  <xsl:choose>
4417    <xsl:when test="parent::list">
4418      <xsl:apply-templates select="ed:del/node()" />
4419      <xsl:apply-templates select="ed:ins/node()" />
4420    </xsl:when>
4421    <xsl:when test="ancestor::references">
4422      <xsl:apply-templates select="ed:del/node()" />
4423      <xsl:apply-templates select="ed:ins/node()" />
4424    </xsl:when>
4425    <xsl:otherwise>
4426      <xsl:if test="@cite">
4427        <a class="editor-issue" href="{@cite}" target="_blank" title="see {@cite}">
4428          <xsl:text>&#160;i&#160;</xsl:text>
4429        </a>
4430      </xsl:if>
4431      <xsl:call-template name="insert-issue-pointer"/>
4432      <xsl:if test="ed:del">
4433        <del>
4434          <xsl:copy-of select="@*[namespace-uri()='']"/>
4435          <xsl:if test="not(@title) and ancestor-or-self::xsl:template[@ed:entered-by] and @datetime">
4436            <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4437          </xsl:if>
4438          <xsl:apply-templates select="ed:del/node()" />
4439        </del>
4440      </xsl:if>
4441      <xsl:if test="ed:ins">
4442        <ins>
4443          <xsl:copy-of select="@*[namespace-uri()='']"/>
4444          <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
4445            <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4446          </xsl:if>
4447          <xsl:apply-templates select="ed:ins/node()" />
4448        </ins>
4449      </xsl:if>
4450    </xsl:otherwise>
4451  </xsl:choose>
4452</xsl:template>
4453
4454<!-- convenience template for helping Mozilla (pre/ins inheritance problem) -->
4455<xsl:template name="insertInsDelClass">
4456  <xsl:if test="ancestor::ed:del">
4457    <xsl:attribute name="class">del</xsl:attribute>
4458  </xsl:if>
4459  <xsl:if test="ancestor::ed:ins">
4460    <xsl:attribute name="class">ins</xsl:attribute>
4461  </xsl:if>
4462</xsl:template>
4463
4464
4465<xsl:template name="sectionnumberAndEdits">
4466  <xsl:choose>
4467    <xsl:when test="ancestor::ed:del">del-<xsl:number count="ed:del//section" level="any"/></xsl:when>
4468    <xsl:when test="@x:fixed-section-number">
4469      <xsl:value-of select="@x:fixed-section-number"/>
4470    </xsl:when>
4471    <xsl:when test="self::section and parent::ed:ins and local-name(../..)='replace'">
4472      <xsl:for-each select="../.."><xsl:call-template name="sectionnumberAndEdits" /></xsl:for-each>
4473      <xsl:for-each select="..">
4474        <xsl:if test="parent::ed:replace">
4475          <xsl:for-each select="..">
4476            <xsl:if test="parent::section">.</xsl:if>
4477            <xsl:variable name="cnt" select="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)" />
4478            <xsl:choose>
4479              <xsl:when test="ancestor::back and not(ancestor::section)"><xsl:number format="A" value="$cnt"/></xsl:when>
4480              <xsl:otherwise><xsl:value-of select="$cnt"/></xsl:otherwise>
4481            </xsl:choose>
4482          </xsl:for-each>
4483        </xsl:if>
4484      </xsl:for-each>
4485    </xsl:when>
4486    <xsl:when test="self::section[parent::ed:ins]">
4487      <xsl:for-each select="../.."><xsl:call-template name="sectionnumberAndEdits" /></xsl:for-each>
4488      <xsl:for-each select="..">
4489        <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)" />
4490      </xsl:for-each>
4491    </xsl:when>
4492    <xsl:when test="self::section">
4493      <xsl:for-each select=".."><xsl:call-template name="sectionnumberAndEdits" /></xsl:for-each>
4494      <xsl:if test="parent::section">.</xsl:if>
4495      <xsl:choose>
4496        <xsl:when test="parent::back">
4497          <xsl:number format="A" value="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)" />
4498        </xsl:when>
4499        <xsl:otherwise>
4500          <xsl:number value="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)" />
4501        </xsl:otherwise>
4502      </xsl:choose>
4503    </xsl:when>
4504    <xsl:when test="self::references">
4505      <xsl:choose>
4506        <xsl:when test="count(/*/back/references)+count(/*/back/ed:replace/ed:ins/references)=1"><xsl:call-template name="get-references-section-number"/></xsl:when>
4507        <xsl:otherwise><xsl:call-template name="get-references-section-number"/>.<xsl:number level="any"/></xsl:otherwise>
4508      </xsl:choose>
4509    </xsl:when>
4510    <xsl:when test="self::middle or self::back"><!-- done --></xsl:when>
4511    <xsl:otherwise>
4512      <!-- go up one level -->
4513      <xsl:for-each select=".."><xsl:call-template name="sectionnumberAndEdits" /></xsl:for-each>
4514    </xsl:otherwise>
4515  </xsl:choose>
4516</xsl:template>
4517
4518<!-- utilities for warnings -->
4519
4520<xsl:template name="warning">
4521  <xsl:param name="msg"/>
4522  <xsl:param name="msg2"/>
4523  <xsl:param name="inline"/>
4524  <xsl:if test="$inline!='no'">
4525    <div class="error">WARNING: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/></div>
4526  </xsl:if>
4527  <xsl:message>WARNING: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/><xsl:call-template name="lineno"/></xsl:message>
4528</xsl:template>
4529
4530<xsl:template name="error">
4531  <xsl:param name="msg"/>
4532  <xsl:param name="msg2"/>
4533  <xsl:param name="inline"/>
4534  <xsl:if test="$inline='no'">
4535    <div class="error">ERROR: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/></div>
4536  </xsl:if>
4537  <xsl:message>ERROR: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/><xsl:call-template name="lineno"/></xsl:message>
4538</xsl:template>
4539
4540<!-- table formatting -->
4541
4542<xsl:template match="texttable">
4543
4544  <xsl:variable name="anch">
4545    <xsl:call-template name="get-table-anchor"/>
4546  </xsl:variable>
4547
4548  <div id="{$anch}">
4549    <xsl:if test="@anchor!=''">
4550      <div id="{@anchor}"/>
4551    </xsl:if>
4552    <xsl:apply-templates select="preamble" />
4553    <xsl:variable name="style">
4554      <xsl:text>tt </xsl:text>
4555      <xsl:choose>
4556        <xsl:when test="@style!=''">
4557          <xsl:value-of select="@style"/>
4558        </xsl:when>
4559        <xsl:otherwise>full</xsl:otherwise>
4560      </xsl:choose>
4561    </xsl:variable>
4562    <table summary="{preamble}" class="{$style}" cellpadding="3" cellspacing="0">
4563      <thead>
4564        <tr>
4565          <xsl:apply-templates select="ttcol" />
4566        </tr>
4567      </thead>
4568      <tbody>
4569        <xsl:variable name="columns" select="count(ttcol)" />
4570        <xsl:variable name="fields" select="c | ed:replace/ed:ins/c | ed:replace/ed:del/c" />
4571        <xsl:for-each select="$fields[(position() mod $columns) = 1]">
4572          <tr>
4573            <xsl:for-each select=". | following-sibling::c[position() &lt; $columns]">
4574              <td>
4575                <xsl:call-template name="insertInsDelClass"/>
4576                <xsl:variable name="pos" select="position()" />
4577                <xsl:variable name="col" select="../ttcol[position() = $pos]" />
4578                <xsl:choose>
4579                  <xsl:when test="$col/@align='right' or $col/@align='center'">
4580                    <xsl:attribute name="class"><xsl:value-of select="$col/@align"/></xsl:attribute>
4581                  </xsl:when>
4582                  <xsl:when test="$col/@align='left' or not($col/@align)">
4583                    <!-- that's the default, nothing to do here -->
4584                  </xsl:when>
4585                  <xsl:otherwise>
4586                    <xsl:message>Unknown align attribute on ttcol: <xsl:value-of select="$col/@align"/></xsl:message>
4587                  </xsl:otherwise>
4588                </xsl:choose>
4589                <xsl:apply-templates select="node()" />
4590              </td>
4591            </xsl:for-each>
4592          </tr>
4593        </xsl:for-each>
4594      </tbody>
4595    </table>
4596    <xsl:apply-templates select="postamble" />
4597
4598    <xsl:if test="(@title!='' or @anchor!='') and not(@suppress-title='true')">
4599      <xsl:variable name="n"><xsl:number level="any" count="texttable[(@title!='' or @anchor!='') and not(@suppress-title='true')]" /></xsl:variable>
4600      <p class="figure">Table <xsl:value-of select="$n"/><xsl:if test="@title!=''">: <xsl:value-of select="@title" /></xsl:if></p>
4601    </xsl:if>
4602  </div>
4603 
4604</xsl:template>
4605
4606<xsl:template match="ttcol">
4607  <th>
4608   
4609    <xsl:choose>
4610      <xsl:when test="@align='right' or @align='center' or @align='left'">
4611        <xsl:attribute name="class"><xsl:value-of select="@align"/></xsl:attribute>
4612      </xsl:when>
4613      <xsl:when test="not(@align)">
4614        <!-- that's the default, nothing to do here -->
4615      </xsl:when>
4616      <xsl:otherwise>
4617        <xsl:message>Unknown align attribute on ttcol: <xsl:value-of select="@align"/></xsl:message>
4618      </xsl:otherwise>
4619    </xsl:choose>
4620   
4621    <xsl:if test="@width">
4622      <xsl:attribute name="style">width: <xsl:value-of select="@width" />;</xsl:attribute>
4623    </xsl:if>
4624
4625    <xsl:apply-templates />
4626  </th>
4627</xsl:template>
4628
4629<!-- cref support -->
4630
4631<xsl:template match="cref">
4632  <xsl:if test="$xml2rfc-comments!='no'">
4633    <xsl:variable name="cid">
4634      <xsl:choose>
4635        <xsl:when test="@anchor">
4636          <xsl:value-of select="@anchor"/>
4637        </xsl:when>
4638        <xsl:otherwise>
4639          <xsl:value-of select="$anchor-prefix"/>
4640          <xsl:text>.comment.</xsl:text>
4641          <xsl:number count="cref[not(@anchor)]" level="any"/>
4642        </xsl:otherwise>
4643      </xsl:choose>
4644    </xsl:variable>
4645   
4646    <span class="comment">
4647      <xsl:if test="$xml2rfc-inline!='yes'">
4648        <xsl:attribute name="title">
4649          <xsl:if test="@source"><xsl:value-of select="@source"/>: </xsl:if>
4650          <xsl:apply-templates select="text()|eref"/>
4651        </xsl:attribute>
4652      </xsl:if>
4653      <xsl:text>[</xsl:text>
4654      <xsl:choose>
4655        <xsl:when test="$xml2rfc-inline='yes'">
4656          <xsl:value-of select="$cid"/>
4657          <xsl:text>: </xsl:text>
4658          <xsl:apply-templates select="text()|eref"/>
4659          <xsl:if test="@source"> --<xsl:value-of select="@source"/></xsl:if>
4660        </xsl:when>
4661        <xsl:otherwise>
4662          <a href="#{$cid}">
4663            <xsl:value-of select="$cid"/>
4664          </a>
4665        </xsl:otherwise>
4666      </xsl:choose>
4667      <xsl:text>]</xsl:text>
4668    </span>
4669  </xsl:if>
4670</xsl:template>
4671
4672<xsl:template name="insertComments">
4673
4674  <xsl:call-template name="insert-conditional-hrule"/>
4675   
4676  <h1>
4677    <xsl:call-template name="insert-conditional-pagebreak"/>
4678    <a id="{$anchor-prefix}.comments" href="#{$anchor-prefix}.comments">Editorial Comments</a>
4679  </h1>
4680
4681  <dl>
4682    <xsl:for-each select="//cref">
4683      <xsl:variable name="cid">
4684        <xsl:choose>
4685          <xsl:when test="@anchor">
4686            <xsl:value-of select="@anchor"/>
4687          </xsl:when>
4688          <xsl:otherwise>
4689            <xsl:value-of select="$anchor-prefix"/>
4690            <xsl:text>.comment.</xsl:text>
4691            <xsl:number count="cref[not(@anchor)]" level="any"/>
4692          </xsl:otherwise>
4693        </xsl:choose>
4694      </xsl:variable>
4695      <dt id="{$cid}">
4696        [<xsl:value-of select="$cid"/>]
4697      </dt>
4698      <dd>
4699        <xsl:value-of select="."/>
4700        <xsl:if test="@source"> --<xsl:value-of select="@source"/></xsl:if>
4701      </dd>
4702    </xsl:for-each>
4703  </dl>
4704</xsl:template>
4705
4706
4707<!-- Chapter Link Generation -->
4708
4709<xsl:template match="*" mode="links"><xsl:apply-templates mode="links"/></xsl:template>
4710<xsl:template match="text()" mode="links" />
4711
4712<xsl:template match="/*/middle//section[not(myns:unnumbered) and not(ancestor::section)]" mode="links">
4713  <xsl:variable name="sectionNumber"><xsl:call-template name="get-section-number" /></xsl:variable>
4714  <link rel="Chapter" title="{$sectionNumber} {@title}" href="#{$anchor-prefix}.section.{$sectionNumber}" />
4715  <xsl:apply-templates mode="links" />
4716</xsl:template>
4717
4718<xsl:template match="/*/back//section[not(myns:unnumbered) and not(ancestor::section)]" mode="links">
4719  <xsl:variable name="sectionNumber"><xsl:call-template name="get-section-number" /></xsl:variable>
4720  <link rel="Appendix" title="{$sectionNumber} {@title}" href="#{$anchor-prefix}.section.{$sectionNumber}" />
4721  <xsl:apply-templates mode="links" />
4722</xsl:template>
4723
4724<xsl:template match="/*/back/references[position()=1]" mode="links">
4725  <xsl:variable name="sectionNumber"><xsl:call-template name="get-references-section-number" /></xsl:variable>
4726  <link rel="Chapter" href="#{$anchor-prefix}.section.{$sectionNumber}">
4727    <xsl:choose>
4728      <xsl:when test="@title and count(/*/back/references)=1">
4729        <xsl:attribute name="title">
4730          <xsl:call-template name="get-references-section-number"/>
4731          <xsl:text> </xsl:text>
4732          <xsl:value-of select="@title"/>
4733        </xsl:attribute>
4734      </xsl:when>
4735      <xsl:otherwise>
4736        <xsl:attribute name="title">
4737          <xsl:call-template name="get-references-section-number"/>
4738          <xsl:text> References</xsl:text>
4739        </xsl:attribute>
4740      </xsl:otherwise>
4741    </xsl:choose>
4742  </link>
4743</xsl:template>
4744
4745<!-- convenience templates -->
4746
4747<xsl:template name="get-author-summary">
4748  <xsl:choose>
4749    <xsl:when test="count(/rfc/front/author)=1">
4750      <xsl:value-of select="/rfc/front/author[1]/@surname" />
4751    </xsl:when>
4752    <xsl:when test="count(/rfc/front/author)=2">
4753      <xsl:value-of select="concat(/rfc/front/author[1]/@surname,' &amp; ',/rfc/front/author[2]/@surname)" />
4754    </xsl:when>
4755    <xsl:otherwise>
4756      <xsl:value-of select="concat(/rfc/front/author[1]/@surname,', et al.')" />
4757    </xsl:otherwise>
4758  </xsl:choose>
4759</xsl:template>
4760
4761<xsl:template name="get-authors">
4762  <xsl:for-each select="/rfc/front/author">
4763    <xsl:value-of select="@fullname" />
4764    <xsl:if test="position()!=last()">, </xsl:if>
4765  </xsl:for-each>
4766</xsl:template>
4767
4768<xsl:template name="get-category-long">
4769  <xsl:choose>
4770    <xsl:when test="$xml2rfc-footer"><xsl:value-of select="$xml2rfc-footer" /></xsl:when>
4771    <xsl:when test="$xml2rfc-private"/> <!-- private draft, footer not set -->
4772    <xsl:when test="/rfc/@category='bcp'">Best Current Practice</xsl:when>
4773    <xsl:when test="/rfc/@category='historic'">Historic</xsl:when>
4774    <xsl:when test="/rfc/@category='info' or not(/rfc/@category)">Informational</xsl:when>
4775    <xsl:when test="/rfc/@category='std'">Standards Track</xsl:when>
4776    <xsl:when test="/rfc/@category='exp'">Experimental</xsl:when>
4777    <xsl:otherwise>(category unknown)</xsl:otherwise>
4778  </xsl:choose>
4779</xsl:template>
4780
4781<xsl:template name="get-header-center">
4782  <xsl:choose>
4783    <xsl:when test="string-length(/rfc/front/title/@abbrev) &gt; 0">
4784      <xsl:value-of select="/rfc/front/title/@abbrev" />
4785    </xsl:when>
4786    <xsl:otherwise>
4787      <xsl:apply-templates select="/rfc/front/title" mode="get-text-content" />
4788    </xsl:otherwise>
4789  </xsl:choose>
4790</xsl:template>
4791
4792<xsl:template name="get-header-left">
4793  <xsl:choose>
4794    <xsl:when test="$xml2rfc-header"><xsl:value-of select="$xml2rfc-header" /></xsl:when>
4795    <xsl:when test="$xml2rfc-private"/> <!-- private draft, header not set -->
4796    <xsl:when test="/rfc/@ipr and not(/rfc/@number)">INTERNET DRAFT</xsl:when>
4797    <xsl:otherwise>RFC <xsl:value-of select="/rfc/@number"/></xsl:otherwise>
4798  </xsl:choose>
4799</xsl:template>
4800
4801<xsl:template name="get-generator">
4802  <xsl:variable name="gen">
4803    <xsl:text>http://greenbytes.de/tech/webdav/rfc2629.xslt, </xsl:text>
4804    <!-- when RCS keyword substitution in place, add version info -->
4805    <xsl:if test="contains('$Revision: 1.367 $',':')">
4806      <xsl:value-of select="concat('Revision ',normalize-space(translate(substring-after('$Revision: 1.367 $', 'Revision: '),'$','')),', ')" />
4807    </xsl:if>
4808    <xsl:if test="contains('$Date: 2008-05-19 13:00:19 $',':')">
4809      <xsl:value-of select="concat(normalize-space(translate(substring-after('$Date: 2008-05-19 13:00:19 $', 'Date: '),'$','')),', ')" />
4810    </xsl:if>
4811    <xsl:value-of select="concat('XSLT vendor: ',system-property('xsl:vendor'),' ',system-property('xsl:vendor-url'))" />
4812  </xsl:variable>
4813  <xsl:value-of select="$gen" />
4814</xsl:template>
4815
4816<xsl:template name="get-header-right">
4817  <xsl:value-of select="concat($xml2rfc-ext-pub-month, ' ', $xml2rfc-ext-pub-year)" />
4818</xsl:template>
4819
4820<xsl:template name="get-keywords">
4821  <xsl:variable name="keyw">
4822    <xsl:for-each select="/rfc/front/keyword">
4823      <xsl:value-of select="translate(.,',',' ')" />
4824      <xsl:if test="position()!=last()">, </xsl:if>
4825    </xsl:for-each>
4826  </xsl:variable>
4827  <xsl:value-of select="normalize-space($keyw)" />
4828</xsl:template>
4829
4830<!-- get language from context node. nearest ancestor or return the default of "en" -->
4831<xsl:template name="get-lang">
4832  <xsl:choose>
4833    <xsl:when test="ancestor-or-self::*[@xml:lang]"><xsl:value-of select="ancestor-or-self::*/@xml:lang" /></xsl:when>
4834    <xsl:otherwise>en</xsl:otherwise>
4835  </xsl:choose>
4836</xsl:template>
4837
4838<xsl:template name="get-section-number">
4839  <xsl:variable name="hasEdits" select="count(//ed:del|//ed:ins)!=0" />
4840  <xsl:variable name="anchor" select="@anchor"/>
4841  <xsl:choose>
4842    <xsl:when test="@x:fixed-section-number">
4843      <xsl:value-of select="@x:fixed-section-number"/>
4844    </xsl:when>
4845    <xsl:when test="$hasEdits or ancestor::*/@x:fixed-section-number">
4846      <xsl:call-template name="sectionnumberAndEdits" />
4847    </xsl:when>
4848    <xsl:otherwise>
4849      <xsl:choose>
4850        <xsl:when test="self::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:when>
4860        <xsl:when test="self::reference">
4861          <xsl:for-each select="parent::references">
4862            <xsl:choose>
4863              <xsl:when test="count(/*/back/references)=1">
4864                <xsl:call-template name="get-references-section-number"/>
4865              </xsl:when>
4866              <xsl:otherwise>
4867                <xsl:call-template name="get-references-section-number"/>.<xsl:number count="references"/>
4868              </xsl:otherwise>
4869            </xsl:choose>
4870          </xsl:for-each>
4871        </xsl:when>
4872        <xsl:when test="ancestor::back"><xsl:number count="section|appendix" level="multiple" format="A.1.1.1.1.1.1.1" /></xsl:when>
4873        <xsl:when test="self::appendix"><xsl:number count="appendix" level="multiple" format="A.1.1.1.1.1.1.1" /></xsl:when>
4874        <xsl:otherwise><xsl:number count="section" level="multiple"/></xsl:otherwise>
4875      </xsl:choose>
4876    </xsl:otherwise>
4877  </xsl:choose>
4878</xsl:template>
4879
4880<!-- get the section number for the references section -->
4881<xsl:template name="get-references-section-number">
4882  <xsl:value-of select="count(/rfc/middle/section) + count(/rfc/middle/ed:replace/ed:ins/section) + 1"/>
4883</xsl:template>
4884
4885<xsl:template name="emit-section-number">
4886  <xsl:param name="no"/>
4887  <xsl:value-of select="$no"/><xsl:if test="not(contains($no,'.')) or $xml2rfc-ext-sec-no-trailing-dots='yes'">.</xsl:if>
4888</xsl:template>
4889
4890<xsl:template name="get-section-type">
4891  <xsl:param name="prec" />
4892  <xsl:choose>
4893    <xsl:when test="ancestor::back">Appendix</xsl:when>
4894    <xsl:otherwise>Section</xsl:otherwise>
4895  </xsl:choose>
4896</xsl:template>
4897
4898<xsl:template name="get-table-anchor">
4899  <xsl:value-of select="$anchor-prefix"/>
4900  <xsl:text>.table.</xsl:text>
4901  <xsl:choose>
4902    <xsl:when test="@title!='' or @anchor!=''">
4903      <xsl:number level="any" count="texttable[@title!='' or @anchor!='']" />
4904    </xsl:when>
4905    <xsl:otherwise>
4906      <xsl:text>u.</xsl:text>
4907      <xsl:number level="any" count="texttable[not(@title!='' or @anchor!='')]" />
4908    </xsl:otherwise>
4909  </xsl:choose>
4910</xsl:template>
4911
4912<xsl:template name="get-figure-anchor">
4913  <xsl:value-of select="$anchor-prefix"/>
4914  <xsl:text>.figure.</xsl:text>
4915  <xsl:choose>
4916    <xsl:when test="@title!='' or @anchor!=''">
4917      <xsl:number level="any" count="figure[@title!='' or @anchor!='']" />
4918    </xsl:when>
4919    <xsl:otherwise>
4920      <xsl:text>u.</xsl:text>
4921      <xsl:number level="any" count="figure[not(@title!='' or @anchor!='')]" />
4922    </xsl:otherwise>
4923  </xsl:choose>
4924</xsl:template>
4925
4926<!-- reformat contents of author/@initials -->
4927<xsl:template name="format-initials">
4928  <xsl:choose>
4929    <xsl:when test="string-length(@initials)=1">
4930      <xsl:value-of select="concat(@initials,'.')"/>
4931    </xsl:when>
4932    <xsl:otherwise>
4933      <xsl:value-of select="@initials"/>
4934    </xsl:otherwise>
4935  </xsl:choose>
4936</xsl:template>
4937
4938<xsl:template name="insert-conditional-pagebreak">
4939  <xsl:if test="$xml2rfc-compact!='yes'">
4940    <xsl:attribute name="class">np</xsl:attribute>
4941  </xsl:if>
4942</xsl:template>
4943
4944<xsl:template name="insert-conditional-hrule">
4945  <xsl:if test="$xml2rfc-compact!='yes'">
4946    <hr class="noprint" />
4947  </xsl:if>
4948</xsl:template>
4949
4950<!-- get text content from marked-up text -->
4951
4952<xsl:template match="text()" mode="get-text-content">
4953  <xsl:value-of select="."/>
4954</xsl:template>
4955
4956<xsl:template match="*" mode="get-text-content">
4957  <xsl:apply-templates mode="get-text-content"/>
4958</xsl:template>
4959
4960<xsl:template match="ed:del" mode="get-text-content">
4961</xsl:template>
4962
4963<!-- diag support -->
4964<xsl:template name="lineno">
4965  <xsl:if test="function-available('saxon-old:line-number')">
4966    <xsl:if test="saxon-old:line-number() > 0">
4967      <xsl:text> (at line </xsl:text>
4968      <xsl:value-of select="saxon-old:line-number()"/>
4969      <xsl:text>)</xsl:text>
4970    </xsl:if>
4971  </xsl:if>
4972  <xsl:if test="function-available('saxon:line-number')">
4973    <xsl:if test="saxon:line-number() > 0">
4974      <xsl:text> (at line </xsl:text>
4975      <xsl:value-of select="saxon:line-number()"/>
4976      <xsl:text>)</xsl:text>
4977    </xsl:if>
4978  </xsl:if>
4979</xsl:template>
4980
4981<!-- date handling -->
4982
4983<msxsl:script language="JScript" implements-prefix="date">
4984  this['year'] = function (x) {
4985    if (x) {throw "not supported"};
4986    return (new Date()).getFullYear();
4987  }
4988
4989  this['month-in-year'] = function (x) {
4990    if (x) {throw "not supported"};
4991    return 1 + (new Date()).getMonth();
4992  }
4993
4994  this['day-in-month'] = function (x) {
4995    if (x) {throw "not supported"};
4996    return (new Date()).getDate();
4997  }
4998</msxsl:script>
4999
5000<xsl:variable name="may-default-dates">
5001  <xsl:choose>
5002    <xsl:when test="function-available('date:year') and function-available('date:month-in-year') and date:day-in-month()">
5003      <xsl:variable name="year-specified" select="/rfc/front/date/@year and /rfc/front/date/@year!=''"/>
5004      <xsl:variable name="month-specified" select="/rfc/front/date/@month and /rfc/front/date/@month!=''"/>
5005      <xsl:variable name="day-specified" select="/rfc/front/date/@day and /rfc/front/date/@day!=''"/>
5006      <xsl:variable name="system-month">
5007        <xsl:call-template name="get-month-as-name">
5008          <xsl:with-param name="month" select="date:month-in-year()"/>
5009        </xsl:call-template>
5010      </xsl:variable>
5011      <xsl:choose>
5012        <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>
5013        <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>
5014        <xsl:when test="$day-specified and /rfc/front/date/@day!=date:day-in-month()">Specified day does not match system date</xsl:when>
5015        <xsl:when test="not($year-specified) and ($month-specified or $day-specified)">Can't default year when month or day is specified</xsl:when>
5016        <xsl:when test="not($month-specified) and $day-specified">Can't default month when day is specified</xsl:when>
5017        <xsl:otherwise>yes</xsl:otherwise>
5018      </xsl:choose>
5019    </xsl:when>
5020    <!-- may, but won't -->
5021    <xsl:otherwise>yes</xsl:otherwise>
5022  </xsl:choose>
5023</xsl:variable>
5024
5025<xsl:param name="xml2rfc-ext-pub-year">
5026  <xsl:choose>
5027    <xsl:when test="/rfc/front/date/@year and /rfc/front/date/@year!=''">
5028      <xsl:value-of select="/rfc/front/date/@year"/>
5029    </xsl:when>
5030    <xsl:when test="function-available('date:year')">
5031      <xsl:if test="/rfc/front/date/@month and /rfc/front/date/@month!=''">
5032        <xsl:call-template name="error">
5033          <xsl:with-param name="msg" select="'defaulting publication year although month was specified'"/>
5034        </xsl:call-template>
5035      </xsl:if>
5036      <xsl:if test="/rfc/front/date/@day and /rfc/front/date/@day!=''">
5037        <xsl:call-template name="error">
5038          <xsl:with-param name="msg" select="'defaulting publication year although day was specified'"/>
5039        </xsl:call-template>
5040      </xsl:if>
5041      <xsl:value-of select="date:year()"/>
5042    </xsl:when>
5043    <xsl:otherwise>
5044      <xsl:call-template name="error">
5045        <xsl:with-param name="msg" select="'/rfc/front/date/@year missing (and XSLT processor cannot compute the system date)'"/>
5046      </xsl:call-template>
5047    </xsl:otherwise>
5048  </xsl:choose>
5049</xsl:param>
5050
5051<xsl:param name="xml2rfc-ext-pub-month">
5052  <xsl:choose>
5053    <xsl:when test="/rfc/front/date/@month and /rfc/front/date/@month!=''">
5054      <xsl:value-of select="/rfc/front/date/@month"/>
5055    </xsl:when>
5056    <xsl:when test="function-available('date:month-in-year') and $may-default-dates='yes'">
5057      <xsl:call-template name="get-month-as-name">
5058        <xsl:with-param name="month" select="date:month-in-year()"/>
5059      </xsl:call-template>
5060    </xsl:when>
5061    <xsl:when test="function-available('date:month-in-year') and $may-default-dates!='yes'">
5062      <xsl:call-template name="warning">
5063        <xsl:with-param name="inline" select="'no'"/>
5064        <xsl:with-param name="msg" select="$may-default-dates"/>
5065      </xsl:call-template>
5066    </xsl:when>
5067    <xsl:otherwise>
5068      <xsl:call-template name="error">
5069        <xsl:with-param name="msg" select="'/rfc/front/date/@month missing (and XSLT processor cannot compute the system date)'"/>
5070      </xsl:call-template>
5071    </xsl:otherwise>
5072  </xsl:choose>
5073</xsl:param>
5074
5075<xsl:param name="xml2rfc-ext-pub-month-numeric">
5076  <xsl:call-template name="get-month-as-num">
5077    <xsl:with-param name="month" select="$xml2rfc-ext-pub-month" />
5078  </xsl:call-template>
5079</xsl:param>
5080
5081<xsl:param name="xml2rfc-ext-pub-day">
5082  <xsl:choose>
5083    <xsl:when test="/rfc/front/date/@day and /rfc/front/date/@day!=''">
5084      <xsl:value-of select="/rfc/front/date/@day"/>
5085    </xsl:when>
5086    <xsl:when test="function-available('date:day-in-month') and $may-default-dates='yes'">
5087      <xsl:value-of select="date:day-in-month()"/>
5088    </xsl:when>
5089    <xsl:otherwise /> <!-- harmless, we just don't have it -->
5090  </xsl:choose>
5091</xsl:param>
5092
5093</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.