source: rfc2629xslt/rfc2629toXHTML.xslt @ 120

Last change on this file since 120 was 118, checked in by julian.reschke@…, 12 years ago

Update to latest version of rfc2629.xslt.

  • Property svn:eol-style set to native
File size: 176.0 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!--Auto-generated from rfc2629.xslt through HTMLtoXHTML.xslt-->
3<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 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:saxon="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="ed exslt msxsl myns saxon 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<!-- process some of the processing instructions supported by Marshall T. Rose's
10     xml2rfc sofware, see <http://xml.resource.org/> -->
11
12<!-- delimiters in PIs -->
13<xsl:variable name="quote-chars">"'</xsl:variable>     
14     
15<!-- rfc comments PI -->
16
17<xsl:param name="xml2rfc-comments" select="substring-after(       translate(/processing-instruction('rfc')[contains(.,'comments=')], concat($quote-chars,' '), ''),         'comments=')"/>
18
19<!-- rfc compact PI -->
20
21<xsl:param name="xml2rfc-compact" select="substring-after(       translate(/processing-instruction('rfc')[contains(.,'compact=')], concat($quote-chars,' '), ''),         'compact=')"/>
22
23<!-- rfc footer PI -->
24
25<xsl:param name="xml2rfc-footer" select="substring-after(       translate(/processing-instruction('rfc')[contains(.,'footer=')], concat($quote-chars,' '), ''),         'footer=')"/>
26
27<!-- rfc header PI -->
28
29<xsl:param name="xml2rfc-header" select="substring-after(       translate(/processing-instruction('rfc')[contains(.,'header=')], concat($quote-chars,' '), ''),         'header=')"/>
30
31<!-- rfc inline PI -->
32
33<xsl:param name="xml2rfc-inline" select="substring-after(       translate(/processing-instruction('rfc')[contains(.,'inline=')], concat($quote-chars,' '), ''),         'inline=')"/>
34
35<!-- rfc strict PI -->
36
37<xsl:param name="xml2rfc-strict" select="substring-after(       translate(/processing-instruction('rfc')[contains(.,'strict=')], concat($quote-chars,' '), ''),         'strict=')"/>
38
39<!-- include a table of contents if a processing instruction <?rfc?>
40     exists with contents toc="yes". Can be overriden by an XSLT parameter -->
41
42<xsl:param name="xml2rfc-toc" select="substring-after(       translate(/processing-instruction('rfc')[contains(.,'toc=')], concat($quote-chars,' '), ''),         'toc=')"/>
43
44<!-- optional tocdepth-->
45
46<xsl:param name="xml2rfc-tocdepth" select="substring-after(       translate(/processing-instruction('rfc')[contains(.,'tocdepth=')], concat($quote-chars,' '), ''),         'tocdepth=')"/>
47
48<xsl:variable name="parsedTocDepth">
49  <xsl:choose>
50    <xsl:when test="$xml2rfc-tocdepth='1'">1</xsl:when>
51    <xsl:when test="$xml2rfc-tocdepth='2'">2</xsl:when>
52    <xsl:when test="$xml2rfc-tocdepth='3'">3</xsl:when>
53    <xsl:when test="$xml2rfc-tocdepth='4'">4</xsl:when>
54    <xsl:when test="$xml2rfc-tocdepth='5'">5</xsl:when>
55    <xsl:otherwise>99</xsl:otherwise>
56  </xsl:choose>
57</xsl:variable>
58
59<!-- suppress top block if a processing instruction <?rfc?>
60     exists with contents tocblock="no". Can be overriden by an XSLT parameter -->
61
62<xsl:param name="xml2rfc-topblock" select="substring-after(       translate(/processing-instruction('rfc')[contains(.,'topblock=')], concat($quote-chars,' '), ''),         'topblock=')"/>
63
64<!-- use symbolic reference names instead of numeric ones unless a processing instruction <?rfc?>
65     exists with contents symrefs="no". Can be overriden by an XSLT parameter -->
66
67<xsl:param name="xml2rfc-symrefs" select="substring-after(       translate(/processing-instruction('rfc')[contains(.,'symrefs=')], concat($quote-chars,' '), ''),         'symrefs=')"/>
68
69<!-- sort references if a processing instruction <?rfc?>
70     exists with contents sortrefs="yes". Can be overriden by an XSLT parameter -->
71
72<xsl:param name="xml2rfc-sortrefs" select="substring-after(       translate(/processing-instruction('rfc')[contains(.,'sortrefs=')], concat($quote-chars,' '), ''),         'sortrefs=')"/>
73
74<!-- insert editing marks if a processing instruction <?rfc?>
75     exists with contents editing="yes". Can be overriden by an XSLT parameter -->
76
77<xsl:param name="xml2rfc-editing" select="substring-after(       translate(/processing-instruction('rfc')[contains(.,'editing=')], concat($quote-chars,' '), ''),         'editing=')"/>
78
79<!-- make it a private paper -->
80
81<xsl:param name="xml2rfc-private" select="substring-after(       translate(/processing-instruction('rfc')[contains(.,'private=')], $quote-chars, ''),         'private=')"/>
82
83<!-- background image? -->
84
85<xsl:param name="xml2rfc-background" select="substring-after(       translate(/processing-instruction('rfc')[contains(.,'background=')], $quote-chars, ''),         'background=')"/>
86
87<!-- extension for XML parsing in artwork -->
88
89<xsl:param name="xml2rfc-ext-parse-xml-in-artwork" select="substring-after(       translate(/processing-instruction('rfc-ext')[contains(.,'parse-xml-in-artwork=')], concat($quote-chars,' '), ''),         'parse-xml-in-artwork=')"/>
90
91<!-- extension for excluding DCMI properties in meta tag (RFC2731) -->
92
93<xsl:param name="xml2rfc-ext-support-rfc2731" select="substring-after(       translate(/processing-instruction('rfc-ext')[contains(.,'support-rfc2731=')], concat($quote-chars,' '), ''),         'support-rfc2731=')"/>
94
95<!-- extension for allowing markup inside artwork -->
96
97<xsl:param name="xml2rfc-ext-allow-markup-in-artwork" select="substring-after(       translate(/processing-instruction('rfc-ext')[contains(.,'allow-markup-in-artwork=')], concat($quote-chars,' '), ''),         'allow-markup-in-artwork=')"/>
98
99<!-- extension for including references into index -->
100
101<xsl:param name="xml2rfc-ext-include-references-in-index" select="substring-after(       translate(/processing-instruction('rfc-ext')[contains(.,'include-references-in-index=')], concat($quote-chars,' '), ''),         'include-references-in-index=')"/>
102
103<!-- position of author's section -->
104
105<xsl:param name="xml2rfc-ext-authors-section" select="substring-after(       translate(/processing-instruction('rfc-ext')[contains(.,'authors-section=')], concat($quote-chars,' '), ''),         'authors-section=')"/>
106
107<!-- justification? -->
108
109<xsl:param name="xml2rfc-ext-justification" select="substring-after(       translate(/processing-instruction('rfc-ext')[contains(.,'justification=')], concat($quote-chars,' '), ''),         'justification=')"/>
110
111<!-- trailing dots in section numbers -->
112
113<xsl:param name="xml2rfc-ext-sec-no-trailing-dots" select="substring-after(       translate(/processing-instruction('rfc-ext')[contains(.,'sec-no-trailing-dots=')], concat($quote-chars,' '), ''),         'sec-no-trailing-dots=')"/>
114
115<!-- choose whether or not to do mailto links --> 
116 
117 <xsl:param name="xml2rfc-linkmailto" select="substring-after(         translate(/processing-instruction('rfc')[contains(.,'linkmailto=')], concat($quote-chars,' '), ''),           'linkmailto=')"/> 
118
119
120<!-- iprnotified switch --> 
121 
122 <xsl:param name="xml2rfc-iprnotified" select="substring-after(         translate(/processing-instruction('rfc')[contains(.,'iprnotified=')], concat($quote-chars,' '), ''),           'iprnotified=')"/> 
123
124
125<!-- URL templates for RFCs and Internet Drafts. -->
126
127<!-- Reference the authorative ASCII versions
128<xsl:param name="rfcUrlPrefix" select="'http://www.ietf.org/rfc/rfc'" />
129<xsl:param name="rfcUrlPostfix" select="'.txt'" />
130-->
131<!-- Reference the marked up versions over on http://tools.ietf.org/html. -->
132<xsl:param name="rfcUrlPrefix" select="'http://tools.ietf.org/html/rfc'"/>
133<xsl:param name="rfcUrlPostfix" select="''"/>
134<xsl:param name="rfcUrlFrag" select="'section-'"/>
135<xsl:param name="internetDraftUrlPrefix" select="'http://tools.ietf.org/html/'"/>
136<xsl:param name="internetDraftUrlPostfix" select="''"/>
137<xsl:param name="internetDraftUrlFrag" select="'section-'"/>
138
139<!-- warning re: absent node-set ext. function -->
140<xsl:variable name="node-set-warning">
141  This stylesheet requires either an XSLT-1.0 processor with node-set()
142  extension function, or an XSLT-2.0 processor. Therefore, parts of the
143  document couldn't be displayed.
144</xsl:variable>
145
146<!-- character translation tables -->
147<xsl:variable name="lcase" select="'abcdefghijklmnopqrstuvwxyz'"/>
148<xsl:variable name="ucase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>       
149
150<xsl:variable name="plain" select="' #/ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
151<xsl:variable name="touri" select="'___abcdefghijklmnopqrstuvwxyz'"/>
152
153<!-- build help keys for indices -->
154<xsl:key name="index-first-letter" match="iref|reference" use="translate(substring(concat(@anchor,@item),1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
155
156<xsl:key name="index-item" match="iref" use="@item"/>
157
158<xsl:key name="index-item-subitem" match="iref" use="concat(@item,'..',@subitem)"/>
159
160<xsl:key name="index-xref-by-sec" match="xref[@x:sec]" use="concat(@target,'..',@x:sec)"/>
161
162<xsl:key name="index-xref-by-anchor" match="xref[@x:rel]" use="concat(@target,'..',@x:rel)"/>
163
164<!-- prefix for automatically generated anchors -->
165<xsl:variable name="anchor-prefix" select="'rfc'"/>
166
167<!-- IPR version switch -->
168<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)   )"/>
169
170<xsl:variable name="ipr-rfc4748" select="(   $ipr-rfc3667 and     (       (/rfc/@number &gt; 4671) or       (/rfc/front/date/@year &gt; 2006) or       (/rfc/front/date/@year &gt; 2005 and (/rfc/front/date/@month='November' or /rfc/front/date/@month='December'))     )   )"/>
171
172<!-- will document have an index -->
173<xsl:variable name="has-index" select="//iref or (//xref and $xml2rfc-ext-include-references-in-index='yes')"/>
174         
175<!-- Templates for the various elements of rfc2629.dtd -->
176             
177<xsl:template match="text()[not(ancestor::artwork)]">
178  <xsl:variable name="starts-with-ws" select="translate(substring(.,1,1),'&#x9;&#xA;&#xD; ','')"/>
179  <xsl:variable name="ends-with-ws" select="translate(substring(.,string-length(.),1),'&#x9;&#xA;&#xD; ','')"/>
180  <!--<xsl:message> Orig: "<xsl:value-of select="."/>"</xsl:message>
181  <xsl:message>Start: "<xsl:value-of select="$starts-with-ws"/>"</xsl:message>
182  <xsl:message>  End: "<xsl:value-of select="$ends-with-ws"/>"</xsl:message> -->
183  <xsl:if test="$starts-with-ws='' and preceding-sibling::node()">
184    <xsl:text> </xsl:text>
185  </xsl:if>
186  <xsl:value-of select="normalize-space(.)"/>
187  <xsl:if test="$ends-with-ws='' and following-sibling::node()">
188    <xsl:text> </xsl:text>
189  </xsl:if>
190</xsl:template>
191             
192             
193<xsl:template match="abstract">
194  <h1 xmlns="http://www.w3.org/1999/xhtml" id="{$anchor-prefix}.abstract"><a href="#{$anchor-prefix}.abstract">Abstract</a></h1>
195  <xsl:apply-templates/>
196</xsl:template>
197
198<msxsl:script language="JScript" implements-prefix="myns">
199  function parseXml(str) {
200    try {
201      var doc = new ActiveXObject("MSXML2.DOMDocument");
202      doc.async = false;
203      if (doc.loadXML(str)) {
204        return "";
205      }
206      else {
207        return doc.parseError.reason + "\n" + doc.parseError.srcText + " (" + doc.parseError.line + "/" + doc.parseError.linepos + ")";
208      }
209    }
210    catch(e) {
211      return "";
212    }
213  }
214</msxsl:script>
215
216<xsl:template name="add-artwork-class">
217  <xsl:choose>
218    <xsl:when test="@type='abnf' or @type='abnf2616' or @type='application/xml-dtd' or @type='inline' or @type='application/relax-ng-compact-syntax'">
219      <xsl:attribute name="class">inline</xsl:attribute>
220    </xsl:when>
221    <xsl:when test="starts-with(@type,'message/http') and contains(@type,'msgtype=&#34;request&#34;')">
222      <xsl:attribute name="class">text2</xsl:attribute>
223    </xsl:when>
224    <xsl:when test="starts-with(@type,'message/http')">
225      <xsl:attribute name="class">text</xsl:attribute>
226    </xsl:when>
227    <xsl:when test="starts-with(@type,'drawing')">
228      <xsl:attribute name="class">drawing</xsl:attribute>
229    </xsl:when>
230    <xsl:when test="starts-with(@type,'text/plain') or @type='example' or @type='code'">
231      <xsl:attribute name="class">text</xsl:attribute>
232    </xsl:when>
233    <xsl:otherwise/>
234  </xsl:choose>
235</xsl:template>
236
237<xsl:template match="artwork">
238  <xsl:if test="not(ancestor::ed:del) and $xml2rfc-ext-parse-xml-in-artwork='yes' and function-available('myns:parseXml')">
239    <xsl:if test="contains(.,'&lt;?xml')">
240      <xsl:variable name="body" select="substring-after(substring-after(.,'&lt;?xml'),'?&gt;')"/> 
241      <xsl:if test="$body!='' and myns:parseXml($body)!=''">
242        <table xmlns="http://www.w3.org/1999/xhtml" style="background-color: red; border-width: thin; border-style: solid; border-color: black;">
243        <tr><td>
244        XML PARSE ERROR; parsed the body below:
245        <pre>
246        <xsl:value-of select="$body"/>
247        </pre>
248        resulting in:
249        <pre>
250        <xsl:value-of select="myns:parseXml($body)"/>
251        </pre>
252        </td></tr></table>
253      </xsl:if>
254    </xsl:if>
255    <xsl:if test="@ed:parse-xml-after">
256      <xsl:if test="myns:parseXml(string(.))!=''">
257        <table xmlns="http://www.w3.org/1999/xhtml" style="background-color: red; border-width: thin; border-style: solid; border-color: black;">
258        <tr><td>
259        XML PARSE ERROR:
260        <pre><xsl:value-of select="myns:parseXml(string(.))"/></pre>
261        </td></tr></table>
262      </xsl:if>
263    </xsl:if>
264  </xsl:if>
265  <xsl:variable name="display">
266    <xsl:choose>
267      <xsl:when test="$xml2rfc-ext-allow-markup-in-artwork='yes'">
268        <xsl:apply-templates/>
269      </xsl:when>
270      <xsl:otherwise>
271        <xsl:value-of select="."/>
272      </xsl:otherwise>
273    </xsl:choose>
274  </xsl:variable> 
275  <xsl:choose>
276    <xsl:when test="@align='right'">
277      <div xmlns="http://www.w3.org/1999/xhtml" style="display:table; margin-left: auto; margin-right: 0pt;">
278        <pre style="margin-left: 0em;">
279          <xsl:call-template name="add-artwork-class"/>
280          <xsl:call-template name="insertInsDelClass"/>
281          <xsl:copy-of select="$display"/>
282        </pre>         
283      </div>
284    </xsl:when>
285    <xsl:when test="@align='center'">
286      <div xmlns="http://www.w3.org/1999/xhtml" style="display:table; margin-left: auto; margin-right: auto;">
287        <pre style="margin-left: 0em;">
288          <xsl:call-template name="add-artwork-class"/>
289          <xsl:call-template name="insertInsDelClass"/>
290          <xsl:copy-of select="$display"/>
291        </pre>         
292      </div>
293    </xsl:when>
294    <xsl:otherwise>
295      <pre xmlns="http://www.w3.org/1999/xhtml">
296        <xsl:call-template name="add-artwork-class"/>
297        <xsl:call-template name="insertInsDelClass"/>
298        <xsl:copy-of select="$display"/>
299      </pre>
300    </xsl:otherwise>
301  </xsl:choose>
302  <xsl:call-template name="check-artwork-width">
303    <xsl:with-param name="content"><xsl:apply-templates/></xsl:with-param>
304  </xsl:call-template>
305</xsl:template>
306
307<!-- special case for first text node in artwork -->
308<xsl:template match="artwork/text()[1]">
309  <xsl:choose>
310    <xsl:when test="starts-with(.,'&#xA;')">
311      <!-- reduce leading whitespace -->
312      <xsl:value-of select="substring(.,2)"/>
313    </xsl:when>
314    <xsl:otherwise>
315      <xsl:value-of select="."/>
316    </xsl:otherwise>
317  </xsl:choose>
318</xsl:template>
319
320
321<xsl:template name="check-artwork-width">
322  <xsl:param name="content"/>
323  <xsl:choose>
324    <xsl:when test="not(contains($content,'&#xA;'))">
325      <xsl:if test="string-length($content) &gt; 69">
326        <xsl:message>artwork line too long: <xsl:value-of select="$content"/></xsl:message>
327      </xsl:if>
328    </xsl:when>
329    <xsl:otherwise>
330      <xsl:variable name="start" select="substring-before($content,'&#xA;')"/> 
331      <xsl:variable name="end" select="substring-after($content,'&#xA;')"/> 
332      <xsl:if test="string-length($start) &gt; 69">
333        <xsl:message>WARNING: artwork line too long: <xsl:value-of select="$start"/><xsl:call-template name="lineno"/></xsl:message>
334      </xsl:if>
335      <xsl:call-template name="check-artwork-width">
336        <xsl:with-param name="content" select="$end"/>
337      </xsl:call-template>
338    </xsl:otherwise>
339  </xsl:choose>
340</xsl:template>
341
342<xsl:template match="artwork[@src and starts-with(@type,'image/')]">
343  <p xmlns="http://www.w3.org/1999/xhtml">
344    <img src="{@src}" alt="{.}">
345      <xsl:copy-of select="@width|@height"/>
346    </img>
347  </p>
348</xsl:template>
349
350<xsl:template match="author">
351
352    <address xmlns="http://www.w3.org/1999/xhtml" class="vcard">
353      <span class="vcardline">
354        <span class="fn">
355          <xsl:value-of select="@fullname"/>
356        </span>
357        <xsl:if test="@role">
358          (<xsl:value-of select="@role"/>)
359        </xsl:if>
360        <!-- components of name (hidden from display -->
361        <span class="n hidden">
362          <span class="family-name"><xsl:value-of select="@surname"/></span>
363          <!-- given-name family-name -->
364          <xsl:if test="@surname=substring(@fullname,1 + string-length(@fullname) - string-length(@surname))">
365            <span class="given-name"><xsl:value-of select="normalize-space(substring(@fullname,1,string-length(@fullname) - string-length(@surname)))"/></span>
366          </xsl:if>
367          <!-- family-name given-name -->
368          <xsl:if test="starts-with(@fullname,@surname)">
369            <span class="given-name"><xsl:value-of select="normalize-space(substring-after(@fullname,@surname))"/></span>
370          </xsl:if>
371        </span>
372      </span>
373      <xsl:if test="normalize-space(organization) != ''">
374        <span class="org vcardline">
375          <xsl:value-of select="organization"/>
376        </span>
377      </xsl:if>
378      <xsl:if test="address/postal">
379        <span class="adr">
380          <xsl:if test="address/postal/street!=''">
381            <xsl:for-each select="address/postal/street">
382              <span class="street-address vcardline">
383                <xsl:value-of select="."/>
384              </span>
385            </xsl:for-each>
386          </xsl:if>
387          <xsl:if test="address/postal/city|address/postal/region|address/postal/code">
388            <span class="vcardline">
389              <xsl:if test="address/postal/city"><span class="locality"><xsl:value-of select="address/postal/city"/></span>, </xsl:if>
390              <xsl:if test="address/postal/region"><span class="region"><xsl:value-of select="address/postal/region"/></span> </xsl:if>
391              <xsl:if test="address/postal/code"><span class="postal-code"><xsl:value-of select="address/postal/code"/></span></xsl:if>
392            </span>
393          </xsl:if>
394          <xsl:if test="address/postal/country">
395            <span class="country-name vcardline"><xsl:value-of select="address/postal/country"/></span>
396          </xsl:if>
397        </span>
398      </xsl:if>
399      <xsl:if test="address/phone">
400        <span class="vcardline tel">
401          <xsl:text>Phone: </xsl:text>
402          <a href="tel:{translate(address/phone,' ','')}"><span class="value"><xsl:value-of select="address/phone"/></span></a>
403        </span>
404      </xsl:if>
405      <xsl:if test="address/facsimile">
406        <span class="vcardline tel">
407          <span class="type">Fax</span><xsl:text>: </xsl:text>
408          <a href="fax:{translate(address/facsimile,' ','')}"><span class="value"><xsl:value-of select="address/facsimile"/></span></a>
409        </span>
410      </xsl:if>
411      <xsl:if test="address/email">
412        <span class="vcardline">
413        <xsl:text>EMail: </xsl:text>
414        <a>
415          <xsl:if test="$xml2rfc-linkmailto!='no'">
416            <xsl:attribute name="href">mailto:<xsl:value-of select="address/email"/></xsl:attribute>
417          </xsl:if>
418          <span class="email"><xsl:value-of select="address/email"/></span>
419        </a>
420        </span>
421      </xsl:if>
422      <xsl:if test="address/uri">
423        <span class="vcardline">
424          <xsl:text>URI: </xsl:text>
425          <a href="{address/uri}" class="url"><xsl:value-of select="address/uri"/></a>
426        </span>
427      </xsl:if>
428    </address>
429
430</xsl:template>
431
432<xsl:template match="back">
433
434  <!-- add references section first, no matter where it appears in the
435    source document -->
436  <!-- as of April 2004, process from middle section
437  <xsl:apply-templates select="references" />
438  -->
439 
440  <!-- add editorial comments -->
441  <xsl:if test="//cref and $xml2rfc-comments='yes' and $xml2rfc-inline!='yes'">
442    <xsl:call-template name="insertComments"/>
443  </xsl:if>
444 
445  <!-- next, add information about the document's authors -->
446  <xsl:if test="$xml2rfc-ext-authors-section!='end'">
447    <xsl:call-template name="insertAuthors"/>
448  </xsl:if>
449     
450  <!-- add all other top-level sections under <back> -->
451  <xsl:apply-templates select="*[not(self::references) and not(self::ed:replace and .//references)]"/>
452
453  <xsl:if test="$xml2rfc-ext-authors-section='end'">
454    <xsl:call-template name="insertAuthors"/>
455  </xsl:if>
456
457  <xsl:if test="not($xml2rfc-private)">
458    <!-- copyright statements -->
459    <xsl:variable name="copyright"><xsl:call-template name="insertCopyright"/></xsl:variable>
460 
461    <!-- emit it -->
462    <xsl:choose>
463      <xsl:when test="function-available('msxsl:node-set')">
464        <xsl:apply-templates select="msxsl:node-set($copyright)"/>
465      </xsl:when>
466      <xsl:when test="function-available('exslt:node-set')">
467        <xsl:apply-templates select="exslt:node-set($copyright)"/>
468      </xsl:when>
469      <xsl:otherwise>
470        <xsl:call-template name="error">
471          <xsl:with-param name="msg" select="$node-set-warning"/>
472        </xsl:call-template>
473      </xsl:otherwise>
474    </xsl:choose>
475  </xsl:if>
476 
477  <!-- insert the index if index entries exist -->
478  <xsl:if test="$has-index">
479    <xsl:call-template name="insertIndex"/>
480  </xsl:if>
481
482</xsl:template>
483
484<xsl:template match="eref[node()]">
485  <a xmlns="http://www.w3.org/1999/xhtml" href="{@target}"><xsl:apply-templates/></a>
486</xsl:template>
487               
488<xsl:template match="eref[not(node())]">
489  <xsl:text>&lt;</xsl:text>
490  <a xmlns="http://www.w3.org/1999/xhtml" href="{@target}"><xsl:value-of select="@target"/></a>
491  <xsl:text>&gt;</xsl:text>
492</xsl:template>
493
494<xsl:template match="figure">
495  <xsl:if test="@anchor!=''">
496    <div xmlns="http://www.w3.org/1999/xhtml" id="{@anchor}"/>
497  </xsl:if>
498  <xsl:variable name="anch">
499    <xsl:call-template name="get-figure-anchor"/>
500  </xsl:variable>
501  <div xmlns="http://www.w3.org/1999/xhtml" id="{$anch}"/>
502  <xsl:apply-templates/>
503  <xsl:if test="@title!='' or @anchor!=''">
504    <xsl:variable name="n"><xsl:number level="any" count="figure[@title!='' or @anchor!='']"/></xsl:variable>
505    <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>
506  </xsl:if>
507</xsl:template>
508
509<xsl:template match="front">
510 
511  <xsl:if test="$xml2rfc-topblock!='no'">
512    <!-- collect information for left column -->
513     
514    <xsl:variable name="leftColumn">
515      <xsl:call-template name="collectLeftHeaderColumn"/>   
516    </xsl:variable>
517 
518    <!-- collect information for right column -->
519     
520    <xsl:variable name="rightColumn">
521      <xsl:call-template name="collectRightHeaderColumn"/>   
522    </xsl:variable>
523     
524    <!-- insert the collected information -->
525    <table xmlns="http://www.w3.org/1999/xhtml" summary="header information" class="header" border="0" cellpadding="1" cellspacing="1">
526      <xsl:choose>
527        <xsl:when test="function-available('msxsl:node-set')">
528          <xsl:call-template name="emitheader">
529            <xsl:with-param name="lc" select="msxsl:node-set($leftColumn)"/>   
530            <xsl:with-param name="rc" select="msxsl:node-set($rightColumn)"/>   
531          </xsl:call-template>
532        </xsl:when>   
533        <xsl:when test="function-available('exslt:node-set')">
534          <xsl:call-template name="emitheader">
535            <xsl:with-param name="lc" select="exslt:node-set($leftColumn)"/>   
536            <xsl:with-param name="rc" select="exslt:node-set($rightColumn)"/>   
537          </xsl:call-template>
538        </xsl:when>   
539        <xsl:otherwise>
540          <xsl:call-template name="error">
541            <xsl:with-param name="msg" select="$node-set-warning"/>
542          </xsl:call-template>
543        </xsl:otherwise>
544      </xsl:choose>
545    </table>
546  </xsl:if>
547   
548  <p xmlns="http://www.w3.org/1999/xhtml" class="title">
549    <!-- main title -->
550    <xsl:apply-templates select="title"/>
551    <xsl:if test="/rfc/@docName">
552      <br/>
553      <span class="filename"><xsl:value-of select="/rfc/@docName"/></span>
554     
555      <xsl:if test="contains(/rfc/@docName,'.')">
556        <xsl:call-template name="warning">
557          <xsl:with-param name="msg">The @docName attribute should contain the base name, not the filename (thus no file extension).</xsl:with-param>
558        </xsl:call-template>
559      </xsl:if>
560    </xsl:if> 
561  </p>
562 
563  <!-- insert notice about update -->
564  <xsl:variable name="published-as" select="/*/x:link[@rel='Alternate' and starts-with(@title,'RFC')]"/>
565  <xsl:if test="$published-as">
566    <p xmlns="http://www.w3.org/1999/xhtml" style="color: green; text-align: center; font-size: 14pt; background-color: yellow;">
567      <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>.
568    </p>
569  </xsl:if>
570   
571  <xsl:if test="not($xml2rfc-private)">
572    <!-- Get status info formatted as per RFC2629-->
573    <xsl:variable name="preamble"><xsl:call-template name="insertPreamble"/></xsl:variable>
574   
575    <!-- emit it -->
576    <xsl:choose>
577      <xsl:when test="function-available('msxsl:node-set')">
578        <xsl:apply-templates select="msxsl:node-set($preamble)"/>
579      </xsl:when>
580      <xsl:when test="function-available('exslt:node-set')">
581        <xsl:apply-templates select="exslt:node-set($preamble)"/>
582      </xsl:when>
583      <xsl:otherwise>
584        <xsl:call-template name="error">
585          <xsl:with-param name="msg" select="$node-set-warning"/>
586        </xsl:call-template>
587      </xsl:otherwise>
588    </xsl:choose>
589  </xsl:if>
590           
591  <xsl:apply-templates select="abstract"/>
592  <xsl:apply-templates select="note"/>
593  <!-- show notes inside change tracking as well -->
594  <xsl:apply-templates select="ed:replace[.//note]"/>
595   
596  <xsl:if test="$xml2rfc-toc='yes'">
597    <xsl:apply-templates select="/" mode="toc"/>
598    <xsl:call-template name="insertTocAppendix"/>
599  </xsl:if>
600
601</xsl:template>
602
603
604<xsl:template match="iref">
605  <xsl:variable name="anchor"><xsl:call-template name="compute-iref-anchor"/></xsl:variable>
606  <xsl:choose>
607    <xsl:when test="ancestor::t|ancestor::figure">
608      <span xmlns="http://www.w3.org/1999/xhtml" id="{$anchor}"/>
609    </xsl:when>
610    <xsl:otherwise>
611      <div xmlns="http://www.w3.org/1999/xhtml" id="{$anchor}"/>
612    </xsl:otherwise>
613  </xsl:choose>
614</xsl:template>
615
616<xsl:template name="compute-iref-anchor">
617  <xsl:variable name="first" select="translate(substring(@item,1,1),$ucase,$lcase)"/>
618  <xsl:variable name="nkey" select="translate($first,$lcase,'')"/>
619  <xsl:choose>
620    <xsl:when test="$nkey=''">
621      <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)]"/>
622    </xsl:when>
623    <xsl:otherwise>
624      <xsl:value-of select="$anchor-prefix"/>.iref.<xsl:number level="any" count="iref[translate(substring(@item,1,1),concat($lcase,$ucase),'')='']"/>
625    </xsl:otherwise>
626  </xsl:choose>
627</xsl:template>
628
629<!-- list templates depend on the list style -->
630
631<xsl:template match="list[@style='empty' or not(@style)]">
632  <dl xmlns="http://www.w3.org/1999/xhtml" class="empty">
633    <xsl:call-template name="insertInsDelClass"/>
634    <xsl:apply-templates/>
635  </dl>
636</xsl:template>
637
638<xsl:template match="list[starts-with(@style,'format ')]">
639  <dl xmlns="http://www.w3.org/1999/xhtml">
640    <xsl:call-template name="insertInsDelClass"/>
641    <xsl:apply-templates/>
642  </dl>
643</xsl:template>
644
645<xsl:template match="list[@style='hanging']">
646  <dl xmlns="http://www.w3.org/1999/xhtml">
647    <xsl:call-template name="insertInsDelClass"/>
648    <xsl:apply-templates/>
649  </dl>
650</xsl:template>
651
652<xsl:template match="list[@style='numbers']">
653  <ol xmlns="http://www.w3.org/1999/xhtml">
654    <xsl:call-template name="insertInsDelClass"/>
655    <xsl:apply-templates/>
656  </ol>
657</xsl:template>
658
659<!-- numbered list inside numbered list -->
660<xsl:template match="list[@style='numbers']/t/list[@style='numbers']" priority="9">
661  <ol xmlns="http://www.w3.org/1999/xhtml" style="list-style-type: lower-alpha">
662    <xsl:call-template name="insertInsDelClass"/>
663    <xsl:apply-templates/>
664  </ol>
665</xsl:template>
666
667<xsl:template match="list[@style='letters']">
668  <ol xmlns="http://www.w3.org/1999/xhtml" style="list-style-type: lower-alpha">
669    <xsl:call-template name="insertInsDelClass"/>
670    <xsl:apply-templates/>
671  </ol>
672</xsl:template>
673
674<!-- nested lettered list uses uppercase -->
675<xsl:template match="list//t//list[@style='letters']" priority="9">
676  <ol xmlns="http://www.w3.org/1999/xhtml" style="list-style-type: upper-alpha">
677    <xsl:call-template name="insertInsDelClass"/>
678    <xsl:apply-templates/>
679  </ol>
680</xsl:template>
681   
682<xsl:template match="list[@style='symbols']">
683  <ul xmlns="http://www.w3.org/1999/xhtml">
684    <xsl:call-template name="insertInsDelClass"/>
685    <xsl:apply-templates/>
686  </ul>
687</xsl:template>
688
689
690<!-- same for t(ext) elements -->
691
692<xsl:template match="list[@style='empty' or not(@style)]/t | list[@style='empty' or not(@style)]/ed:replace/ed:*/t">
693  <!-- Inherited through CSS now <dd style="margin-top: .5em">-->
694  <dd xmlns="http://www.w3.org/1999/xhtml">
695    <xsl:call-template name="insertInsDelClass"/>
696    <xsl:if test="@anchor"><xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute></xsl:if>
697    <xsl:apply-templates/>
698  </dd>
699</xsl:template>
700
701<xsl:template match="list[@style='numbers' or @style='symbols' or @style='letters']/x:lt">
702  <li xmlns="http://www.w3.org/1999/xhtml">
703    <xsl:if test="@anchor"><xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute></xsl:if>
704    <xsl:apply-templates select="t"/>
705  </li>
706</xsl:template>
707
708<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">
709  <li xmlns="http://www.w3.org/1999/xhtml">
710    <xsl:call-template name="insertInsDelClass"/>
711    <xsl:for-each select="../..">
712      <xsl:call-template name="insert-issue-pointer"/>
713    </xsl:for-each>
714    <xsl:if test="@anchor"><xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute></xsl:if>
715    <xsl:apply-templates/>
716  </li>
717</xsl:template>
718
719<xsl:template match="list[@style='hanging']/x:lt">
720  <xsl:if test="@hangText!=''">
721    <dt xmlns="http://www.w3.org/1999/xhtml">
722      <xsl:call-template name="insertInsDelClass"/>
723      <xsl:variable name="del-node" select="ancestor::ed:del"/>
724      <xsl:variable name="rep-node" select="ancestor::ed:replace"/>
725      <xsl:variable name="deleted" select="$del-node and ($rep-node/ed:ins)"/>
726      <xsl:for-each select="../..">
727        <xsl:call-template name="insert-issue-pointer">
728          <xsl:with-param name="deleted-anchor" select="$deleted"/>
729        </xsl:call-template>
730      </xsl:for-each>
731      <xsl:if test="@anchor"><xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute></xsl:if>
732      <xsl:value-of select="@hangText"/>
733    </dt>
734  </xsl:if>
735  <dd xmlns="http://www.w3.org/1999/xhtml">
736    <xsl:call-template name="insertInsDelClass"/>
737    <!-- if hangIndent present, use 0.7 of the specified value (1em is the width of the "m" character -->
738    <xsl:if test="../@hangIndent and ../@hangIndent!='0'">
739      <xsl:attribute name="style">margin-left: <xsl:value-of select="../@hangIndent * 0.7"/>em</xsl:attribute>
740    </xsl:if>
741    <xsl:apply-templates select="t"/>
742  </dd>
743</xsl:template>
744
745<xsl:template match="list[@style='hanging']/t | list[@style='hanging']/ed:replace/ed:*/t">
746  <xsl:if test="@hangText!=''">
747    <dt xmlns="http://www.w3.org/1999/xhtml">
748      <xsl:call-template name="insertInsDelClass"/>
749      <xsl:if test="count(preceding-sibling::t)=0">
750        <xsl:variable name="del-node" select="ancestor::ed:del"/>
751        <xsl:variable name="rep-node" select="ancestor::ed:replace"/>
752        <xsl:variable name="deleted" select="$del-node and ($rep-node/ed:ins)"/>
753        <xsl:for-each select="../..">
754          <xsl:call-template name="insert-issue-pointer">
755            <xsl:with-param name="deleted-anchor" select="$deleted"/>
756          </xsl:call-template>
757        </xsl:for-each>
758      </xsl:if>
759      <xsl:if test="@anchor"><xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute></xsl:if>
760      <xsl:value-of select="@hangText"/>
761    </dt>
762  </xsl:if>
763
764  <xsl:variable name="dd-content">
765    <xsl:apply-templates/>
766  </xsl:variable>
767
768  <xsl:if test="$dd-content!=''">
769    <dd xmlns="http://www.w3.org/1999/xhtml">
770      <xsl:call-template name="insertInsDelClass"/>
771      <!-- if hangIndent present, use 0.7 of the specified value (1em is the width of the "m" character -->
772      <xsl:if test="../@hangIndent and ../@hangIndent!='0'">
773        <xsl:attribute name="style">margin-left: <xsl:value-of select="../@hangIndent * 0.7"/>em</xsl:attribute>
774      </xsl:if>
775      <xsl:apply-templates/>
776    </dd>
777  </xsl:if>
778</xsl:template>
779
780<xsl:template match="list[starts-with(@style,'format ') and (contains(@style,'%c') or contains(@style,'%d'))]/t">
781  <xsl:variable name="list" select=".."/>
782  <xsl:variable name="format" select="substring-after(../@style,'format ')"/>
783  <xsl:variable name="pos">
784    <xsl:choose>
785      <xsl:when test="$list/@counter">
786        <xsl:number level="any" count="list[@counter=$list/@counter or (not(@counter) and @style=concat('format ',$list/@counter))]/t"/>
787      </xsl:when>
788      <xsl:otherwise>
789        <xsl:number level="any" count="list[concat('format ',@counter)=$list/@style or (not(@counter) and @style=$list/@style)]/t"/>
790      </xsl:otherwise>
791    </xsl:choose>
792  </xsl:variable>
793  <dt xmlns="http://www.w3.org/1999/xhtml">
794    <xsl:if test="@anchor"><xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute></xsl:if>
795    <xsl:choose>
796      <xsl:when test="contains($format,'%c')">
797        <xsl:value-of select="substring-before($format,'%c')"/><xsl:number value="$pos" format="a"/><xsl:value-of select="substring-after($format,'%c')"/>
798      </xsl:when>
799      <xsl:otherwise>
800        <xsl:value-of select="substring-before($format,'%d')"/><xsl:number value="$pos" format="1"/><xsl:value-of select="substring-after($format,'%d')"/>
801      </xsl:otherwise>
802    </xsl:choose>
803  </dt>
804  <dd xmlns="http://www.w3.org/1999/xhtml">
805    <xsl:apply-templates/>
806  </dd>
807</xsl:template>
808
809<xsl:template match="middle">
810  <xsl:apply-templates/>
811  <xsl:apply-templates select="../back//references"/>
812</xsl:template>
813
814<xsl:template match="note">
815  <xsl:variable name="num"><xsl:number/></xsl:variable>
816    <h1 xmlns="http://www.w3.org/1999/xhtml" id="{$anchor-prefix}.note.{$num}">
817      <xsl:call-template name="insertInsDelClass"/>
818      <a href="#{$anchor-prefix}.note.{$num}">
819        <xsl:value-of select="@title"/>
820      </a>
821    </h1>
822  <xsl:apply-templates/>
823</xsl:template>
824
825<xsl:template match="postamble">
826  <xsl:if test="normalize-space(.) != ''">
827    <p xmlns="http://www.w3.org/1999/xhtml">
828      <xsl:call-template name="insertInsDelClass"/>
829      <xsl:call-template name="editingMark"/>
830      <xsl:apply-templates/>
831    </p>
832  </xsl:if>
833</xsl:template>
834
835<xsl:template match="preamble">
836  <xsl:if test="normalize-space(.) != ''">
837    <p xmlns="http://www.w3.org/1999/xhtml">
838      <xsl:if test="@anchor">
839        <xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute>
840      </xsl:if>
841      <xsl:call-template name="insertInsDelClass"/>
842      <xsl:call-template name="editingMark"/>
843      <xsl:apply-templates/>
844    </p>
845  </xsl:if>
846</xsl:template>
847
848<xsl:template name="computed-auto-target">
849  <xsl:param name="bib"/>
850  <xsl:param name="ref"/>
851
852  <xsl:choose>
853    <xsl:when test="$ref and $bib/x:source/@href and $bib/x:source/@basename and $ref/@x:rel">
854      <xsl:value-of select="concat($bib/x:source/@basename,'.html',$ref/@x:rel)"/>
855    </xsl:when>
856    <xsl:when test="$bib/seriesInfo/@name='RFC'">
857      <xsl:variable name="sec">
858        <xsl:choose>
859          <xsl:when test="$ref and starts-with($ref/@x:rel,'#') and not($ref/@x:sec)">
860            <xsl:variable name="extdoc" select="document($bib/x:source/@href)"/>
861            <xsl:for-each select="$extdoc//*[@anchor=substring-after($ref/@x:rel,'#')]">
862              <xsl:call-template name="get-section-number"/>
863            </xsl:for-each>
864          </xsl:when>
865          <xsl:when test="$ref">
866            <xsl:value-of select="$ref/@x:sec"/>
867          </xsl:when>
868          <xsl:otherwise/>
869        </xsl:choose>
870      </xsl:variable>
871      <xsl:value-of select="concat($rfcUrlPrefix,$bib/seriesInfo[@name='RFC']/@value,$rfcUrlPostfix)"/>
872      <xsl:if test="$ref and $sec!='' and $rfcUrlFrag">
873        <xsl:value-of select="concat('#',$rfcUrlFrag,$sec)"/>
874      </xsl:if>
875    </xsl:when>
876    <xsl:when test="$bib/seriesInfo/@name='Internet-Draft'">
877      <xsl:value-of select="concat($internetDraftUrlPrefix,$bib/seriesInfo[@name='Internet-Draft']/@value,$internetDraftUrlPostfix)"/>
878      <xsl:if test="$ref and $ref/@x:sec and $internetDraftUrlFrag">
879        <xsl:value-of select="concat('#',$internetDraftUrlFrag,$ref/@x:sec)"/>
880      </xsl:if>
881    </xsl:when>
882    <xsl:otherwise/>
883  </xsl:choose> 
884 
885</xsl:template>
886
887<xsl:template name="computed-target">
888  <xsl:param name="bib"/>
889  <xsl:param name="ref"/>
890
891  <xsl:choose>
892    <xsl:when test="$bib/@target">
893      <xsl:if test="$ref and $ref/@x:sec and $ref/@x:rel">
894        <xsl:value-of select="concat($bib/@target,$ref/@x:rel)"/>
895      </xsl:if>
896    </xsl:when>
897    <xsl:otherwise>
898      <xsl:call-template name="computed-auto-target">
899        <xsl:with-param name="bib" select="$bib"/>
900        <xsl:with-param name="ref" select="$ref"/>
901      </xsl:call-template>
902    </xsl:otherwise>
903  </xsl:choose> 
904 
905</xsl:template>
906
907<xsl:template match="reference">
908
909  <!-- check for reference to reference -->
910  <xsl:variable name="anchor" select="@anchor"/>
911  <xsl:if test="not(ancestor::ed:del) and not(//xref[@target=$anchor])">
912    <xsl:message>WARNING: unused reference '<xsl:value-of select="@anchor"/>'<xsl:call-template name="lineno"/></xsl:message>
913  </xsl:if>
914
915  <xsl:variable name="target">
916    <xsl:choose>
917      <xsl:when test="@target"><xsl:value-of select="@target"/></xsl:when>
918      <xsl:otherwise>
919        <xsl:call-template name="computed-auto-target">
920          <xsl:with-param name="bib" select="."/>
921        </xsl:call-template>
922      </xsl:otherwise>
923    </xsl:choose>
924  </xsl:variable>
925 
926  <tr xmlns="http://www.w3.org/1999/xhtml">
927    <td class="reference">
928      <xsl:call-template name="insertInsDelClass"/>
929      <xsl:variable name="del-node" select="ancestor::ed:del"/>
930      <xsl:variable name="rep-node" select="ancestor::ed:replace"/>
931      <xsl:variable name="deleted" select="$del-node and ($rep-node/ed:ins)"/>
932      <xsl:for-each select="../..">
933        <xsl:call-template name="insert-issue-pointer">
934          <xsl:with-param name="deleted-anchor" select="$deleted"/>
935        </xsl:call-template>
936      </xsl:for-each>
937      <b id="{@anchor}">
938        <xsl:call-template name="referencename">
939          <xsl:with-param name="node" select="."/>
940        </xsl:call-template>
941      </b>
942    </td>
943   
944    <td class="top">
945      <xsl:call-template name="insertInsDelClass"/>
946      <xsl:for-each select="front/author">
947        <xsl:variable name="initials">
948          <xsl:call-template name="format-initials"/>
949        </xsl:variable>
950     
951        <xsl:choose>
952          <xsl:when test="@surname and @surname!=''">
953            <xsl:variable name="displayname">
954              <!-- surname/initials is reversed for last author except when it's the only one -->
955              <xsl:choose>
956                <xsl:when test="position()=last() and position()!=1">
957                  <xsl:value-of select="concat($initials,' ',@surname)"/>
958                </xsl:when>
959                <xsl:otherwise>
960                  <xsl:value-of select="concat(@surname,', ',$initials)"/>
961                </xsl:otherwise>
962              </xsl:choose>
963              <xsl:if test="@role='editor'">
964                <xsl:text>, Ed.</xsl:text>
965              </xsl:if>
966            </xsl:variable>
967            <xsl:choose>
968              <xsl:when test="address/email">
969                <a>
970                  <xsl:if test="$xml2rfc-linkmailto!='no'">
971                    <xsl:attribute name="href">mailto:<xsl:value-of select="address/email"/></xsl:attribute>
972                  </xsl:if>
973                  <xsl:if test="organization/text()">
974                    <xsl:attribute name="title"><xsl:value-of select="organization/text()"/></xsl:attribute>
975                  </xsl:if>
976                  <xsl:value-of select="$displayname"/>
977                </a>
978              </xsl:when>
979              <xsl:otherwise>
980                <xsl:value-of select="$displayname"/>
981              </xsl:otherwise>
982            </xsl:choose>
983           
984            <xsl:choose>
985              <xsl:when test="position()=last() - 1">
986                <xsl:if test="last() &gt; 2">,</xsl:if>
987                <xsl:text> and </xsl:text>
988              </xsl:when>
989              <xsl:otherwise>
990                <xsl:text>, </xsl:text>
991              </xsl:otherwise>
992            </xsl:choose>
993          </xsl:when>
994          <xsl:when test="organization/text()">
995            <xsl:choose>
996              <xsl:when test="address/uri">
997                <a href="{address/uri}"><xsl:value-of select="organization"/></a>
998              </xsl:when>
999              <xsl:otherwise>
1000                <xsl:value-of select="organization"/>
1001              </xsl:otherwise>
1002            </xsl:choose>
1003           
1004            <xsl:choose>
1005              <xsl:when test="position()=last() - 1">
1006                <xsl:if test="last() &gt; 2">,</xsl:if>
1007                <xsl:text> and </xsl:text>
1008              </xsl:when>
1009              <xsl:otherwise>
1010                <xsl:text>, </xsl:text>
1011              </xsl:otherwise>
1012            </xsl:choose>
1013          </xsl:when>
1014          <xsl:otherwise/>
1015        </xsl:choose>
1016      </xsl:for-each>
1017         
1018      <xsl:choose>
1019        <xsl:when test="string-length($target) &gt; 0">
1020          <xsl:text>&#8220;</xsl:text><a href="{$target}"><xsl:value-of select="front/title"/></a><xsl:text>&#8221;</xsl:text>
1021        </xsl:when>
1022        <xsl:otherwise>
1023          <xsl:text>&#8220;</xsl:text><xsl:value-of select="front/title"/><xsl:text>&#8221;</xsl:text>
1024        </xsl:otherwise>
1025      </xsl:choose>
1026           
1027      <xsl:for-each select="seriesInfo">
1028        <xsl:text>, </xsl:text>
1029        <xsl:choose>
1030          <xsl:when test="not(@name) and not(@value) and ./text()"><xsl:value-of select="."/></xsl:when>
1031          <xsl:otherwise>
1032            <xsl:value-of select="@name"/>
1033            <xsl:if test="@value!=''"> <xsl:value-of select="@value"/></xsl:if>
1034            <xsl:if test="translate(@name,$ucase,$lcase)='internet-draft'"> (work in progress)</xsl:if>
1035          </xsl:otherwise>
1036        </xsl:choose>
1037      </xsl:for-each>
1038     
1039      <xsl:if test="front/date/@year != '' and front/date/@year != '???'">
1040        <xsl:text>, </xsl:text>
1041        <xsl:if test="front/date/@month and (front/date/@month!='???' and front/date/@month!='')"><xsl:value-of select="front/date/@month"/> </xsl:if>
1042        <xsl:value-of select="front/date/@year"/>
1043      </xsl:if>
1044     
1045      <xsl:if test="@target">
1046        <xsl:text>, &lt;</xsl:text>
1047        <a href="{@target}"><xsl:value-of select="@target"/></a>
1048        <xsl:text>&gt;</xsl:text>
1049      </xsl:if>
1050     
1051      <xsl:text>.</xsl:text>
1052
1053      <xsl:for-each select="annotation">
1054        <br/>
1055        <xsl:apply-templates/>
1056      </xsl:for-each>
1057
1058    </td>
1059  </tr>
1060 
1061 
1062</xsl:template>
1063
1064
1065<xsl:template match="references">
1066
1067  <xsl:variable name="name">
1068    <xsl:if test="ancestor::ed:del">
1069      <xsl:text>del-</xsl:text>
1070    </xsl:if>
1071    <xsl:number level="any"/>     
1072  </xsl:variable>
1073 
1074  <xsl:variable name="refseccount" select="count(/rfc/back/references)+count(/rfc/back/ed:replace/ed:ins/references)"/>
1075
1076  <!-- insert pseudo section when needed -->
1077  <xsl:if test="not(preceding::references) and $refseccount!=1">
1078    <xsl:call-template name="insert-conditional-hrule"/>
1079    <h1 xmlns="http://www.w3.org/1999/xhtml" id="{$anchor-prefix}.references">
1080      <xsl:call-template name="insert-conditional-pagebreak"/>
1081      <xsl:variable name="sectionNumber">
1082        <xsl:call-template name="get-references-section-number"/>
1083      </xsl:variable>
1084      <a id="{$anchor-prefix}.section.{$sectionNumber}" href="#{$anchor-prefix}.section.{$sectionNumber}">
1085        <xsl:call-template name="emit-section-number">
1086          <xsl:with-param name="no" select="$sectionNumber"/>
1087        </xsl:call-template>
1088      </a>
1089      <xsl:text> References</xsl:text>
1090    </h1>
1091  </xsl:if>
1092 
1093  <xsl:variable name="elemtype">
1094    <xsl:choose>
1095      <xsl:when test="$refseccount!=1">h2</xsl:when>
1096      <xsl:otherwise>h1</xsl:otherwise>
1097    </xsl:choose>
1098  </xsl:variable>
1099 
1100  <xsl:variable name="title">
1101    <xsl:choose>
1102      <xsl:when test="not(@title) or @title=''">References</xsl:when>
1103      <xsl:otherwise><xsl:value-of select="@title"/></xsl:otherwise>
1104    </xsl:choose>
1105  </xsl:variable>
1106 
1107  <xsl:element namespace="http://www.w3.org/1999/xhtml" name="{$elemtype}"> 
1108    <xsl:if test="$name='1'">
1109      <xsl:call-template name="insert-conditional-pagebreak"/>
1110    </xsl:if>
1111    <xsl:variable name="sectionNumber">
1112      <xsl:call-template name="get-section-number"/>
1113    </xsl:variable>
1114    <xsl:variable name="anchorpref">
1115      <xsl:choose>
1116        <xsl:when test="$elemtype='h1'"/>
1117        <xsl:otherwise>.<xsl:value-of select="$name"/></xsl:otherwise>
1118      </xsl:choose>
1119    </xsl:variable>
1120    <xsl:attribute name="id"><xsl:value-of select="concat($anchor-prefix,'.references',$anchorpref)"/></xsl:attribute>
1121    <a xmlns="http://www.w3.org/1999/xhtml" href="#{$anchor-prefix}.section.{$sectionNumber}" id="{$anchor-prefix}.section.{$sectionNumber}">
1122      <xsl:call-template name="emit-section-number">
1123        <xsl:with-param name="no" select="$sectionNumber"/>
1124      </xsl:call-template>
1125    </a>
1126    <xsl:text> </xsl:text>
1127    <xsl:value-of select="$title"/>
1128  </xsl:element>
1129 
1130  <table xmlns="http://www.w3.org/1999/xhtml" summary="{$title}">
1131    <xsl:choose>
1132      <xsl:when test="$xml2rfc-sortrefs='yes' and $xml2rfc-symrefs!='no'">
1133        <xsl:apply-templates>
1134          <xsl:sort select="@anchor|.//ed:ins//reference/@anchor"/>
1135        </xsl:apply-templates>
1136      </xsl:when>
1137      <xsl:otherwise>
1138        <xsl:apply-templates/>
1139      </xsl:otherwise>
1140    </xsl:choose>
1141  </table>
1142
1143</xsl:template>
1144
1145<xsl:template match="rfc">
1146 
1147  <!-- conformance checks -->
1148  <xsl:if test="$xml2rfc-symrefs!='no' and $xml2rfc-symrefs!='yes' and //reference">
1149    <xsl:message>WARNING: symrefs PI not specified; default has changed from 'no' to 'yes'.</xsl:message>
1150  </xsl:if>
1151 
1152  <xsl:variable name="lang">
1153    <xsl:call-template name="get-lang"/>
1154  </xsl:variable>
1155
1156  <html xmlns="http://www.w3.org/1999/xhtml" lang="{$lang}">
1157    <head profile="http://www.w3.org/2006/03/hcard">
1158      <title>
1159        <xsl:apply-templates select="front/title" mode="get-text-content"/>
1160      </title>
1161      <style type="text/css" title="Xml2Rfc (sans serif)">
1162        <xsl:call-template name="insertCss"/>
1163      </style>
1164      <!-- <link rel="alternate stylesheet" type="text/css" media="screen" title="Plain (typewriter)" href="rfc2629tty.css" /> -->
1165           
1166      <!-- link elements -->
1167      <xsl:if test="$xml2rfc-toc='yes'">
1168        <link rel="Contents" href="#{$anchor-prefix}.toc"/>
1169      </xsl:if>
1170      <link rel="Author" href="#{$anchor-prefix}.authors"/>
1171      <xsl:if test="not($xml2rfc-private)">
1172        <link rel="Copyright" href="#{$anchor-prefix}.copyright"/>
1173      </xsl:if>
1174      <xsl:if test="$has-index">
1175        <link rel="Index" href="#{$anchor-prefix}.index"/>
1176      </xsl:if>
1177      <xsl:apply-templates select="/" mode="links"/>
1178      <xsl:for-each select="/rfc/x:link">
1179        <link><xsl:copy-of select="@*"/></link>
1180      </xsl:for-each>
1181      <xsl:if test="/rfc/@number">
1182        <link rel="Alternate" title="Authorative ASCII version" href="http://www.ietf.org/rfc/rfc{/rfc/@number}.txt"/>
1183      </xsl:if>
1184
1185      <!-- generator -->
1186      <xsl:variable name="gen">
1187        <xsl:call-template name="get-generator"/>
1188      </xsl:variable>
1189      <meta name="generator" content="{$gen}"/>
1190     
1191      <!-- keywords -->
1192      <xsl:if test="front/keyword">
1193        <xsl:variable name="keyw">
1194          <xsl:call-template name="get-keywords"/>
1195        </xsl:variable>
1196        <meta name="keywords" content="{$keyw}"/>
1197      </xsl:if>
1198
1199      <xsl:if test="$xml2rfc-ext-support-rfc2731!='no'">
1200        <!-- Dublin Core Metadata -->
1201        <link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"/>
1202             
1203        <!-- DC creator, see RFC2731 -->
1204        <xsl:for-each select="/rfc/front/author">
1205          <xsl:variable name="initials">
1206            <xsl:call-template name="format-initials"/>
1207          </xsl:variable>
1208          <meta name="DC.Creator" content="{concat(@surname,', ',$initials)}"/>
1209        </xsl:for-each>
1210       
1211        <xsl:if test="not($xml2rfc-private)">
1212          <xsl:choose>
1213            <xsl:when test="/rfc/@number">
1214              <meta name="DC.Identifier" content="urn:ietf:rfc:{/rfc/@number}"/>
1215            </xsl:when>
1216            <xsl:when test="/rfc/@docName">
1217              <meta name="DC.Identifier" content="urn:ietf:id:{/rfc/@docName}"/>
1218            </xsl:when>
1219            <xsl:otherwise/>
1220          </xsl:choose>
1221          <xsl:variable name="month"><xsl:call-template name="get-month-as-num"/></xsl:variable>
1222          <meta name="DC.Date.Issued" scheme="ISO8601" content="{/rfc/front/date/@year}-{$month}"/>
1223 
1224          <xsl:if test="/rfc/@obsoletes!=''">
1225            <xsl:call-template name="rfclist-for-dcmeta">
1226              <xsl:with-param name="list" select="/rfc/@obsoletes"/>
1227            </xsl:call-template>
1228          </xsl:if>
1229        </xsl:if>
1230 
1231        <xsl:if test="/rfc/front/abstract">
1232          <meta name="DC.Description.Abstract" content="{normalize-space(/rfc/front/abstract)}"/>
1233        </xsl:if>     
1234      </xsl:if>     
1235    </head>
1236    <body>
1237      <!-- insert diagnostics -->
1238      <xsl:call-template name="insert-diagnostics"/>
1239
1240      <xsl:apply-templates select="front"/>
1241      <xsl:apply-templates select="middle"/>
1242      <xsl:apply-templates select="back"/>
1243    </body>
1244  </html>
1245</xsl:template>               
1246
1247
1248<xsl:template match="t">
1249  <xsl:if test="preceding-sibling::section or preceding-sibling::appendix">
1250    <xsl:call-template name="warning">
1251      <xsl:with-param name="msg">The paragraph below is misplaced; maybe a section is closed in the wrong place: </xsl:with-param>
1252      <xsl:with-param name="msg2"><xsl:value-of select="."/></xsl:with-param>
1253    </xsl:call-template>
1254  </xsl:if>
1255  <xsl:choose>
1256    <xsl:when test="@anchor">
1257      <div xmlns="http://www.w3.org/1999/xhtml" id="{@anchor}"><xsl:apply-templates mode="t-content" select="node()[1]"/></div>
1258    </xsl:when>
1259    <xsl:otherwise>
1260      <xsl:apply-templates mode="t-content" select="node()[1]"/>
1261    </xsl:otherwise>
1262  </xsl:choose>
1263</xsl:template>
1264
1265<!-- for t-content, dispatch to default templates if it's block-level content -->
1266<xsl:template mode="t-content" match="list|figure|texttable">
1267  <!-- <xsl:comment>t-content block-level</xsl:comment>  -->
1268  <xsl:apply-templates select="."/>
1269  <xsl:apply-templates select="following-sibling::node()[1]" mode="t-content"/>
1270</xsl:template>               
1271               
1272<!-- ... otherwise group into p elements -->
1273<xsl:template mode="t-content" match="*|node()">
1274  <xsl:variable name="p">
1275    <xsl:call-template name="get-paragraph-number"/>
1276  </xsl:variable>
1277
1278  <!-- do not open a new p element if this is a whitespace-only text node and no siblings follow --> 
1279  <xsl:if test="not(self::text() and normalize-space(.)='' and not(following-sibling::node()))">
1280    <p xmlns="http://www.w3.org/1999/xhtml">
1281      <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">
1282        <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$p"/></xsl:attribute>
1283      </xsl:if>
1284      <xsl:call-template name="insertInsDelClass"/>
1285      <xsl:call-template name="editingMark"/>
1286      <xsl:apply-templates mode="t-content2" select="."/>
1287    </p>
1288  </xsl:if>
1289  <xsl:apply-templates mode="t-content" select="following-sibling::*[self::list or self::figure or self::texttable][1]"/>
1290</xsl:template>               
1291               
1292<xsl:template mode="t-content2" match="*">
1293  <xsl:apply-templates select="."/>
1294  <xsl:if test="not(following-sibling::node()[1] [self::list or self::figure or self::texttable])">
1295    <xsl:apply-templates select="following-sibling::node()[1]" mode="t-content2"/>
1296  </xsl:if>
1297</xsl:template>       
1298
1299<xsl:template mode="t-content2" match="text()">
1300  <xsl:apply-templates select="."/>
1301  <xsl:if test="not(following-sibling::node()[1] [self::list or self::figure or self::texttable])">
1302    <xsl:apply-templates select="following-sibling::node()[1]" mode="t-content2"/>
1303  </xsl:if>
1304</xsl:template>               
1305
1306<xsl:template match="title">
1307  <xsl:apply-templates/>
1308</xsl:template>
1309
1310<xsl:template name="insertTitle">
1311  <xsl:choose>
1312    <xsl:when test="@ed:old-title">
1313      <del xmlns="http://www.w3.org/1999/xhtml">
1314        <xsl:if test="ancestor-or-self::*[@ed:entered-by] and @ed:datetime">
1315          <xsl:attribute name="title"><xsl:value-of select="concat(@ed:datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
1316        </xsl:if>
1317        <xsl:value-of select="@ed:old-title"/>
1318      </del>
1319      <ins xmlns="http://www.w3.org/1999/xhtml">
1320        <xsl:if test="ancestor-or-self::*[@ed:entered-by] and @ed:datetime">
1321          <xsl:attribute name="title"><xsl:value-of select="concat(@ed:datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
1322        </xsl:if>
1323        <xsl:value-of select="@title"/>
1324      </ins>
1325    </xsl:when>
1326    <xsl:otherwise>
1327      <xsl:value-of select="@title"/>
1328    </xsl:otherwise>
1329  </xsl:choose>
1330</xsl:template>
1331
1332<xsl:template match="section|appendix">
1333
1334  <xsl:variable name="sectionNumber">
1335    <xsl:choose>
1336      <xsl:when test="@myns:unnumbered"/>
1337      <xsl:otherwise><xsl:call-template name="get-section-number"/></xsl:otherwise>
1338    </xsl:choose>
1339  </xsl:variable>
1340   
1341  <xsl:if test="not(ancestor::section) and not(@myns:notoclink)">
1342    <xsl:call-template name="insert-conditional-hrule"/>
1343  </xsl:if>
1344 
1345  <xsl:variable name="elemtype">
1346    <xsl:choose>
1347      <xsl:when test="count(ancestor::section) = 0">h1</xsl:when>
1348      <xsl:when test="count(ancestor::section) = 1">h2</xsl:when>
1349      <xsl:when test="count(ancestor::section) = 2">h3</xsl:when>
1350      <xsl:when test="count(ancestor::section) = 3">h4</xsl:when>
1351      <xsl:otherwise>h5</xsl:otherwise>
1352    </xsl:choose>
1353  </xsl:variable>
1354 
1355  <!-- process irefs immediadetely following the section so that their anchor
1356  actually is the section heading -->
1357  <xsl:apply-templates select="iref[count(preceding-sibling::*[not(self::iref)])=0]"/>
1358
1359  <xsl:element namespace="http://www.w3.org/1999/xhtml" name="{$elemtype}">
1360    <xsl:if test="$sectionNumber!=''">
1361      <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$sectionNumber"/></xsl:attribute>
1362    </xsl:if>
1363    <xsl:choose>
1364      <xsl:when test="$sectionNumber='1'">
1365        <!-- pagebreak, this the first section -->
1366        <xsl:attribute name="class">np</xsl:attribute>
1367      </xsl:when>
1368      <xsl:when test="not(ancestor::section) and not(@myns:notoclink)">
1369        <xsl:call-template name="insert-conditional-pagebreak"/>
1370      </xsl:when>
1371      <xsl:otherwise/>
1372    </xsl:choose>
1373   
1374    <xsl:call-template name="insertInsDelClass"/>
1375       
1376    <xsl:if test="$sectionNumber!=''">
1377      <a xmlns="http://www.w3.org/1999/xhtml" href="#{$anchor-prefix}.section.{$sectionNumber}">
1378        <xsl:call-template name="emit-section-number">
1379          <xsl:with-param name="no" select="$sectionNumber"/>
1380        </xsl:call-template>
1381      </a>
1382      <xsl:text> </xsl:text>
1383    </xsl:if>
1384   
1385    <!-- issue tracking? -->
1386    <xsl:if test="@ed:resolves">
1387      <xsl:call-template name="insert-issue-pointer"/>
1388    </xsl:if>
1389   
1390    <xsl:choose>
1391      <xsl:when test="@anchor">
1392        <a xmlns="http://www.w3.org/1999/xhtml" id="{@anchor}" href="#{@anchor}"><xsl:call-template name="insertTitle"/></a>
1393      </xsl:when>
1394      <xsl:otherwise>
1395        <xsl:call-template name="insertTitle"/>
1396      </xsl:otherwise>
1397    </xsl:choose>
1398  </xsl:element>
1399  <!-- continue with all child elements but the irefs processed above -->
1400  <xsl:apply-templates select="*[not(self::iref)]|iref[count(preceding-sibling::*[not(self::iref)])!=0]"/>
1401</xsl:template>
1402
1403<xsl:template match="spanx[@style='emph' or not(@style)]">
1404  <em xmlns="http://www.w3.org/1999/xhtml">
1405    <xsl:if test="@anchor">
1406      <xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute>
1407    </xsl:if>
1408    <xsl:apply-templates/>
1409  </em>
1410</xsl:template>
1411
1412<xsl:template match="spanx[@style='verb']">
1413  <samp xmlns="http://www.w3.org/1999/xhtml">
1414    <xsl:if test="@anchor">
1415      <xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute>
1416    </xsl:if>
1417    <xsl:apply-templates/>
1418  </samp>
1419</xsl:template>
1420
1421<xsl:template match="spanx[@style='strong']">
1422  <strong xmlns="http://www.w3.org/1999/xhtml">
1423    <xsl:if test="@anchor">
1424      <xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute>
1425    </xsl:if>
1426    <xsl:apply-templates/>
1427  </strong>
1428</xsl:template>
1429
1430<xsl:template name="insert-blank-lines">
1431  <xsl:param name="no"/>
1432  <xsl:choose>
1433    <xsl:when test="$no &lt;= 0">
1434      <br xmlns="http://www.w3.org/1999/xhtml"/>
1435      <!-- done -->
1436    </xsl:when>
1437    <xsl:otherwise>
1438      <br xmlns="http://www.w3.org/1999/xhtml"/>
1439      <xsl:call-template name="insert-blank-lines">
1440        <xsl:with-param name="no" select="$no - 1"/>
1441      </xsl:call-template>
1442    </xsl:otherwise>
1443  </xsl:choose>
1444</xsl:template>
1445
1446<xsl:template match="vspace[not(@blankLines)]">
1447  <br xmlns="http://www.w3.org/1999/xhtml"/>
1448</xsl:template>
1449
1450<xsl:template match="vspace">
1451  <xsl:call-template name="insert-blank-lines">
1452    <xsl:with-param name="no" select="@blankLines"/>
1453  </xsl:call-template>
1454</xsl:template>
1455
1456<!-- keep the root for the case when we process XSLT-inline markup -->
1457<xsl:variable name="src" select="/"/>
1458
1459<xsl:template name="render-section-ref">
1460  <xsl:param name="from"/>
1461  <xsl:param name="to"/>
1462
1463  <xsl:variable name="refname">
1464    <xsl:for-each select="$to">
1465      <xsl:call-template name="get-section-type">
1466        <xsl:with-param name="prec" select="$from/preceding-sibling::node()[1]"/>
1467      </xsl:call-template>
1468    </xsl:for-each>
1469  </xsl:variable>
1470  <xsl:variable name="refnum">
1471    <xsl:for-each select="$to">
1472      <xsl:call-template name="get-section-number"/>
1473    </xsl:for-each>
1474  </xsl:variable>
1475  <xsl:attribute name="title">
1476    <xsl:value-of select="$to/@title"/>
1477  </xsl:attribute>
1478  <xsl:choose>
1479    <xsl:when test="@format='counter'">
1480      <xsl:value-of select="$refnum"/>
1481    </xsl:when>
1482    <xsl:when test="@format='title'">
1483      <xsl:value-of select="$to/@title"/>
1484    </xsl:when>
1485    <xsl:otherwise>
1486      <xsl:value-of select="normalize-space(concat($refname,' ',$refnum))"/>
1487    </xsl:otherwise>
1488  </xsl:choose>
1489</xsl:template>
1490
1491<xsl:template match="xref[node()]">
1492
1493  <xsl:variable name="target" select="@target"/>
1494  <xsl:variable name="node" select="$src//*[@anchor=$target]"/>
1495  <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>
1496
1497  <xsl:choose>
1498
1499    <!-- x:fmt='none': do not generate any links -->
1500    <xsl:when test="@x:fmt='none'">
1501      <xsl:choose>
1502        <xsl:when test="name($node)='reference'">
1503          <cite xmlns="http://www.w3.org/1999/xhtml" title="{normalize-space($node/front/title)}">
1504            <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
1505              <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1506            </xsl:if>
1507            <!-- insert id when a backlink to this xref is needed in the index -->
1508            <xsl:if test="//iref[@x:for-anchor=$target] | //iref[@x:for-anchor='' and ../@anchor=$target]">
1509              <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1510            </xsl:if>
1511            <xsl:apply-templates/>
1512          </cite>
1513        </xsl:when>
1514        <xsl:otherwise>
1515          <xsl:apply-templates/>
1516        </xsl:otherwise>
1517      </xsl:choose>
1518    </xsl:when>
1519 
1520    <!-- Other x:fmt values than "none": unsupported -->
1521    <xsl:when test="@x:fmt and @x:fmt!='none'">
1522      <xsl:call-template name="error">
1523        <xsl:with-param name="msg" select="concat('unknown xref/@x:fmt extension: ',@x:fmt)"/>
1524      </xsl:call-template>
1525    </xsl:when>
1526
1527    <!-- Section links -->
1528    <xsl:when test="name($node)='section' or name($node)='appendix'">
1529      <xsl:apply-templates/>
1530      <xsl:variable name="context" select="."/>
1531      <xsl:text> (</xsl:text>
1532      <a xmlns="http://www.w3.org/1999/xhtml" href="#{@target}">
1533        <!-- insert id when a backlink to this xref is needed in the index -->
1534        <xsl:if test="//iref[@x:for-anchor=$target] | //iref[@x:for-anchor='' and ../@anchor=$target]">
1535          <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1536        </xsl:if>
1537        <xsl:call-template name="render-section-ref">
1538          <xsl:with-param name="from" select="."/>
1539          <xsl:with-param name="to" select="$node"/>
1540        </xsl:call-template>
1541      </a>
1542      <xsl:text>)</xsl:text>
1543    </xsl:when>
1544
1545    <xsl:otherwise>
1546      <a xmlns="http://www.w3.org/1999/xhtml" href="#{$target}"><xsl:apply-templates/></a>
1547      <xsl:for-each select="$src/rfc/back/references//reference[@anchor=$target]">
1548        <xsl:text> </xsl:text>
1549        <cite xmlns="http://www.w3.org/1999/xhtml" title="{normalize-space(front/title)}">
1550          <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
1551            <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1552          </xsl:if>
1553          <xsl:call-template name="referencename">
1554             <xsl:with-param name="node" select="."/>
1555          </xsl:call-template>
1556        </cite>
1557      </xsl:for-each>
1558    </xsl:otherwise>
1559  </xsl:choose>
1560
1561</xsl:template>
1562               
1563<xsl:template match="xref[not(node())]">
1564
1565  <xsl:variable name="context" select="."/>
1566  <xsl:variable name="target" select="@target"/>
1567  <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>
1568  <xsl:variable name="node" select="$src//*[@anchor=$target]"/>
1569  <xsl:if test="count($node)=0 and not(ancestor::ed:del)">
1570    <xsl:call-template name="error">
1571      <xsl:with-param name="msg" select="concat('Undefined target: ',@target)"/>
1572    </xsl:call-template>
1573  </xsl:if>
1574
1575  <xsl:choose>
1576 
1577    <!-- Section links -->
1578    <xsl:when test="name($node)='section' or name($node)='appendix'">
1579      <a xmlns="http://www.w3.org/1999/xhtml" href="#{@target}">
1580        <!-- insert id when a backlink to this xref is needed in the index -->
1581        <xsl:if test="//iref[@x:for-anchor=$target] | //iref[@x:for-anchor='' and ../@anchor=$target]">
1582          <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1583        </xsl:if>
1584        <xsl:call-template name="render-section-ref">
1585          <xsl:with-param name="from" select="."/>
1586          <xsl:with-param name="to" select="$node"/>
1587        </xsl:call-template>
1588      </a>
1589    </xsl:when>
1590
1591    <!-- Figure links -->
1592    <xsl:when test="name($node)='figure'">
1593      <a xmlns="http://www.w3.org/1999/xhtml" href="#{$target}">
1594        <xsl:variable name="figcnt">
1595          <xsl:for-each select="$node">
1596            <xsl:number level="any" count="figure[@title!='' or @anchor!='']"/>
1597          </xsl:for-each>
1598        </xsl:variable>
1599        <xsl:choose>
1600          <xsl:when test="@format='counter'">
1601            <xsl:value-of select="$figcnt"/>
1602          </xsl:when>
1603          <xsl:when test="@format='title'">
1604            <xsl:value-of select="$node/@title"/>
1605          </xsl:when>
1606          <xsl:otherwise>
1607            <xsl:value-of select="normalize-space(concat('Figure ',$figcnt))"/>
1608          </xsl:otherwise>
1609        </xsl:choose>
1610      </a>
1611    </xsl:when>
1612   
1613    <!-- Table links -->
1614    <xsl:when test="name($node)='texttable'">
1615      <a xmlns="http://www.w3.org/1999/xhtml" href="#{$target}">
1616        <xsl:variable name="tabcnt">
1617          <xsl:for-each select="$node">
1618            <xsl:number level="any" count="texttable[@title!='' or @anchor!='']"/>
1619          </xsl:for-each>
1620        </xsl:variable>
1621        <xsl:choose>
1622          <xsl:when test="@format='counter'">
1623            <xsl:value-of select="$tabcnt"/>
1624          </xsl:when>
1625          <xsl:when test="@format='title'">
1626            <xsl:value-of select="$node/@title"/>
1627          </xsl:when>
1628          <xsl:otherwise>
1629            <xsl:value-of select="normalize-space(concat('Table ',$tabcnt))"/>
1630          </xsl:otherwise>
1631        </xsl:choose>
1632      </a>
1633    </xsl:when>
1634   
1635    <!-- Reference links -->
1636    <xsl:when test="name($node)='reference'">
1637
1638      <xsl:variable name="href">
1639        <xsl:call-template name="computed-target">
1640          <xsl:with-param name="bib" select="$node"/>
1641          <xsl:with-param name="ref" select="."/>
1642        </xsl:call-template>
1643      </xsl:variable>
1644     
1645      <xsl:variable name="sec">
1646        <xsl:choose>
1647          <xsl:when test="starts-with(@x:rel,'#') and not(@x:sec) and $node/x:source/@href">
1648            <xsl:variable name="extdoc" select="document($node/x:source/@href)"/>
1649            <xsl:variable name="nodes" select="$extdoc//*[@anchor=substring-after(current()/@x:rel,'#')]"/>
1650            <xsl:if test="not($nodes)">
1651              <xsl:call-template name="error">
1652                <xsl:with-param name="msg">Anchor '<xsl:value-of select="substring-after(current()/@x:rel,'#')"/>' not found in <xsl:value-of select="$node/x:source/@href"/>.</xsl:with-param>
1653              </xsl:call-template>
1654            </xsl:if>
1655            <xsl:for-each select="$nodes">
1656              <xsl:call-template name="get-section-number"/>
1657            </xsl:for-each>
1658          </xsl:when>
1659          <xsl:otherwise>
1660            <xsl:value-of select="@x:sec"/>
1661          </xsl:otherwise>
1662        </xsl:choose>
1663      </xsl:variable>
1664     
1665      <xsl:variable name="secterm">
1666        <xsl:choose>
1667          <!-- starts with letter? -->
1668          <xsl:when test="translate(substring($sec,1,1),$ucase,'')=''">Appendix</xsl:when>
1669          <xsl:otherwise>Section</xsl:otherwise>
1670        </xsl:choose>
1671      </xsl:variable>
1672
1673      <xsl:variable name="fmt">
1674        <xsl:choose>
1675          <xsl:when test="@x:fmt!=''"><xsl:value-of select="@x:fmt"/></xsl:when>
1676          <xsl:when test="ancestor::artwork">,</xsl:when>
1677          <xsl:otherwise>of</xsl:otherwise>
1678        </xsl:choose>
1679      </xsl:variable>
1680
1681      <xsl:variable name="title">
1682        <xsl:choose>
1683          <xsl:when test="starts-with(@x:rel,'#') and not(@x:sec) and $node/x:source/@href">
1684            <xsl:variable name="extdoc" select="document($node/x:source/@href)"/>
1685            <xsl:variable name="nodes" select="$extdoc//*[@anchor=substring-after(current()/@x:rel,'#')]"/>
1686            <xsl:if test="not($nodes)">
1687              <xsl:call-template name="error">
1688                <xsl:with-param name="msg">Anchor '<xsl:value-of select="substring-after(current()/@x:rel,'#')"/>' not found in <xsl:value-of select="$node/x:source/@href"/>.</xsl:with-param>
1689              </xsl:call-template>
1690            </xsl:if>
1691            <xsl:for-each select="$nodes">
1692              <xsl:value-of select="@title"/>
1693            </xsl:for-each>
1694          </xsl:when>
1695          <xsl:otherwise/>
1696        </xsl:choose>
1697      </xsl:variable>
1698
1699      <!--
1700      Formats:
1701     
1702        ()      [XXXX] (Section SS)
1703        ,       [XXXX], Section SS
1704        of      Section SS of [XXXX]
1705        sec     Section SS
1706        number  SS
1707      -->
1708     
1709      <xsl:if test="$fmt and not($fmt='()' or $fmt=',' or $fmt='of' or $fmt='sec' or $fmt='anchor' or $fmt='number')">
1710        <xsl:call-template name="error">
1711          <xsl:with-param name="msg" select="concat('unknown xref/@x:fmt extension: ',$fmt)"/>
1712        </xsl:call-template>
1713      </xsl:if>
1714
1715      <xsl:if test="$sec!=''">
1716             
1717        <xsl:choose>
1718          <xsl:when test="$fmt='of' or $fmt='sec'">
1719            <xsl:choose>
1720              <xsl:when test="$href!=''">
1721                <a xmlns="http://www.w3.org/1999/xhtml" href="{$href}">
1722                  <xsl:if test="$title!=''">
1723                    <xsl:attribute name="title"><xsl:value-of select="$title"/></xsl:attribute>
1724                  </xsl:if>
1725                  <xsl:if test="$fmt='sec' and $xml2rfc-ext-include-references-in-index='yes'">
1726                    <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1727                  </xsl:if>
1728                  <xsl:value-of select="$secterm"/>
1729                  <xsl:text> </xsl:text>
1730                  <xsl:value-of select="$sec"/>
1731                </a>
1732              </xsl:when>
1733              <xsl:otherwise><xsl:value-of select="$secterm"/><xsl:text> </xsl:text><xsl:value-of select="$sec"/></xsl:otherwise>
1734            </xsl:choose>
1735            <xsl:if test="$fmt='of'">
1736              <xsl:text> of </xsl:text>
1737            </xsl:if>
1738          </xsl:when>
1739          <xsl:when test="$fmt='number'">
1740            <xsl:choose>
1741              <xsl:when test="$href!=''">
1742                <a xmlns="http://www.w3.org/1999/xhtml" href="{$href}">
1743                  <xsl:if test="$title!=''">
1744                    <xsl:attribute name="title"><xsl:value-of select="$title"/></xsl:attribute>
1745                  </xsl:if>
1746                  <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
1747                    <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1748                  </xsl:if>
1749                  <xsl:value-of select="$sec"/>
1750                </a>
1751              </xsl:when>
1752              <xsl:otherwise><xsl:value-of select="$sec"/></xsl:otherwise>
1753            </xsl:choose>
1754          </xsl:when>
1755          <xsl:otherwise/>
1756        </xsl:choose>
1757      </xsl:if>
1758
1759      <xsl:if test="$sec='' or ($fmt!='sec' and $fmt!='number')">
1760        <a xmlns="http://www.w3.org/1999/xhtml" href="#{$target}">
1761          <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
1762            <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1763          </xsl:if>
1764          <cite title="{normalize-space($node/front/title)}">
1765            <xsl:variable name="val">
1766              <xsl:call-template name="referencename">
1767                <xsl:with-param name="node" select="$node"/>
1768              </xsl:call-template>
1769            </xsl:variable>
1770            <xsl:choose>
1771              <xsl:when test="$fmt='anchor'">
1772                <!-- remove brackets -->
1773                <xsl:value-of select="substring($val,2,string-length($val)-2)"/>
1774              </xsl:when>
1775              <xsl:otherwise>
1776                <xsl:value-of select="$val"/>
1777              </xsl:otherwise>
1778            </xsl:choose>
1779          </cite>
1780        </a>
1781      </xsl:if>
1782     
1783      <xsl:if test="$sec!=''">
1784        <xsl:choose>
1785          <xsl:when test="$fmt='()'">
1786            <xsl:text> (</xsl:text>
1787            <xsl:choose>
1788              <xsl:when test="$href!=''">
1789                <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>
1790              </xsl:when>
1791              <xsl:otherwise><xsl:value-of select="$secterm"/><xsl:text> </xsl:text><xsl:value-of select="$sec"/></xsl:otherwise>
1792            </xsl:choose>
1793            <xsl:text>)</xsl:text>
1794          </xsl:when>
1795          <xsl:when test="$fmt=','">
1796            <xsl:text>, </xsl:text>
1797            <xsl:choose>
1798              <xsl:when test="$href!=''">
1799                <a xmlns="http://www.w3.org/1999/xhtml" href="{$href}">
1800                  <xsl:if test="$title!=''">
1801                    <xsl:attribute name="title"><xsl:value-of select="$title"/></xsl:attribute>
1802                  </xsl:if>
1803                  <xsl:value-of select="$secterm"/>
1804                  <xsl:text> </xsl:text>
1805                  <xsl:value-of select="$sec"/>
1806                </a>
1807              </xsl:when>
1808              <xsl:otherwise><xsl:value-of select="$secterm"/><xsl:text> </xsl:text><xsl:value-of select="$sec"/></xsl:otherwise>
1809            </xsl:choose>
1810          </xsl:when>
1811          <xsl:otherwise/>
1812        </xsl:choose>
1813      </xsl:if>
1814    </xsl:when>
1815   
1816    <xsl:otherwise>
1817      <xsl:call-template name="error">
1818        <xsl:with-param name="msg" select="concat('xref to unknown element: ',name($node))"/>
1819      </xsl:call-template>
1820    </xsl:otherwise>
1821  </xsl:choose>
1822</xsl:template>
1823
1824
1825<!-- mark unmatched elements red -->
1826
1827<xsl:template match="*">
1828  <xsl:message>ERROR: no XSLT template for element: &lt;<xsl:value-of select="name()"/>&gt;</xsl:message>   
1829  <tt xmlns="http://www.w3.org/1999/xhtml" class="error">&lt;<xsl:value-of select="name()"/>&gt;</tt>
1830  <xsl:copy><xsl:apply-templates select="node()|@*"/></xsl:copy>
1831  <tt xmlns="http://www.w3.org/1999/xhtml" class="error">&lt;/<xsl:value-of select="name()"/>&gt;</tt>
1832</xsl:template>
1833
1834<xsl:template match="/">
1835  <xsl:apply-templates select="*"/>
1836</xsl:template>
1837
1838<!-- utility templates -->
1839
1840<xsl:template name="collectLeftHeaderColumn">
1841  <xsl:param name="mode"/>
1842  <!-- default case -->
1843  <xsl:if test="not($xml2rfc-private)">
1844    <myns:item>Network Working Group</myns:item>
1845    <myns:item>
1846       <xsl:choose>
1847        <xsl:when test="/rfc/@ipr and not(/rfc/@number)">Internet Draft</xsl:when>
1848        <xsl:otherwise>Request for Comments: <xsl:value-of select="/rfc/@number"/></xsl:otherwise>
1849      </xsl:choose>
1850    </myns:item>
1851    <xsl:if test="/rfc/@docName and $mode!='nroff'">
1852      <myns:item>
1853        &lt;<xsl:value-of select="/rfc/@docName"/>&gt;
1854      </myns:item>
1855    </xsl:if>
1856    <xsl:if test="/rfc/@obsoletes and /rfc/@obsoletes!=''">
1857      <myns:item>
1858        <xsl:text>Obsoletes: </xsl:text>
1859        <xsl:call-template name="rfclist">
1860          <xsl:with-param name="list" select="normalize-space(/rfc/@obsoletes)"/>
1861        </xsl:call-template>
1862        <xsl:if test="not(/rfc/@number)"> (if approved)</xsl:if>
1863      </myns:item>
1864    </xsl:if>
1865    <xsl:if test="/rfc/@seriesNo">
1866       <myns:item>
1867        <xsl:choose>
1868          <xsl:when test="/rfc/@category='bcp'">BCP: <xsl:value-of select="/rfc/@seriesNo"/></xsl:when>
1869          <xsl:when test="/rfc/@category='info'">FYI: <xsl:value-of select="/rfc/@seriesNo"/></xsl:when>
1870          <xsl:when test="/rfc/@category='std'">STD: <xsl:value-of select="/rfc/@seriesNo"/></xsl:when>
1871          <xsl:otherwise><xsl:value-of select="concat(/rfc/@category,': ',/rfc/@seriesNo)"/></xsl:otherwise>
1872        </xsl:choose>
1873      </myns:item>
1874    </xsl:if>
1875    <xsl:if test="/rfc/@updates and /rfc/@updates!=''">
1876      <myns:item>
1877        <xsl:text>Updates: </xsl:text>
1878          <xsl:call-template name="rfclist">
1879             <xsl:with-param name="list" select="normalize-space(/rfc/@updates)"/>
1880          </xsl:call-template>
1881          <xsl:if test="not(/rfc/@number)"> (if approved)</xsl:if>
1882      </myns:item>
1883    </xsl:if>
1884    <xsl:if test="$mode!='nroff'">
1885      <myns:item>
1886        <xsl:choose>
1887          <xsl:when test="/rfc/@number">
1888            <xsl:text>Category: </xsl:text>
1889          </xsl:when>
1890          <xsl:otherwise>
1891            <xsl:text>Intended status: </xsl:text>
1892          </xsl:otherwise>
1893        </xsl:choose>
1894        <xsl:call-template name="get-category-long"/>
1895      </myns:item>
1896    </xsl:if>
1897    <xsl:if test="/rfc/@ipr and not(/rfc/@number)">
1898       <myns:item>Expires: <xsl:call-template name="expirydate"/></myns:item>
1899    </xsl:if>
1900  </xsl:if>
1901   
1902  <!-- private case -->
1903  <xsl:if test="$xml2rfc-private">
1904    <myns:item><xsl:value-of select="$xml2rfc-private"/></myns:item>
1905  </xsl:if>
1906</xsl:template>
1907
1908<xsl:template name="collectRightHeaderColumn">
1909  <xsl:for-each select="author">
1910    <xsl:variable name="initials">
1911      <xsl:call-template name="format-initials"/>
1912    </xsl:variable>
1913    <xsl:if test="@surname">
1914      <myns:item>
1915        <xsl:value-of select="concat($initials,' ',@surname)"/>
1916        <xsl:if test="@role">
1917          <xsl:choose>
1918            <xsl:when test="@role='editor'">
1919              <xsl:text>, Editor</xsl:text>
1920            </xsl:when>
1921            <xsl:otherwise>
1922              <xsl:text>, </xsl:text><xsl:value-of select="@role"/>
1923            </xsl:otherwise>
1924          </xsl:choose>
1925        </xsl:if>
1926      </myns:item>
1927    </xsl:if>
1928    <xsl:variable name="org">
1929      <xsl:choose>
1930        <xsl:when test="organization/@abbrev"><xsl:value-of select="organization/@abbrev"/></xsl:when>
1931        <xsl:otherwise><xsl:value-of select="organization"/></xsl:otherwise>
1932      </xsl:choose>
1933    </xsl:variable>
1934    <xsl:variable name="orgOfFollowing">
1935      <xsl:choose>
1936        <xsl:when test="following-sibling::*[1]/organization/@abbrev"><xsl:value-of select="following-sibling::*[1]/organization/@abbrev"/></xsl:when>
1937        <xsl:otherwise><xsl:value-of select="following-sibling::*/organization"/></xsl:otherwise>
1938      </xsl:choose>
1939    </xsl:variable>
1940    <xsl:if test="$org != $orgOfFollowing and $org != ''">
1941      <myns:item><xsl:value-of select="$org"/></myns:item>
1942    </xsl:if>
1943  </xsl:for-each>
1944  <myns:item>
1945    <xsl:value-of select="concat(date/@month,' ',date/@year)"/>
1946  </myns:item>
1947</xsl:template>
1948
1949
1950<xsl:template name="emitheader">
1951  <xsl:param name="lc"/>
1952  <xsl:param name="rc"/>
1953
1954  <xsl:for-each select="$lc/myns:item | $rc/myns:item">
1955    <xsl:variable name="pos" select="position()"/>
1956    <xsl:if test="$pos &lt; count($lc/myns:item) + 1 or $pos &lt; count($rc/myns:item) + 1"> 
1957      <tr xmlns="http://www.w3.org/1999/xhtml">
1958        <td class="header left"><xsl:call-template name="copynodes"><xsl:with-param name="nodes" select="$lc/myns:item[$pos]/node()"/></xsl:call-template></td>
1959        <td class="header right"><xsl:call-template name="copynodes"><xsl:with-param name="nodes" select="$rc/myns:item[$pos]/node()"/></xsl:call-template></td>
1960      </tr>
1961    </xsl:if>
1962  </xsl:for-each>
1963</xsl:template>
1964
1965<!-- convenience template that avoids copying namespace nodes we don't want -->
1966<xsl:template name="copynodes">
1967  <xsl:param name="nodes"/>
1968  <xsl:for-each select="$nodes">
1969    <xsl:choose>
1970      <xsl:when test="namespace-uri()='http://www.w3.org/1999/xhtml'">
1971        <xsl:element namespace="{namespace-uri()}" name="{name()}">
1972          <xsl:copy-of select="@*|node()"/>
1973        </xsl:element>
1974      </xsl:when>
1975      <xsl:when test="self::*">
1976        <xsl:element namespace="http://www.w3.org/1999/xhtml" name="{name()}">
1977          <xsl:copy-of select="@*|node()"/>
1978        </xsl:element>
1979      </xsl:when>
1980      <!-- workaround for opera, remove when Opera > 9.0.x comes out -->
1981      <xsl:when test="self::text()">
1982        <xsl:value-of select="."/>
1983      </xsl:when>
1984      <xsl:otherwise>
1985        <xsl:copy-of select="."/>
1986      </xsl:otherwise>
1987    </xsl:choose>
1988  </xsl:for-each>
1989</xsl:template>
1990
1991
1992<xsl:template name="expirydate">
1993  <xsl:variable name="date" select="/rfc/front/date"/>
1994  <xsl:choose>
1995      <xsl:when test="$date/@month='January'">July <xsl:value-of select="$date/@year"/></xsl:when>
1996      <xsl:when test="$date/@month='February'">August <xsl:value-of select="$date/@year"/></xsl:when>
1997      <xsl:when test="$date/@month='March'">September <xsl:value-of select="$date/@year"/></xsl:when>
1998      <xsl:when test="$date/@month='April'">October <xsl:value-of select="$date/@year"/></xsl:when>
1999      <xsl:when test="$date/@month='May'">November <xsl:value-of select="$date/@year"/></xsl:when>
2000      <xsl:when test="$date/@month='June'">December <xsl:value-of select="$date/@year"/></xsl:when>
2001      <xsl:when test="$date/@month='July'">January <xsl:value-of select="$date/@year + 1"/></xsl:when>
2002      <xsl:when test="$date/@month='August'">February <xsl:value-of select="$date/@year + 1"/></xsl:when>
2003      <xsl:when test="$date/@month='September'">March <xsl:value-of select="$date/@year + 1"/></xsl:when>
2004      <xsl:when test="$date/@month='October'">April <xsl:value-of select="$date/@year + 1"/></xsl:when>
2005      <xsl:when test="$date/@month='November'">May <xsl:value-of select="$date/@year + 1"/></xsl:when>
2006      <xsl:when test="$date/@month='December'">June <xsl:value-of select="$date/@year + 1"/></xsl:when>
2007        <xsl:otherwise>WRONG SYNTAX FOR MONTH</xsl:otherwise>
2008     </xsl:choose>
2009</xsl:template>
2010
2011<xsl:template name="get-month-as-num">
2012  <xsl:variable name="date" select="/rfc/front/date"/>
2013  <xsl:choose>
2014      <xsl:when test="$date/@month='January'">01</xsl:when>
2015      <xsl:when test="$date/@month='February'">02</xsl:when>
2016      <xsl:when test="$date/@month='March'">03</xsl:when>
2017      <xsl:when test="$date/@month='April'">04</xsl:when>
2018      <xsl:when test="$date/@month='May'">05</xsl:when>
2019      <xsl:when test="$date/@month='June'">06</xsl:when>
2020      <xsl:when test="$date/@month='July'">07</xsl:when>
2021      <xsl:when test="$date/@month='August'">08</xsl:when>
2022      <xsl:when test="$date/@month='September'">09</xsl:when>
2023      <xsl:when test="$date/@month='October'">10</xsl:when>
2024      <xsl:when test="$date/@month='November'">11</xsl:when>
2025      <xsl:when test="$date/@month='December'">12</xsl:when>
2026        <xsl:otherwise>WRONG SYNTAX FOR MONTH</xsl:otherwise>
2027     </xsl:choose>
2028</xsl:template>
2029
2030<!-- produce back section with author information -->
2031<xsl:template name="get-authors-section-title">
2032  <xsl:choose>
2033    <xsl:when test="count(/rfc/front/author)=1">Author's Address</xsl:when>
2034    <xsl:otherwise>Authors' Addresses</xsl:otherwise>
2035  </xsl:choose>
2036</xsl:template>
2037
2038<xsl:template name="get-authors-section-number">
2039  <xsl:if test="/*/x:assign-section-number[@builtin-target='authors']">
2040    <xsl:value-of select="/*/x:assign-section-number[@builtin-target='authors']/@number"/>
2041  </xsl:if>
2042</xsl:template>
2043
2044<xsl:template name="insertAuthors">
2045
2046  <xsl:call-template name="insert-conditional-hrule"/>
2047 
2048  <xsl:variable name="number">
2049    <xsl:call-template name="get-authors-section-number"/>
2050  </xsl:variable>
2051   
2052  <h1 xmlns="http://www.w3.org/1999/xhtml" id="{$anchor-prefix}.authors">
2053    <xsl:call-template name="insert-conditional-pagebreak"/>
2054    <xsl:if test="$number != ''">
2055      <a href="#{$anchor-prefix}.section.{$number}" id="{$anchor-prefix}.section.{$number}"><xsl:value-of select="$number"/>.</a>
2056      <xsl:text> </xsl:text>
2057    </xsl:if>
2058    <a href="#{$anchor-prefix}.authors"><xsl:call-template name="get-authors-section-title"/></a>
2059  </h1>
2060
2061  <xsl:apply-templates select="/rfc/front/author"/>
2062</xsl:template>
2063
2064
2065
2066<!-- insert copyright statement -->
2067
2068<xsl:template name="insertCopyright" myns:namespaceless-elements="xml2rfc">
2069
2070  <xsl:choose>
2071    <xsl:when test="$ipr-rfc3667">
2072      <section title="Full Copyright Statement" anchor="{$anchor-prefix}.copyright" myns:unnumbered="unnumbered" myns:notoclink="notoclink">
2073        <t>
2074          <xsl:choose>
2075            <xsl:when test="$ipr-rfc4748">
2076              Copyright © The IETF Trust (<xsl:value-of select="/rfc/front/date/@year"/>).
2077            </xsl:when>
2078            <xsl:otherwise>
2079              Copyright © The Internet Society (<xsl:value-of select="/rfc/front/date/@year"/>).
2080            </xsl:otherwise>
2081          </xsl:choose>
2082        </t>
2083        <t>
2084          This document is subject to the rights, licenses and restrictions
2085          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
2086          retain all their rights.
2087        </t>
2088        <t>
2089          <xsl:choose>
2090            <xsl:when test="$ipr-rfc4748">
2091              This document and the information contained herein are provided
2092              on an &#8220;AS IS&#8221; basis and THE CONTRIBUTOR,
2093              THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY),
2094              THE INTERNET SOCIETY, THE IETF TRUST AND THE INTERNET ENGINEERING
2095              TASK FORCE DISCLAIM ALL WARRANTIES,
2096              EXPRESS OR IMPLIED,
2097              INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
2098              INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
2099              WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
2100            </xsl:when>
2101            <xsl:otherwise>
2102              This document and the information contained herein are provided
2103              on an &#8220;AS IS&#8221; basis and THE CONTRIBUTOR,
2104              THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY),
2105              THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIM
2106              ALL WARRANTIES,
2107              EXPRESS OR IMPLIED,
2108              INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
2109              INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
2110              WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
2111            </xsl:otherwise>
2112          </xsl:choose>
2113        </t>
2114      </section>   
2115    </xsl:when>
2116    <xsl:otherwise>
2117      <!-- <http://tools.ietf.org/html/rfc2026#section-10.4> -->
2118      <section title="Full Copyright Statement" anchor="{$anchor-prefix}.copyright" myns:unnumbered="unnumbered" myns:notoclink="notoclink">
2119        <t>
2120          Copyright © The Internet Society (<xsl:value-of select="/rfc/front/date/@year"/>). All Rights Reserved.
2121        </t>
2122        <t>
2123          This document and translations of it may be copied and furnished to
2124          others, and derivative works that comment on or otherwise explain it
2125          or assist in its implementation may be prepared, copied, published and
2126          distributed, in whole or in part, without restriction of any kind,
2127          provided that the above copyright notice and this paragraph are
2128          included on all such copies and derivative works. However, this
2129          document itself may not be modified in any way, such as by removing
2130          the copyright notice or references to the Internet Society or other
2131          Internet organizations, except as needed for the purpose of
2132          developing Internet standards in which case the procedures for
2133          copyrights defined in the Internet Standards process must be
2134          followed, or as required to translate it into languages other than
2135          English.
2136        </t>
2137        <t>
2138          The limited permissions granted above are perpetual and will not be
2139          revoked by the Internet Society or its successors or assignees.
2140        </t>
2141        <t>
2142          This document and the information contained herein is provided on an
2143          &#8220;;AS IS&#8221; basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
2144          TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
2145          BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
2146          HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
2147          MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
2148        </t>
2149      </section>
2150    </xsl:otherwise>
2151  </xsl:choose>
2152
2153  <section title="Intellectual Property" anchor="{$anchor-prefix}.ipr" myns:unnumbered="unnumbered">
2154    <xsl:choose>
2155      <xsl:when test="$ipr-rfc3667">
2156        <t>
2157          The IETF takes no position regarding the validity or scope of any
2158          Intellectual Property Rights or other rights that might be claimed to
2159          pertain to the implementation or use of the technology described in
2160          this document or the extent to which any license under such rights
2161          might or might not be available; nor does it represent that it has
2162          made any independent effort to identify any such rights.  Information
2163          on the procedures with respect to rights in RFC documents
2164          can be found in BCP 78 and BCP 79.
2165        </t>       
2166        <t>
2167          Copies of IPR disclosures made to the IETF Secretariat and any
2168          assurances of licenses to be made available, or the result of an
2169          attempt made to obtain a general license or permission for the use
2170          of such proprietary rights by implementers or users of this
2171          specification can be obtained from the IETF on-line IPR repository
2172          at <eref target="http://www.ietf.org/ipr"/>.
2173        </t>       
2174        <t>
2175          The IETF invites any interested party to bring to its attention any
2176          copyrights, patents or patent applications, or other proprietary
2177          rights that may cover technology that may be required to implement
2178          this standard. Please address the information to the IETF at
2179          <eref target="mailto:ietf-ipr@ietf.org">ietf-ipr@ietf.org</eref>.
2180        </t>       
2181      </xsl:when>
2182      <xsl:otherwise>
2183        <t>
2184          The IETF takes no position regarding the validity or scope of
2185          any intellectual property or other rights that might be claimed
2186          to  pertain to the implementation or use of the technology
2187          described in this document or the extent to which any license
2188          under such rights might or might not be available; neither does
2189          it represent that it has made any effort to identify any such
2190          rights. Information on the IETF's procedures with respect to
2191          rights in standards-track and standards-related documentation
2192          can be found in BCP-11. Copies of claims of rights made
2193          available for publication and any assurances of licenses to
2194          be made available, or the result of an attempt made
2195          to obtain a general license or permission for the use of such
2196          proprietary rights by implementors or users of this
2197          specification can be obtained from the IETF Secretariat.
2198        </t>
2199        <t>
2200          The IETF invites any interested party to bring to its
2201          attention any copyrights, patents or patent applications, or
2202          other proprietary rights which may cover technology that may be
2203          required to practice this standard. Please address the
2204          information to the IETF Executive Director.
2205        </t>
2206        <xsl:if test="$xml2rfc-iprnotified='yes'">
2207          <t>
2208            The IETF has been notified of intellectual property rights
2209            claimed in regard to some or all of the specification contained
2210            in this document. For more information consult the online list
2211            of claimed rights.
2212          </t>
2213        </xsl:if>
2214      </xsl:otherwise>
2215    </xsl:choose>
2216  </section>
2217 
2218  <section title="Acknowledgement" myns:unnumbered="unnumbered" myns:notoclink="notoclink">
2219    <t>
2220      Funding for the RFC Editor function is provided by the IETF
2221      Administrative Support Activity (IASA).
2222    </t>
2223  </section>
2224
2225</xsl:template>
2226
2227
2228<!-- insert CSS style info -->
2229
2230<xsl:template name="insertCss">
2231a {
2232  text-decoration: none;
2233}
2234a.smpl {
2235  color: black;
2236}
2237a:hover {
2238  text-decoration: underline;
2239}
2240a:active {
2241  text-decoration: underline;
2242}
2243address {
2244  margin-top: 1em;
2245  margin-left: 2em;
2246  font-style: normal;
2247}<xsl:if test="//x:blockquote">
2248blockquote {
2249  border-style: solid;
2250  border-color: gray;
2251  border-width: 0 0 0 .25em;
2252  font-style: italic;
2253  padding-left: 0.5em;
2254}</xsl:if>
2255body {<xsl:if test="$xml2rfc-background!=''">
2256  background: url(<xsl:value-of select="$xml2rfc-background"/>) #ffffff left top;</xsl:if>
2257  color: black;
2258  font-family: verdana, helvetica, arial, sans-serif;
2259  font-size: 10pt;
2260}<xsl:if test="//xhtml:p">
2261br.p {
2262  line-height: 150%;
2263}</xsl:if>
2264cite {
2265  font-style: normal;
2266}
2267dd {
2268  margin-right: 2em;<xsl:if test="$xml2rfc-ext-justification='always'">
2269  text-align: justify;</xsl:if>
2270}
2271dl {
2272  margin-left: 2em;
2273}
2274<!-- spacing between two entries in definition lists -->
2275dl.empty dd {
2276  margin-top: .5em;
2277}
2278dl p {
2279  margin-left: 0em;
2280}
2281dt {
2282  margin-top: .5em;
2283}
2284h1 {
2285  font-size: 14pt;
2286  line-height: 21pt;
2287  page-break-after: avoid;
2288}
2289h1.np {
2290  page-break-before: always;
2291}
2292h1 a {
2293  color: #333333;
2294}
2295h2 {
2296  font-size: 12pt;
2297  line-height: 15pt;
2298  page-break-after: avoid;
2299}
2300h2 a {
2301  color: black;
2302}
2303h3 {
2304  font-size: 10pt;
2305  page-break-after: avoid;
2306}
2307h3 a {
2308  color: black;
2309}
2310h4 {
2311  font-size: 10pt;
2312  page-break-after: avoid;
2313}
2314h4 a {
2315  color: black;
2316}
2317h5 {
2318  font-size: 10pt;
2319  page-break-after: avoid;
2320}
2321h5 a {
2322  color: black;
2323}
2324img {
2325  margin-left: 3em;
2326}
2327li {
2328  margin-left: 2em;
2329  margin-right: 2em;<xsl:if test="$xml2rfc-ext-justification='always'">
2330  text-align: justify;</xsl:if>
2331}
2332ol {
2333  margin-left: 2em;
2334  margin-right: 2em;
2335}
2336ol p {
2337  margin-left: 0em;
2338}<xsl:if test="//xhtml:q">
2339q {
2340  font-style: italic;
2341}</xsl:if>
2342p {
2343  margin-left: 2em;
2344  margin-right: 2em;<xsl:if test="$xml2rfc-ext-justification='always'">
2345  text-align: justify;</xsl:if>
2346}
2347pre {
2348  margin-left: 3em;
2349  background-color: lightyellow;
2350  padding: .25em;
2351}
2352pre.text2 {
2353  border-style: dotted;
2354  border-width: 1px;
2355  background-color: #f0f0f0;
2356  width: 69em;
2357}
2358pre.inline {
2359  background-color: white;
2360  padding: 0em;
2361}
2362pre.text {
2363  border-style: dotted;
2364  border-width: 1px;
2365  background-color: #f8f8f8;
2366  width: 69em;
2367}
2368pre.drawing {
2369  border-style: solid;
2370  border-width: 1px;
2371  background-color: #f8f8f8;
2372  padding: 2em;
2373}<xsl:if test="//x:q">
2374q {
2375  font-style: italic;
2376}</xsl:if>
2377table {
2378  margin-left: 2em;
2379}<xsl:if test="//texttable">
2380table.tt {
2381  vertical-align: top;
2382}
2383table.full {
2384  border-style: outset;
2385  border-width: 1px;
2386}
2387table.headers {
2388  border-style: outset;
2389  border-width: 1px;
2390}
2391table.tt td {
2392  vertical-align: top;
2393}
2394table.full td {
2395  border-style: inset;
2396  border-width: 1px;
2397}
2398table.tt th {
2399  vertical-align: top;
2400}
2401table.full th {
2402  border-style: inset;
2403  border-width: 1px;
2404}
2405table.headers th {
2406  border-style: none none inset none;
2407  border-width: 1px;
2408}</xsl:if>
2409table.header {
2410  width: 95%;
2411  font-size: 10pt;
2412  color: white;
2413}
2414td.top {
2415  vertical-align: top;
2416}
2417td.topnowrap {
2418  vertical-align: top;
2419  white-space: nowrap;
2420}
2421td.header {
2422  background-color: gray;
2423  width: 50%;
2424}
2425td.reference {
2426  vertical-align: top;
2427  white-space: nowrap;
2428  padding-right: 1em;
2429}
2430thead {
2431  display:table-header-group;
2432}
2433ul.toc {
2434  list-style: none;
2435  margin-left: 1.5em;
2436  margin-right: 0em;
2437  padding-left: 0em;
2438}
2439li.tocline0 {
2440  line-height: 150%;
2441  font-weight: bold;
2442  font-size: 10pt;
2443  margin-left: 0em;
2444  margin-right: 0em;
2445}
2446li.tocline1 {
2447  line-height: normal;
2448  font-weight: normal;
2449  font-size: 9pt;
2450  margin-left: 0em;
2451  margin-right: 0em;
2452}
2453li.tocline2 {
2454  font-size: 0pt;
2455}
2456ul p {
2457  margin-left: 0em;
2458}
2459ul.ind {
2460  list-style: none;
2461  margin-left: 1.5em;
2462  margin-right: 0em;
2463  padding-left: 0em;
2464}
2465li.indline0 {
2466  font-weight: bold;
2467  line-height: 200%;
2468  margin-left: 0em;
2469  margin-right: 0em;
2470}
2471li.indline1 {
2472  font-weight: normal;
2473  line-height: 150%;
2474  margin-left: 0em;
2475  margin-right: 0em;
2476}
2477<xsl:if test="//x:bcp14">.bcp14 {
2478  font-style: normal;
2479  text-transform: lowercase;
2480  font-variant: small-caps;
2481}</xsl:if><xsl:if test="//x:blockquote">
2482blockquote &gt; * .bcp14 {
2483  font-style: italic;
2484}</xsl:if>
2485.comment {
2486  background-color: yellow;
2487}<xsl:if test="$xml2rfc-editing='yes'">
2488.editingmark {
2489  background-color: khaki;
2490}</xsl:if>
2491.center {
2492  text-align: center;
2493}
2494.error {
2495  color: red;
2496  font-style: italic;
2497  font-weight: bold;
2498}
2499.figure {
2500  font-weight: bold;
2501  text-align: center;
2502  font-size: 9pt;
2503}
2504.filename {
2505  color: #333333;
2506  font-weight: bold;
2507  font-size: 12pt;
2508  line-height: 21pt;
2509  text-align: center;
2510}
2511.fn {
2512  font-weight: bold;
2513}
2514.hidden {
2515  display: none;
2516}
2517.left {
2518  text-align: left;
2519}
2520.right {
2521  text-align: right;
2522}
2523.title {
2524  color: #990000;
2525  font-size: 18pt;
2526  line-height: 18pt;
2527  font-weight: bold;
2528  text-align: center;
2529  margin-top: 36pt;
2530}
2531.vcardline {
2532  display: block;
2533}
2534.warning {
2535  font-size: 14pt;
2536  background-color: yellow;
2537}
2538<xsl:if test="//ed:del|//ed:replace|//ed:ins">del {
2539  color: red;
2540  text-decoration: line-through;
2541}
2542.del {
2543  color: red;
2544  text-decoration: line-through;
2545}
2546ins {
2547  color: green;
2548  text-decoration: underline;
2549}
2550.ins {
2551  color: green;
2552  text-decoration: underline;
2553}
2554div.issuepointer {
2555  float: left;
2556}</xsl:if><xsl:if test="//ed:issue">
2557table.openissue {
2558  background-color: khaki;
2559  border-width: thin;
2560  border-style: solid;
2561  border-color: black;
2562}
2563table.closedissue {
2564  background-color: white;
2565  border-width: thin;
2566  border-style: solid;
2567  border-color: gray;
2568  color: gray;
2569}
2570thead th {
2571  text-align: left;
2572}
2573.bg-issue {
2574  border: solid;
2575  border-width: 1px;
2576  font-size: 7pt;
2577}
2578.closed-issue {
2579  border: solid;
2580  border-width: thin;
2581  background-color: lime;
2582  font-size: smaller;
2583  font-weight: bold;
2584}
2585.open-issue {
2586  border: solid;
2587  border-width: thin;
2588  background-color: red;
2589  font-size: smaller;
2590  font-weight: bold;
2591}
2592.editor-issue {
2593  border: solid;
2594  border-width: thin;
2595  background-color: yellow;
2596  font-size: smaller;
2597  font-weight: bold;
2598}</xsl:if>
2599
2600@media print {
2601  .noprint {
2602    display: none;
2603  }
2604 
2605  a {
2606    color: black;
2607    text-decoration: none;
2608  }
2609
2610  table.header {
2611    width: 90%;
2612  }
2613
2614  td.header {
2615    width: 50%;
2616    color: black;
2617    background-color: white;
2618    vertical-align: top;
2619    font-size: 12pt;
2620  }
2621
2622  ul.toc a::after {
2623    content: leader('.') target-counter(attr(href), page);
2624  }
2625 
2626  a.iref {
2627    content: target-counter(attr(href), page);
2628  }
2629 
2630  .print2col {
2631    column-count: 2;
2632    -moz-column-count: 2;<!-- for Firefox -->
2633    column-fill: auto;<!-- for PrinceXML -->
2634  }
2635<xsl:if test="$xml2rfc-ext-justification='print'">
2636  dd {
2637    text-align: justify;
2638  }
2639  li {
2640    text-align: justify;
2641  }
2642  p {
2643    text-align: justify;
2644  }
2645</xsl:if>}
2646
2647@page {
2648  @top-left {
2649       content: "<xsl:call-template name="get-header-left"/>";
2650  }
2651  @top-right {
2652       content: "<xsl:call-template name="get-header-right"/>";
2653  }
2654  @top-center {
2655       content: "<xsl:call-template name="get-header-center"/>";
2656  }
2657  @bottom-left {
2658       content: "<xsl:call-template name="get-author-summary"/>";
2659  }
2660  @bottom-center {
2661       content: "<xsl:call-template name="get-category-long"/>";
2662  }
2663  @bottom-right {
2664       content: "[Page " counter(page) "]";
2665  }
2666}
2667
2668@page:first {
2669    @top-left {
2670      content: normal;
2671    }
2672    @top-right {
2673      content: normal;
2674    }
2675    @top-center {
2676      content: normal;
2677    }
2678}
2679</xsl:template>
2680
2681
2682<!-- generate the index section -->
2683
2684<xsl:template name="insertSingleIref">
2685  <xsl:choose>
2686    <xsl:when test="@ed:xref">
2687      <!-- special index generator mode -->
2688      <xsl:text>[</xsl:text>
2689      <a xmlns="http://www.w3.org/1999/xhtml" href="#{@ed:xref}"><xsl:value-of select="@ed:xref"/></a>
2690      <xsl:text>, </xsl:text>
2691      <a xmlns="http://www.w3.org/1999/xhtml">
2692        <xsl:variable name="htmluri" select="//reference[@anchor=current()/@ed:xref]/format[@type='HTML']/@target"/>
2693        <xsl:if test="$htmluri">
2694          <xsl:attribute name="href"><xsl:value-of select="concat($htmluri,'#',@ed:frag)"/></xsl:attribute>
2695        </xsl:if>       
2696        <xsl:choose>
2697          <xsl:when test="@primary='true'"><b><xsl:value-of select="@ed:label"/></b></xsl:when>
2698          <xsl:otherwise><xsl:value-of select="@ed:label"/></xsl:otherwise>
2699        </xsl:choose>
2700      </a>
2701      <xsl:text>]</xsl:text>
2702      <xsl:if test="position()!=last()">, </xsl:if>
2703    </xsl:when>
2704    <xsl:otherwise>
2705      <xsl:variable name="_n">
2706        <xsl:call-template name="get-section-number"/>
2707      </xsl:variable>
2708      <xsl:variable name="n">
2709        <xsl:choose>
2710          <xsl:when test="$_n!=''">
2711            <xsl:value-of select="$_n"/>
2712          </xsl:when>
2713          <xsl:otherwise>§</xsl:otherwise>
2714        </xsl:choose>
2715      </xsl:variable>
2716      <xsl:variable name="backlink">
2717        <xsl:choose>
2718          <xsl:when test="self::xref">
2719            <xsl:variable name="target" select="@target"/>
2720            <xsl:text>#</xsl:text>
2721            <xsl:value-of select="$anchor-prefix"/>
2722            <xsl:text>.xref.</xsl:text>
2723            <xsl:value-of select="@target"/>.<xsl:number level="any" count="xref[@target=$target]"/>
2724          </xsl:when>
2725          <xsl:when test="self::iref">
2726            <xsl:text>#</xsl:text>
2727            <xsl:call-template name="compute-iref-anchor"/>
2728          </xsl:when>
2729          <xsl:otherwise>
2730            <xsl:message>Unsupported element type for insertSingleIref</xsl:message>
2731          </xsl:otherwise>
2732        </xsl:choose>
2733      </xsl:variable>
2734      <a xmlns="http://www.w3.org/1999/xhtml" class="iref" href="{$backlink}">
2735        <xsl:call-template name="insertInsDelClass"/>
2736        <xsl:choose>
2737          <xsl:when test="@primary='true'"><b><xsl:value-of select="$n"/></b></xsl:when>
2738          <xsl:otherwise><xsl:value-of select="$n"/></xsl:otherwise>
2739        </xsl:choose>
2740      </a>
2741      <xsl:if test="position()!=last()">, </xsl:if>
2742    </xsl:otherwise>
2743  </xsl:choose>
2744</xsl:template>
2745
2746<xsl:template name="insertSingleXref">
2747  <xsl:variable name="_n">
2748    <xsl:call-template name="get-section-number"/>
2749  </xsl:variable>
2750  <xsl:variable name="n">
2751    <xsl:choose>
2752      <xsl:when test="$_n!=''">
2753        <xsl:value-of select="$_n"/>
2754      </xsl:when>
2755      <xsl:otherwise>§</xsl:otherwise>
2756    </xsl:choose>
2757  </xsl:variable>
2758  <xsl:choose>
2759    <xsl:when test="self::reference">
2760      <a xmlns="http://www.w3.org/1999/xhtml" class="iref" href="#{@anchor}">
2761        <xsl:call-template name="insertInsDelClass"/>
2762        <b><xsl:value-of select="$n"/></b>
2763      </a>
2764    </xsl:when>
2765    <xsl:otherwise>
2766      <xsl:variable name="target" select="@target"/>
2767      <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>
2768      <a xmlns="http://www.w3.org/1999/xhtml" class="iref" href="{$backlink}">
2769        <xsl:call-template name="insertInsDelClass"/>
2770        <xsl:value-of select="$n"/>
2771      </a>
2772    </xsl:otherwise>
2773  </xsl:choose>
2774  <xsl:if test="position()!=last()">, </xsl:if>
2775</xsl:template>
2776
2777<xsl:template name="insertIndex">
2778
2779  <xsl:call-template name="insert-conditional-hrule"/>
2780
2781  <h1 xmlns="http://www.w3.org/1999/xhtml" id="{$anchor-prefix}.index">
2782    <xsl:call-template name="insert-conditional-pagebreak"/>
2783    <a href="#{$anchor-prefix}.index">Index</a>
2784  </h1>
2785 
2786  <!-- generate navigation links to index subsections -->
2787  <p xmlns="http://www.w3.org/1999/xhtml" class="noprint">
2788    <xsl:variable name="irefs" select="//iref[generate-id(.) = generate-id(key('index-first-letter',translate(substring(@item,1,1),$lcase,$ucase)))]"/>
2789    <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)))]"/>
2790 
2791    <xsl:for-each select="$irefs | $xrefs">
2792   
2793      <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)"/>
2794         
2795      <xsl:variable name="letter" select="translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase)"/>
2796
2797      <!-- character? -->
2798      <xsl:if test="translate($letter,concat($lcase,$ucase,'0123456789'),'')=''">
2799     
2800        <xsl:variable name="showit">
2801          <xsl:choose>
2802            <xsl:when test="$xml2rfc-ext-include-references-in-index!='yes'">
2803              <xsl:if test="$irefs[starts-with(translate(@item,$lcase,$ucase),$letter)]">
2804                <xsl:text>yes</xsl:text>
2805              </xsl:if>
2806            </xsl:when>
2807            <xsl:otherwise>
2808              <xsl:text>yes</xsl:text>
2809            </xsl:otherwise>
2810          </xsl:choose>
2811        </xsl:variable>
2812       
2813        <xsl:if test="$showit='yes'">
2814          <a href="#{$anchor-prefix}.index.{$letter}">
2815            <xsl:value-of select="$letter"/>
2816          </a>
2817          <xsl:text> </xsl:text>
2818        </xsl:if>
2819     
2820      </xsl:if>
2821
2822    </xsl:for-each>
2823  </p>
2824
2825  <!-- for each index subsection -->
2826  <div xmlns="http://www.w3.org/1999/xhtml" class="print2col">
2827  <ul class="ind">
2828    <xsl:variable name="irefs2" select="//iref[generate-id(.) = generate-id(key('index-first-letter',translate(substring(@item,1,1),$lcase,$ucase)))]"/>
2829    <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)))]"/>
2830 
2831    <xsl:for-each select="$irefs2 | $xrefs2">
2832      <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)"/>
2833      <xsl:variable name="letter" select="translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase)"/>
2834           
2835      <xsl:variable name="showit">
2836        <xsl:choose>
2837          <xsl:when test="$xml2rfc-ext-include-references-in-index!='yes'">
2838            <xsl:if test="$irefs2[starts-with(translate(@item,$lcase,$ucase),$letter)]">
2839              <xsl:text>yes</xsl:text>
2840            </xsl:if>
2841          </xsl:when>
2842          <xsl:otherwise>
2843            <xsl:text>yes</xsl:text>
2844          </xsl:otherwise>
2845        </xsl:choose>
2846      </xsl:variable>
2847
2848      <xsl:if test="$showit='yes'">
2849        <li class="indline0">
2850         
2851          <!-- make letters and digits stand out -->
2852          <xsl:choose>
2853            <xsl:when test="translate($letter,concat($lcase,$ucase,'0123456789'),'')=''">
2854              <a id="{$anchor-prefix}.index.{$letter}" href="#{$anchor-prefix}.index.{$letter}">
2855                <b><xsl:value-of select="$letter"/></b>
2856              </a>
2857            </xsl:when>
2858            <xsl:otherwise>
2859              <b><xsl:value-of select="$letter"/></b>
2860            </xsl:otherwise>
2861          </xsl:choose>
2862       
2863          <ul class="ind"> 
2864            <xsl:for-each select="key('index-first-letter',translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase))">
2865       
2866              <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)"/>
2867             
2868                <xsl:choose>
2869                  <xsl:when test="self::reference">
2870                    <xsl:if test="$xml2rfc-ext-include-references-in-index='yes' and not(starts-with(@anchor,'deleted-'))">
2871                      <li class="indline1">
2872                        <em>
2873                          <xsl:value-of select="@anchor"/>
2874                        </em>
2875                        <xsl:text>  </xsl:text>
2876                       
2877                        <xsl:variable name="rs" select="//xref[@target=current()/@anchor] | . | //reference[@anchor=concat('deleted-',current()/@anchor)]"/>
2878                        <xsl:for-each select="$rs">
2879                          <xsl:call-template name="insertSingleXref"/>
2880                        </xsl:for-each>
2881
2882                        <xsl:variable name="rs2" select="$rs[@x:sec]"/>
2883
2884                        <xsl:if test="$rs2">
2885                          <ul class="ind"> 
2886                            <xsl:for-each select="$rs2">
2887                              <xsl:sort select="substring-before(concat(@x:sec,'.'),'.')" data-type="number"/>
2888                              <xsl:sort select="substring(@x:sec,1+string-length(substring-before(@x:sec,'.')))" data-type="number"/>
2889                              <xsl:if test="generate-id(.) = generate-id(key('index-xref-by-sec',concat(@target,'..',@x:sec)))">
2890                                <li class="indline1">
2891                                  <em>
2892                                    <xsl:text>Section </xsl:text>
2893                                    <xsl:value-of select="@x:sec"/>
2894                                  </em>
2895                                  <xsl:text>  </xsl:text>
2896                                  <xsl:for-each select="key('index-xref-by-sec',concat(@target,'..',@x:sec))">
2897                                    <xsl:call-template name="insertSingleXref"/>
2898                                  </xsl:for-each>
2899                                </li>
2900                              </xsl:if>
2901                            </xsl:for-each>
2902                          </ul>
2903                        </xsl:if>
2904
2905                        <xsl:if test="current()/x:source/@href">
2906                          <xsl:variable name="rs3" select="$rs[not(@x:sec) and @x:rel]"/>
2907                          <xsl:variable name="doc" select="document(current()/x:source/@href)"/>
2908                          <xsl:if test="$rs3">
2909                            <ul class="ind"> 
2910                              <xsl:for-each select="$rs3">
2911                                <xsl:sort select="count($doc//*[@anchor and following::*/@anchor=substring-after(current()/@x:rel,'#')])" order="ascending" data-type="number"/>
2912                                <xsl:if test="generate-id(.) = generate-id(key('index-xref-by-anchor',concat(@target,'..',@x:rel)))">
2913                                  <li class="indline1">
2914                                    <em>
2915                                      <xsl:text>Section </xsl:text>
2916                                      <xsl:for-each select="$doc//*[@anchor=substring-after(current()/@x:rel,'#')]">
2917                                        <xsl:call-template name="get-section-number"/>
2918                                      </xsl:for-each>
2919                                    </em>
2920                                    <xsl:text>  </xsl:text>
2921                                    <xsl:for-each select="key('index-xref-by-anchor',concat(@target,'..',@x:rel))">
2922                                      <xsl:call-template name="insertSingleXref"/>
2923                                    </xsl:for-each>
2924                                  </li>
2925                                </xsl:if>
2926                              </xsl:for-each>
2927                            </ul>
2928                          </xsl:if>
2929                        </xsl:if>
2930                      </li>
2931                    </xsl:if>
2932                  </xsl:when>
2933                  <xsl:otherwise>
2934                    <!-- regular iref -->
2935                    <xsl:if test="generate-id(.) = generate-id(key('index-item',concat(@item,@anchor)))">
2936                      <xsl:variable name="item" select="@item"/>
2937                      <xsl:variable name="in-artwork" select="count(//iref[@item=$item and @primary='true' and ancestor::artwork])!=0"/>
2938                         
2939                      <li class="indline1">
2940                        <xsl:choose>
2941                          <xsl:when test="$in-artwork">
2942                            <tt><xsl:value-of select="@item"/></tt>
2943                          </xsl:when>
2944                          <xsl:otherwise>
2945                            <xsl:value-of select="@item"/>
2946                          </xsl:otherwise>
2947                        </xsl:choose>
2948                        <xsl:text>  </xsl:text>
2949                       
2950                        <xsl:variable name="irefs3" select="key('index-item',@item)[not(@subitem) or @subitem='']"/>
2951                        <xsl:variable name="xrefs3" select="//xref[@target=$irefs3[@x:for-anchor='']/../@anchor or @target=$irefs3/@x:for-anchor]"/>
2952
2953                        <xsl:for-each select="$irefs3|$xrefs3">
2954                          <!-- <xsl:sort select="translate(@item,$lcase,$ucase)" />  -->
2955                          <xsl:call-template name="insertSingleIref"/>
2956                        </xsl:for-each>
2957         
2958                        <xsl:variable name="s2" select="key('index-item',@item)[@subitem and @subitem!='']"/>
2959                        <xsl:if test="$s2">
2960                          <ul class="ind"> 
2961                            <xsl:for-each select="$s2">
2962                              <xsl:sort select="translate(@subitem,$lcase,$ucase)"/>
2963                             
2964                              <xsl:if test="generate-id(.) = generate-id(key('index-item-subitem',concat(@item,'..',@subitem)))">
2965                 
2966                                <xsl:variable name="itemsubitem" select="concat(@item,'..',@subitem)"/>
2967                                <xsl:variable name="in-artwork2" select="count(//iref[concat(@item,'..',@subitem)=$itemsubitem and @primary='true' and ancestor::artwork])!=0"/>
2968                 
2969                                <li class="indline1">
2970             
2971                                  <xsl:choose>
2972                                    <xsl:when test="$in-artwork2">
2973                                      <tt><xsl:value-of select="@subitem"/></tt>
2974                                    </xsl:when>
2975                                    <xsl:otherwise>
2976                                      <xsl:value-of select="@subitem"/>
2977                                    </xsl:otherwise>
2978                                  </xsl:choose>
2979                                  <xsl:text>  </xsl:text>
2980                                   
2981                                  <xsl:variable name="irefs4" select="key('index-item-subitem',concat(@item,'..',@subitem))"/>
2982                                  <xsl:variable name="xrefs4" select="//xref[@target=$irefs4[@x:for-anchor='']/../@anchor or @target=$irefs4/@x:for-anchor]"/>
2983
2984                                  <xsl:for-each select="$irefs4|$xrefs4">
2985                                    <!--<xsl:sort select="translate(@item,$lcase,$ucase)" />-->                   
2986                                    <xsl:call-template name="insertSingleIref"/>
2987                                  </xsl:for-each>
2988               
2989                                </li>
2990                              </xsl:if>
2991                            </xsl:for-each>
2992                          </ul>
2993                        </xsl:if>
2994                      </li>
2995                    </xsl:if>
2996                  </xsl:otherwise>
2997                </xsl:choose>
2998             
2999                     
3000            </xsl:for-each>           
3001          </ul>
3002        </li>
3003      </xsl:if>
3004     
3005    </xsl:for-each>
3006  </ul>
3007  </div>
3008 
3009</xsl:template>
3010
3011
3012
3013
3014<xsl:template name="insertPreamble" myns:namespaceless-elements="xml2rfc">
3015
3016  <section title="Status of this Memo" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.status">
3017
3018  <xsl:choose>
3019    <xsl:when test="/rfc/@ipr and not(/rfc/@number)">
3020      <t>
3021        <xsl:choose>
3022         
3023          <!-- RFC2026 -->
3024          <xsl:when test="/rfc/@ipr = 'full2026'">
3025            This document is an Internet-Draft and is
3026            in full conformance with all provisions of Section 10 of RFC2026.   
3027          </xsl:when>
3028          <xsl:when test="/rfc/@ipr = 'noDerivativeWorks2026'">
3029            This document is an Internet-Draft and is
3030            in full conformance with all provisions of Section 10 of RFC2026
3031            except that the right to produce derivative works is not granted.   
3032          </xsl:when>
3033          <xsl:when test="/rfc/@ipr = 'noDerivativeWorksNow'">
3034            This document is an Internet-Draft and is
3035            in full conformance with all provisions of Section 10 of RFC2026
3036            except that the right to produce derivative works is not granted.
3037            (If this document becomes part of an IETF working group activity,
3038            then it will be brought into full compliance with Section 10 of RFC2026.) 
3039          </xsl:when>
3040          <xsl:when test="/rfc/@ipr = 'none'">
3041            This document is an Internet-Draft and is
3042            NOT offered in accordance with Section 10 of RFC2026,
3043            and the author does not provide the IETF with any rights other
3044            than to publish as an Internet-Draft.
3045          </xsl:when>
3046         
3047          <!-- RFC3667 -->
3048          <xsl:when test="/rfc/@ipr = 'full3667'">
3049            This document is an Internet-Draft and is subject to all provisions
3050            of section 3 of RFC 3667.  By submitting this Internet-Draft, each
3051            author represents that any applicable patent or other IPR claims of
3052            which he or she is aware have been or will be disclosed, and any of
3053            which he or she become aware will be disclosed, in accordance with
3054            RFC 3668.
3055          </xsl:when>
3056          <xsl:when test="/rfc/@ipr = 'noModification3667'">
3057            This document is an Internet-Draft and is subject to all provisions
3058            of section 3 of RFC 3667.  By submitting this Internet-Draft, each
3059            author represents that any applicable patent or other IPR claims of
3060            which he or she is aware have been or will be disclosed, and any of
3061            which he or she become aware will be disclosed, in accordance with
3062            RFC 3668.  This document may not be modified, and derivative works of
3063            it may not be created, except to publish it as an RFC and to
3064            translate it into languages other than English<xsl:if test="/rfc/@iprExtract">,
3065            other than to extract <xref target="{/rfc/@iprExtract}"/> as-is
3066            for separate use.</xsl:if>.
3067          </xsl:when>
3068          <xsl:when test="/rfc/@ipr = 'noDerivatives3667'">
3069            This document is an Internet-Draft and is subject to all provisions
3070            of section 3 of RFC 3667 except for the right to produce derivative
3071            works.  By submitting this Internet-Draft, each author represents
3072            that any applicable patent or other IPR claims of which he or she
3073            is aware have been or will be disclosed, and any of which he or she
3074            become aware will be disclosed, in accordance with RFC 3668.  This
3075            document may not be modified, and derivative works of it may
3076            not be created<xsl:if test="/rfc/@iprExtract">, other than to extract
3077            <xref target="{/rfc/@iprExtract}"/> as-is for separate use.</xsl:if>.
3078          </xsl:when>
3079         
3080          <!-- RFC3978 -->
3081          <xsl:when test="/rfc/@ipr = 'full3978'">
3082            By submitting this Internet-Draft, each
3083            author represents that any applicable patent or other IPR claims of
3084            which he or she is aware have been or will be disclosed, and any of
3085            which he or she becomes aware will be disclosed, in accordance with
3086            Section 6 of BCP 79.
3087          </xsl:when>
3088          <xsl:when test="/rfc/@ipr = 'noModification3978'">
3089            By submitting this Internet-Draft, each
3090            author represents that any applicable patent or other IPR claims of
3091            which he or she is aware have been or will be disclosed, and any of
3092            which he or she becomes aware will be disclosed, in accordance with
3093            Section 6 of BCP 79.  This document may not be modified, and derivative works of
3094            it may not be created, except to publish it as an RFC and to
3095            translate it into languages other than English<xsl:if test="/rfc/@iprExtract">,
3096            other than to extract <xref target="{/rfc/@iprExtract}"/> as-is
3097            for separate use.</xsl:if>.
3098          </xsl:when>
3099          <xsl:when test="/rfc/@ipr = 'noDerivatives3978'">
3100            By submitting this Internet-Draft, each author represents
3101            that any applicable patent or other IPR claims of which he or she
3102            is aware have been or will be disclosed, and any of which he or she
3103            becomes aware will be disclosed, in accordance with Section 6 of BCP 79.  This
3104            document may not be modified, and derivative works of it may
3105            not be created<xsl:if test="/rfc/@iprExtract">, other than to extract
3106            <xref target="{/rfc/@iprExtract}"/> as-is for separate use.</xsl:if>.
3107          </xsl:when>
3108
3109          <xsl:otherwise>CONFORMANCE UNDEFINED.</xsl:otherwise>
3110        </xsl:choose>
3111      </t>
3112      <t>
3113        Internet-Drafts are working documents of the Internet Engineering
3114        Task Force (IETF), its areas, and its working groups.
3115        Note that other groups may also distribute working documents as
3116        Internet-Drafts.
3117      </t>
3118      <t>
3119        Internet-Drafts are draft documents valid for a maximum of six months
3120        and may be updated, replaced, or obsoleted by other documents at any time.
3121        It is inappropriate to use Internet-Drafts as reference material or to cite
3122        them other than as &#8220;work in progress&#8221;.
3123      </t>
3124      <t>
3125        The list of current Internet-Drafts can be accessed at
3126        <eref target="http://www.ietf.org/ietf/1id-abstracts.txt"/>.
3127      </t>
3128      <t>
3129        The list of Internet-Draft Shadow Directories can be accessed at
3130        <eref target="http://www.ietf.org/shadow.html"/>.
3131      </t>
3132      <t>
3133        This Internet-Draft will expire in <xsl:call-template name="expirydate"/>.
3134      </t>
3135    </xsl:when>
3136
3137    <xsl:when test="/rfc/@category='bcp'">
3138      <t>
3139        This document specifies an Internet Best Current Practices for the Internet
3140        Community, and requests discussion and suggestions for improvements.
3141        Distribution of this memo is unlimited.
3142      </t>
3143    </xsl:when>
3144    <xsl:when test="/rfc/@category='exp'">
3145      <t>
3146        This memo defines an Experimental Protocol for the Internet community.
3147        It does not specify an Internet standard of any kind.
3148        Discussion and suggestions for improvement are requested.
3149        Distribution of this memo is unlimited.
3150      </t>
3151    </xsl:when>
3152    <xsl:when test="/rfc/@category='historic'">
3153      <t>
3154        This memo describes a historic protocol for the Internet community.
3155        It does not specify an Internet standard of any kind.
3156        Distribution of this memo is unlimited.
3157      </t>
3158    </xsl:when>
3159    <xsl:when test="/rfc/@category='info' or not(/rfc/@category)">
3160      <t>
3161        This memo provides information for the Internet community.
3162        It does not specify an Internet standard of any kind.
3163        Distribution of this memo is unlimited.
3164      </t>
3165    </xsl:when>
3166    <xsl:when test="/rfc/@category='std'">
3167      <t>
3168        This document specifies an Internet standards track protocol for the Internet
3169        community, and requests discussion and suggestions for improvements.
3170        Please refer to the current edition of the &#8220;Internet Official Protocol
3171        Standards&#8221; (STD 1) for the standardization state and status of this
3172        protocol. Distribution of this memo is unlimited.
3173      </t>
3174    </xsl:when>
3175    <xsl:otherwise>
3176      <t>UNSUPPORTED CATEGORY.</t>
3177    </xsl:otherwise>
3178  </xsl:choose>
3179 
3180  </section>
3181
3182  <section title="Copyright Notice" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.copyrightnotice">
3183  <t>
3184    <xsl:choose>
3185      <xsl:when test="$ipr-rfc4748">
3186        Copyright © The IETF Trust (<xsl:value-of select="/rfc/front/date/@year"/>).  All Rights Reserved.
3187      </xsl:when>
3188      <xsl:otherwise>
3189        Copyright © The Internet Society (<xsl:value-of select="/rfc/front/date/@year"/>).  All Rights Reserved.
3190      </xsl:otherwise>
3191    </xsl:choose>
3192  </t>
3193  </section>
3194 
3195</xsl:template>
3196
3197<!-- TOC generation -->
3198
3199<xsl:template match="/" mode="toc">
3200  <hr xmlns="http://www.w3.org/1999/xhtml" class="noprint"/>
3201
3202  <h1 xmlns="http://www.w3.org/1999/xhtml" class="np" id="{$anchor-prefix}.toc"> <!-- this pagebreak occurs always -->
3203    <a href="#{$anchor-prefix}.toc">Table of Contents</a>
3204  </h1>
3205
3206  <ul xmlns="http://www.w3.org/1999/xhtml" class="toc">
3207    <xsl:apply-templates mode="toc"/>
3208  </ul>
3209</xsl:template>
3210
3211<xsl:template name="insert-toc-line">
3212  <xsl:param name="number"/>
3213  <xsl:param name="target"/>
3214  <xsl:param name="title"/>
3215  <xsl:param name="tocparam"/>
3216  <xsl:param name="oldtitle"/>
3217  <xsl:param name="waschanged"/>
3218
3219  <!-- handle tocdepth parameter -->
3220  <xsl:choose>
3221    <xsl:when test="($tocparam='' or $tocparam='default') and string-length(translate($number,'.ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890§','.')) &gt;= $parsedTocDepth">
3222      <!-- dropped entry because excluded -->
3223      <xsl:attribute name="class">tocline2</xsl:attribute>
3224    </xsl:when>
3225    <xsl:when test="$tocparam='exclude'">
3226      <!-- dropped entry because excluded -->
3227      <xsl:attribute name="class">tocline2</xsl:attribute>
3228    </xsl:when>
3229    <xsl:otherwise>
3230      <xsl:choose>
3231        <xsl:when test="starts-with($number,'del-')">
3232          <del xmlns="http://www.w3.org/1999/xhtml">
3233            <xsl:value-of select="$number"/>
3234            <a href="#{$target}"><xsl:value-of select="$title"/></a>
3235          </del>
3236        </xsl:when>
3237        <xsl:otherwise>
3238          <xsl:choose>
3239            <xsl:when test="not(contains($number,'.'))">
3240              <xsl:attribute name="class">tocline0</xsl:attribute>
3241            </xsl:when>
3242            <xsl:otherwise>
3243              <xsl:attribute name="class">tocline1</xsl:attribute>
3244            </xsl:otherwise>
3245          </xsl:choose>
3246          <xsl:if test="$number != ''">
3247            <xsl:call-template name="emit-section-number">
3248              <xsl:with-param name="no" select="$number"/>
3249            </xsl:call-template>
3250            <xsl:text>   </xsl:text>
3251          </xsl:if>
3252          <a xmlns="http://www.w3.org/1999/xhtml" href="#{$target}">
3253            <xsl:choose>
3254              <xsl:when test="$waschanged!=''">
3255                <ins><xsl:value-of select="$title"/></ins>
3256                <del><xsl:value-of select="$oldtitle"/></del>
3257              </xsl:when>
3258              <xsl:otherwise>
3259                <xsl:value-of select="$title"/>
3260              </xsl:otherwise>
3261            </xsl:choose>
3262          </a>
3263        </xsl:otherwise>
3264      </xsl:choose>
3265    </xsl:otherwise>
3266  </xsl:choose>
3267</xsl:template>
3268
3269<xsl:template match="back" mode="toc">
3270
3271  <!-- <xsl:apply-templates select="references" mode="toc" /> -->
3272
3273  <xsl:if test="//cref and $xml2rfc-comments='yes' and $xml2rfc-inline!='yes'">
3274    <li xmlns="http://www.w3.org/1999/xhtml">
3275      <xsl:call-template name="insert-toc-line">
3276        <xsl:with-param name="target" select="concat($anchor-prefix,'.comments')"/>
3277        <xsl:with-param name="title" select="'Editorial Comments'"/>
3278      </xsl:call-template>
3279    </li>
3280  </xsl:if>
3281
3282  <xsl:if test="$xml2rfc-ext-authors-section!='end'">
3283    <xsl:apply-templates select="/rfc/front" mode="toc"/>
3284  </xsl:if>
3285  <xsl:apply-templates select="*[not(self::references)]" mode="toc"/>
3286
3287  <xsl:if test="$xml2rfc-ext-authors-section='end'">
3288    <xsl:apply-templates select="/rfc/front" mode="toc"/>
3289  </xsl:if>
3290
3291  <!-- copyright statements -->
3292  <xsl:if test="not($xml2rfc-private)">
3293    <li xmlns="http://www.w3.org/1999/xhtml">
3294      <xsl:call-template name="insert-toc-line">
3295        <xsl:with-param name="target" select="concat($anchor-prefix,'.ipr')"/>
3296        <xsl:with-param name="title" select="'Intellectual Property and Copyright Statements'"/>
3297      </xsl:call-template>
3298    </li>
3299  </xsl:if>
3300 
3301  <!-- insert the index if index entries exist -->
3302  <xsl:if test="//iref">
3303    <li xmlns="http://www.w3.org/1999/xhtml">
3304      <xsl:call-template name="insert-toc-line">
3305        <xsl:with-param name="target" select="concat($anchor-prefix,'.index')"/>
3306        <xsl:with-param name="title" select="'Index'"/>
3307      </xsl:call-template>
3308    </li>
3309  </xsl:if>
3310
3311</xsl:template>
3312
3313<xsl:template match="front" mode="toc">
3314 
3315  <li xmlns="http://www.w3.org/1999/xhtml">
3316    <xsl:variable name="authors-title">
3317      <xsl:call-template name="get-authors-section-title"/>
3318    </xsl:variable>
3319    <xsl:variable name="authors-number">
3320      <xsl:call-template name="get-authors-section-number"/>
3321    </xsl:variable>
3322    <xsl:call-template name="insert-toc-line">
3323      <xsl:with-param name="target" select="concat($anchor-prefix,'.authors')"/>
3324      <xsl:with-param name="title" select="$authors-title"/>
3325      <xsl:with-param name="number" select="$authors-number"/>
3326    </xsl:call-template>
3327  </li>
3328
3329</xsl:template>
3330
3331<xsl:template name="references-toc">
3332
3333  <!-- distinguish two cases: (a) single references element (process
3334  as toplevel section; (b) multiple references sections (add one toplevel
3335  container with subsection) -->
3336
3337  <xsl:variable name="refsecs" select="/rfc/back/references|/rfc/back/ed:replace/ed:ins/references"/>
3338   
3339  <xsl:choose>
3340    <xsl:when test="count($refsecs) = 0">
3341      <!-- nop -->
3342    </xsl:when>
3343    <xsl:when test="count($refsecs) = 1">
3344      <xsl:for-each select="$refsecs">
3345        <xsl:variable name="title">
3346          <xsl:choose>
3347            <xsl:when test="@title!=''"><xsl:value-of select="@title"/></xsl:when>
3348            <xsl:otherwise>References</xsl:otherwise>
3349          </xsl:choose>
3350        </xsl:variable>
3351     
3352        <li xmlns="http://www.w3.org/1999/xhtml">
3353          <xsl:call-template name="insert-toc-line">
3354            <xsl:with-param name="number">
3355              <xsl:call-template name="get-references-section-number"/>
3356            </xsl:with-param>
3357            <xsl:with-param name="target" select="concat($anchor-prefix,'.references')"/>
3358            <xsl:with-param name="title" select="$title"/>
3359          </xsl:call-template>
3360        </li>
3361      </xsl:for-each>
3362    </xsl:when>
3363    <xsl:otherwise>
3364      <li xmlns="http://www.w3.org/1999/xhtml">
3365        <!-- insert pseudo container -->   
3366        <xsl:call-template name="insert-toc-line">
3367          <xsl:with-param name="number">
3368            <xsl:call-template name="get-references-section-number"/>
3369          </xsl:with-param>
3370          <xsl:with-param name="target" select="concat($anchor-prefix,'.references')"/>
3371          <xsl:with-param name="title" select="'References'"/>
3372        </xsl:call-template>
3373 
3374        <ul class="toc">
3375          <!-- ...with subsections... -->   
3376          <xsl:for-each select="$refsecs">
3377            <xsl:variable name="title">
3378              <xsl:choose>
3379                <xsl:when test="@title!=''"><xsl:value-of select="@title"/></xsl:when>
3380                <xsl:otherwise>References</xsl:otherwise>
3381              </xsl:choose>
3382            </xsl:variable>
3383         
3384            <xsl:variable name="sectionNumber">
3385              <xsl:call-template name="get-section-number"/>
3386            </xsl:variable>
3387   
3388            <xsl:variable name="num">
3389              <xsl:number level="any"/>
3390            </xsl:variable>
3391   
3392            <li>
3393              <xsl:call-template name="insert-toc-line">
3394                <xsl:with-param name="number" select="$sectionNumber"/>
3395                <xsl:with-param name="target" select="concat($anchor-prefix,'.references','.',$num)"/>
3396                <xsl:with-param name="title" select="$title"/>
3397              </xsl:call-template>
3398            </li>
3399          </xsl:for-each>
3400        </ul>
3401      </li>
3402    </xsl:otherwise>
3403  </xsl:choose>
3404</xsl:template>
3405
3406<xsl:template match="section|appendix" mode="toc">
3407  <xsl:variable name="sectionNumber">
3408    <xsl:call-template name="get-section-number"/>
3409  </xsl:variable>
3410
3411  <xsl:variable name="target">
3412    <xsl:choose>
3413      <xsl:when test="@anchor"><xsl:value-of select="@anchor"/></xsl:when>
3414       <xsl:otherwise><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$sectionNumber"/></xsl:otherwise>
3415    </xsl:choose>
3416  </xsl:variable>
3417
3418  <!-- obtain content, just to check whether we need to recurse at all -->
3419  <xsl:variable name="content">
3420    <li xmlns="http://www.w3.org/1999/xhtml">
3421      <xsl:call-template name="insert-toc-line">
3422        <xsl:with-param name="number" select="$sectionNumber"/>
3423        <xsl:with-param name="target" select="$target"/>
3424        <xsl:with-param name="title" select="@title"/>
3425        <xsl:with-param name="tocparam" select="@toc"/>
3426        <xsl:with-param name="oldtitle" select="@ed:old-title"/>
3427        <xsl:with-param name="waschanged" select="@ed:resolves"/>
3428      </xsl:call-template>
3429   
3430      <ul class="toc">
3431        <xsl:apply-templates mode="toc"/>
3432      </ul>
3433    </li>
3434  </xsl:variable>
3435 
3436  <xsl:if test="$content!=''">
3437    <li xmlns="http://www.w3.org/1999/xhtml">
3438      <xsl:call-template name="insert-toc-line">
3439        <xsl:with-param name="number" select="$sectionNumber"/>
3440        <xsl:with-param name="target" select="$target"/>
3441        <xsl:with-param name="title" select="@title"/>
3442        <xsl:with-param name="tocparam" select="@toc"/>
3443        <xsl:with-param name="oldtitle" select="@ed:old-title"/>
3444        <xsl:with-param name="waschanged" select="@ed:resolves"/>
3445      </xsl:call-template>
3446   
3447      <!-- obtain nested content, just to check whether we need to recurse at all -->
3448      <xsl:variable name="nested-content">
3449        <ul class="toc">
3450          <xsl:apply-templates mode="toc"/>
3451        </ul>
3452      </xsl:variable>
3453     
3454      <!-- only recurse if we need to (do not produce useless list container) -->     
3455      <xsl:if test="$nested-content!=''">
3456        <ul class="toc">
3457          <xsl:apply-templates mode="toc"/>
3458        </ul>
3459      </xsl:if>
3460    </li>
3461  </xsl:if>
3462</xsl:template>
3463
3464<xsl:template match="middle" mode="toc">
3465  <xsl:apply-templates mode="toc"/>
3466  <xsl:call-template name="references-toc"/>
3467</xsl:template>
3468
3469<xsl:template match="rfc" mode="toc">
3470  <xsl:apply-templates select="middle|back" mode="toc"/>
3471</xsl:template>
3472
3473<xsl:template match="ed:del|ed:ins|ed:replace" mode="toc">
3474  <xsl:apply-templates mode="toc"/>
3475</xsl:template>
3476
3477<xsl:template match="*|text()" mode="toc"/>
3478
3479
3480<xsl:template name="insertTocAppendix">
3481 
3482  <xsl:if test="//figure[@title!='' or @anchor!='']">
3483    <ul xmlns="http://www.w3.org/1999/xhtml" class="toc">
3484      <xsl:for-each select="//figure[@title!='' or @anchor!='']">
3485        <xsl:variable name="title">Figure <xsl:value-of select="position()"/><xsl:if test="@title">: <xsl:value-of select="@title"/></xsl:if>
3486        </xsl:variable>
3487        <li>
3488          <xsl:call-template name="insert-toc-line">
3489            <xsl:with-param name="target" select="concat($anchor-prefix,'.figure.',position())"/>
3490            <xsl:with-param name="title" select="$title"/>
3491          </xsl:call-template>
3492        </li>
3493      </xsl:for-each>
3494    </ul>
3495  </xsl:if>
3496 
3497  <!-- experimental -->
3498  <xsl:if test="//ed:issue">
3499    <xsl:call-template name="insertIssuesList"/>
3500  </xsl:if>
3501
3502</xsl:template>
3503
3504<xsl:template name="referencename">
3505  <xsl:param name="node"/>
3506 
3507  <xsl:for-each select="$node">
3508    <xsl:choose>
3509      <xsl:when test="$xml2rfc-symrefs!='no' and ancestor::ed:del">
3510        <xsl:variable name="unprefixed" select="substring-after(@anchor,'deleted-')"/>
3511        <xsl:choose>
3512          <xsl:when test="$unprefixed!=''">
3513            <xsl:value-of select="concat('[',$unprefixed,']')"/>
3514          </xsl:when>
3515          <xsl:otherwise>
3516            <xsl:if test="count(//reference[@anchor=current()/@anchor])!=1">
3517              <xsl:message>Deleted duplicate anchors should have the prefix "deleted-": <xsl:value-of select="@anchor"/></xsl:message>
3518            </xsl:if>
3519            <xsl:value-of select="concat('[',@anchor,']')"/>
3520          </xsl:otherwise>
3521        </xsl:choose>
3522      </xsl:when>
3523      <xsl:when test="$xml2rfc-symrefs!='no'">[<xsl:value-of select="@anchor"/>]</xsl:when>
3524      <xsl:when test="ancestor::ed:del">
3525        <xsl:text>[del]</xsl:text>
3526      </xsl:when>
3527      <xsl:otherwise>[<xsl:number level="any" count="reference[not(ancestor::ed:del)]"/>]</xsl:otherwise>
3528    </xsl:choose>
3529  </xsl:for-each> 
3530</xsl:template>
3531
3532
3533
3534<xsl:template name="replace-substring">
3535
3536  <xsl:param name="string"/>
3537  <xsl:param name="replace"/>
3538  <xsl:param name="by"/>
3539
3540  <xsl:choose>
3541    <xsl:when test="contains($string,$replace)">
3542      <xsl:value-of select="concat(substring-before($string, $replace),$by)"/>
3543      <xsl:call-template name="replace-substring">
3544        <xsl:with-param name="string" select="substring-after($string,$replace)"/>
3545        <xsl:with-param name="replace" select="$replace"/>
3546        <xsl:with-param name="by" select="$by"/>
3547      </xsl:call-template>
3548    </xsl:when>
3549    <xsl:otherwise><xsl:value-of select="$string"/></xsl:otherwise>
3550  </xsl:choose>
3551
3552</xsl:template>
3553
3554
3555<xsl:template name="rfclist">
3556  <xsl:param name="list"/>
3557  <xsl:choose>
3558    <xsl:when test="contains($list,',')">
3559      <xsl:variable name="rfcNo" select="substring-before($list,',')"/>
3560      <xsl:if test="count(//references//reference/seriesInfo[@name='RFC' and @value=$rfcNo])=0">
3561        <xsl:call-template name="warning">
3562          <xsl:with-param name="inline" select="'no'"/>
3563          <xsl:with-param name="msg" select="concat('front matter mentions RFC',$rfcNo,' for which there is no reference element')"/>
3564        </xsl:call-template>
3565      </xsl:if>
3566      <a xmlns="http://www.w3.org/1999/xhtml" href="{concat($rfcUrlPrefix,$rfcNo,$rfcUrlPostfix)}"><xsl:value-of select="$rfcNo"/></a>,
3567      <xsl:call-template name="rfclist">
3568        <xsl:with-param name="list" select="normalize-space(substring-after($list,','))"/>
3569      </xsl:call-template>
3570    </xsl:when>
3571    <xsl:otherwise>
3572      <xsl:variable name="rfcNo" select="$list"/>
3573      <xsl:if test="count(//references//reference/seriesInfo[@name='RFC' and @value=$rfcNo])=0">
3574        <xsl:call-template name="warning">
3575          <xsl:with-param name="inline" select="'no'"/>
3576          <xsl:with-param name="msg" select="concat('front matter mentions RFC',$rfcNo,' for which there is no reference element')"/>
3577        </xsl:call-template>
3578      </xsl:if>
3579      <a xmlns="http://www.w3.org/1999/xhtml" href="{concat($rfcUrlPrefix,$rfcNo,$rfcUrlPostfix)}"><xsl:value-of select="$rfcNo"/></a>
3580    </xsl:otherwise>
3581  </xsl:choose>
3582</xsl:template>
3583
3584<xsl:template name="rfclist-for-dcmeta">
3585  <xsl:param name="list"/>
3586  <xsl:choose>
3587    <xsl:when test="contains($list,',')">
3588      <xsl:variable name="rfcNo" select="substring-before($list,',')"/>
3589      <meta xmlns="http://www.w3.org/1999/xhtml" name="DC.Relation.Replaces" content="urn:ietf:rfc:{$rfcNo}"/>
3590      <xsl:call-template name="rfclist-for-dcmeta">
3591        <xsl:with-param name="list" select="normalize-space(substring-after($list,','))"/>
3592      </xsl:call-template>
3593    </xsl:when>
3594    <xsl:otherwise>
3595      <xsl:variable name="rfcNo" select="$list"/>
3596      <meta xmlns="http://www.w3.org/1999/xhtml" name="DC.Relation.Replaces" content="urn:ietf:rfc:{$rfcNo}"/>
3597    </xsl:otherwise>
3598  </xsl:choose>
3599</xsl:template>
3600
3601<xsl:template name="get-paragraph-number">
3602  <!-- get section number of ancestor section element, then add t or figure number -->
3603  <xsl:if test="ancestor::section and not(ancestor::section[@myns:unnumbered='unnumbered']) and not(ancestor::x:blockquote)">
3604    <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"/>
3605  </xsl:if>
3606</xsl:template>
3607
3608<xsl:template name="editingMark">
3609  <xsl:if test="$xml2rfc-editing='yes' and ancestor::rfc">
3610    <sup xmlns="http://www.w3.org/1999/xhtml" class="editingmark"><span><xsl:number level="any" count="postamble|preamble|t"/></span> </sup>
3611  </xsl:if>
3612</xsl:template>
3613
3614<!-- internal ref support -->
3615<xsl:template match="x:ref">
3616  <xsl:variable name="val" select="."/>
3617  <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)]"/>
3618  <xsl:choose>
3619    <xsl:when test="$target">
3620      <a xmlns="http://www.w3.org/1999/xhtml" href="#{$target/@anchor}" class="smpl"><xsl:value-of select="."/></a>
3621    </xsl:when>
3622    <xsl:otherwise>
3623      <xsl:message>WARNING: internal link target for '<xsl:value-of select="."/>' does not exist.<xsl:call-template name="lineno"/></xsl:message>
3624      <xsl:value-of select="."/>
3625    </xsl:otherwise>
3626  </xsl:choose>
3627</xsl:template>
3628
3629<!-- Nothing to do here -->
3630<xsl:template match="x:anchor-alias"/>
3631
3632<!-- Quotes -->
3633<xsl:template match="x:q">
3634  <q xmlns="http://www.w3.org/1999/xhtml">
3635    <xsl:copy-of select="@cite"/>
3636    <xsl:apply-templates/>
3637  </q>
3638</xsl:template>
3639
3640<xsl:template match="x:bcp14">
3641  <!-- check valid BCP14 keywords, then emphasize them -->
3642  <xsl:variable name="c" select="normalize-space(.)"/>
3643  <xsl:choose>
3644    <xsl:when test="$c='MUST' or $c='REQUIRED' or $c='SHALL'">
3645      <em xmlns="http://www.w3.org/1999/xhtml" class="bcp14"><xsl:value-of select="."/></em>
3646    </xsl:when>
3647    <xsl:when test="$c='MUST NOT' or $c='SHALL NOT'">
3648      <em xmlns="http://www.w3.org/1999/xhtml" class="bcp14"><xsl:value-of select="."/></em>
3649    </xsl:when>
3650    <xsl:when test="$c='SHOULD' or $c='RECOMMENDED'">
3651      <em xmlns="http://www.w3.org/1999/xhtml" class="bcp14"><xsl:value-of select="."/></em>
3652    </xsl:when>
3653    <xsl:when test="$c='SHOULD NOT' or $c='NOT RECOMMENDED'">
3654      <em xmlns="http://www.w3.org/1999/xhtml" class="bcp14"><xsl:value-of select="."/></em>
3655    </xsl:when>
3656    <xsl:when test="$c='MAY' or $c='OPTIONAL'">
3657      <em xmlns="http://www.w3.org/1999/xhtml" class="bcp14"><xsl:value-of select="."/></em>
3658    </xsl:when>
3659    <xsl:otherwise>
3660      <xsl:value-of select="."/>
3661      <xsl:message>ERROR: unknown BCP14 keyword: <xsl:value-of select="."/></xsl:message>
3662    </xsl:otherwise>
3663  </xsl:choose>
3664</xsl:template>
3665
3666<xsl:template match="x:blockquote">
3667  <xsl:variable name="p">
3668    <xsl:call-template name="get-paragraph-number"/>
3669  </xsl:variable>
3670
3671  <blockquote xmlns="http://www.w3.org/1999/xhtml">
3672    <xsl:if test="string-length($p) &gt; 0 and not(ancestor::ed:del) and not(ancestor::ed:ins)">
3673      <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$p"/></xsl:attribute>
3674    </xsl:if>
3675    <xsl:call-template name="insertInsDelClass"/>
3676    <xsl:call-template name="editingMark"/>
3677    <xsl:copy-of select="@cite"/>
3678    <xsl:apply-templates/>
3679  </blockquote>
3680</xsl:template>
3681
3682<!-- Definitions -->
3683<xsl:template match="x:dfn">
3684  <dfn xmlns="http://www.w3.org/1999/xhtml">
3685    <xsl:apply-templates/>
3686  </dfn>
3687</xsl:template>
3688
3689<!-- headings -->
3690<xsl:template match="x:h">
3691  <b xmlns="http://www.w3.org/1999/xhtml">
3692    <xsl:apply-templates/>
3693  </b>
3694</xsl:template>
3695
3696<!-- box drawing -->
3697
3698<!-- nop for alignment -->
3699<xsl:template match="x:x"/>
3700
3701<!-- box (top) -->
3702<xsl:template match="x:bt">
3703  <xsl:text>&#9484;</xsl:text>
3704  <xsl:value-of select="translate(substring(.,2,string-length(.)-2),'-','&#9472;')"/>
3705  <xsl:text>&#9488;</xsl:text>
3706</xsl:template>
3707
3708<!-- box (center) -->
3709<xsl:template match="x:bc">
3710  <xsl:variable name="first" select="substring(.,1)"/>
3711  <xsl:variable name="last" select="substring(.,string-length(.)-1)"/>
3712  <xsl:variable name="content" select="substring(.,2,string-length(.)-2)"/>
3713  <xsl:variable name="is-delimiter" select="translate($content,'-','')=''"/>
3714 
3715  <xsl:choose>
3716    <xsl:when test="$is-delimiter">
3717      <xsl:text>&#9500;</xsl:text>
3718      <xsl:value-of select="translate($content,'-','&#9472;')"/>
3719      <xsl:text>&#9508;</xsl:text>
3720    </xsl:when>
3721    <xsl:when test="*">
3722      <xsl:for-each select="node()">
3723        <xsl:choose>
3724          <xsl:when test="position()=1">
3725            <xsl:text>&#9474;</xsl:text>
3726            <xsl:value-of select="substring(.,2)"/>
3727          </xsl:when>
3728          <xsl:when test="position()=last()">
3729            <xsl:value-of select="substring(.,1,string-length(.)-1)"/>
3730            <xsl:text>&#9474;</xsl:text>
3731          </xsl:when>
3732          <xsl:otherwise>
3733            <xsl:apply-templates select="."/>
3734          </xsl:otherwise>
3735        </xsl:choose>
3736      </xsl:for-each>
3737    </xsl:when>
3738    <xsl:otherwise>
3739      <xsl:text>&#9474;</xsl:text>
3740      <xsl:value-of select="$content"/>
3741      <xsl:text>&#9474;</xsl:text>
3742    </xsl:otherwise>
3743  </xsl:choose>
3744 
3745</xsl:template>
3746
3747<!-- box (bottom) -->
3748<xsl:template match="x:bb">
3749  <xsl:text>&#9492;</xsl:text>
3750  <xsl:value-of select="translate(substring(.,2,string-length(.)-2),'-','&#9472;')"/>
3751  <xsl:text>&#9496;</xsl:text>
3752</xsl:template>
3753
3754<!-- experimental annotation support -->
3755
3756<xsl:template match="ed:issueref">
3757  <xsl:choose>
3758    <xsl:when test=".=//ed:issue/@name">
3759      <a xmlns="http://www.w3.org/1999/xhtml" href="#{$anchor-prefix}.issue.{.}">
3760        <xsl:apply-templates/>
3761      </a>
3762    </xsl:when>
3763    <xsl:otherwise>
3764      <xsl:call-template name="warning">
3765        <xsl:with-param name="msg">Dangling ed:issueref: <xsl:value-of select="."/></xsl:with-param>
3766      </xsl:call-template>
3767      <xsl:apply-templates/>
3768    </xsl:otherwise>
3769  </xsl:choose>
3770</xsl:template>
3771
3772<xsl:template match="ed:issue">
3773  <xsl:variable name="class">
3774    <xsl:choose>
3775      <xsl:when test="@status='closed'">closedissue</xsl:when>
3776      <xsl:otherwise>openissue</xsl:otherwise>
3777    </xsl:choose>
3778  </xsl:variable>
3779 
3780  <table xmlns="http://www.w3.org/1999/xhtml" summary="issue {@name}" class="{$class}">
3781    <tr>
3782      <td colspan="3">
3783        <a id="{$anchor-prefix}.issue.{@name}">
3784          <xsl:choose>
3785            <xsl:when test="@status='closed'">
3786              <xsl:attribute name="class">closed-issue</xsl:attribute>
3787            </xsl:when>
3788            <xsl:when test="@status='editor'">
3789              <xsl:attribute name="class">editor-issue</xsl:attribute>
3790            </xsl:when>
3791            <xsl:otherwise>
3792              <xsl:attribute name="class">open-issue</xsl:attribute>
3793            </xsl:otherwise>
3794          </xsl:choose>
3795          <xsl:text> I </xsl:text>
3796        </a>
3797        <xsl:text> </xsl:text>
3798        <xsl:choose>
3799          <xsl:when test="@href">
3800            <em><a href="{@href}"><xsl:value-of select="@name"/></a></em>
3801          </xsl:when>
3802          <xsl:when test="@alternate-href">
3803            <em>[<a href="{@alternate-href}">alternate link</a>]</em>
3804          </xsl:when>
3805          <xsl:otherwise>
3806            <em><xsl:value-of select="@name"/></em>
3807          </xsl:otherwise>
3808        </xsl:choose>
3809         
3810        (type: <xsl:value-of select="@type"/>, status: <xsl:value-of select="@status"/>)
3811      </td>
3812    </tr>
3813
3814    <xsl:apply-templates select="ed:item"/>
3815    <xsl:apply-templates select="ed:resolution"/>
3816
3817    <xsl:variable name="changes" select="//*[@ed:resolves=current()/@name or ed:resolves=current()/@name]"/>
3818    <xsl:if test="$changes">
3819      <tr>
3820        <td class="top" colspan="3">
3821          Associated changes in this document:
3822          <xsl:variable name="issue" select="@name"/>
3823          <xsl:for-each select="$changes">
3824            <a href="#{$anchor-prefix}.change.{$issue}.{position()}">
3825              <xsl:variable name="label">
3826                <xsl:call-template name="get-section-number"/>
3827              </xsl:variable>
3828              <xsl:choose>
3829                <xsl:when test="$label!=''"><xsl:value-of select="$label"/></xsl:when>
3830                <xsl:otherwise>&lt;<xsl:value-of select="concat('#',$anchor-prefix,'.change.',$issue,'.',position())"/>&gt;</xsl:otherwise>
3831              </xsl:choose>
3832            </a>
3833            <xsl:if test="position()!=last()">, </xsl:if>
3834          </xsl:for-each>
3835          <xsl:text>.</xsl:text>
3836        </td>
3837      </tr>
3838    </xsl:if>
3839  </table>
3840   
3841</xsl:template>
3842
3843<xsl:template match="ed:item">
3844  <tr xmlns="http://www.w3.org/1999/xhtml">
3845    <td class="top">
3846      <xsl:if test="@entered-by">
3847        <a href="mailto:{@entered-by}?subject={/rfc/@docName},%20{../@name}">
3848          <i><xsl:value-of select="@entered-by"/></i>
3849        </a>
3850      </xsl:if>
3851    </td>
3852    <td class="topnowrap">
3853      <xsl:value-of select="@date"/>
3854    </td>
3855    <td class="top">
3856      <xsl:apply-templates select="node()" mode="issuehtml"/>
3857    </td>
3858  </tr>
3859</xsl:template>
3860
3861<xsl:template match="ed:resolution">
3862  <tr xmlns="http://www.w3.org/1999/xhtml">
3863    <td class="top">
3864      <xsl:if test="@entered-by">
3865        <a href="mailto:{@entered-by}?subject={/rfc/@docName},%20{../@name}"><i><xsl:value-of select="@entered-by"/></i></a>
3866      </xsl:if>
3867    </td>
3868    <td class="topnowrap">
3869      <xsl:value-of select="@datetime"/>
3870    </td>
3871    <td class="top">
3872      <em>Resolution:</em>
3873      <xsl:apply-templates select="node()" mode="issuehtml"/>
3874    </td>
3875  </tr>
3876</xsl:template>
3877
3878<xsl:template match="ed:annotation">
3879  <em xmlns="http://www.w3.org/1999/xhtml">
3880    <xsl:apply-templates/>
3881  </em>
3882</xsl:template>
3883
3884<!-- special templates for handling XHTML in issues -->
3885<xsl:template match="text()" mode="issuehtml">
3886  <xsl:value-of select="."/>
3887</xsl:template>
3888
3889<xsl:template match="*|@*" mode="issuehtml">
3890  <xsl:message terminate="yes">Unexpected node in issue HTML: <xsl:value-of select="local-name(.)"/></xsl:message>
3891</xsl:template>
3892
3893<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">
3894  <xsl:element namespace="http://www.w3.org/1999/xhtml" name="{local-name()}">
3895    <xsl:apply-templates select="@*|node()" mode="issuehtml"/>
3896  </xsl:element>
3897</xsl:template>
3898
3899<xsl:template match="xhtml:p" mode="issuehtml">
3900  <xsl:apply-templates select="node()" mode="issuehtml"/>
3901  <br xmlns="http://www.w3.org/1999/xhtml" class="p"/>
3902</xsl:template>
3903
3904<xsl:template match="xhtml:a/@href|xhtml:q/@cite" mode="issuehtml">
3905  <xsl:attribute name="{local-name(.)}">
3906    <xsl:value-of select="."/>
3907  </xsl:attribute>
3908</xsl:template>
3909
3910<xsl:template match="ed:issueref" mode="issuehtml">
3911  <xsl:apply-templates select="."/>
3912</xsl:template>
3913
3914<xsl:template match="ed:eref" mode="issuehtml">
3915  <xsl:text>&lt;</xsl:text>
3916  <a xmlns="http://www.w3.org/1999/xhtml" href="{.}"><xsl:value-of select="."/></a>
3917  <xsl:text>&gt;</xsl:text>
3918</xsl:template>
3919
3920<xsl:template name="insertIssuesList">
3921
3922  <h2 xmlns="http://www.w3.org/1999/xhtml" id="{$anchor-prefix}.issues-list"><a href="#{$anchor-prefix}.issues-list">Issues list</a></h2>
3923  <table xmlns="http://www.w3.org/1999/xhtml" summary="Issues list">
3924    <thead>
3925      <tr>
3926        <th>Id</th>
3927        <th>Type</th>
3928        <th>Status</th>
3929        <th>Date</th>
3930        <th>Raised By</th>
3931      </tr>
3932    </thead>
3933    <tbody>
3934      <xsl:for-each select="//ed:issue">
3935        <xsl:sort select="@status"/>
3936        <xsl:sort select="@name"/>
3937        <tr>
3938          <td><a href="#{$anchor-prefix}.issue.{@name}"><xsl:value-of select="@name"/></a></td>
3939          <td><xsl:value-of select="@type"/></td>
3940          <td><xsl:value-of select="@status"/></td>
3941          <td><xsl:value-of select="ed:item[1]/@date"/></td>
3942          <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>
3943        </tr>
3944      </xsl:for-each>
3945    </tbody>
3946  </table>
3947 
3948</xsl:template>
3949
3950<xsl:template name="formatTitle">
3951  <xsl:if test="@who">
3952    <xsl:value-of select="@who"/>
3953  </xsl:if>
3954  <xsl:if test="@datetime">
3955    <xsl:value-of select="concat(' (',@datetime,')')"/>
3956  </xsl:if>
3957  <xsl:if test="@reason">
3958    <xsl:value-of select="concat(': ',@reason)"/>
3959  </xsl:if>
3960  <xsl:if test="@cite">
3961    <xsl:value-of select="concat(' &lt;',@cite,'&gt;')"/>
3962  </xsl:if>
3963</xsl:template>
3964
3965<xsl:template name="insert-diagnostics">
3966 
3967  <!-- check anchor names -->
3968  <xsl:variable name="badAnchors" select="//*[starts-with(@anchor,concat($anchor-prefix,'.'))]"/>
3969  <xsl:if test="$badAnchors">
3970    <p xmlns="http://www.w3.org/1999/xhtml" class="warning">
3971      The following anchor names may collide with internally generated anchors because of their prefix "<xsl:value-of select="$anchor-prefix"/>":
3972      <xsl:for-each select="$badAnchors">
3973        <xsl:value-of select="@anchor"/><xsl:if test="position()!=last()">, </xsl:if>
3974      </xsl:for-each>
3975    </p>
3976    <xsl:message>
3977      The following anchor names may collide with internally generated anchors because of their prefix "<xsl:value-of select="$anchor-prefix"/>":
3978      <xsl:for-each select="$badAnchors">
3979        <xsl:value-of select="@anchor"/><xsl:if test="position()!=last()">, </xsl:if>
3980      </xsl:for-each>
3981    </xsl:message>
3982  </xsl:if>
3983 
3984  <!-- check IDs -->
3985  <xsl:variable name="badTargets" select="//xref[not(@target=//@anchor) and not(ancestor::ed:del)]"/>
3986  <xsl:if test="$badTargets">
3987    <p xmlns="http://www.w3.org/1999/xhtml" class="error">
3988      The following target names do not exist:
3989      <xsl:for-each select="$badTargets">
3990        <xsl:value-of select="@target"/><xsl:if test="position()!=last()">, </xsl:if>
3991      </xsl:for-each>
3992    </p>
3993    <xsl:message>
3994      The following target names do not exist:
3995      <xsl:for-each select="$badTargets">
3996        <xsl:value-of select="@target"/><xsl:if test="position()!=last()">, </xsl:if>
3997      </xsl:for-each>
3998    </xsl:message>
3999  </xsl:if>
4000 
4001 
4002</xsl:template>
4003
4004<!-- special change mark support, not supported by RFC2629 yet -->
4005
4006<xsl:template match="@ed:*"/>
4007
4008<xsl:template match="ed:del">
4009  <xsl:call-template name="insert-issue-pointer"/>
4010  <del xmlns="http://www.w3.org/1999/xhtml">
4011    <xsl:copy-of select="@*[namespace-uri()='']"/>
4012    <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
4013      <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4014    </xsl:if>
4015    <xsl:apply-templates/>
4016  </del>
4017</xsl:template>
4018
4019<xsl:template match="ed:ins">
4020  <xsl:call-template name="insert-issue-pointer"/>
4021  <ins xmlns="http://www.w3.org/1999/xhtml">
4022    <xsl:copy-of select="@*[namespace-uri()='']"/>
4023    <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
4024      <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4025    </xsl:if>
4026    <xsl:apply-templates/>
4027  </ins>
4028</xsl:template>
4029
4030<xsl:template name="insert-issue-pointer">
4031  <xsl:param name="deleted-anchor"/>
4032  <xsl:variable name="change" select="."/>
4033  <xsl:for-each select="@ed:resolves|ed:resolves">
4034    <xsl:variable name="resolves" select="."/>
4035    <!-- need the right context node for proper numbering -->
4036    <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>
4037    <xsl:variable name="total" select="count(//*[@ed:resolves=$resolves or ed:resolves=$resolves])"/>
4038    <xsl:variable name="id">
4039      <xsl:value-of select="$anchor-prefix"/>.change.<xsl:value-of select="$resolves"/>.<xsl:value-of select="$count"/>
4040    </xsl:variable>
4041    <xsl:choose>
4042      <!-- block level? -->
4043      <xsl:when test="not(ancestor::t) and not(ancestor::title) and not(ancestor::figure) and not($change/@ed:old-title)">
4044        <div xmlns="http://www.w3.org/1999/xhtml" class="issuepointer noprint">
4045          <xsl:if test="not($deleted-anchor)">
4046            <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
4047          </xsl:if>
4048          <xsl:if test="$count &gt; 1">
4049            <a class="bg-issue" title="previous change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count - 1}">&#8593;</a>
4050          </xsl:if>
4051          <a class="open-issue" href="#{$anchor-prefix}.issue.{$resolves}" title="resolves: {$resolves}">
4052            <xsl:choose>
4053              <xsl:when test="//ed:issue[@name=$resolves and @status='closed']">
4054                <xsl:attribute name="class">closed-issue</xsl:attribute>
4055              </xsl:when>
4056              <xsl:when test="//ed:issue[@name=$resolves and @status='editor']">
4057                <xsl:attribute name="class">editor-issue</xsl:attribute>
4058              </xsl:when>
4059              <xsl:otherwise>
4060                <xsl:attribute name="class">open-issue</xsl:attribute>
4061              </xsl:otherwise>
4062            </xsl:choose>
4063            <xsl:text> I </xsl:text>
4064          </a>
4065          <xsl:if test="$count &lt; $total">
4066            <a class="bg-issue" title="next change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count + 1}">&#8595;</a>
4067          </xsl:if>
4068          <xsl:text> </xsl:text>
4069        </div>
4070      </xsl:when>
4071      <xsl:otherwise>
4072        <xsl:if test="$count &gt; 1">
4073          <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>
4074        </xsl:if>
4075        <a xmlns="http://www.w3.org/1999/xhtml" title="resolves: {$resolves}" href="#{$anchor-prefix}.issue.{$resolves}">
4076          <xsl:if test="not($deleted-anchor)">
4077            <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
4078          </xsl:if>
4079          <xsl:choose>
4080            <xsl:when test="//ed:issue[@name=$resolves and @status='closed']">
4081              <xsl:attribute name="class">closed-issue noprint</xsl:attribute>
4082            </xsl:when>
4083            <xsl:when test="//ed:issue[@name=$resolves and @status='editor']">
4084              <xsl:attribute name="class">editor-issue noprint</xsl:attribute>
4085            </xsl:when>
4086            <xsl:otherwise>
4087              <xsl:attribute name="class">open-issue noprint</xsl:attribute>
4088            </xsl:otherwise>
4089          </xsl:choose>
4090          <xsl:text> I </xsl:text>
4091        </a>
4092        <xsl:if test="$count &lt; $total">
4093          <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>
4094        </xsl:if>
4095      </xsl:otherwise>
4096    </xsl:choose>
4097  </xsl:for-each>
4098</xsl:template>
4099
4100<xsl:template match="ed:replace">
4101  <!-- we need to special-case things like lists and tables -->
4102  <xsl:choose>
4103    <xsl:when test="parent::list">
4104      <xsl:apply-templates select="ed:del/node()"/>
4105      <xsl:apply-templates select="ed:ins/node()"/>
4106    </xsl:when>
4107    <xsl:when test="ancestor::references">
4108      <xsl:apply-templates select="ed:del/node()"/>
4109      <xsl:apply-templates select="ed:ins/node()"/>
4110    </xsl:when>
4111    <xsl:otherwise>
4112      <xsl:if test="@cite">
4113        <a xmlns="http://www.w3.org/1999/xhtml" class="editor-issue" href="{@cite}" target="_blank" title="see {@cite}">
4114          <xsl:text> i </xsl:text>
4115        </a>
4116      </xsl:if>
4117      <xsl:call-template name="insert-issue-pointer"/>
4118      <xsl:if test="ed:del">
4119        <del xmlns="http://www.w3.org/1999/xhtml">
4120          <xsl:copy-of select="@*[namespace-uri()='']"/>
4121          <xsl:if test="not(@title) and ancestor-or-self::xsl:template[@ed:entered-by] and @datetime">
4122            <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4123          </xsl:if>
4124          <xsl:apply-templates select="ed:del/node()"/>
4125        </del>
4126      </xsl:if>
4127      <xsl:if test="ed:ins">
4128        <ins xmlns="http://www.w3.org/1999/xhtml">
4129          <xsl:copy-of select="@*[namespace-uri()='']"/>
4130          <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
4131            <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4132          </xsl:if>
4133          <xsl:apply-templates select="ed:ins/node()"/>
4134        </ins>
4135      </xsl:if>
4136    </xsl:otherwise>
4137  </xsl:choose>
4138</xsl:template>
4139
4140<!-- convenience template for helping Mozilla (pre/ins inheritance problem) -->
4141<xsl:template name="insertInsDelClass">
4142  <xsl:if test="ancestor::ed:del">
4143    <xsl:attribute name="class">del</xsl:attribute>
4144  </xsl:if>
4145  <xsl:if test="ancestor::ed:ins">
4146    <xsl:attribute name="class">ins</xsl:attribute>
4147  </xsl:if>
4148</xsl:template>
4149
4150
4151<xsl:template name="sectionnumberAndEdits">
4152  <xsl:choose>
4153    <xsl:when test="ancestor::ed:del">del-<xsl:number count="ed:del//section" level="any"/></xsl:when>
4154    <xsl:when test="@x:fixed-section-number">
4155      <xsl:value-of select="@x:fixed-section-number"/>
4156    </xsl:when>
4157    <xsl:when test="self::section and parent::ed:ins and local-name(../..)='replace'">
4158      <xsl:for-each select="../.."><xsl:call-template name="sectionnumberAndEdits"/></xsl:for-each>
4159      <xsl:for-each select="..">
4160        <xsl:if test="parent::ed:replace">
4161          <xsl:for-each select="..">
4162            <xsl:if test="parent::section">.</xsl:if>
4163            <xsl:variable name="cnt" select="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)"/>
4164            <xsl:choose>
4165              <xsl:when test="ancestor::back and not(ancestor::section)"><xsl:number format="A" value="$cnt"/></xsl:when>
4166              <xsl:otherwise><xsl:value-of select="$cnt"/></xsl:otherwise>
4167            </xsl:choose>
4168          </xsl:for-each>
4169        </xsl:if>
4170      </xsl:for-each>
4171    </xsl:when>
4172    <xsl:when test="self::section[parent::ed:ins]">
4173      <xsl:for-each select="../.."><xsl:call-template name="sectionnumberAndEdits"/></xsl:for-each>
4174      <xsl:for-each select="..">
4175        <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)"/>
4176      </xsl:for-each>
4177    </xsl:when>
4178    <xsl:when test="self::section">
4179      <xsl:for-each select=".."><xsl:call-template name="sectionnumberAndEdits"/></xsl:for-each>
4180      <xsl:if test="parent::section">.</xsl:if>
4181      <xsl:choose>
4182        <xsl:when test="parent::back">
4183          <xsl:number format="A" value="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)"/>
4184        </xsl:when>
4185        <xsl:otherwise>
4186          <xsl:number value="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)"/>
4187        </xsl:otherwise>
4188      </xsl:choose>
4189    </xsl:when>
4190    <xsl:when test="self::references">
4191      <xsl:choose>
4192        <xsl:when test="count(/*/back/references)+count(/*/back/ed:replace/ed:ins/references)=1"><xsl:call-template name="get-references-section-number"/></xsl:when>
4193        <xsl:otherwise><xsl:call-template name="get-references-section-number"/>.<xsl:number level="any"/></xsl:otherwise>
4194      </xsl:choose>
4195    </xsl:when>
4196    <xsl:when test="self::middle or self::back"><!-- done --></xsl:when>
4197    <xsl:otherwise>
4198      <!-- go up one level -->
4199      <xsl:for-each select=".."><xsl:call-template name="sectionnumberAndEdits"/></xsl:for-each>
4200    </xsl:otherwise>
4201  </xsl:choose>
4202</xsl:template>
4203
4204<!-- utilities for warnings -->
4205
4206<xsl:template name="warning">
4207  <xsl:param name="msg"/>
4208  <xsl:param name="msg2"/>
4209  <xsl:param name="inline"/>
4210  <xsl:if test="$inline!='no'">
4211    <div xmlns="http://www.w3.org/1999/xhtml" class="error">WARNING: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/></div>
4212  </xsl:if>
4213  <xsl:message>WARNING: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/><xsl:call-template name="lineno"/></xsl:message>
4214</xsl:template>
4215
4216<xsl:template name="error">
4217  <xsl:param name="msg"/>
4218  <xsl:param name="msg2"/>
4219  <xsl:param name="inline"/>
4220  <xsl:if test="$inline='no'">
4221    <div xmlns="http://www.w3.org/1999/xhtml" class="error">ERROR: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/></div>
4222  </xsl:if>
4223  <xsl:message>ERROR: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/><xsl:call-template name="lineno"/></xsl:message>
4224</xsl:template>
4225
4226<!-- table formatting -->
4227
4228<xsl:template match="texttable">
4229
4230  <xsl:variable name="anch">
4231    <xsl:call-template name="get-table-anchor"/>
4232  </xsl:variable>
4233
4234  <div xmlns="http://www.w3.org/1999/xhtml" id="{$anch}">
4235    <xsl:if test="@anchor!=''">
4236      <div id="{@anchor}"/>
4237    </xsl:if>
4238    <xsl:apply-templates select="preamble"/>
4239    <xsl:variable name="style">
4240      <xsl:text>tt </xsl:text>
4241      <xsl:choose>
4242        <xsl:when test="@style!=''">
4243          <xsl:value-of select="@style"/>
4244        </xsl:when>
4245        <xsl:otherwise>full</xsl:otherwise>
4246      </xsl:choose>
4247    </xsl:variable>
4248    <table summary="{preamble}" class="{$style}" cellpadding="3" cellspacing="0">
4249      <thead>
4250        <tr>
4251          <xsl:apply-templates select="ttcol"/>
4252        </tr>
4253      </thead>
4254      <tbody>
4255        <xsl:variable name="columns" select="count(ttcol)"/>
4256        <xsl:variable name="fields" select="c | ed:replace/ed:ins/c | ed:replace/ed:del/c"/>
4257        <xsl:for-each select="$fields[(position() mod $columns) = 1]">
4258          <tr>
4259            <xsl:for-each select=". | following-sibling::c[position() &lt; $columns]">
4260              <td>
4261                <xsl:call-template name="insertInsDelClass"/>
4262                <xsl:variable name="pos" select="position()"/>
4263                <xsl:variable name="col" select="../ttcol[position() = $pos]"/>
4264                <xsl:choose>
4265                  <xsl:when test="$col/@align='right' or $col/@align='center'">
4266                    <xsl:attribute name="class"><xsl:value-of select="$col/@align"/></xsl:attribute>
4267                  </xsl:when>
4268                  <xsl:when test="$col/@align='left' or not($col/@align)">
4269                    <!-- that's the default, nothing to do here -->
4270                  </xsl:when>
4271                  <xsl:otherwise>
4272                    <xsl:message>Unknown align attribute on ttcol: <xsl:value-of select="$col/@align"/></xsl:message>
4273                  </xsl:otherwise>
4274                </xsl:choose>
4275                <xsl:apply-templates select="node()"/>
4276              </td>
4277            </xsl:for-each>
4278          </tr>
4279        </xsl:for-each>
4280      </tbody>
4281    </table>
4282    <xsl:apply-templates select="postamble"/>
4283
4284    <xsl:if test="@title!='' or @anchor!=''">
4285      <xsl:variable name="n"><xsl:number level="any" count="texttable[@title!='' or @anchor!='']"/></xsl:variable>
4286      <p class="figure">Table <xsl:value-of select="$n"/><xsl:if test="@title!=''">: <xsl:value-of select="@title"/></xsl:if></p>
4287    </xsl:if>
4288  </div>
4289 
4290</xsl:template>
4291
4292<xsl:template match="ttcol">
4293  <th xmlns="http://www.w3.org/1999/xhtml">
4294   
4295    <xsl:choose>
4296      <xsl:when test="@align='right' or @align='center' or @align='left'">
4297        <xsl:attribute name="class"><xsl:value-of select="@align"/></xsl:attribute>
4298      </xsl:when>
4299      <xsl:when test="not(@align)">
4300        <!-- that's the default, nothing to do here -->
4301      </xsl:when>
4302      <xsl:otherwise>
4303        <xsl:message>Unknown align attribute on ttcol: <xsl:value-of select="@align"/></xsl:message>
4304      </xsl:otherwise>
4305    </xsl:choose>
4306   
4307    <xsl:if test="@width">
4308      <xsl:attribute name="style">width: <xsl:value-of select="@width"/>;</xsl:attribute>
4309    </xsl:if>
4310
4311    <xsl:apply-templates/>
4312  </th>
4313</xsl:template>
4314
4315<!-- cref support -->
4316
4317<xsl:template match="cref">
4318  <xsl:if test="$xml2rfc-comments!='no'">
4319    <xsl:variable name="cid">
4320      <xsl:choose>
4321        <xsl:when test="@anchor">
4322          <xsl:value-of select="@anchor"/>
4323        </xsl:when>
4324        <xsl:otherwise>
4325          <xsl:value-of select="$anchor-prefix"/>
4326          <xsl:text>.comment.</xsl:text>
4327          <xsl:number count="cref[not(@anchor)]" level="any"/>
4328        </xsl:otherwise>
4329      </xsl:choose>
4330    </xsl:variable>
4331   
4332    <span xmlns="http://www.w3.org/1999/xhtml" class="comment">
4333      <xsl:if test="$xml2rfc-inline!='yes'">
4334        <xsl:attribute name="title">
4335          <xsl:if test="@source"><xsl:value-of select="@source"/>: </xsl:if>
4336          <xsl:value-of select="."/>
4337        </xsl:attribute>
4338      </xsl:if>
4339      <xsl:text>[</xsl:text>
4340      <xsl:choose>
4341        <xsl:when test="$xml2rfc-inline='yes'">
4342          <xsl:value-of select="$cid"/>
4343          <xsl:text>: </xsl:text>
4344          <xsl:value-of select="."/>
4345          <xsl:if test="@source"> --<xsl:value-of select="@source"/></xsl:if>
4346        </xsl:when>
4347        <xsl:otherwise>
4348          <a href="#{$cid}">
4349            <xsl:value-of select="$cid"/>
4350          </a>
4351        </xsl:otherwise>
4352      </xsl:choose>
4353      <xsl:text>]</xsl:text>
4354    </span>
4355  </xsl:if>
4356</xsl:template>
4357
4358<xsl:template name="insertComments">
4359
4360  <xsl:call-template name="insert-conditional-hrule"/>
4361   
4362  <h1 xmlns="http://www.w3.org/1999/xhtml">
4363    <xsl:call-template name="insert-conditional-pagebreak"/>
4364    <a id="{$anchor-prefix}.comments" href="#{$anchor-prefix}.comments">Editorial Comments</a>
4365  </h1>
4366
4367  <dl xmlns="http://www.w3.org/1999/xhtml">
4368    <xsl:for-each select="//cref">
4369      <xsl:variable name="cid">
4370        <xsl:choose>
4371          <xsl:when test="@anchor">
4372            <xsl:value-of select="@anchor"/>
4373          </xsl:when>
4374          <xsl:otherwise>
4375            <xsl:value-of select="$anchor-prefix"/>
4376            <xsl:text>.comment.</xsl:text>
4377            <xsl:number count="cref[not(@anchor)]" level="any"/>
4378          </xsl:otherwise>
4379        </xsl:choose>
4380      </xsl:variable>
4381      <dt id="{$cid}">
4382        [<xsl:value-of select="$cid"/>]
4383      </dt>
4384      <dd>
4385        <xsl:value-of select="."/>
4386        <xsl:if test="@source"> --<xsl:value-of select="@source"/></xsl:if>
4387      </dd>
4388    </xsl:for-each>
4389  </dl>
4390</xsl:template>
4391
4392
4393<!-- Chapter Link Generation -->
4394
4395<xsl:template match="*" mode="links"><xsl:apply-templates mode="links"/></xsl:template>
4396<xsl:template match="text()" mode="links"/>
4397
4398<xsl:template match="/*/middle//section[not(myns:unnumbered) and not(ancestor::section)]" mode="links">
4399  <xsl:variable name="sectionNumber"><xsl:call-template name="get-section-number"/></xsl:variable>
4400  <link xmlns="http://www.w3.org/1999/xhtml" rel="Chapter" title="{$sectionNumber} {@title}" href="#{$anchor-prefix}.section.{$sectionNumber}"/>
4401  <xsl:apply-templates mode="links"/>
4402</xsl:template>
4403
4404<xsl:template match="/*/back//section[not(myns:unnumbered) and not(ancestor::section)]" mode="links">
4405  <xsl:variable name="sectionNumber"><xsl:call-template name="get-section-number"/></xsl:variable>
4406  <link xmlns="http://www.w3.org/1999/xhtml" rel="Appendix" title="{$sectionNumber} {@title}" href="#{$anchor-prefix}.section.{$sectionNumber}"/>
4407  <xsl:apply-templates mode="links"/>
4408</xsl:template>
4409
4410<xsl:template match="/*/back/references[position()=1]" mode="links">
4411  <xsl:variable name="sectionNumber"><xsl:call-template name="get-references-section-number"/></xsl:variable>
4412  <link xmlns="http://www.w3.org/1999/xhtml" rel="Chapter" href="#{$anchor-prefix}.section.{$sectionNumber}">
4413    <xsl:choose>
4414      <xsl:when test="@title and count(/*/back/references)=1">
4415        <xsl:attribute name="title">
4416          <xsl:call-template name="get-references-section-number"/>
4417          <xsl:text> </xsl:text>
4418          <xsl:value-of select="@title"/>
4419        </xsl:attribute>
4420      </xsl:when>
4421      <xsl:otherwise>
4422        <xsl:attribute name="title">
4423          <xsl:call-template name="get-references-section-number"/>
4424          <xsl:text> References</xsl:text>
4425        </xsl:attribute>
4426      </xsl:otherwise>
4427    </xsl:choose>
4428  </link>
4429</xsl:template>
4430
4431<!-- convenience templates -->
4432
4433<xsl:template name="get-author-summary">
4434  <xsl:choose>
4435    <xsl:when test="count(/rfc/front/author)=1">
4436      <xsl:value-of select="/rfc/front/author[1]/@surname"/>
4437    </xsl:when>
4438    <xsl:when test="count(/rfc/front/author)=2">
4439      <xsl:value-of select="concat(/rfc/front/author[1]/@surname,' &amp; ',/rfc/front/author[2]/@surname)"/>
4440    </xsl:when>
4441    <xsl:otherwise>
4442      <xsl:value-of select="concat(/rfc/front/author[1]/@surname,', et al.')"/>
4443    </xsl:otherwise>
4444  </xsl:choose>
4445</xsl:template>
4446
4447<xsl:template name="get-authors">
4448  <xsl:for-each select="/rfc/front/author">
4449    <xsl:value-of select="@fullname"/>
4450    <xsl:if test="position()!=last()">, </xsl:if>
4451  </xsl:for-each>
4452</xsl:template>
4453
4454<xsl:template name="get-category-long">
4455  <xsl:choose>
4456    <xsl:when test="$xml2rfc-footer"><xsl:value-of select="$xml2rfc-footer"/></xsl:when>
4457    <xsl:when test="$xml2rfc-private"/> <!-- private draft, footer not set -->
4458    <xsl:when test="/rfc/@category='bcp'">Best Current Practice</xsl:when>
4459    <xsl:when test="/rfc/@category='historic'">Historic</xsl:when>
4460    <xsl:when test="/rfc/@category='info' or not(/rfc/@category)">Informational</xsl:when>
4461    <xsl:when test="/rfc/@category='std'">Standards Track</xsl:when>
4462    <xsl:when test="/rfc/@category='exp'">Experimental</xsl:when>
4463    <xsl:otherwise>(category unknown)</xsl:otherwise>
4464  </xsl:choose>
4465</xsl:template>
4466
4467<xsl:template name="get-header-center">
4468  <xsl:choose>
4469    <xsl:when test="string-length(/rfc/front/title/@abbrev) &gt; 0">
4470      <xsl:value-of select="/rfc/front/title/@abbrev"/>
4471    </xsl:when>
4472    <xsl:otherwise>
4473      <xsl:apply-templates select="/rfc/front/title" mode="get-text-content"/>
4474    </xsl:otherwise>
4475  </xsl:choose>
4476</xsl:template>
4477
4478<xsl:template name="get-header-left">
4479  <xsl:choose>
4480    <xsl:when test="$xml2rfc-header"><xsl:value-of select="$xml2rfc-header"/></xsl:when>
4481    <xsl:when test="$xml2rfc-private"/> <!-- private draft, header not set -->
4482    <xsl:when test="/rfc/@ipr and not(/rfc/@number)">INTERNET DRAFT</xsl:when>
4483    <xsl:otherwise>RFC <xsl:value-of select="/rfc/@number"/></xsl:otherwise>
4484  </xsl:choose>
4485</xsl:template>
4486
4487<xsl:template name="get-generator">
4488  <xsl:variable name="gen">
4489    <xsl:text>http://greenbytes.de/tech/webdav/rfc2629.xslt, </xsl:text>
4490    <!-- when RCS keyword substitution in place, add version info -->
4491    <xsl:if test="contains('$Revision: 1.354 $',':')">
4492      <xsl:value-of select="concat('Revision ',normalize-space(translate(substring-after('$Revision: 1.354 $', 'Revision: '),'$','')),', ')"/>
4493    </xsl:if>
4494    <xsl:if test="contains('$Date: 2007/12/31 13:43:05 $',':')">
4495      <xsl:value-of select="concat(normalize-space(translate(substring-after('$Date: 2007/12/31 13:43:05 $', 'Date: '),'$','')),', ')"/>
4496    </xsl:if>
4497    <xsl:value-of select="concat('XSLT vendor: ',system-property('xsl:vendor'),' ',system-property('xsl:vendor-url'))"/>
4498  </xsl:variable>
4499  <xsl:value-of select="$gen"/>
4500</xsl:template>
4501
4502<xsl:template name="get-header-right">
4503  <xsl:value-of select="concat(/rfc/front/date/@month,' ',/rfc/front/date/@year)"/>
4504</xsl:template>
4505
4506<xsl:template name="get-keywords">
4507  <xsl:variable name="keyw">
4508    <xsl:for-each select="/rfc/front/keyword">
4509      <xsl:value-of select="translate(.,',',' ')"/>
4510      <xsl:if test="position()!=last()">, </xsl:if>
4511    </xsl:for-each>
4512  </xsl:variable>
4513  <xsl:value-of select="normalize-space($keyw)"/>
4514</xsl:template>
4515
4516<!-- get language from context node. nearest ancestor or return the default of "en" -->
4517<xsl:template name="get-lang">
4518  <xsl:choose>
4519    <xsl:when test="ancestor-or-self::*[@xml:lang]"><xsl:value-of select="ancestor-or-self::*/@xml:lang"/></xsl:when>
4520    <xsl:otherwise>en</xsl:otherwise>
4521  </xsl:choose>
4522</xsl:template>
4523
4524<xsl:template name="get-section-number">
4525  <xsl:variable name="hasEdits" select="count(//ed:del|//ed:ins)!=0"/>
4526  <xsl:variable name="anchor" select="@anchor"/>
4527  <xsl:choose>
4528    <xsl:when test="@x:fixed-section-number">
4529      <xsl:value-of select="@x:fixed-section-number"/>
4530    </xsl:when>
4531    <xsl:when test="$hasEdits or ancestor::*/@x:fixed-section-number">
4532      <xsl:call-template name="sectionnumberAndEdits"/>
4533    </xsl:when>
4534    <xsl:otherwise>
4535      <xsl:choose>
4536        <xsl:when test="self::references">
4537          <xsl:choose>
4538            <xsl:when test="count(/*/back/references)=1">
4539              <xsl:call-template name="get-references-section-number"/>
4540            </xsl:when>
4541            <xsl:otherwise>
4542              <xsl:call-template name="get-references-section-number"/>.<xsl:number count="references"/>
4543            </xsl:otherwise>
4544          </xsl:choose>
4545        </xsl:when>
4546        <xsl:when test="self::reference">
4547          <xsl:for-each select="parent::references">
4548            <xsl:choose>
4549              <xsl:when test="count(/*/back/references)=1">
4550                <xsl:call-template name="get-references-section-number"/>
4551              </xsl:when>
4552              <xsl:otherwise>
4553                <xsl:call-template name="get-references-section-number"/>.<xsl:number count="references"/>
4554              </xsl:otherwise>
4555            </xsl:choose>
4556          </xsl:for-each>
4557        </xsl:when>
4558        <xsl:when test="ancestor::back"><xsl:number count="section|appendix" level="multiple" format="A.1.1.1.1.1.1.1"/></xsl:when>
4559        <xsl:when test="self::appendix"><xsl:number count="appendix" level="multiple" format="A.1.1.1.1.1.1.1"/></xsl:when>
4560        <xsl:otherwise><xsl:number count="section" level="multiple"/></xsl:otherwise>
4561      </xsl:choose>
4562    </xsl:otherwise>
4563  </xsl:choose>
4564</xsl:template>
4565
4566<!-- get the section number for the references section -->
4567<xsl:template name="get-references-section-number">
4568  <xsl:value-of select="count(/rfc/middle/section) + count(/rfc/middle/ed:replace/ed:ins/section) + 1"/>
4569</xsl:template>
4570
4571<xsl:template name="emit-section-number">
4572  <xsl:param name="no"/>
4573  <xsl:value-of select="$no"/><xsl:if test="not(contains($no,'.')) or $xml2rfc-ext-sec-no-trailing-dots='yes'">.</xsl:if>
4574</xsl:template>
4575
4576<xsl:template name="get-section-type">
4577  <xsl:param name="prec"/>
4578  <xsl:choose>
4579    <xsl:when test="ancestor::back">Appendix</xsl:when>
4580    <xsl:otherwise>Section</xsl:otherwise>
4581  </xsl:choose>
4582</xsl:template>
4583
4584<xsl:template name="get-table-anchor">
4585  <xsl:value-of select="$anchor-prefix"/>
4586  <xsl:text>.table.</xsl:text>
4587  <xsl:choose>
4588    <xsl:when test="@title!='' or @anchor!=''">
4589      <xsl:number level="any" count="texttable[@title!='' or @anchor!='']"/>
4590    </xsl:when>
4591    <xsl:otherwise>
4592      <xsl:text>u.</xsl:text>
4593      <xsl:number level="any" count="texttable[not(@title!='' or @anchor!='')]"/>
4594    </xsl:otherwise>
4595  </xsl:choose>
4596</xsl:template>
4597
4598<xsl:template name="get-figure-anchor">
4599  <xsl:value-of select="$anchor-prefix"/>
4600  <xsl:text>.figure.</xsl:text>
4601  <xsl:choose>
4602    <xsl:when test="@title!='' or @anchor!=''">
4603      <xsl:number level="any" count="figure[@title!='' or @anchor!='']"/>
4604    </xsl:when>
4605    <xsl:otherwise>
4606      <xsl:text>u.</xsl:text>
4607      <xsl:number level="any" count="figure[not(@title!='' or @anchor!='')]"/>
4608    </xsl:otherwise>
4609  </xsl:choose>
4610</xsl:template>
4611
4612<!-- reformat contents of author/@initials -->
4613<xsl:template name="format-initials">
4614  <xsl:choose>
4615    <xsl:when test="string-length(@initials)=1">
4616      <xsl:value-of select="concat(@initials,'.')"/>
4617    </xsl:when>
4618    <xsl:otherwise>
4619      <xsl:value-of select="@initials"/>
4620    </xsl:otherwise>
4621  </xsl:choose>
4622</xsl:template>
4623
4624<xsl:template name="insert-conditional-pagebreak">
4625  <xsl:if test="$xml2rfc-compact!='yes'">
4626    <xsl:attribute name="class">np</xsl:attribute>
4627  </xsl:if>
4628</xsl:template>
4629
4630<xsl:template name="insert-conditional-hrule">
4631  <xsl:if test="$xml2rfc-compact!='yes'">
4632    <hr xmlns="http://www.w3.org/1999/xhtml" class="noprint"/>
4633  </xsl:if>
4634</xsl:template>
4635
4636<!-- get text content from marked-up text -->
4637
4638<xsl:template match="text()" mode="get-text-content">
4639  <xsl:value-of select="."/>
4640</xsl:template>
4641
4642<xsl:template match="*" mode="get-text-content">
4643  <xsl:apply-templates mode="get-text-content"/>
4644</xsl:template>
4645
4646<xsl:template match="ed:del" mode="get-text-content">
4647</xsl:template>
4648
4649<!-- diag support -->
4650<xsl:template name="lineno">
4651  <xsl:if test="function-available('saxon:line-number')">
4652    <xsl:if test="saxon:line-number() &gt; 0">
4653      <xsl:text> (at line </xsl:text>
4654      <xsl:value-of select="saxon:line-number()"/>
4655      <xsl:text>)</xsl:text>
4656    </xsl:if>
4657  </xsl:if>
4658</xsl:template>
4659
4660</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.