source: rfc2629xslt/rfc2629.xslt @ 560

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

update to latest version of rfc2629.xslt

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