source: rfc2629xslt/rfc2629toXHTML.xslt @ 213

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

Update to latest eUpdate to latest version of rfc2629.xslt

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