source: rfc2629xslt/rfc2629.xslt @ 573

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

update to latest version of rfc2629.xslt; bump up document dates

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