source: rfc2629xslt/rfc2629toXHTML.xslt @ 741

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

Update to latest version of xml2rfc and rfc2629.xslt, bump document dates

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