source: rfc2629xslt/rfc2629.xslt @ 446

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

Update to latest version of rfc2629.xslt, and add experimental version of xml2rfc.tcl (supporting the new IPR escape clause), use that clause in P1..P7 (but not for the method registrations).

  • Property svn:eol-style set to native
File size: 206.4 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()">
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}</xsl:if>
2804table.header {
2805  width: 95%;
2806  font-size: 10pt;
2807  color: white;
2808}
2809td.top {
2810  vertical-align: top;
2811}
2812td.topnowrap {
2813  vertical-align: top;
2814  white-space: nowrap;
2815}
2816td.header {
2817  background-color: gray;
2818  width: 50%;
2819}<xsl:if test="/rfc/@obsoletes | /rfc/@updates">
2820td.header a {
2821  color: white;
2822}</xsl:if>
2823td.reference {
2824  vertical-align: top;
2825  white-space: nowrap;
2826  padding-right: 1em;
2827}
2828thead {
2829  display:table-header-group;
2830}
2831ul.toc {
2832  list-style: none;
2833  margin-left: 1.5em;
2834  margin-right: 0em;
2835  padding-left: 0em;
2836}
2837li.tocline0 {
2838  line-height: 150%;
2839  font-weight: bold;
2840  font-size: 10pt;
2841  margin-left: 0em;
2842  margin-right: 0em;
2843}
2844li.tocline1 {
2845  line-height: normal;
2846  font-weight: normal;
2847  font-size: 9pt;
2848  margin-left: 0em;
2849  margin-right: 0em;
2850}
2851li.tocline2 {
2852  font-size: 0pt;
2853}
2854ul p {
2855  margin-left: 0em;
2856}
2857<xsl:if test="$has-index">ul.ind {
2858  list-style: none;
2859  margin-left: 1.5em;
2860  margin-right: 0em;
2861  padding-left: 0em;
2862  page-break-before: avoid;
2863}
2864li.indline0 {
2865  font-weight: bold;
2866  line-height: 200%;
2867  margin-left: 0em;
2868  margin-right: 0em;
2869}
2870li.indline1 {
2871  font-weight: normal;
2872  line-height: 150%;
2873  margin-left: 0em;
2874  margin-right: 0em;
2875}
2876</xsl:if><xsl:if test="//x:bcp14">.bcp14 {
2877  font-style: normal;
2878  text-transform: lowercase;
2879  font-variant: small-caps;
2880}</xsl:if><xsl:if test="//x:blockquote">
2881blockquote > * .bcp14 {
2882  font-style: italic;
2883}</xsl:if>
2884.comment {
2885  background-color: yellow;
2886}<xsl:if test="$xml2rfc-editing='yes'">
2887.editingmark {
2888  background-color: khaki;
2889}</xsl:if>
2890.center {
2891  text-align: center;
2892}
2893.error {
2894  color: red;
2895  font-style: italic;
2896  font-weight: bold;
2897}
2898.figure {
2899  font-weight: bold;
2900  text-align: center;
2901  font-size: 9pt;
2902}
2903.filename {
2904  color: #333333;
2905  font-weight: bold;
2906  font-size: 12pt;
2907  line-height: 21pt;
2908  text-align: center;
2909}
2910.fn {
2911  font-weight: bold;
2912}
2913.hidden {
2914  display: none;
2915}
2916.left {
2917  text-align: left;
2918}
2919.right {
2920  text-align: right;
2921}
2922.title {
2923  color: #990000;
2924  font-size: 18pt;
2925  line-height: 18pt;
2926  font-weight: bold;
2927  text-align: center;
2928  margin-top: 36pt;
2929}
2930.vcardline {
2931  display: block;
2932}
2933.warning {
2934  font-size: 14pt;
2935  background-color: yellow;
2936}
2937<xsl:if test="$has-edits">del {
2938  color: red;
2939  text-decoration: line-through;
2940}
2941.del {
2942  color: red;
2943  text-decoration: line-through;
2944}
2945ins {
2946  color: green;
2947  text-decoration: underline;
2948}
2949.ins {
2950  color: green;
2951  text-decoration: underline;
2952}
2953div.issuepointer {
2954  float: left;
2955}</xsl:if><xsl:if test="//ed:issue">
2956table.openissue {
2957  background-color: khaki;
2958  border-width: thin;
2959  border-style: solid;
2960  border-color: black;
2961}
2962table.closedissue {
2963  background-color: white;
2964  border-width: thin;
2965  border-style: solid;
2966  border-color: gray;
2967  color: gray;
2968}
2969thead th {
2970  text-align: left;
2971}
2972.bg-issue {
2973  border: solid;
2974  border-width: 1px;
2975  font-size: 7pt;
2976}
2977.closed-issue {
2978  border: solid;
2979  border-width: thin;
2980  background-color: lime;
2981  font-size: smaller;
2982  font-weight: bold;
2983}
2984.open-issue {
2985  border: solid;
2986  border-width: thin;
2987  background-color: red;
2988  font-size: smaller;
2989  font-weight: bold;
2990}
2991.editor-issue {
2992  border: solid;
2993  border-width: thin;
2994  background-color: yellow;
2995  font-size: smaller;
2996  font-weight: bold;
2997}</xsl:if>
2998
2999@media print {
3000  .noprint {
3001    display: none;
3002  }
3003 
3004  a {
3005    color: black;
3006    text-decoration: none;
3007  }
3008
3009  table.header {
3010    width: 90%;
3011  }
3012
3013  td.header {
3014    width: 50%;
3015    color: black;
3016    background-color: white;
3017    vertical-align: top;
3018    font-size: 12pt;
3019  }
3020
3021  ul.toc a::after {
3022    content: leader('.') target-counter(attr(href), page);
3023  }
3024 
3025  a.iref {
3026    content: target-counter(attr(href), page);
3027  }
3028 
3029  .print2col {
3030    column-count: 2;
3031    -moz-column-count: 2;<!-- for Firefox -->
3032    column-fill: auto;<!-- for PrinceXML -->
3033  }
3034<xsl:if test="$xml2rfc-ext-justification='print'">
3035  dd {
3036    text-align: justify;
3037  }
3038  li {
3039    text-align: justify;
3040  }
3041  p {
3042    text-align: justify;
3043  }
3044</xsl:if>}
3045
3046@page {
3047  @top-left {
3048       content: "<xsl:call-template name="get-header-left"/>";
3049  }
3050  @top-right {
3051       content: "<xsl:call-template name="get-header-right"/>";
3052  }
3053  @top-center {
3054       content: "<xsl:call-template name="get-header-center"/>";
3055  }
3056  @bottom-left {
3057       content: "<xsl:call-template name="get-author-summary"/>";
3058  }
3059  @bottom-center {
3060       content: "<xsl:call-template name="get-category-long"/>";
3061  }
3062  @bottom-right {
3063       content: "[Page " counter(page) "]";
3064  }
3065}
3066
3067@page:first {
3068    @top-left {
3069      content: normal;
3070    }
3071    @top-right {
3072      content: normal;
3073    }
3074    @top-center {
3075      content: normal;
3076    }
3077}
3078</xsl:template>
3079
3080
3081<!-- generate the index section -->
3082
3083<xsl:template name="insertSingleIref">
3084  <xsl:choose>
3085    <xsl:when test="@ed:xref">
3086      <!-- special index generator mode -->
3087      <xsl:text>[</xsl:text>
3088      <a href="#{@ed:xref}"><xsl:value-of select="@ed:xref"/></a>
3089      <xsl:text>, </xsl:text>
3090      <a>
3091        <xsl:variable name="htmluri" select="//reference[@anchor=current()/@ed:xref]/format[@type='HTML']/@target"/>
3092        <xsl:if test="$htmluri">
3093          <xsl:attribute name="href"><xsl:value-of select="concat($htmluri,'#',@ed:frag)"/></xsl:attribute>
3094        </xsl:if>       
3095        <xsl:choose>
3096          <xsl:when test="@primary='true'"><b><xsl:value-of select="@ed:label" /></b></xsl:when>
3097          <xsl:otherwise><xsl:value-of select="@ed:label" /></xsl:otherwise>
3098        </xsl:choose>
3099      </a>
3100      <xsl:text>]</xsl:text>
3101      <xsl:if test="position()!=last()">, </xsl:if>
3102    </xsl:when>
3103    <xsl:otherwise>
3104      <xsl:variable name="_n">
3105        <xsl:call-template name="get-section-number" />
3106      </xsl:variable>
3107      <xsl:variable name="n">
3108        <xsl:choose>
3109          <xsl:when test="$_n!=''">
3110            <xsl:value-of select="$_n"/>
3111          </xsl:when>
3112          <xsl:otherwise>&#167;</xsl:otherwise>
3113        </xsl:choose>
3114      </xsl:variable>
3115      <xsl:variable name="backlink">
3116        <xsl:choose>
3117          <xsl:when test="self::xref">
3118            <xsl:variable name="target" select="@target"/>
3119            <xsl:text>#</xsl:text>
3120            <xsl:value-of select="$anchor-prefix"/>
3121            <xsl:text>.xref.</xsl:text>
3122            <xsl:value-of select="@target"/>.<xsl:number level="any" count="xref[@target=$target]"/>
3123          </xsl:when>
3124          <xsl:when test="self::iref">
3125            <xsl:text>#</xsl:text>
3126            <xsl:call-template name="compute-iref-anchor"/>
3127          </xsl:when>
3128          <xsl:when test="self::x:ref">
3129            <xsl:text>#</xsl:text>
3130            <xsl:call-template name="compute-extref-anchor"/>
3131          </xsl:when>
3132          <xsl:otherwise>
3133            <xsl:message>Unsupported element type for insertSingleIref</xsl:message>
3134          </xsl:otherwise>
3135        </xsl:choose>
3136      </xsl:variable>
3137      <a class="iref" href="{$backlink}">
3138        <xsl:call-template name="insertInsDelClass"/>
3139        <xsl:choose>
3140          <xsl:when test="@primary='true'"><b><xsl:value-of select="$n"/></b></xsl:when>
3141          <xsl:otherwise><xsl:value-of select="$n"/></xsl:otherwise>
3142        </xsl:choose>
3143      </a>
3144      <xsl:if test="position()!=last()">, </xsl:if>
3145    </xsl:otherwise>
3146  </xsl:choose>
3147</xsl:template>
3148
3149<xsl:template name="insertSingleXref">
3150  <xsl:variable name="_n">
3151    <xsl:call-template name="get-section-number" />
3152  </xsl:variable>
3153  <xsl:variable name="n">
3154    <xsl:choose>
3155      <xsl:when test="$_n!=''">
3156        <xsl:value-of select="$_n"/>
3157      </xsl:when>
3158      <xsl:otherwise>&#167;</xsl:otherwise>
3159    </xsl:choose>
3160  </xsl:variable>
3161  <xsl:choose>
3162    <xsl:when test="self::reference">
3163      <a class="iref" href="#{@anchor}">
3164        <xsl:call-template name="insertInsDelClass"/>
3165        <b><xsl:value-of select="$n"/></b>
3166      </a>
3167    </xsl:when>
3168    <xsl:otherwise>
3169      <xsl:variable name="target" select="@target"/>
3170      <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>
3171      <a class="iref" href="{$backlink}">
3172        <xsl:call-template name="insertInsDelClass"/>
3173        <xsl:value-of select="$n"/>
3174      </a>
3175    </xsl:otherwise>
3176  </xsl:choose>
3177  <xsl:if test="position()!=last()">, </xsl:if>
3178</xsl:template>
3179
3180<xsl:template name="insertIndex">
3181
3182  <xsl:call-template name="insert-conditional-hrule"/>
3183
3184  <h1 id="{$anchor-prefix}.index">
3185    <xsl:call-template name="insert-conditional-pagebreak"/>
3186    <a href="#{$anchor-prefix}.index">Index</a>
3187  </h1>
3188 
3189  <!-- generate navigation links to index subsections -->
3190  <p class="noprint">
3191    <xsl:variable name="irefs" select="//iref[generate-id(.) = generate-id(key('index-first-letter',translate(substring(@item,1,1),$lcase,$ucase)))]"/>
3192    <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)))]"/>
3193 
3194    <xsl:for-each select="$irefs | $xrefs">
3195   
3196      <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)" />
3197         
3198      <xsl:variable name="letter" select="translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase)"/>
3199
3200      <!-- character? -->
3201      <xsl:if test="translate($letter,concat($lcase,$ucase,'0123456789'),'')=''">
3202     
3203        <xsl:variable name="showit">
3204          <xsl:choose>
3205            <xsl:when test="$xml2rfc-ext-include-references-in-index!='yes'">
3206              <xsl:if test="$irefs[starts-with(translate(@item,$lcase,$ucase),$letter)]">
3207                <xsl:text>yes</xsl:text>
3208              </xsl:if>
3209            </xsl:when>
3210            <xsl:otherwise>
3211              <xsl:text>yes</xsl:text>
3212            </xsl:otherwise>
3213          </xsl:choose>
3214        </xsl:variable>
3215       
3216        <xsl:if test="$showit='yes'">
3217          <a href="#{$anchor-prefix}.index.{$letter}">
3218            <xsl:value-of select="$letter" />
3219          </a>
3220          <xsl:text> </xsl:text>
3221        </xsl:if>
3222     
3223      </xsl:if>
3224
3225    </xsl:for-each>
3226  </p>
3227
3228  <!-- for each index subsection -->
3229  <div class="print2col">
3230  <ul class="ind">
3231    <xsl:variable name="irefs2" select="//iref[generate-id(.) = generate-id(key('index-first-letter',translate(substring(@item,1,1),$lcase,$ucase)))]"/>
3232    <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)))]"/>
3233 
3234    <xsl:for-each select="$irefs2 | $xrefs2">
3235      <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)" />
3236      <xsl:variable name="letter" select="translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase)"/>
3237           
3238      <xsl:variable name="showit">
3239        <xsl:choose>
3240          <xsl:when test="$xml2rfc-ext-include-references-in-index!='yes'">
3241            <xsl:if test="$irefs2[starts-with(translate(@item,$lcase,$ucase),$letter)]">
3242              <xsl:text>yes</xsl:text>
3243            </xsl:if>
3244          </xsl:when>
3245          <xsl:otherwise>
3246            <xsl:text>yes</xsl:text>
3247          </xsl:otherwise>
3248        </xsl:choose>
3249      </xsl:variable>
3250
3251      <xsl:if test="$showit='yes'">
3252        <li class="indline0">
3253         
3254          <!-- make letters and digits stand out -->
3255          <xsl:choose>
3256            <xsl:when test="translate($letter,concat($lcase,$ucase,'0123456789'),'')=''">
3257              <a id="{$anchor-prefix}.index.{$letter}" href="#{$anchor-prefix}.index.{$letter}">
3258                <b><xsl:value-of select="$letter" /></b>
3259              </a>
3260            </xsl:when>
3261            <xsl:otherwise>
3262              <b><xsl:value-of select="$letter" /></b>
3263            </xsl:otherwise>
3264          </xsl:choose>
3265       
3266          <ul class="ind"> 
3267            <xsl:for-each select="key('index-first-letter',translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase))">
3268       
3269              <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)" />
3270             
3271                <xsl:choose>
3272                  <xsl:when test="self::reference">
3273                    <xsl:if test="$xml2rfc-ext-include-references-in-index='yes' and not(starts-with(@anchor,'deleted-'))">
3274                      <li class="indline1">
3275                        <em>
3276                          <xsl:value-of select="@anchor"/>
3277                        </em>
3278                        <xsl:text>&#160;&#160;</xsl:text>
3279                       
3280                        <xsl:variable name="rs" select="key('xref-item',current()/@anchor) | . | key('anchor-item',concat('deleted-',current()/@anchor))"/>
3281                       
3282                        <xsl:for-each select="$rs">
3283                          <xsl:call-template name="insertSingleXref" />
3284                        </xsl:for-each>
3285
3286                        <xsl:variable name="rs2" select="$rs[@x:sec]"/>
3287
3288                        <xsl:if test="$rs2">
3289                          <ul class="ind"> 
3290                            <xsl:for-each select="$rs2">
3291                              <xsl:sort select="substring-before(concat(@x:sec,'.'),'.')" data-type="number"/>
3292                              <xsl:sort select="substring(@x:sec,1+string-length(substring-before(@x:sec,'.')))" data-type="number"/>
3293                              <xsl:if test="generate-id(.) = generate-id(key('index-xref-by-sec',concat(@target,'..',@x:sec)))">
3294                                <li class="indline1">
3295                                  <em>
3296                                    <xsl:choose>
3297                                      <xsl:when test="translate(substring(@x:sec,1,1),$ucase,'')=''">
3298                                        <xsl:text>Appendix </xsl:text>
3299                                      </xsl:when>
3300                                      <xsl:otherwise>
3301                                        <xsl:text>Section </xsl:text>
3302                                      </xsl:otherwise>
3303                                    </xsl:choose>
3304                                    <xsl:value-of select="@x:sec"/>
3305                                  </em>
3306                                  <xsl:text>&#160;&#160;</xsl:text>
3307                                  <xsl:for-each select="key('index-xref-by-sec',concat(@target,'..',@x:sec))">
3308                                    <xsl:call-template name="insertSingleXref" />
3309                                  </xsl:for-each>
3310                                </li>
3311                              </xsl:if>
3312                            </xsl:for-each>
3313                          </ul>
3314                        </xsl:if>
3315
3316                        <xsl:if test="current()/x:source/@href">
3317                          <xsl:variable name="rs3" select="$rs[not(@x:sec) and @x:rel]"/>
3318                          <xsl:variable name="doc" select="document(current()/x:source/@href)"/>
3319                          <xsl:if test="$rs3">
3320                            <ul class="ind"> 
3321                              <xsl:for-each select="$rs3">
3322                                <xsl:sort select="count($doc//*[@anchor and following::*/@anchor=substring-after(current()/@x:rel,'#')])" order="ascending" data-type="number"/>
3323                                <xsl:if test="generate-id(.) = generate-id(key('index-xref-by-anchor',concat(@target,'..',@x:rel)))">
3324                                  <li class="indline1">
3325                                    <em>
3326                                      <xsl:variable name="sec">
3327                                        <xsl:for-each select="$doc//*[@anchor=substring-after(current()/@x:rel,'#')]">
3328                                          <xsl:call-template name="get-section-number"/>
3329                                        </xsl:for-each>
3330                                      </xsl:variable>
3331                                      <xsl:choose>
3332                                        <xsl:when test="translate(substring($sec,1,1),$ucase,'')=''">
3333                                          <xsl:text>Appendix </xsl:text>
3334                                        </xsl:when>
3335                                        <xsl:otherwise>
3336                                          <xsl:text>Section </xsl:text>
3337                                        </xsl:otherwise>
3338                                      </xsl:choose>
3339                                      <xsl:value-of select="$sec"/>
3340                                    </em>
3341                                    <xsl:text>&#160;&#160;</xsl:text>
3342                                    <xsl:for-each select="key('index-xref-by-anchor',concat(@target,'..',@x:rel))">
3343                                      <xsl:call-template name="insertSingleXref" />
3344                                    </xsl:for-each>
3345                                  </li>
3346                                </xsl:if>
3347                              </xsl:for-each>
3348                            </ul>
3349                          </xsl:if>
3350                        </xsl:if>
3351                      </li>
3352                    </xsl:if>
3353                  </xsl:when>
3354                  <xsl:otherwise>
3355                    <!-- regular iref -->
3356                    <xsl:if test="generate-id(.) = generate-id(key('index-item',concat(@item,@anchor)))">
3357                      <xsl:variable name="item" select="@item"/>
3358                      <xsl:variable name="in-artwork" select="key('index-item',$item)[@primary='true' and ancestor::artwork]"/>
3359                         
3360                      <li class="indline1">
3361                        <xsl:choose>
3362                          <xsl:when test="$in-artwork">
3363                            <tt><xsl:value-of select="@item" /></tt>
3364                          </xsl:when>
3365                          <xsl:otherwise>
3366                            <xsl:value-of select="@item" />
3367                          </xsl:otherwise>
3368                        </xsl:choose>
3369                        <xsl:text>&#160;&#160;</xsl:text>
3370                       
3371                        <xsl:variable name="irefs3" select="key('index-item',@item)[not(@subitem) or @subitem='']"/>
3372                        <xsl:variable name="xrefs3" select="key('xref-item',$irefs3[@x:for-anchor='']/../@anchor) | key('xref-item',$irefs3/@x:for-anchor)"/>
3373                        <xsl:variable name="extrefs3" select="key('extref-item',$irefs3[@x:for-anchor='']/../@anchor) | key('extref-item',$irefs3/@x:for-anchor)"/>
3374
3375                        <xsl:for-each select="$irefs3|$xrefs3|$extrefs3">
3376                          <!-- <xsl:sort select="translate(@item,$lcase,$ucase)" />  -->
3377                          <xsl:call-template name="insertSingleIref" />
3378                        </xsl:for-each>
3379         
3380                        <xsl:variable name="s2" select="key('index-item',@item)[@subitem and @subitem!='']"/>
3381                        <xsl:if test="$s2">
3382                          <ul class="ind"> 
3383                            <xsl:for-each select="$s2">
3384                              <xsl:sort select="translate(@subitem,$lcase,$ucase)" />
3385                             
3386                              <xsl:if test="generate-id(.) = generate-id(key('index-item-subitem',concat(@item,'..',@subitem)))">
3387                 
3388                                <xsl:variable name="in-artwork2" select="key('index-item-subitem',concat(@item,'..',@subitem))[@primary='true' and ancestor::artwork]" />
3389                 
3390                                <li class="indline1">
3391             
3392                                  <xsl:choose>
3393                                    <xsl:when test="$in-artwork2">
3394                                      <tt><xsl:value-of select="@subitem" /></tt>
3395                                    </xsl:when>
3396                                    <xsl:otherwise>
3397                                      <xsl:value-of select="@subitem" />
3398                                    </xsl:otherwise>
3399                                  </xsl:choose>
3400                                  <xsl:text>&#160;&#160;</xsl:text>
3401                                   
3402                                  <xsl:variable name="irefs4" select="key('index-item-subitem',concat(@item,'..',@subitem))"/>
3403                                  <xsl:variable name="xrefs4" select="key('xref-item',$irefs4[@x:for-anchor='']/../@anchor) | key('xref-item',$irefs4/@x:for-anchor)"/>
3404                                  <xsl:variable name="extrefs4" select="key('extref-item',$irefs4[@x:for-anchor='']/../@anchor) | key('extref-item',$irefs4/@x:for-anchor)"/>
3405
3406                                  <xsl:for-each select="$irefs4|$xrefs4|$extrefs4">
3407                                    <!--<xsl:sort select="translate(@item,$lcase,$ucase)" />-->                   
3408                                    <xsl:call-template name="insertSingleIref" />
3409                                  </xsl:for-each>
3410               
3411                                </li>
3412                              </xsl:if>
3413                            </xsl:for-each>
3414                          </ul>
3415                        </xsl:if>
3416                      </li>
3417                    </xsl:if>
3418                  </xsl:otherwise>
3419                </xsl:choose>
3420             
3421                     
3422            </xsl:for-each>           
3423          </ul>
3424        </li>
3425      </xsl:if>
3426     
3427    </xsl:for-each>
3428  </ul>
3429  </div>
3430 
3431</xsl:template>
3432
3433
3434
3435
3436<xsl:template name="insertPreamble" myns:namespaceless-elements="xml2rfc">
3437
3438  <section myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.status">
3439  <xsl:attribute name="title">
3440    <xsl:choose>
3441      <xsl:when test="$xml2rfc-rfcedstyle='yes'">Status of This Memo</xsl:when>
3442      <xsl:otherwise>Status of this Memo</xsl:otherwise>
3443    </xsl:choose>
3444  </xsl:attribute>
3445
3446  <xsl:choose>
3447    <xsl:when test="/rfc/@ipr and not(/rfc/@number)">
3448      <t>
3449        <xsl:choose>
3450         
3451          <!-- RFC2026 -->
3452          <xsl:when test="/rfc/@ipr = 'full2026'">
3453            This document is an Internet-Draft and is
3454            in full conformance with all provisions of Section 10 of RFC2026.   
3455          </xsl:when>
3456          <xsl:when test="/rfc/@ipr = 'noDerivativeWorks2026'">
3457            This document is an Internet-Draft and is
3458            in full conformance with all provisions of Section 10 of RFC2026
3459            except that the right to produce derivative works is not granted.   
3460          </xsl:when>
3461          <xsl:when test="/rfc/@ipr = 'noDerivativeWorksNow'">
3462            This document is an Internet-Draft and is
3463            in full conformance with all provisions of Section 10 of RFC2026
3464            except that the right to produce derivative works is not granted.
3465            (If this document becomes part of an IETF working group activity,
3466            then it will be brought into full compliance with Section 10 of RFC2026.) 
3467          </xsl:when>
3468          <xsl:when test="/rfc/@ipr = 'none'">
3469            This document is an Internet-Draft and is
3470            NOT offered in accordance with Section 10 of RFC2026,
3471            and the author does not provide the IETF with any rights other
3472            than to publish as an Internet-Draft.
3473          </xsl:when>
3474         
3475          <!-- RFC3667 -->
3476          <xsl:when test="/rfc/@ipr = 'full3667'">
3477            This document is an Internet-Draft and is subject to all provisions
3478            of section 3 of RFC 3667.  By submitting this Internet-Draft, each
3479            author represents that any applicable patent or other IPR claims of
3480            which he or she is aware have been or will be disclosed, and any of
3481            which he or she become aware will be disclosed, in accordance with
3482            RFC 3668.
3483          </xsl:when>
3484          <xsl:when test="/rfc/@ipr = 'noModification3667'">
3485            This document is an Internet-Draft and is subject to all provisions
3486            of section 3 of RFC 3667.  By submitting this Internet-Draft, each
3487            author represents that any applicable patent or other IPR claims of
3488            which he or she is aware have been or will be disclosed, and any of
3489            which he or she become aware will be disclosed, in accordance with
3490            RFC 3668.  This document may not be modified, and derivative works of
3491            it may not be created, except to publish it as an RFC and to
3492            translate it into languages other than English<xsl:if test="/rfc/@iprExtract">,
3493            other than to extract <xref target="{/rfc/@iprExtract}"/> as-is
3494            for separate use.</xsl:if>.
3495          </xsl:when>
3496          <xsl:when test="/rfc/@ipr = 'noDerivatives3667'">
3497            This document is an Internet-Draft and is subject to all provisions
3498            of section 3 of RFC 3667 except for the right to produce derivative
3499            works.  By submitting this Internet-Draft, each author represents
3500            that any applicable patent or other IPR claims of which he or she
3501            is aware have been or will be disclosed, and any of which he or she
3502            become aware will be disclosed, in accordance with RFC 3668.  This
3503            document may not be modified, and derivative works of it may
3504            not be created<xsl:if test="/rfc/@iprExtract">, other than to extract
3505            <xref target="{/rfc/@iprExtract}"/> as-is for separate use.</xsl:if>.
3506          </xsl:when>
3507         
3508          <!-- RFC3978 -->
3509          <xsl:when test="/rfc/@ipr = 'full3978'">
3510            By submitting this Internet-Draft, each
3511            author represents that any applicable patent or other IPR claims of
3512            which he or she is aware have been or will be disclosed, and any of
3513            which he or she becomes aware will be disclosed, in accordance with
3514            Section 6 of BCP 79.
3515          </xsl:when>
3516          <xsl:when test="/rfc/@ipr = 'noModification3978'">
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.  This document may not be modified, and derivative works of
3522            it may not be created, except to publish it as an RFC and to
3523            translate it into languages other than English<xsl:if test="/rfc/@iprExtract">,
3524            other than to extract <xref target="{/rfc/@iprExtract}"/> as-is
3525            for separate use.</xsl:if>.
3526          </xsl:when>
3527          <xsl:when test="/rfc/@ipr = 'noDerivatives3978'">
3528            By submitting this Internet-Draft, each author represents
3529            that any applicable patent or other IPR claims of which he or she
3530            is aware have been or will be disclosed, and any of which he or she
3531            becomes aware will be disclosed, in accordance with Section 6 of BCP 79.  This
3532            document may not be modified, and derivative works of it may
3533            not be created<xsl:if test="/rfc/@iprExtract">, other than to extract
3534            <xref target="{/rfc/@iprExtract}"/> as-is for separate use.</xsl:if>.
3535          </xsl:when>
3536 
3537          <!-- as of Nov 2008 -->
3538          <xsl:when test="/rfc/@ipr = 'trust200811'">
3539            This Internet-Draft is submitted to IETF pursuant to, and in full
3540            conformance with, the provisions of BCP 78 and BCP 79.
3541          </xsl:when>
3542          <xsl:when test="/rfc/@ipr = 'noModificationTrust200811'">
3543            This Internet-Draft is submitted to IETF pursuant to, and in full
3544            conformance with, the provisions of BCP 78 and BCP 79.
3545            This document may not be modified, and derivative works of it may
3546            not be created, except to format it for publication as an RFC and
3547            to translate it into languages other than English.
3548          </xsl:when>
3549          <xsl:when test="/rfc/@ipr = 'noDerivativesTrust200811'">
3550            This Internet-Draft is submitted to IETF pursuant to, and in full
3551            conformance with, the provisions of BCP 78 and BCP 79.
3552            This document may not be modified, and derivative works of it may
3553            not be created, and it may not be published except as an Internet-Draft.
3554          </xsl:when>
3555 
3556          <!-- as of Feb 2009 -->
3557          <xsl:when test="/rfc/@ipr = 'trust200902'">
3558            This Internet-Draft is submitted to IETF pursuant to, and in full
3559            conformance with, the provisions of BCP 78 and BCP 79.
3560          </xsl:when>
3561          <xsl:when test="/rfc/@ipr = 'noModificationTrust200902'">
3562            This Internet-Draft is submitted to IETF pursuant to, and in full
3563            conformance with, the provisions of BCP 78 and BCP 79.
3564            This document may not be modified, and derivative works of it may
3565            not be created, except to format it for publication as an RFC or
3566            to translate it into languages other than English.
3567          </xsl:when>
3568          <xsl:when test="/rfc/@ipr = 'noDerivativesTrust200902'">
3569            This Internet-Draft is submitted to IETF pursuant to, and in full
3570            conformance with, the provisions of BCP 78 and BCP 79.
3571            This document may not be modified, and derivative works of it may
3572            not be created, and it may not be published except as an Internet-Draft.
3573          </xsl:when>
3574          <xsl:when test="/rfc/@ipr = 'pre5378Trust200902'">
3575            This Internet-Draft is submitted to IETF pursuant to, and in full
3576            conformance with, the provisions of BCP 78 and BCP 79.
3577            This document may contain material from IETF Documents or IETF Contributions published or
3578            made publicly available before November 10, 2008. The person(s) controlling the copyright in
3579            some of this material may not have granted the IETF Trust the right to allow modifications of such
3580            material outside the IETF Standards Process. Without obtaining an adequate license from the
3581            person(s) controlling the copyright in such materials, this document may not be modified outside
3582            the IETF Standards Process, and derivative works of it may not be created outside the IETF
3583            Standards Process, except to format it for publication as an RFC or to translate it into languages
3584            other than English.
3585          </xsl:when>
3586 
3587          <xsl:otherwise>
3588            CONFORMANCE UNDEFINED.
3589          </xsl:otherwise>
3590        </xsl:choose>
3591      </t>
3592      <t>
3593        Internet-Drafts are working documents of the Internet Engineering
3594        Task Force (IETF), its areas, and its working groups.
3595        Note that other groups may also distribute working documents as
3596        Internet-Drafts.
3597      </t>
3598      <t>
3599        Internet-Drafts are draft documents valid for a maximum of six months
3600        and may be updated, replaced, or obsoleted by other documents at any time.
3601        It is inappropriate to use Internet-Drafts as reference material or to cite
3602        them other than as &#8220;work in progress&#8221;.
3603      </t>
3604      <t>
3605        The list of current Internet-Drafts can be accessed at
3606        <eref target='http://www.ietf.org/ietf/1id-abstracts.txt'/>.
3607      </t>
3608      <t>
3609        The list of Internet-Draft Shadow Directories can be accessed at
3610        <eref target='http://www.ietf.org/shadow.html'/>.
3611      </t>
3612      <t>
3613        This Internet-Draft will expire in <xsl:call-template name="expirydate" />.
3614      </t>
3615    </xsl:when>
3616
3617    <xsl:when test="/rfc/@category='bcp'">
3618      <t>
3619        This document specifies an Internet Best Current Practices for the Internet
3620        Community, and requests discussion and suggestions for improvements.
3621        Distribution of this memo is unlimited.
3622      </t>
3623    </xsl:when>
3624    <xsl:when test="/rfc/@category='exp'">
3625      <t>
3626        This memo defines an Experimental Protocol for the Internet community.
3627        It does not specify an Internet standard of any kind.
3628        Discussion and suggestions for improvement are requested.
3629        Distribution of this memo is unlimited.
3630      </t>
3631    </xsl:when>
3632    <xsl:when test="/rfc/@category='historic'">
3633      <t>
3634        This memo describes a historic protocol for the Internet community.
3635        It does not specify an Internet standard of any kind.
3636        Distribution of this memo is unlimited.
3637      </t>
3638    </xsl:when>
3639    <xsl:when test="/rfc/@category='info' or not(/rfc/@category)">
3640      <t>
3641        This memo provides information for the Internet community.
3642        It does not specify an Internet standard of any kind.
3643        Distribution of this memo is unlimited.
3644      </t>
3645    </xsl:when>
3646    <xsl:when test="/rfc/@category='std'">
3647      <t>
3648        This document specifies an Internet standards track protocol for the Internet
3649        community, and requests discussion and suggestions for improvements.
3650        Please refer to the current edition of the &#8220;Internet Official Protocol
3651        Standards&#8221; (STD 1) for the standardization state and status of this
3652        protocol. Distribution of this memo is unlimited.
3653      </t>
3654    </xsl:when>
3655    <xsl:otherwise>
3656      <t>UNSUPPORTED CATEGORY.</t>
3657    </xsl:otherwise>
3658  </xsl:choose>
3659  </section>
3660 
3661  <xsl:choose>
3662    <xsl:when test="$ipr-2008-11">
3663      <section title="Copyright Notice" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.copyrightnotice">
3664        <t>
3665          Copyright &#169; <xsl:value-of select="$xml2rfc-ext-pub-year" /> IETF Trust and the persons identified
3666          as the document authors.  All rights reserved.
3667        </t>
3668        <xsl:choose>
3669          <xsl:when test="$ipr-2009-02">
3670            <t>
3671              This document is subject to BCP 78 and the IETF Trust's Legal
3672              Provisions Relating to IETF Documents in effect on the date of
3673              publication of this document
3674              (<eref target="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</eref>).
3675              Please review these documents carefully, as they describe your rights and restrictions with
3676              respect to this document.
3677            </t>
3678          </xsl:when>
3679          <xsl:otherwise>
3680            <t>
3681              This document is subject to BCP 78 and the IETF Trust's Legal
3682              Provisions Relating to IETF Documents
3683              (<eref target="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</eref>) in effect on the date of
3684              publication of this document.  Please review these documents
3685              carefully, as they describe your rights and restrictions with respect
3686              to this document.
3687            </t>
3688          </xsl:otherwise>
3689        </xsl:choose>
3690       
3691        <!-- special case: RFC5378 escape applies to RFCs as well -->
3692        <xsl:if test="/rfc/@ipr = 'pre5378Trust200902' and /rfc/@number">
3693          <t>
3694            This document may contain material from IETF Documents or IETF Contributions published or
3695            made publicly available before November 10, 2008. The person(s) controlling the copyright in
3696            some of this material may not have granted the IETF Trust the right to allow modifications of such
3697            material outside the IETF Standards Process. Without obtaining an adequate license from the
3698            person(s) controlling the copyright in such materials, this document may not be modified outside
3699            the IETF Standards Process, and derivative works of it may not be created outside the IETF
3700            Standards Process, except to format it for publication as an RFC or to translate it into languages
3701            other than English.
3702          </t>
3703        </xsl:if>
3704       
3705      </section>
3706    </xsl:when>
3707    <xsl:when test="$ipr-2007-08">
3708      <!-- no copyright notice -->
3709    </xsl:when>
3710    <xsl:when test="$ipr-rfc4748">
3711      <section title="Copyright Notice" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.copyrightnotice">
3712        <t>
3713          Copyright &#169; The IETF Trust (<xsl:value-of select="$xml2rfc-ext-pub-year" />).  All Rights Reserved.
3714        </t>
3715      </section>
3716    </xsl:when>
3717    <xsl:otherwise>
3718      <section title="Copyright Notice" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.copyrightnotice">
3719        <t>
3720          Copyright &#169; The Internet Society (<xsl:value-of select="$xml2rfc-ext-pub-year" />).  All Rights Reserved.
3721        </t>
3722      </section>
3723    </xsl:otherwise>
3724  </xsl:choose>
3725 
3726</xsl:template>
3727
3728<!-- TOC generation -->
3729
3730<xsl:template match="/" mode="toc">
3731  <hr class="noprint"/>
3732
3733  <h1 class="np" id="{$anchor-prefix}.toc"> <!-- this pagebreak occurs always -->
3734    <a href="#{$anchor-prefix}.toc">Table of Contents</a>
3735  </h1>
3736
3737  <ul class="toc">
3738    <xsl:apply-templates mode="toc" />
3739  </ul>
3740</xsl:template>
3741
3742<xsl:template name="insert-toc-line">
3743  <xsl:param name="number" />
3744  <xsl:param name="target" />
3745  <xsl:param name="title" />
3746  <xsl:param name="tocparam" />
3747  <xsl:param name="oldtitle" />
3748  <xsl:param name="waschanged" />
3749
3750  <!-- handle tocdepth parameter -->
3751  <xsl:choose>
3752    <xsl:when test="($tocparam='' or $tocparam='default') and string-length(translate($number,'.ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890&#167;','.')) &gt;= $parsedTocDepth">
3753      <!-- dropped entry because excluded -->
3754      <xsl:attribute name="class">tocline2</xsl:attribute>
3755    </xsl:when>
3756    <xsl:when test="$tocparam='exclude'">
3757      <!-- dropped entry because excluded -->
3758      <xsl:attribute name="class">tocline2</xsl:attribute>
3759    </xsl:when>
3760    <xsl:otherwise>
3761      <xsl:choose>
3762        <xsl:when test="starts-with($number,'del-')">
3763          <del>
3764            <xsl:value-of select="$number" />
3765            <a href="#{$target}"><xsl:value-of select="$title"/></a>
3766          </del>
3767        </xsl:when>
3768        <xsl:otherwise>
3769          <xsl:choose>
3770            <xsl:when test="not(contains($number,'.'))">
3771              <xsl:attribute name="class">tocline0</xsl:attribute>
3772            </xsl:when>
3773            <xsl:otherwise>
3774              <xsl:attribute name="class">tocline1</xsl:attribute>
3775            </xsl:otherwise>
3776          </xsl:choose>
3777          <xsl:if test="$number != ''">
3778            <xsl:call-template name="emit-section-number">
3779              <xsl:with-param name="no" select="$number"/>
3780            </xsl:call-template>
3781            <xsl:text>&#160;&#160;&#160;</xsl:text>
3782          </xsl:if>
3783          <a href="#{$target}">
3784            <xsl:choose>
3785              <xsl:when test="$waschanged!=''">
3786                <ins><xsl:value-of select="$title"/></ins>
3787                <del><xsl:value-of select="$oldtitle"/></del>
3788              </xsl:when>
3789              <xsl:otherwise>
3790                <xsl:value-of select="$title"/>
3791              </xsl:otherwise>
3792            </xsl:choose>
3793          </a>
3794        </xsl:otherwise>
3795      </xsl:choose>
3796    </xsl:otherwise>
3797  </xsl:choose>
3798</xsl:template>
3799
3800<xsl:template match="back" mode="toc">
3801
3802  <!-- <xsl:apply-templates select="references" mode="toc" /> -->
3803
3804  <xsl:if test="//cref and $xml2rfc-comments='yes' and $xml2rfc-inline!='yes'">
3805    <li>
3806      <xsl:call-template name="insert-toc-line">
3807        <xsl:with-param name="target" select="concat($anchor-prefix,'.comments')"/>
3808        <xsl:with-param name="title" select="'Editorial Comments'"/>
3809      </xsl:call-template>
3810    </li>
3811  </xsl:if>
3812
3813  <xsl:if test="$xml2rfc-ext-authors-section!='end'">
3814    <xsl:apply-templates select="/rfc/front" mode="toc" />
3815  </xsl:if>
3816  <xsl:apply-templates select="*[not(self::references)]" mode="toc" />
3817
3818  <xsl:if test="$xml2rfc-ext-authors-section='end'">
3819    <xsl:apply-templates select="/rfc/front" mode="toc" />
3820  </xsl:if>
3821
3822  <!-- copyright statements -->
3823  <xsl:if test="not($xml2rfc-private) and not($no-copylong)">
3824    <li>
3825      <xsl:call-template name="insert-toc-line">
3826        <xsl:with-param name="target" select="concat($anchor-prefix,'.ipr')"/>
3827        <xsl:with-param name="title" select="'Intellectual Property and Copyright Statements'"/>
3828      </xsl:call-template>
3829    </li>
3830  </xsl:if>
3831 
3832  <!-- insert the index if index entries exist -->
3833  <xsl:if test="//iref">
3834    <li>
3835      <xsl:call-template name="insert-toc-line">
3836        <xsl:with-param name="target" select="concat($anchor-prefix,'.index')"/>
3837        <xsl:with-param name="title" select="'Index'"/>
3838      </xsl:call-template>
3839    </li>
3840  </xsl:if>
3841
3842</xsl:template>
3843
3844<xsl:template match="front" mode="toc">
3845 
3846  <xsl:variable name="authors-title">
3847    <xsl:call-template name="get-authors-section-title"/>
3848  </xsl:variable>
3849  <xsl:variable name="authors-number">
3850    <xsl:call-template name="get-authors-section-number"/>
3851  </xsl:variable>
3852
3853  <xsl:if test="$authors-number!='suppress'">
3854    <li>
3855      <xsl:call-template name="insert-toc-line">
3856        <xsl:with-param name="target" select="concat($anchor-prefix,'.authors')"/>
3857        <xsl:with-param name="title" select="$authors-title"/>
3858        <xsl:with-param name="number" select="$authors-number"/>
3859      </xsl:call-template>
3860    </li>
3861  </xsl:if>
3862
3863</xsl:template>
3864
3865<xsl:template name="references-toc">
3866
3867  <!-- distinguish two cases: (a) single references element (process
3868  as toplevel section; (b) multiple references sections (add one toplevel
3869  container with subsection) -->
3870
3871  <xsl:variable name="refsecs" select="/rfc/back/references|/rfc/back/ed:replace/ed:ins/references"/>
3872   
3873  <xsl:choose>
3874    <xsl:when test="count($refsecs) = 0">
3875      <!-- nop -->
3876    </xsl:when>
3877    <xsl:when test="count($refsecs) = 1">
3878      <xsl:for-each select="$refsecs">
3879        <xsl:variable name="title">
3880          <xsl:choose>
3881            <xsl:when test="@title!=''"><xsl:value-of select="@title" /></xsl:when>
3882            <xsl:otherwise>References</xsl:otherwise>
3883          </xsl:choose>
3884        </xsl:variable>
3885     
3886        <li>
3887          <xsl:call-template name="insert-toc-line">
3888            <xsl:with-param name="number">
3889              <xsl:call-template name="get-references-section-number"/>
3890            </xsl:with-param>
3891            <xsl:with-param name="target" select="concat($anchor-prefix,'.references')"/>
3892            <xsl:with-param name="title" select="$title"/>
3893          </xsl:call-template>
3894        </li>
3895      </xsl:for-each>
3896    </xsl:when>
3897    <xsl:otherwise>
3898      <li>
3899        <!-- insert pseudo container -->   
3900        <xsl:call-template name="insert-toc-line">
3901          <xsl:with-param name="number">
3902            <xsl:call-template name="get-references-section-number"/>
3903          </xsl:with-param>
3904          <xsl:with-param name="target" select="concat($anchor-prefix,'.references')"/>
3905          <xsl:with-param name="title" select="'References'"/>
3906        </xsl:call-template>
3907 
3908        <ul class="toc">
3909          <!-- ...with subsections... -->   
3910          <xsl:for-each select="$refsecs">
3911            <xsl:variable name="title">
3912              <xsl:choose>
3913                <xsl:when test="@title!=''"><xsl:value-of select="@title" /></xsl:when>
3914                <xsl:otherwise>References</xsl:otherwise>
3915              </xsl:choose>
3916            </xsl:variable>
3917         
3918            <xsl:variable name="sectionNumber">
3919              <xsl:call-template name="get-section-number" />
3920            </xsl:variable>
3921   
3922            <xsl:variable name="num">
3923              <xsl:number level="any"/>
3924            </xsl:variable>
3925   
3926            <li>
3927              <xsl:call-template name="insert-toc-line">
3928                <xsl:with-param name="number" select="$sectionNumber"/>
3929                <xsl:with-param name="target" select="concat($anchor-prefix,'.references','.',$num)"/>
3930                <xsl:with-param name="title" select="$title"/>
3931              </xsl:call-template>
3932            </li>
3933          </xsl:for-each>
3934        </ul>
3935      </li>
3936    </xsl:otherwise>
3937  </xsl:choose>
3938</xsl:template>
3939
3940<xsl:template match="section|appendix" mode="toc">
3941  <xsl:variable name="sectionNumber">
3942    <xsl:call-template name="get-section-number" />
3943  </xsl:variable>
3944
3945  <xsl:variable name="target">
3946    <xsl:choose>
3947      <xsl:when test="@anchor"><xsl:value-of select="@anchor" /></xsl:when>
3948       <xsl:otherwise><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$sectionNumber" /></xsl:otherwise>
3949    </xsl:choose>
3950  </xsl:variable>
3951
3952  <!-- obtain content, just to check whether we need to recurse at all -->
3953  <xsl:variable name="content">
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="$target"/>
3958        <xsl:with-param name="title" select="@title"/>
3959        <xsl:with-param name="tocparam" select="@toc"/>
3960        <xsl:with-param name="oldtitle" select="@ed:old-title"/>
3961        <xsl:with-param name="waschanged" select="@ed:resolves"/>
3962      </xsl:call-template>
3963   
3964      <ul class="toc">
3965        <xsl:apply-templates mode="toc" />
3966      </ul>
3967    </li>
3968  </xsl:variable>
3969 
3970  <xsl:if test="$content!=''">
3971    <li>
3972      <xsl:call-template name="insert-toc-line">
3973        <xsl:with-param name="number" select="$sectionNumber"/>
3974        <xsl:with-param name="target" select="$target"/>
3975        <xsl:with-param name="title" select="@title"/>
3976        <xsl:with-param name="tocparam" select="@toc"/>
3977        <xsl:with-param name="oldtitle" select="@ed:old-title"/>
3978        <xsl:with-param name="waschanged" select="@ed:resolves"/>
3979      </xsl:call-template>
3980   
3981      <!-- obtain nested content, just to check whether we need to recurse at all -->
3982      <xsl:variable name="nested-content">
3983        <ul class="toc">
3984          <xsl:apply-templates mode="toc" />
3985        </ul>
3986      </xsl:variable>
3987     
3988      <!-- only recurse if we need to (do not produce useless list container) -->     
3989      <xsl:if test="$nested-content!=''">
3990        <ul class="toc">
3991          <xsl:apply-templates mode="toc" />
3992        </ul>
3993      </xsl:if>
3994    </li>
3995  </xsl:if>
3996</xsl:template>
3997
3998<xsl:template match="middle" mode="toc">
3999  <xsl:apply-templates mode="toc" />
4000  <xsl:call-template name="references-toc" />
4001</xsl:template>
4002
4003<xsl:template match="rfc" mode="toc">
4004  <xsl:apply-templates select="middle|back" mode="toc" />
4005</xsl:template>
4006
4007<xsl:template match="ed:del|ed:ins|ed:replace" mode="toc">
4008  <xsl:apply-templates mode="toc" />
4009</xsl:template>
4010
4011<xsl:template match="*|text()" mode="toc" />
4012
4013
4014<xsl:template name="insertTocAppendix">
4015 
4016  <xsl:if test="//figure[@title!='' or @anchor!='']">
4017    <ul class="toc">
4018      <xsl:for-each select="//figure[@title!='' or @anchor!='']">
4019        <xsl:variable name="title">Figure <xsl:value-of select="position()"/><xsl:if test="@title">: <xsl:value-of select="@title"/></xsl:if>
4020        </xsl:variable>
4021        <li>
4022          <xsl:call-template name="insert-toc-line">
4023            <xsl:with-param name="target" select="concat($anchor-prefix,'.figure.',position())" />
4024            <xsl:with-param name="title" select="$title" />
4025          </xsl:call-template>
4026        </li>
4027      </xsl:for-each>
4028    </ul>
4029  </xsl:if>
4030 
4031  <!-- experimental -->
4032  <xsl:if test="//ed:issue">
4033    <xsl:call-template name="insertIssuesList" />
4034  </xsl:if>
4035
4036</xsl:template>
4037
4038<xsl:template name="referencename">
4039  <xsl:param name="node" />
4040 
4041  <xsl:for-each select="$node">
4042    <xsl:choose>
4043      <xsl:when test="$xml2rfc-symrefs!='no' and ancestor::ed:del">
4044        <xsl:variable name="unprefixed" select="substring-after(@anchor,'deleted-')"/>
4045        <xsl:choose>
4046          <xsl:when test="$unprefixed!=''">
4047            <xsl:value-of select="concat('[',$unprefixed,']')"/>
4048          </xsl:when>
4049          <xsl:otherwise>
4050            <xsl:if test="count(//reference[@anchor=current()/@anchor])!=1">
4051              <xsl:message>Deleted duplicate anchors should have the prefix "deleted-": <xsl:value-of select="@anchor"/></xsl:message>
4052            </xsl:if>
4053            <xsl:value-of select="concat('[',@anchor,']')"/>
4054          </xsl:otherwise>
4055        </xsl:choose>
4056      </xsl:when>
4057      <xsl:when test="$xml2rfc-symrefs!='no'">[<xsl:value-of select="@anchor" />]</xsl:when>
4058      <xsl:when test="ancestor::ed:del">
4059        <xsl:text>[del]</xsl:text>
4060      </xsl:when>
4061      <xsl:otherwise>[<xsl:number level="any" count="reference[not(ancestor::ed:del)]"/>]</xsl:otherwise>
4062    </xsl:choose>
4063  </xsl:for-each> 
4064</xsl:template>
4065
4066
4067
4068<xsl:template name="replace-substring">
4069
4070  <xsl:param name="string" />
4071  <xsl:param name="replace" />
4072  <xsl:param name="by" />
4073
4074  <xsl:choose>
4075    <xsl:when test="contains($string,$replace)">
4076      <xsl:value-of select="concat(substring-before($string, $replace),$by)" />
4077      <xsl:call-template name="replace-substring">
4078        <xsl:with-param name="string" select="substring-after($string,$replace)" />
4079        <xsl:with-param name="replace" select="$replace" />
4080        <xsl:with-param name="by" select="$by" />
4081      </xsl:call-template>
4082    </xsl:when>
4083    <xsl:otherwise><xsl:value-of select="$string" /></xsl:otherwise>
4084  </xsl:choose>
4085
4086</xsl:template>
4087
4088
4089<xsl:template name="rfclist">
4090  <xsl:param name="list" />
4091  <xsl:choose>
4092    <xsl:when test="contains($list,',')">
4093      <xsl:variable name="rfcNo" select="substring-before($list,',')" />
4094      <xsl:call-template name="check-front-matter-ref">
4095        <xsl:with-param name="name" select="$rfcNo"/>
4096      </xsl:call-template>
4097      <a href="{concat($rfcUrlPrefix,$rfcNo,$rfcUrlPostfix)}"><xsl:value-of select="$rfcNo" /></a>,
4098      <xsl:call-template name="rfclist">
4099        <xsl:with-param name="list" select="normalize-space(substring-after($list,','))" />
4100      </xsl:call-template>
4101    </xsl:when>
4102    <xsl:otherwise>
4103      <xsl:variable name="rfcNo" select="$list" />
4104      <xsl:call-template name="check-front-matter-ref">
4105        <xsl:with-param name="name" select="$rfcNo"/>
4106      </xsl:call-template>
4107      <a href="{concat($rfcUrlPrefix,$rfcNo,$rfcUrlPostfix)}"><xsl:value-of select="$rfcNo" /></a>
4108    </xsl:otherwise>
4109  </xsl:choose>
4110</xsl:template>
4111
4112<xsl:template name="check-front-matter-ref">
4113  <xsl:param name="name"/>
4114  <xsl:choose>
4115    <xsl:when test="starts-with($name,'draft-')">
4116      <xsl:if test="not(//references//reference/seriesInfo[@name='Internet-Draft' and @value=$name])">
4117        <xsl:call-template name="warning">
4118          <xsl:with-param name="inline" select="'no'"/>
4119          <xsl:with-param name="msg" select="concat('front matter mentions I-D ',$name,' for which there is no reference element')"/>
4120        </xsl:call-template>
4121      </xsl:if>
4122    </xsl:when>
4123    <xsl:otherwise>
4124      <xsl:if test="not(//references//reference/seriesInfo[@name='RFC' and @value=$name])">
4125        <xsl:call-template name="warning">
4126          <xsl:with-param name="inline" select="'no'"/>
4127          <xsl:with-param name="msg" select="concat('front matter mentions RFC ',$name,' for which there is no reference element')"/>
4128        </xsl:call-template>
4129      </xsl:if>
4130    </xsl:otherwise>
4131  </xsl:choose>
4132</xsl:template>
4133
4134<xsl:template name="check-anchor">
4135  <xsl:if test="@anchor and @anchor!=''">
4136    <!-- check validity of anchor name -->
4137    <xsl:variable name="test">
4138      <xsl:element name="{@anchor}"/>
4139    </xsl:variable>
4140    <xsl:if test="count(exslt:node-set($test)//*) = 0">
4141      <xsl:call-template name="error">
4142        <xsl:with-param name="msg" select="concat('&quot;',@anchor,'&quot; is not a valid XML name')"/>
4143      </xsl:call-template>
4144    </xsl:if>
4145  </xsl:if>
4146</xsl:template>
4147
4148<xsl:template name="copy-anchor">
4149  <xsl:call-template name="check-anchor"/>
4150  <xsl:if test="@anchor and @anchor!=''">
4151    <xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute>
4152  </xsl:if>
4153</xsl:template>
4154
4155<xsl:template name="rfclist-for-dcmeta">
4156  <xsl:param name="list" />
4157  <xsl:choose>
4158    <xsl:when test="contains($list,',')">
4159      <xsl:variable name="rfcNo" select="substring-before($list,',')" />
4160      <meta name="DC.Relation.Replaces" content="urn:ietf:rfc:{$rfcNo}" />
4161      <xsl:call-template name="rfclist-for-dcmeta">
4162        <xsl:with-param name="list" select="normalize-space(substring-after($list,','))" />
4163      </xsl:call-template>
4164    </xsl:when>
4165    <xsl:otherwise>
4166      <xsl:variable name="rfcNo" select="$list" />
4167      <meta name="DC.Relation.Replaces" content="urn:ietf:rfc:{$rfcNo}" />
4168    </xsl:otherwise>
4169  </xsl:choose>
4170</xsl:template>
4171
4172<xsl:template name="get-paragraph-number">
4173  <!-- get section number of ancestor section element, then add t or figure number -->
4174  <xsl:if test="ancestor::section and not(ancestor::section[@myns:unnumbered='unnumbered']) and not(ancestor::x:blockquote) and not(ancestor::x:note)">
4175    <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" />
4176  </xsl:if>
4177</xsl:template>
4178
4179<xsl:template name="editingMark">
4180  <xsl:if test="$xml2rfc-editing='yes' and ancestor::rfc">
4181    <sup class="editingmark"><span><xsl:number level="any" count="postamble|preamble|t"/></span>&#0160;</sup>
4182  </xsl:if>
4183</xsl:template>
4184
4185<!-- internal ref support -->
4186<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"/>
4187
4188<xsl:template match="x:ref">
4189  <xsl:variable name="val" select="."/>
4190<!--  <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)]"/> -->
4191  <xsl:variable name="target" select="key('anchor-item',$val) | key('anchor-item-alias',$val)"/>
4192  <xsl:variable name="irefs" select="//iref[@x:for-anchor=$val]"/>
4193  <xsl:choose>
4194    <xsl:when test="$target">
4195      <a href="#{$target/@anchor}" class="smpl">
4196        <!-- to be indexed? -->
4197        <xsl:if test="$irefs">
4198          <xsl:attribute name="id"><xsl:call-template name="compute-extref-anchor"/></xsl:attribute>
4199        </xsl:if>
4200        <xsl:value-of select="."/>
4201      </a>
4202    </xsl:when>
4203    <xsl:otherwise>
4204      <xsl:call-template name="warning">
4205        <xsl:with-param name="inline" select="'no'"/>
4206        <xsl:with-param name="msg">internal link target for '<xsl:value-of select="."/>' does not exist.</xsl:with-param>
4207      </xsl:call-template>
4208      <xsl:value-of select="."/>
4209    </xsl:otherwise>
4210  </xsl:choose>
4211</xsl:template>
4212
4213<!-- Nothing to do here -->
4214<xsl:template match="x:anchor-alias" />
4215
4216<!-- Quotes -->
4217<xsl:template match="x:q">
4218  <q>
4219    <xsl:copy-of select="@cite"/>
4220    <xsl:apply-templates/>
4221  </q>
4222</xsl:template>
4223
4224<!-- Notes -->
4225<xsl:template match="x:note">
4226  <div class="note">
4227    <xsl:apply-templates/>
4228  </div>
4229</xsl:template>
4230
4231<xsl:template match="x:bcp14">
4232  <!-- check valid BCP14 keywords, then emphasize them -->
4233  <xsl:variable name="c" select="normalize-space(.)"/>
4234  <xsl:choose>
4235    <xsl:when test="$c='MUST' or $c='REQUIRED' or $c='SHALL'">
4236      <em class="bcp14"><xsl:value-of select="."/></em>
4237    </xsl:when>
4238    <xsl:when test="$c='MUST NOT' or $c='SHALL NOT'">
4239      <em class="bcp14"><xsl:value-of select="."/></em>
4240    </xsl:when>
4241    <xsl:when test="$c='SHOULD' or $c='RECOMMENDED'">
4242      <em class="bcp14"><xsl:value-of select="."/></em>
4243    </xsl:when>
4244    <xsl:when test="$c='SHOULD NOT' or $c='NOT RECOMMENDED'">
4245      <em class="bcp14"><xsl:value-of select="."/></em>
4246    </xsl:when>
4247    <xsl:when test="$c='MAY' or $c='OPTIONAL'">
4248      <em class="bcp14"><xsl:value-of select="."/></em>
4249    </xsl:when>
4250    <xsl:otherwise>
4251      <xsl:value-of select="."/>
4252      <xsl:message>ERROR: unknown BCP14 keyword: <xsl:value-of select="."/></xsl:message>
4253    </xsl:otherwise>
4254  </xsl:choose>
4255</xsl:template>
4256
4257<xsl:template match="x:blockquote">
4258  <xsl:variable name="p">
4259    <xsl:call-template name="get-paragraph-number" />
4260  </xsl:variable>
4261
4262  <blockquote>
4263    <xsl:if test="string-length($p) &gt; 0 and not(ancestor::ed:del) and not(ancestor::ed:ins)">
4264      <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$p"/></xsl:attribute>
4265    </xsl:if>
4266    <xsl:call-template name="insertInsDelClass"/>
4267    <xsl:call-template name="editingMark" />
4268    <xsl:copy-of select="@cite"/>
4269    <xsl:apply-templates/>
4270  </blockquote>
4271</xsl:template>
4272
4273<!-- Definitions -->
4274<xsl:template match="x:dfn">
4275  <dfn>
4276    <xsl:call-template name="copy-anchor"/>
4277    <xsl:apply-templates/>
4278  </dfn>
4279</xsl:template>
4280
4281<!-- headings -->
4282<xsl:template match="x:h">
4283  <b>
4284    <xsl:apply-templates/>
4285  </b>
4286</xsl:template>
4287
4288<!-- superscripts -->
4289<xsl:template match="x:sup">
4290  <sup>
4291    <xsl:apply-templates/>
4292  </sup>
4293</xsl:template>
4294
4295<!-- bold -->
4296<xsl:template match="x:highlight">
4297  <b>
4298    <xsl:apply-templates/>
4299  </b>
4300</xsl:template>
4301
4302<!-- measuring lengths -->
4303<xsl:template match="x:length-of">
4304  <xsl:variable name="target" select="//*[@anchor=current()/@target]"/>
4305  <xsl:if test="count($target)!=1">
4306    <xsl:call-template name="error">
4307      <xsl:with-param name="msg" select="concat('@target ',@target,' defined ',count($target),' times.')"/>
4308    </xsl:call-template>
4309  </xsl:if>
4310  <xsl:variable name="content">
4311    <xsl:apply-templates select="$target"/>
4312  </xsl:variable>
4313  <xsl:variable name="lineends" select="string-length($content) - string-length(translate($content,'&#10;',''))"/>
4314  <xsl:variable name="indents">
4315    <xsl:choose>
4316      <xsl:when test="@indented">
4317        <xsl:value-of select="number(@indented) * $lineends"/>
4318      </xsl:when>
4319      <xsl:otherwise>0</xsl:otherwise>
4320    </xsl:choose>
4321  </xsl:variable>
4322  <xsl:value-of select="string-length($content) + $lineends - $indents"/>
4323</xsl:template>
4324
4325<!-- Nop -->
4326<xsl:template match="x:span">
4327  <xsl:apply-templates/>
4328</xsl:template>
4329
4330<xsl:template match="x:parse-xml">
4331  <xsl:apply-templates/>
4332
4333  <xsl:if test="function-available('exslt:node-set')">
4334    <xsl:variable name="cleaned">
4335      <xsl:apply-templates mode="cleanup-edits"/>
4336    </xsl:variable>
4337    <xsl:choose>
4338      <xsl:when test="function-available('myns:parseXml')">
4339        <xsl:if test="myns:parseXml(concat($cleaned,''))!=''">
4340          <xsl:call-template name="error">
4341            <xsl:with-param name="msg" select="concat('Parse error in XML: ', myns:parseXml(concat($cleaned,'')))"/>
4342          </xsl:call-template>
4343        </xsl:if>
4344      </xsl:when>
4345      <xsl:when test="function-available('saxon:parse')">
4346        <xsl:variable name="parsed" select="saxon:parse(concat($cleaned,''))"/>
4347        <xsl:if test="$parsed='foo'">
4348          <xsl:comment>should not get here</xsl:comment>
4349        </xsl:if>
4350      </xsl:when>
4351      <xsl:otherwise></xsl:otherwise>
4352    </xsl:choose>
4353  </xsl:if>
4354</xsl:template>
4355
4356<!-- inlined RDF support -->
4357<xsl:template match="rdf:Description">
4358  <!-- ignore -->
4359</xsl:template>
4360
4361<!-- cleanup for ins/del -->
4362
4363<xsl:template match="comment()|@*" mode="cleanup-edits"><xsl:copy/></xsl:template>
4364
4365<xsl:template match="text()" mode="cleanup-edits"><xsl:copy/></xsl:template>
4366
4367<xsl:template match="/" mode="cleanup-edits">
4368        <xsl:copy><xsl:apply-templates select="node()" mode="cleanup-edits" /></xsl:copy>
4369</xsl:template>
4370
4371<xsl:template match="ed:del" mode="cleanup-edits"/>
4372
4373<xsl:template match="ed:replace" mode="cleanup-edits">
4374  <xsl:apply-templates mode="cleanup-edits"/>
4375</xsl:template>
4376
4377<xsl:template match="ed:ins" mode="cleanup-edits">
4378  <xsl:apply-templates mode="cleanup-edits"/>
4379</xsl:template>
4380
4381
4382<!-- ABNF support -->
4383<xsl:template name="to-abnf-char-sequence">
4384  <xsl:param name="chars"/>
4385 
4386  <xsl:variable name="c" select="substring($chars,1,1)"/>
4387  <xsl:variable name="r" select="substring($chars,2)"/>
4388   
4389  <xsl:choose>
4390    <xsl:when test="$c='-'">2D</xsl:when>
4391    <xsl:when test="$c='0'">30</xsl:when>
4392    <xsl:when test="$c='1'">31</xsl:when>
4393    <xsl:when test="$c='2'">32</xsl:when>
4394    <xsl:when test="$c='3'">33</xsl:when>
4395    <xsl:when test="$c='4'">34</xsl:when>
4396    <xsl:when test="$c='5'">35</xsl:when>
4397    <xsl:when test="$c='6'">36</xsl:when>
4398    <xsl:when test="$c='7'">37</xsl:when>
4399    <xsl:when test="$c='8'">38</xsl:when>
4400    <xsl:when test="$c='9'">39</xsl:when>
4401    <xsl:when test="$c='A'">41</xsl:when>
4402    <xsl:when test="$c='B'">42</xsl:when>
4403    <xsl:when test="$c='C'">43</xsl:when>
4404    <xsl:when test="$c='D'">44</xsl:when>
4405    <xsl:when test="$c='E'">45</xsl:when>
4406    <xsl:when test="$c='F'">46</xsl:when>
4407    <xsl:when test="$c='G'">47</xsl:when>
4408    <xsl:when test="$c='H'">48</xsl:when>
4409    <xsl:when test="$c='I'">49</xsl:when>
4410    <xsl:when test="$c='J'">4A</xsl:when>
4411    <xsl:when test="$c='K'">4B</xsl:when>
4412    <xsl:when test="$c='L'">4C</xsl:when>
4413    <xsl:when test="$c='M'">4D</xsl:when>
4414    <xsl:when test="$c='N'">4E</xsl:when>
4415    <xsl:when test="$c='O'">4F</xsl:when>
4416    <xsl:when test="$c='P'">50</xsl:when>
4417    <xsl:when test="$c='Q'">51</xsl:when>
4418    <xsl:when test="$c='R'">52</xsl:when>
4419    <xsl:when test="$c='S'">53</xsl:when>
4420    <xsl:when test="$c='T'">54</xsl:when>
4421    <xsl:when test="$c='U'">55</xsl:when>
4422    <xsl:when test="$c='V'">56</xsl:when>
4423    <xsl:when test="$c='W'">57</xsl:when>
4424    <xsl:when test="$c='X'">58</xsl:when>
4425    <xsl:when test="$c='Y'">59</xsl:when>
4426    <xsl:when test="$c='Z'">5A</xsl:when>
4427    <xsl:when test="$c='a'">61</xsl:when>
4428    <xsl:when test="$c='b'">62</xsl:when>
4429    <xsl:when test="$c='c'">63</xsl:when>
4430    <xsl:when test="$c='d'">64</xsl:when>
4431    <xsl:when test="$c='e'">65</xsl:when>
4432    <xsl:when test="$c='f'">66</xsl:when>
4433    <xsl:when test="$c='g'">67</xsl:when>
4434    <xsl:when test="$c='h'">68</xsl:when>
4435    <xsl:when test="$c='i'">69</xsl:when>
4436    <xsl:when test="$c='j'">6A</xsl:when>
4437    <xsl:when test="$c='k'">6B</xsl:when>
4438    <xsl:when test="$c='l'">6C</xsl:when>
4439    <xsl:when test="$c='m'">6D</xsl:when>
4440    <xsl:when test="$c='n'">6E</xsl:when>
4441    <xsl:when test="$c='o'">6F</xsl:when>
4442    <xsl:when test="$c='p'">70</xsl:when>
4443    <xsl:when test="$c='q'">71</xsl:when>
4444    <xsl:when test="$c='r'">72</xsl:when>
4445    <xsl:when test="$c='s'">73</xsl:when>
4446    <xsl:when test="$c='t'">74</xsl:when>
4447    <xsl:when test="$c='u'">75</xsl:when>
4448    <xsl:when test="$c='v'">76</xsl:when>
4449    <xsl:when test="$c='w'">77</xsl:when>
4450    <xsl:when test="$c='x'">78</xsl:when>
4451    <xsl:when test="$c='y'">79</xsl:when>
4452    <xsl:when test="$c='z'">7A</xsl:when>
4453    <xsl:otherwise>
4454      <xsl:text>??</xsl:text>
4455      <xsl:call-template name="error">
4456        <xsl:with-param name="msg" select="concat('unexpected character in ABNF char sequence: ',substring($chars,1,1))" />
4457      </xsl:call-template>
4458    </xsl:otherwise>
4459  </xsl:choose>
4460
4461  <xsl:if test="$r!=''">
4462    <xsl:text>.</xsl:text>
4463    <xsl:call-template name="to-abnf-char-sequence">
4464      <xsl:with-param name="chars" select="$r"/>
4465    </xsl:call-template>
4466  </xsl:if>
4467 
4468</xsl:template>
4469
4470<xsl:template match="x:abnf-char-sequence">
4471  <xsl:choose>
4472    <xsl:when test="substring(.,1,1) != '&quot;' or substring(.,string-length(.),1) != '&quot;'">
4473      <xsl:call-template name="error">
4474        <xsl:with-param name="msg" select="'contents of x:abnf-char-sequence needs to be quoted.'" />
4475      </xsl:call-template>
4476    </xsl:when>
4477    <xsl:otherwise>
4478      <xsl:text>%x</xsl:text>
4479      <xsl:call-template name="to-abnf-char-sequence">
4480        <xsl:with-param name="chars" select="substring(.,2,string-length(.)-2)"/>
4481      </xsl:call-template>
4482    </xsl:otherwise>
4483  </xsl:choose>
4484</xsl:template>
4485
4486<!-- box drawing -->
4487
4488<!-- nop for alignment -->
4489<xsl:template match="x:x"/>
4490
4491<!-- box (top) -->
4492<xsl:template match="x:bt">
4493  <xsl:text>&#x250c;</xsl:text>
4494  <xsl:value-of select="translate(substring(.,2,string-length(.)-2),'-','&#x2500;')"/>
4495  <xsl:text>&#x2510;</xsl:text>
4496</xsl:template>
4497
4498<!-- box (center) -->
4499<xsl:template match="x:bc">
4500  <xsl:variable name="first" select="substring(.,1)"/>
4501  <xsl:variable name="content" select="substring(.,2,string-length(.)-2)"/>
4502  <xsl:variable name="is-delimiter" select="translate($content,'-','')=''"/>
4503 
4504  <xsl:choose>
4505    <xsl:when test="$is-delimiter">
4506      <xsl:text>&#x251c;</xsl:text>
4507      <xsl:value-of select="translate($content,'-','&#x2500;')"/>
4508      <xsl:text>&#x2524;</xsl:text>
4509    </xsl:when>
4510    <xsl:when test="*">
4511      <xsl:for-each select="node()">
4512        <xsl:choose>
4513          <xsl:when test="position()=1">
4514            <xsl:text>&#x2502;</xsl:text>
4515            <xsl:value-of select="substring(.,2)"/>
4516          </xsl:when>
4517          <xsl:when test="position()=last()">
4518            <xsl:value-of select="substring(.,1,string-length(.)-1)"/>
4519            <xsl:text>&#x2502;</xsl:text>
4520          </xsl:when>
4521          <xsl:otherwise>
4522            <xsl:apply-templates select="."/>
4523          </xsl:otherwise>
4524        </xsl:choose>
4525      </xsl:for-each>
4526    </xsl:when>
4527    <xsl:otherwise>
4528      <xsl:text>&#x2502;</xsl:text>
4529      <xsl:value-of select="$content"/>
4530      <xsl:text>&#x2502;</xsl:text>
4531    </xsl:otherwise>
4532  </xsl:choose>
4533 
4534</xsl:template>
4535
4536<!-- box (bottom) -->
4537<xsl:template match="x:bb">
4538  <xsl:text>&#x2514;</xsl:text>
4539  <xsl:value-of select="translate(substring(.,2,string-length(.)-2),'-','&#x2500;')"/>
4540  <xsl:text>&#x2518;</xsl:text>
4541</xsl:template>
4542
4543<!-- author handling extensions -->
4544<xsl:template match="x:include-author">
4545  <xsl:for-each select="/*/front/author[@anchor=current()/@target]">
4546    <xsl:apply-templates select="."/>
4547  </xsl:for-each>
4548</xsl:template>
4549
4550<!-- boilerplate -->
4551<xsl:template match="x:boilerplate">
4552  <xsl:apply-templates/>
4553</xsl:template>
4554
4555<!-- experimental annotation support -->
4556
4557<xsl:template match="ed:issueref">
4558  <xsl:choose>
4559    <xsl:when test=".=//ed:issue/@name">
4560      <a href="#{$anchor-prefix}.issue.{.}">
4561        <xsl:apply-templates/>
4562      </a>
4563    </xsl:when>
4564    <xsl:otherwise>
4565      <xsl:call-template name="warning">
4566        <xsl:with-param name="msg">Dangling ed:issueref: <xsl:value-of select="."/></xsl:with-param>
4567      </xsl:call-template>
4568      <xsl:apply-templates/>
4569    </xsl:otherwise>
4570  </xsl:choose>
4571</xsl:template>
4572
4573<xsl:template match="ed:issue">
4574  <xsl:variable name="class">
4575    <xsl:choose>
4576      <xsl:when test="@status='closed'">closedissue</xsl:when>
4577      <xsl:otherwise>openissue</xsl:otherwise>
4578    </xsl:choose>
4579  </xsl:variable>
4580 
4581  <table summary="issue {@name}" class="{$class}">
4582    <tr>
4583      <td colspan="3">
4584        <a id="{$anchor-prefix}.issue.{@name}">
4585          <xsl:choose>
4586            <xsl:when test="@status='closed'">
4587              <xsl:attribute name="class">closed-issue</xsl:attribute>
4588            </xsl:when>
4589            <xsl:when test="@status='editor'">
4590              <xsl:attribute name="class">editor-issue</xsl:attribute>
4591            </xsl:when>
4592            <xsl:otherwise>
4593              <xsl:attribute name="class">open-issue</xsl:attribute>
4594            </xsl:otherwise>
4595          </xsl:choose>
4596          <xsl:text>&#160;I&#160;</xsl:text>
4597        </a>
4598        <xsl:text>&#160;</xsl:text>
4599        <xsl:choose>
4600          <xsl:when test="@href">
4601            <em><a href="{@href}"><xsl:value-of select="@name" /></a></em>
4602          </xsl:when>
4603          <xsl:when test="@alternate-href">
4604            <em>[<a href="{@alternate-href}">alternate link</a>]</em>
4605          </xsl:when>
4606          <xsl:otherwise>
4607            <em><xsl:value-of select="@name" /></em>
4608          </xsl:otherwise>
4609        </xsl:choose>
4610        &#0160;
4611        (type: <xsl:value-of select="@type"/>, status: <xsl:value-of select="@status"/>)
4612      </td>
4613    </tr>
4614
4615    <xsl:apply-templates select="ed:item"/>
4616    <xsl:apply-templates select="ed:resolution"/>
4617
4618    <xsl:variable name="changes" select="//*[@ed:resolves=current()/@name or ed:resolves=current()/@name]" />
4619    <xsl:if test="$changes">
4620      <tr>
4621        <td class="top" colspan="3">
4622          Associated changes in this document:
4623          <xsl:variable name="issue" select="@name"/>
4624          <xsl:for-each select="$changes">
4625            <a href="#{$anchor-prefix}.change.{$issue}.{position()}">
4626              <xsl:variable name="label">
4627                <xsl:call-template name="get-section-number"/>
4628              </xsl:variable>
4629              <xsl:choose>
4630                <xsl:when test="$label!=''"><xsl:value-of select="$label"/></xsl:when>
4631                <xsl:otherwise>&lt;<xsl:value-of select="concat('#',$anchor-prefix,'.change.',$issue,'.',position())"/>&gt;</xsl:otherwise>
4632              </xsl:choose>
4633            </a>
4634            <xsl:if test="position()!=last()">, </xsl:if>
4635          </xsl:for-each>
4636          <xsl:text>.</xsl:text>
4637        </td>
4638      </tr>
4639    </xsl:if>
4640  </table>
4641   
4642</xsl:template>
4643
4644<xsl:template match="ed:item">
4645  <tr>
4646    <td class="top">
4647      <xsl:if test="@entered-by">
4648        <a href="mailto:{@entered-by}?subject={/rfc/@docName},%20{../@name}">
4649          <i><xsl:value-of select="@entered-by"/></i>
4650        </a>
4651      </xsl:if>
4652    </td>
4653    <td class="topnowrap">
4654      <xsl:value-of select="@date"/>
4655    </td>
4656    <td class="top">
4657      <xsl:apply-templates select="node()" mode="issuehtml"/>
4658    </td>
4659  </tr>
4660</xsl:template>
4661
4662<xsl:template match="ed:resolution">
4663  <tr>
4664    <td class="top">
4665      <xsl:if test="@entered-by">
4666        <a href="mailto:{@entered-by}?subject={/rfc/@docName},%20{../@name}"><i><xsl:value-of select="@entered-by"/></i></a>
4667      </xsl:if>
4668    </td>
4669    <td class="topnowrap">
4670      <xsl:value-of select="@datetime"/>
4671    </td>
4672    <td class="top">
4673      <em>Resolution:</em>
4674      <xsl:apply-templates select="node()" mode="issuehtml"/>
4675    </td>
4676  </tr>
4677</xsl:template>
4678
4679<xsl:template match="ed:annotation">
4680  <em>
4681    <xsl:apply-templates/>
4682  </em>
4683</xsl:template>
4684
4685<!-- special templates for handling XHTML in issues -->
4686<xsl:template match="text()" mode="issuehtml">
4687  <xsl:value-of select="."/>
4688</xsl:template>
4689
4690<xsl:template match="*|@*" mode="issuehtml">
4691  <xsl:message terminate="yes">Unexpected node in issue HTML: <xsl:value-of select="name(.)"/></xsl:message>
4692</xsl:template>
4693
4694<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">
4695  <xsl:element name="{local-name()}">
4696    <xsl:apply-templates select="@*|node()" mode="issuehtml"/>
4697  </xsl:element>
4698</xsl:template>
4699
4700<xsl:template match="xhtml:p" mode="issuehtml">
4701  <xsl:apply-templates select="node()" mode="issuehtml"/>
4702  <br class="p"/>
4703</xsl:template>
4704
4705<xsl:template match="xhtml:a/@href|xhtml:q/@cite" mode="issuehtml">
4706  <xsl:attribute name="{local-name(.)}">
4707    <xsl:value-of select="."/>
4708  </xsl:attribute>
4709</xsl:template>
4710
4711<xsl:template match="ed:issueref" mode="issuehtml">
4712  <xsl:apply-templates select="."/>
4713</xsl:template>
4714
4715<xsl:template match="ed:eref" mode="issuehtml">
4716  <xsl:text>&lt;</xsl:text>
4717  <a href="{.}"><xsl:value-of select="."/></a>
4718  <xsl:text>&gt;</xsl:text>
4719</xsl:template>
4720
4721<xsl:template name="insertIssuesList">
4722
4723  <h2 id="{$anchor-prefix}.issues-list" ><a href="#{$anchor-prefix}.issues-list">Issues list</a></h2>
4724  <table summary="Issues list">
4725    <thead>
4726      <tr>
4727        <th>Id</th>
4728        <th>Type</th>
4729        <th>Status</th>
4730        <th>Date</th>
4731        <th>Raised By</th>
4732      </tr>
4733    </thead>
4734    <tbody>
4735      <xsl:for-each select="//ed:issue">
4736        <xsl:sort select="@status" />
4737        <xsl:sort select="@name" />
4738        <tr>
4739          <td><a href="#{$anchor-prefix}.issue.{@name}"><xsl:value-of select="@name" /></a></td>
4740          <td><xsl:value-of select="@type" /></td>
4741          <td><xsl:value-of select="@status" /></td>
4742          <td><xsl:value-of select="ed:item[1]/@date" /></td>
4743          <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>
4744        </tr>
4745      </xsl:for-each>
4746    </tbody>
4747  </table>
4748 
4749</xsl:template>
4750
4751<xsl:template name="insert-diagnostics">
4752 
4753  <!-- check anchor names -->
4754  <xsl:variable name="badAnchors"
4755    select="//*[starts-with(@anchor,concat($anchor-prefix,'.'))][@anchor!=concat($anchor-prefix,'.authors') and /*/x:assign-section-number[@number='suppress' and @builtin-target='authors']]" />
4756 
4757  <xsl:if test="$badAnchors">
4758    <xsl:variable name="text">
4759      The following anchor names may collide with internally generated anchors because of their prefix "<xsl:value-of select="$anchor-prefix" />":
4760      <xsl:for-each select="$badAnchors">
4761        <xsl:value-of select="@anchor"/><xsl:if test="position()!=last()">, </xsl:if>
4762      </xsl:for-each>
4763    </xsl:variable>
4764    <xsl:call-template name="warning">
4765      <xsl:with-param name="msg"><xsl:value-of select="$text"/></xsl:with-param>
4766    </xsl:call-template>
4767  </xsl:if>
4768 
4769  <!-- check ABNF syntax references -->
4770  <xsl:if test="//artwork[@type='abnf2616']">
4771    <xsl:if test="not(//reference/seriesInfo[@name='RFC' and (@value='2068' or @value='2616')])">
4772      <xsl:call-template name="warning">
4773        <xsl:with-param name="inline">no</xsl:with-param>
4774        <xsl:with-param name="msg">document uses HTTP-style ABNF syntax, but doesn't reference RFC 2068 or 2616.</xsl:with-param>
4775      </xsl:call-template>
4776    </xsl:if>
4777  </xsl:if>
4778  <xsl:if test="//artwork[@type='abnf']">
4779    <xsl:if test="not(//reference/seriesInfo[@name='RFC' and (@value='2234' or @value='4234' or @value='5234')])">
4780      <xsl:call-template name="warning">
4781        <xsl:with-param name="inline">no</xsl:with-param>
4782        <xsl:with-param name="msg">document uses ABNF syntax, but doesn't reference RFC 2234, 4234 or 5234.</xsl:with-param>
4783      </xsl:call-template>
4784    </xsl:if>
4785  </xsl:if>
4786 
4787  <!-- check IDs -->
4788  <xsl:variable name="badTargets" select="//xref[not(@target=//@anchor) and not(ancestor::ed:del)]" />
4789  <xsl:if test="$badTargets">
4790    <xsl:variable name="text">
4791      The following target names do not exist:
4792      <xsl:for-each select="$badTargets">
4793        <xsl:value-of select="@target"/><xsl:if test="position()!=last()">, </xsl:if>
4794      </xsl:for-each>
4795    </xsl:variable>
4796    <xsl:call-template name="warning">
4797      <xsl:with-param name="msg"><xsl:value-of select="$text"/></xsl:with-param>
4798    </xsl:call-template>
4799  </xsl:if>
4800 
4801 
4802</xsl:template>
4803
4804<!-- special change mark support, not supported by RFC2629 yet -->
4805
4806<xsl:template match="@ed:*" />
4807
4808<xsl:template match="ed:del">
4809  <xsl:call-template name="insert-issue-pointer"/>
4810  <del>
4811    <xsl:copy-of select="@*[namespace-uri()='']"/>
4812    <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
4813      <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4814    </xsl:if>
4815    <xsl:apply-templates />
4816  </del>
4817</xsl:template>
4818
4819<xsl:template match="ed:ins">
4820  <xsl:call-template name="insert-issue-pointer"/>
4821  <ins>
4822    <xsl:copy-of select="@*[namespace-uri()='']"/>
4823    <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
4824      <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4825    </xsl:if>
4826    <xsl:apply-templates />
4827  </ins>
4828</xsl:template>
4829
4830<xsl:template name="insert-issue-pointer">
4831  <xsl:param name="deleted-anchor"/>
4832  <xsl:variable name="change" select="."/>
4833  <xsl:for-each select="@ed:resolves|ed:resolves">
4834    <xsl:variable name="resolves" select="."/>
4835    <!-- need the right context node for proper numbering -->
4836    <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>
4837    <xsl:variable name="total" select="count(//*[@ed:resolves=$resolves or ed:resolves=$resolves])" />
4838    <xsl:variable name="id">
4839      <xsl:value-of select="$anchor-prefix"/>.change.<xsl:value-of select="$resolves"/>.<xsl:value-of select="$count" />
4840    </xsl:variable>
4841    <xsl:choose>
4842      <!-- block level? -->
4843      <xsl:when test="not(ancestor::t) and not(ancestor::title) and not(ancestor::figure) and not($change/@ed:old-title)">
4844        <div class="issuepointer noprint">
4845          <xsl:if test="not($deleted-anchor)">
4846            <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
4847          </xsl:if>
4848          <xsl:if test="$count > 1">
4849            <a class="bg-issue" title="previous change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count - 1}">&#x2191;</a>
4850          </xsl:if>
4851          <a class="open-issue" href="#{$anchor-prefix}.issue.{$resolves}" title="resolves: {$resolves}">
4852            <xsl:choose>
4853              <xsl:when test="//ed:issue[@name=$resolves and @status='closed']">
4854                <xsl:attribute name="class">closed-issue</xsl:attribute>
4855              </xsl:when>
4856              <xsl:when test="//ed:issue[@name=$resolves and @status='editor']">
4857                <xsl:attribute name="class">editor-issue</xsl:attribute>
4858              </xsl:when>
4859              <xsl:otherwise>
4860                <xsl:attribute name="class">open-issue</xsl:attribute>
4861              </xsl:otherwise>
4862            </xsl:choose>
4863            <xsl:text>&#160;I&#160;</xsl:text>
4864          </a>
4865          <xsl:if test="$count &lt; $total">
4866            <a class="bg-issue" title="next change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count + 1}">&#x2193;</a>
4867          </xsl:if>
4868          <xsl:text>&#160;</xsl:text>
4869        </div>
4870      </xsl:when>
4871      <xsl:otherwise>
4872        <xsl:if test="$count > 1">
4873          <a class="bg-issue" title="previous change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count - 1}">&#x2191;</a>
4874        </xsl:if>
4875        <a title="resolves: {$resolves}" href="#{$anchor-prefix}.issue.{$resolves}">
4876          <xsl:if test="not($deleted-anchor)">
4877            <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
4878          </xsl:if>
4879          <xsl:choose>
4880            <xsl:when test="//ed:issue[@name=$resolves and @status='closed']">
4881              <xsl:attribute name="class">closed-issue noprint</xsl:attribute>
4882            </xsl:when>
4883            <xsl:when test="//ed:issue[@name=$resolves and @status='editor']">
4884              <xsl:attribute name="class">editor-issue noprint</xsl:attribute>
4885            </xsl:when>
4886            <xsl:otherwise>
4887              <xsl:attribute name="class">open-issue noprint</xsl:attribute>
4888            </xsl:otherwise>
4889          </xsl:choose>
4890          <xsl:text>&#160;I&#160;</xsl:text>
4891        </a>
4892        <xsl:if test="$count &lt; $total">
4893          <a class="bg-issue" title="next change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count + 1}">&#x2193;</a>
4894        </xsl:if>
4895      </xsl:otherwise>
4896    </xsl:choose>
4897  </xsl:for-each>
4898</xsl:template>
4899
4900<xsl:template match="ed:replace">
4901  <!-- we need to special-case things like lists and tables -->
4902  <xsl:choose>
4903    <xsl:when test="parent::list">
4904      <xsl:apply-templates select="ed:del/node()" />
4905      <xsl:apply-templates select="ed:ins/node()" />
4906    </xsl:when>
4907    <xsl:when test="ancestor::references">
4908      <xsl:apply-templates select="ed:del/node()" />
4909      <xsl:apply-templates select="ed:ins/node()" />
4910    </xsl:when>
4911    <xsl:otherwise>
4912      <xsl:if test="@cite">
4913        <a class="editor-issue" href="{@cite}" target="_blank" title="see {@cite}">
4914          <xsl:text>&#160;i&#160;</xsl:text>
4915        </a>
4916      </xsl:if>
4917      <xsl:call-template name="insert-issue-pointer"/>
4918      <xsl:if test="ed:del">
4919        <del>
4920          <xsl:copy-of select="@*[namespace-uri()='']"/>
4921          <xsl:if test="not(@title) and ancestor-or-self::xsl:template[@ed:entered-by] and @datetime">
4922            <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4923          </xsl:if>
4924          <xsl:apply-templates select="ed:del/node()" />
4925        </del>
4926      </xsl:if>
4927      <xsl:if test="ed:ins">
4928        <ins>
4929          <xsl:copy-of select="@*[namespace-uri()='']"/>
4930          <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
4931            <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4932          </xsl:if>
4933          <xsl:apply-templates select="ed:ins/node()" />
4934        </ins>
4935      </xsl:if>
4936    </xsl:otherwise>
4937  </xsl:choose>
4938</xsl:template>
4939
4940<!-- convenience template for helping Mozilla (pre/ins inheritance problem) -->
4941<xsl:template name="insertInsDelClass">
4942  <xsl:if test="ancestor::ed:del">
4943    <xsl:attribute name="class">del</xsl:attribute>
4944  </xsl:if>
4945  <xsl:if test="ancestor::ed:ins">
4946    <xsl:attribute name="class">ins</xsl:attribute>
4947  </xsl:if>
4948</xsl:template>
4949
4950
4951<xsl:template name="sectionnumberAndEdits">
4952  <xsl:choose>
4953    <xsl:when test="ancestor::ed:del">del-<xsl:number count="ed:del//section" level="any"/></xsl:when>
4954    <xsl:when test="@x:fixed-section-number">
4955      <xsl:value-of select="@x:fixed-section-number"/>
4956    </xsl:when>
4957    <xsl:when test="self::section and parent::ed:ins and local-name(../..)='replace'">
4958      <xsl:for-each select="../.."><xsl:call-template name="sectionnumberAndEdits" /></xsl:for-each>
4959      <xsl:for-each select="..">
4960        <xsl:if test="parent::ed:replace">
4961          <xsl:for-each select="..">
4962            <xsl:if test="parent::section">.</xsl:if>
4963            <xsl:variable name="cnt" select="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)" />
4964            <xsl:choose>
4965              <xsl:when test="ancestor::back and not(ancestor::section)"><xsl:number format="A" value="$cnt"/></xsl:when>
4966              <xsl:otherwise><xsl:value-of select="$cnt"/></xsl:otherwise>
4967            </xsl:choose>
4968          </xsl:for-each>
4969        </xsl:if>
4970      </xsl:for-each>
4971    </xsl:when>
4972    <xsl:when test="self::section[parent::ed:ins]">
4973      <xsl:for-each select="../.."><xsl:call-template name="sectionnumberAndEdits" /></xsl:for-each>
4974      <xsl:for-each select="..">
4975        <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)" />
4976      </xsl:for-each>
4977    </xsl:when>
4978    <xsl:when test="self::section">
4979      <xsl:for-each select=".."><xsl:call-template name="sectionnumberAndEdits" /></xsl:for-each>
4980      <xsl:if test="parent::section">.</xsl:if>
4981      <xsl:choose>
4982        <xsl:when test="parent::back">
4983          <xsl:number format="A" value="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)" />
4984        </xsl:when>
4985        <xsl:otherwise>
4986          <xsl:number value="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)" />
4987        </xsl:otherwise>
4988      </xsl:choose>
4989    </xsl:when>
4990    <xsl:when test="self::references">
4991      <xsl:choose>
4992        <xsl:when test="count(/*/back/references)+count(/*/back/ed:replace/ed:ins/references)=1"><xsl:call-template name="get-references-section-number"/></xsl:when>
4993        <xsl:otherwise><xsl:call-template name="get-references-section-number"/>.<xsl:number level="any"/></xsl:otherwise>
4994      </xsl:choose>
4995    </xsl:when>
4996    <xsl:when test="self::middle or self::back"><!-- done --></xsl:when>
4997    <xsl:otherwise>
4998      <!-- go up one level -->
4999      <xsl:for-each select=".."><xsl:call-template name="sectionnumberAndEdits" /></xsl:for-each>
5000    </xsl:otherwise>
5001  </xsl:choose>
5002</xsl:template>
5003
5004<!-- utilities for warnings -->
5005
5006<xsl:template name="warning">
5007  <xsl:param name="msg"/>
5008  <xsl:param name="msg2"/>
5009  <xsl:param name="inline"/>
5010  <xsl:if test="$inline!='no'">
5011    <div class="error">WARNING: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/></div>
5012  </xsl:if>
5013  <xsl:message>WARNING: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/><xsl:call-template name="lineno"/></xsl:message>
5014</xsl:template>
5015
5016<xsl:template name="error">
5017  <xsl:param name="msg"/>
5018  <xsl:param name="msg2"/>
5019  <xsl:param name="inline"/>
5020  <xsl:if test="$inline!='no'">
5021    <div class="error">ERROR: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/></div>
5022  </xsl:if>
5023  <xsl:message>ERROR: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/><xsl:call-template name="lineno"/></xsl:message>
5024</xsl:template>
5025
5026<!-- table formatting -->
5027
5028<xsl:template match="texttable">
5029
5030  <xsl:variable name="anch">
5031    <xsl:call-template name="get-table-anchor"/>
5032  </xsl:variable>
5033
5034  <div id="{$anch}">
5035    <xsl:if test="@anchor!=''">
5036      <div id="{@anchor}"/>
5037    </xsl:if>
5038    <xsl:apply-templates select="preamble" />
5039    <xsl:variable name="style">
5040      <xsl:text>tt </xsl:text>
5041      <xsl:choose>
5042        <xsl:when test="@style!=''">
5043          <xsl:value-of select="@style"/>
5044        </xsl:when>
5045        <xsl:otherwise>full</xsl:otherwise>
5046      </xsl:choose>
5047    </xsl:variable>
5048    <table summary="{preamble}" class="{$style}" cellpadding="3" cellspacing="0">
5049      <xsl:if test="ttcol!=''">
5050        <!-- skip header when all column titles are empty -->
5051        <thead>
5052          <tr>
5053            <xsl:apply-templates select="ttcol" />
5054          </tr>
5055        </thead>
5056      </xsl:if>
5057      <tbody>
5058        <xsl:variable name="columns" select="count(ttcol)" />
5059        <xsl:variable name="fields" select="c | ed:replace/ed:ins/c | ed:replace/ed:del/c" />
5060        <xsl:for-each select="$fields[(position() mod $columns) = 1]">
5061          <tr>
5062            <xsl:for-each select=". | following-sibling::c[position() &lt; $columns]">
5063              <td>
5064                <xsl:call-template name="insertInsDelClass"/>
5065                <xsl:variable name="pos" select="position()" />
5066                <xsl:variable name="col" select="../ttcol[position() = $pos]" />
5067                <xsl:choose>
5068                  <xsl:when test="$col/@align='right' or $col/@align='center'">
5069                    <xsl:attribute name="class"><xsl:value-of select="$col/@align"/></xsl:attribute>
5070                  </xsl:when>
5071                  <xsl:when test="$col/@align='left' or not($col/@align)">
5072                    <!-- that's the default, nothing to do here -->
5073                  </xsl:when>
5074                  <xsl:otherwise>
5075                    <xsl:message>Unknown align attribute on ttcol: <xsl:value-of select="$col/@align"/></xsl:message>
5076                  </xsl:otherwise>
5077                </xsl:choose>
5078                <xsl:apply-templates select="node()" />
5079              </td>
5080            </xsl:for-each>
5081          </tr>
5082        </xsl:for-each>
5083      </tbody>
5084    </table>
5085    <xsl:apply-templates select="postamble" />
5086
5087    <xsl:if test="(@title!='' or @anchor!='') and not(@suppress-title='true')">
5088      <xsl:variable name="n"><xsl:number level="any" count="texttable[(@title!='' or @anchor!='') and not(@suppress-title='true')]" /></xsl:variable>
5089      <p class="figure">Table <xsl:value-of select="$n"/><xsl:if test="@title!=''">: <xsl:value-of select="@title" /></xsl:if></p>
5090    </xsl:if>
5091  </div>
5092 
5093</xsl:template>
5094
5095<xsl:template match="ttcol">
5096  <th>
5097   
5098    <xsl:choose>
5099      <xsl:when test="@align='right' or @align='center' or @align='left'">
5100        <xsl:attribute name="class"><xsl:value-of select="@align"/></xsl:attribute>
5101      </xsl:when>
5102      <xsl:when test="not(@align)">
5103        <!-- that's the default, nothing to do here -->
5104      </xsl:when>
5105      <xsl:otherwise>
5106        <xsl:message>Unknown align attribute on ttcol: <xsl:value-of select="@align"/></xsl:message>
5107      </xsl:otherwise>
5108    </xsl:choose>
5109   
5110    <xsl:if test="@width">
5111      <xsl:attribute name="style">width: <xsl:value-of select="@width" />;</xsl:attribute>
5112    </xsl:if>
5113
5114    <xsl:apply-templates />
5115  </th>
5116</xsl:template>
5117
5118<!-- cref support -->
5119
5120<xsl:template match="cref">
5121  <xsl:if test="$xml2rfc-comments!='no'">
5122    <xsl:variable name="cid">
5123      <xsl:choose>
5124        <xsl:when test="@anchor">
5125          <xsl:value-of select="@anchor"/>
5126        </xsl:when>
5127        <xsl:otherwise>
5128          <xsl:value-of select="$anchor-prefix"/>
5129          <xsl:text>.comment.</xsl:text>
5130          <xsl:number count="cref[not(@anchor)]" level="any"/>
5131        </xsl:otherwise>
5132      </xsl:choose>
5133    </xsl:variable>
5134   
5135    <span class="comment">
5136      <xsl:if test="$xml2rfc-inline!='yes'">
5137        <xsl:attribute name="title">
5138          <xsl:if test="@source"><xsl:value-of select="@source"/>: </xsl:if>
5139          <xsl:apply-templates select="text()|eref"/>
5140        </xsl:attribute>
5141      </xsl:if>
5142      <xsl:text>[</xsl:text>
5143      <xsl:choose>
5144        <xsl:when test="$xml2rfc-inline='yes'">
5145          <xsl:value-of select="$cid"/>
5146          <xsl:text>: </xsl:text>
5147          <xsl:apply-templates select="text()|eref"/>
5148          <xsl:if test="@source"> --<xsl:value-of select="@source"/></xsl:if>
5149        </xsl:when>
5150        <xsl:otherwise>
5151          <a href="#{$cid}">
5152            <xsl:value-of select="$cid"/>
5153          </a>
5154        </xsl:otherwise>
5155      </xsl:choose>
5156      <xsl:text>]</xsl:text>
5157    </span>
5158  </xsl:if>
5159</xsl:template>
5160
5161<xsl:template name="insertComments">
5162
5163  <xsl:call-template name="insert-conditional-hrule"/>
5164   
5165  <h1>
5166    <xsl:call-template name="insert-conditional-pagebreak"/>
5167    <a id="{$anchor-prefix}.comments" href="#{$anchor-prefix}.comments">Editorial Comments</a>
5168  </h1>
5169
5170  <dl>
5171    <xsl:for-each select="//cref">
5172      <xsl:variable name="cid">
5173        <xsl:choose>
5174          <xsl:when test="@anchor">
5175            <xsl:value-of select="@anchor"/>
5176          </xsl:when>
5177          <xsl:otherwise>
5178            <xsl:value-of select="$anchor-prefix"/>
5179            <xsl:text>.comment.</xsl:text>
5180            <xsl:number count="cref[not(@anchor)]" level="any"/>
5181          </xsl:otherwise>
5182        </xsl:choose>
5183      </xsl:variable>
5184      <dt id="{$cid}">
5185        [<xsl:value-of select="$cid"/>]
5186      </dt>
5187      <dd>
5188        <xsl:apply-templates select="node()"/>
5189        <xsl:if test="@source"> --<xsl:value-of select="@source"/></xsl:if>
5190      </dd>
5191    </xsl:for-each>
5192  </dl>
5193</xsl:template>
5194
5195
5196<!-- Chapter Link Generation -->
5197
5198<xsl:template match="*" mode="links"><xsl:apply-templates mode="links"/></xsl:template>
5199<xsl:template match="text()" mode="links" />
5200
5201<xsl:template match="/*/middle//section[not(myns:unnumbered) and not(ancestor::section)]" mode="links">
5202  <xsl:variable name="sectionNumber"><xsl:call-template name="get-section-number" /></xsl:variable>
5203  <link rel="Chapter" title="{$sectionNumber} {@title}" href="#{$anchor-prefix}.section.{$sectionNumber}" />
5204  <xsl:apply-templates mode="links" />
5205</xsl:template>
5206
5207<xsl:template match="/*/back//section[not(myns:unnumbered) and not(ancestor::section)]" mode="links">
5208  <xsl:variable name="sectionNumber"><xsl:call-template name="get-section-number" /></xsl:variable>
5209  <link rel="Appendix" title="{$sectionNumber} {@title}" href="#{$anchor-prefix}.section.{$sectionNumber}" />
5210  <xsl:apply-templates mode="links" />
5211</xsl:template>
5212
5213<xsl:template match="/*/back/references[position()=1]" mode="links">
5214  <xsl:variable name="sectionNumber"><xsl:call-template name="get-references-section-number" /></xsl:variable>
5215  <link rel="Chapter" href="#{$anchor-prefix}.section.{$sectionNumber}">
5216    <xsl:choose>
5217      <xsl:when test="@title and count(/*/back/references)=1">
5218        <xsl:attribute name="title">
5219          <xsl:call-template name="get-references-section-number"/>
5220          <xsl:text> </xsl:text>
5221          <xsl:value-of select="@title"/>
5222        </xsl:attribute>
5223      </xsl:when>
5224      <xsl:otherwise>
5225        <xsl:attribute name="title">
5226          <xsl:call-template name="get-references-section-number"/>
5227          <xsl:text> References</xsl:text>
5228        </xsl:attribute>
5229      </xsl:otherwise>
5230    </xsl:choose>
5231  </link>
5232</xsl:template>
5233
5234<!-- convenience templates -->
5235
5236<xsl:template name="get-author-summary">
5237  <xsl:choose>
5238    <xsl:when test="count(/rfc/front/author)=1">
5239      <xsl:value-of select="/rfc/front/author[1]/@surname" />
5240    </xsl:when>
5241    <xsl:when test="count(/rfc/front/author)=2">
5242      <xsl:value-of select="concat(/rfc/front/author[1]/@surname,' &amp; ',/rfc/front/author[2]/@surname)" />
5243    </xsl:when>
5244    <xsl:otherwise>
5245      <xsl:value-of select="concat(/rfc/front/author[1]/@surname,', et al.')" />
5246    </xsl:otherwise>
5247  </xsl:choose>
5248</xsl:template>
5249
5250<xsl:template name="get-category-long">
5251  <xsl:choose>
5252    <xsl:when test="$xml2rfc-footer"><xsl:value-of select="$xml2rfc-footer" /></xsl:when>
5253    <xsl:when test="$xml2rfc-private"/> <!-- private draft, footer not set -->
5254    <xsl:when test="/rfc/@category='bcp'">Best Current Practice</xsl:when>
5255    <xsl:when test="/rfc/@category='historic'">Historic</xsl:when>
5256    <xsl:when test="/rfc/@category='info' or not(/rfc/@category)">Informational</xsl:when>
5257    <xsl:when test="/rfc/@category='std'">Standards Track</xsl:when>
5258    <xsl:when test="/rfc/@category='exp'">Experimental</xsl:when>
5259    <xsl:otherwise>(category unknown)</xsl:otherwise>
5260  </xsl:choose>
5261</xsl:template>
5262
5263<xsl:template name="get-header-center">
5264  <xsl:choose>
5265    <xsl:when test="string-length(/rfc/front/title/@abbrev) &gt; 0">
5266      <xsl:value-of select="/rfc/front/title/@abbrev" />
5267    </xsl:when>
5268    <xsl:otherwise>
5269      <xsl:apply-templates select="/rfc/front/title" mode="get-text-content" />
5270    </xsl:otherwise>
5271  </xsl:choose>
5272</xsl:template>
5273
5274<xsl:template name="get-header-left">
5275  <xsl:choose>
5276    <xsl:when test="$xml2rfc-header"><xsl:value-of select="$xml2rfc-header" /></xsl:when>
5277    <xsl:when test="$xml2rfc-private"/> <!-- private draft, header not set -->
5278    <xsl:when test="/rfc/@ipr and not(/rfc/@number)">INTERNET DRAFT</xsl:when>
5279    <xsl:otherwise>RFC <xsl:value-of select="/rfc/@number"/></xsl:otherwise>
5280  </xsl:choose>
5281</xsl:template>
5282
5283<xsl:template name="get-generator">
5284  <xsl:variable name="gen">
5285    <xsl:text>http://greenbytes.de/tech/webdav/rfc2629.xslt, </xsl:text>
5286    <!-- when RCS keyword substitution in place, add version info -->
5287    <xsl:if test="contains('$Revision: 1.421 $',':')">
5288      <xsl:value-of select="concat('Revision ',normalize-space(translate(substring-after('$Revision: 1.421 $', 'Revision: '),'$','')),', ')" />
5289    </xsl:if>
5290    <xsl:if test="contains('$Date: 2009-02-20 13:12:03 $',':')">
5291      <xsl:value-of select="concat(normalize-space(translate(substring-after('$Date: 2009-02-20 13:12:03 $', 'Date: '),'$','')),', ')" />
5292    </xsl:if>
5293    <xsl:value-of select="concat('XSLT vendor: ',system-property('xsl:vendor'),' ',system-property('xsl:vendor-url'))" />
5294  </xsl:variable>
5295  <xsl:value-of select="$gen" />
5296</xsl:template>
5297
5298<xsl:template name="get-header-right">
5299  <xsl:value-of select="concat($xml2rfc-ext-pub-month, ' ', $xml2rfc-ext-pub-year)" />
5300</xsl:template>
5301
5302<xsl:template name="get-keywords">
5303  <xsl:variable name="keyw">
5304    <xsl:for-each select="/rfc/front/keyword">
5305      <xsl:value-of select="translate(.,',',' ')" />
5306      <xsl:if test="position()!=last()">, </xsl:if>
5307    </xsl:for-each>
5308  </xsl:variable>
5309  <xsl:value-of select="normalize-space($keyw)" />
5310</xsl:template>
5311
5312<!-- get language from context node. nearest ancestor or return the default of "en" -->
5313<xsl:template name="get-lang">
5314  <xsl:choose>
5315    <xsl:when test="ancestor-or-self::*[@xml:lang]"><xsl:value-of select="ancestor-or-self::*/@xml:lang" /></xsl:when>
5316    <xsl:otherwise>en</xsl:otherwise>
5317  </xsl:choose>
5318</xsl:template>
5319
5320<xsl:template name="get-section-number">
5321  <xsl:variable name="anchor" select="@anchor"/>
5322  <xsl:choose>
5323    <xsl:when test="@x:fixed-section-number">
5324      <xsl:value-of select="@x:fixed-section-number"/>
5325    </xsl:when>
5326    <xsl:when test="$has-edits or ancestor::*/@x:fixed-section-number">
5327      <xsl:call-template name="sectionnumberAndEdits" />
5328    </xsl:when>
5329    <xsl:otherwise>
5330      <xsl:choose>
5331        <xsl:when test="self::references">
5332          <xsl:choose>
5333            <xsl:when test="count(/*/back/references)=1">
5334              <xsl:call-template name="get-references-section-number"/>
5335            </xsl:when>
5336            <xsl:otherwise>
5337              <xsl:call-template name="get-references-section-number"/>.<xsl:number count="references"/>
5338            </xsl:otherwise>
5339          </xsl:choose>
5340        </xsl:when>
5341        <xsl:when test="self::reference">
5342          <xsl:for-each select="parent::references">
5343            <xsl:choose>
5344              <xsl:when test="count(/*/back/references)=1">
5345                <xsl:call-template name="get-references-section-number"/>
5346              </xsl:when>
5347              <xsl:otherwise>
5348                <xsl:call-template name="get-references-section-number"/>.<xsl:number count="references"/>
5349              </xsl:otherwise>
5350            </xsl:choose>
5351          </xsl:for-each>
5352        </xsl:when>
5353        <xsl:when test="ancestor::reference">
5354          <xsl:for-each select="ancestor::reference">
5355            <xsl:call-template name="get-section-number"/>
5356          </xsl:for-each>
5357        </xsl:when>
5358        <xsl:when test="ancestor::back"><xsl:number count="section|appendix" level="multiple" format="A.1.1.1.1.1.1.1" /></xsl:when>
5359        <xsl:when test="self::appendix"><xsl:number count="appendix" level="multiple" format="A.1.1.1.1.1.1.1" /></xsl:when>
5360        <xsl:otherwise><xsl:number count="section" level="multiple"/></xsl:otherwise>
5361      </xsl:choose>
5362    </xsl:otherwise>
5363  </xsl:choose>
5364</xsl:template>
5365
5366<!-- get the section number for the references section -->
5367<xsl:template name="get-references-section-number">
5368  <xsl:value-of select="count(/rfc/middle/section) + count(/rfc/middle/ed:replace/ed:ins/section) + 1"/>
5369</xsl:template>
5370
5371<xsl:template name="emit-section-number">
5372  <xsl:param name="no"/>
5373  <xsl:value-of select="$no"/><xsl:if test="not(contains($no,'.')) or $xml2rfc-ext-sec-no-trailing-dots='yes'">.</xsl:if>
5374</xsl:template>
5375
5376<xsl:template name="get-section-type">
5377  <xsl:param name="prec" /> <!-- TODO: check this, it's unused -->
5378  <xsl:choose>
5379    <xsl:when test="ancestor::back">Appendix</xsl:when>
5380    <xsl:otherwise>Section</xsl:otherwise>
5381  </xsl:choose>
5382</xsl:template>
5383
5384<xsl:template name="get-table-anchor">
5385  <xsl:value-of select="$anchor-prefix"/>
5386  <xsl:text>.table.</xsl:text>
5387  <xsl:choose>
5388    <xsl:when test="@title!='' or @anchor!=''">
5389      <xsl:number level="any" count="texttable[@title!='' or @anchor!='']" />
5390    </xsl:when>
5391    <xsl:otherwise>
5392      <xsl:text>u.</xsl:text>
5393      <xsl:number level="any" count="texttable[not(@title!='' or @anchor!='')]" />
5394    </xsl:otherwise>
5395  </xsl:choose>
5396</xsl:template>
5397
5398<xsl:template name="get-figure-anchor">
5399  <xsl:value-of select="$anchor-prefix"/>
5400  <xsl:text>.figure.</xsl:text>
5401  <xsl:choose>
5402    <xsl:when test="@title!='' or @anchor!=''">
5403      <xsl:number level="any" count="figure[@title!='' or @anchor!='']" />
5404    </xsl:when>
5405    <xsl:otherwise>
5406      <xsl:text>u.</xsl:text>
5407      <xsl:number level="any" count="figure[not(@title!='' or @anchor!='')]" />
5408    </xsl:otherwise>
5409  </xsl:choose>
5410</xsl:template>
5411
5412<!-- reformat contents of author/@initials -->
5413<xsl:template name="format-initials">
5414  <xsl:choose>
5415    <xsl:when test="string-length(@initials)=1">
5416      <xsl:value-of select="concat(@initials,'.')"/>
5417    </xsl:when>
5418    <xsl:otherwise>
5419      <xsl:value-of select="@initials"/>
5420    </xsl:otherwise>
5421  </xsl:choose>
5422</xsl:template>
5423
5424<!-- checking for email element -->
5425<xsl:template name="extract-email">
5426  <xsl:variable name="email" select="normalize-space(.)"/>
5427  <xsl:if test="string-length(.) != string-length($email) or contains($email,' ')">
5428    <xsl:call-template name="warning">
5429      <xsl:with-param name="inline" select="'no'"/>
5430      <xsl:with-param name="msg">excessive whitespace in email address: '<xsl:value-of select="."/>'</xsl:with-param>
5431    </xsl:call-template>
5432  </xsl:if>
5433 
5434  <xsl:variable name="email2">
5435    <xsl:choose>
5436      <xsl:when test="starts-with($email,'mailto:')">
5437        <xsl:call-template name="warning">
5438          <xsl:with-param name="inline" select="'no'"/>
5439          <xsl:with-param name="msg">email should not include URI scheme: '<xsl:value-of select="."/>'</xsl:with-param>
5440        </xsl:call-template>
5441        <xsl:value-of select="substring($email, 1 + string-length('mailto:'))"/>
5442      </xsl:when>
5443      <xsl:otherwise>
5444        <xsl:value-of select="$email"/>
5445      </xsl:otherwise>
5446    </xsl:choose>
5447  </xsl:variable>
5448 
5449  <xsl:value-of select="$email2"/>
5450</xsl:template>
5451
5452<!-- checking for uri element -->
5453<xsl:template name="extract-uri">
5454  <xsl:variable name="uri" select="normalize-space(.)"/>
5455  <xsl:if test="string-length(.) != string-length($uri) or contains($uri,' ')">
5456    <xsl:call-template name="warning">
5457      <xsl:with-param name="inline" select="'no'"/>
5458      <xsl:with-param name="msg">excessive whitespace in URI: '<xsl:value-of select="."/>'</xsl:with-param>
5459    </xsl:call-template>
5460  </xsl:if>
5461 
5462  <xsl:value-of select="$uri"/>
5463</xsl:template>
5464
5465<xsl:template name="insert-conditional-pagebreak">
5466  <xsl:if test="$xml2rfc-compact!='yes'">
5467    <xsl:attribute name="class">np</xsl:attribute>
5468  </xsl:if>
5469</xsl:template>
5470
5471<xsl:template name="insert-conditional-hrule">
5472  <xsl:if test="$xml2rfc-compact!='yes'">
5473    <hr class="noprint" />
5474  </xsl:if>
5475</xsl:template>
5476
5477<!-- get text content from marked-up text -->
5478
5479<xsl:template match="text()" mode="get-text-content">
5480  <xsl:value-of select="."/>
5481</xsl:template>
5482
5483<xsl:template match="*" mode="get-text-content">
5484  <xsl:apply-templates mode="get-text-content"/>
5485</xsl:template>
5486
5487<xsl:template match="ed:del" mode="get-text-content">
5488</xsl:template>
5489
5490<!-- diag support -->
5491<xsl:template name="lineno">
5492  <xsl:if test="function-available('saxon-old:line-number')">
5493    <xsl:if test="saxon-old:line-number() > 0">
5494      <xsl:text> (at line </xsl:text>
5495      <xsl:value-of select="saxon-old:line-number()"/>
5496      <xsl:text>)</xsl:text>
5497    </xsl:if>
5498  </xsl:if>
5499  <xsl:if test="function-available('saxon:line-number')">
5500    <xsl:if test="saxon:line-number() > 0">
5501      <xsl:text> (at line </xsl:text>
5502      <xsl:value-of select="saxon:line-number()"/>
5503      <xsl:text>)</xsl:text>
5504    </xsl:if>
5505  </xsl:if>
5506</xsl:template>
5507
5508<!-- define exslt:node-set for msxml -->       
5509<msxsl:script language="JScript" implements-prefix="exslt">
5510  this['node-set'] = function (x) {
5511    return x;
5512  }
5513</msxsl:script>
5514
5515<!-- date handling -->
5516
5517<msxsl:script language="JScript" implements-prefix="date">
5518  this['year'] = function (x) {
5519    if (x) {throw "not supported"};
5520    return (new Date()).getFullYear();
5521  }
5522
5523  this['month-in-year'] = function (x) {
5524    if (x) {throw "not supported"};
5525    return 1 + (new Date()).getMonth();
5526  }
5527
5528  this['day-in-month'] = function (x) {
5529    if (x) {throw "not supported"};
5530    return (new Date()).getDate();
5531  }
5532</msxsl:script>
5533
5534<xsl:variable name="may-default-dates">
5535  <xsl:choose>
5536    <xsl:when test="function-available('date:year') and function-available('date:month-in-year') and date:day-in-month()">
5537      <xsl:variable name="year-specified" select="/rfc/front/date/@year and /rfc/front/date/@year!=''"/>
5538      <xsl:variable name="month-specified" select="/rfc/front/date/@month and /rfc/front/date/@month!=''"/>
5539      <xsl:variable name="day-specified" select="/rfc/front/date/@day and /rfc/front/date/@day!=''"/>
5540      <xsl:variable name="system-month">
5541        <xsl:call-template name="get-month-as-name">
5542          <xsl:with-param name="month" select="date:month-in-year()"/>
5543        </xsl:call-template>
5544      </xsl:variable>
5545      <xsl:choose>
5546        <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>
5547        <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>
5548        <xsl:when test="$day-specified and /rfc/front/date/@day!=date:day-in-month()">Specified day does not match system date</xsl:when>
5549        <xsl:when test="not($year-specified) and ($month-specified or $day-specified)">Can't default year when month or day is specified</xsl:when>
5550        <xsl:when test="not($month-specified) and $day-specified">Can't default month when day is specified</xsl:when>
5551        <xsl:otherwise>yes</xsl:otherwise>
5552      </xsl:choose>
5553    </xsl:when>
5554    <!-- may, but won't -->
5555    <xsl:otherwise>yes</xsl:otherwise> 
5556  </xsl:choose>
5557</xsl:variable>
5558
5559<xsl:param name="xml2rfc-ext-pub-year">
5560  <xsl:choose>
5561    <xsl:when test="/rfc/front/date/@year and /rfc/front/date/@year!=''">
5562      <xsl:value-of select="/rfc/front/date/@year"/>
5563    </xsl:when>
5564    <xsl:when test="function-available('date:year')">
5565      <xsl:if test="/rfc/front/date/@month and /rfc/front/date/@month!=''">
5566        <xsl:call-template name="error">
5567          <xsl:with-param name="msg" select="'defaulting publication year although month was specified'"/>
5568        </xsl:call-template>
5569      </xsl:if>
5570      <xsl:if test="/rfc/front/date/@day and /rfc/front/date/@day!=''">
5571        <xsl:call-template name="error">
5572          <xsl:with-param name="msg" select="'defaulting publication year although day was specified'"/>
5573        </xsl:call-template>
5574      </xsl:if>
5575      <xsl:value-of select="date:year()"/>
5576    </xsl:when>
5577    <xsl:otherwise>
5578      <xsl:call-template name="error">
5579        <xsl:with-param name="msg" select="'/rfc/front/date/@year missing (and XSLT processor cannot compute the system date)'"/>
5580      </xsl:call-template>
5581    </xsl:otherwise>
5582  </xsl:choose>
5583</xsl:param>
5584
5585<xsl:param name="xml2rfc-ext-pub-month">
5586  <xsl:choose>
5587    <xsl:when test="/rfc/front/date/@month and /rfc/front/date/@month!=''">
5588      <xsl:value-of select="/rfc/front/date/@month"/>
5589    </xsl:when>
5590    <xsl:when test="function-available('date:month-in-year') and $may-default-dates='yes'">
5591      <xsl:call-template name="get-month-as-name">
5592        <xsl:with-param name="month" select="date:month-in-year()"/>
5593      </xsl:call-template>
5594    </xsl:when>
5595    <xsl:when test="function-available('date:month-in-year') and $may-default-dates!='yes'">
5596      <xsl:call-template name="warning">
5597        <xsl:with-param name="inline" select="'no'"/>
5598        <xsl:with-param name="msg" select="$may-default-dates"/>
5599      </xsl:call-template>
5600    </xsl:when>
5601    <xsl:otherwise>
5602      <xsl:call-template name="error">
5603        <xsl:with-param name="msg" select="'/rfc/front/date/@month missing (and XSLT processor cannot compute the system date)'"/>
5604      </xsl:call-template>
5605    </xsl:otherwise>
5606  </xsl:choose>
5607</xsl:param>
5608
5609<xsl:param name="xml2rfc-ext-pub-month-numeric">
5610  <xsl:call-template name="get-month-as-num">
5611    <xsl:with-param name="month" select="$xml2rfc-ext-pub-month" />
5612  </xsl:call-template>
5613</xsl:param>
5614
5615<xsl:param name="xml2rfc-ext-pub-day">
5616  <xsl:choose>
5617    <xsl:when test="/rfc/front/date/@day and /rfc/front/date/@day!=''">
5618      <xsl:value-of select="/rfc/front/date/@day"/>
5619    </xsl:when>
5620    <xsl:when test="function-available('date:day-in-month') and $may-default-dates='yes'">
5621      <xsl:value-of select="date:day-in-month()"/>
5622    </xsl:when>
5623    <xsl:otherwise /> <!-- harmless, we just don't have it -->
5624  </xsl:choose>
5625</xsl:param>
5626
5627</xsl:transform>
Note: See TracBrowser for help on using the repository browser.