source: rfc2629xslt/rfc2629toXHTML.xslt @ 704

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

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

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