source: rfc2629xslt/rfc2629toXHTML.xslt @ 729

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

Bump up document dates, update to latest versions of rfc2629.xslt

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