source: rfc2629xslt/rfc2629toXHTML.xslt @ 754

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