source: rfc2629xslt/rfc2629.xslt @ 229

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

Update to latest version of rfc2629.xslt (matching xml2rfc 1.33).

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