source: rfc2629xslt/rfc2629toXHTML.xslt @ 32

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

rfc2629.xslt fix: for cross-document references, distinguish between Section and Appendix

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