source: rfc2629xslt/rfc2629.xslt @ 588

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

Update to latest version of rfc2629.xslt and bump up document dates.

  • Property svn:eol-style set to native
File size: 211.1 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 != ''">
1365        <xsl:if test="string(number(front/date/@year)) = 'NaN'">
1366          <xsl:call-template name="warning">
1367            <xsl:with-param name="inline" select="'no'"/>
1368            <xsl:with-param name="msg">date/@year should be a number: '<xsl:value-of select="front/date/@year"/>' in reference '<xsl:value-of select="@anchor"/>'</xsl:with-param>
1369          </xsl:call-template>
1370        </xsl:if>
1371        <xsl:text>, </xsl:text>
1372        <xsl:if test="front/date/@month!=''"><xsl:value-of select="front/date/@month" />&#0160;</xsl:if>
1373        <xsl:value-of select="front/date/@year" />
1374      </xsl:if>
1375     
1376      <xsl:if test="@target">
1377        <xsl:text>, &lt;</xsl:text>
1378        <a href="{@target}"><xsl:value-of select="@target"/></a>
1379        <xsl:text>&gt;</xsl:text>
1380      </xsl:if>
1381     
1382      <xsl:text>.</xsl:text>
1383
1384      <xsl:for-each select="annotation">
1385        <br />
1386        <xsl:apply-templates />
1387      </xsl:for-each>
1388
1389    </td>
1390  </tr>
1391 
1392 
1393</xsl:template>
1394
1395
1396<xsl:template match="references">
1397
1398  <xsl:variable name="name">
1399    <xsl:if test="ancestor::ed:del">
1400      <xsl:text>del-</xsl:text>
1401    </xsl:if>
1402    <xsl:number level="any"/>     
1403  </xsl:variable>
1404 
1405  <xsl:variable name="refseccount" select="count(/rfc/back/references)+count(/rfc/back/ed:replace/ed:ins/references)"/>
1406
1407  <!-- insert pseudo section when needed -->
1408  <xsl:if test="not(preceding::references) and $refseccount!=1">
1409    <xsl:call-template name="insert-conditional-hrule"/>
1410    <h1 id="{$anchor-prefix}.references">
1411      <xsl:call-template name="insert-conditional-pagebreak"/>
1412      <xsl:variable name="sectionNumber">
1413        <xsl:call-template name="get-references-section-number"/>
1414      </xsl:variable>
1415      <a id="{$anchor-prefix}.section.{$sectionNumber}" href="#{$anchor-prefix}.section.{$sectionNumber}">
1416        <xsl:call-template name="emit-section-number">
1417          <xsl:with-param name="no" select="$sectionNumber"/>
1418        </xsl:call-template>
1419      </a>
1420      <xsl:text> References</xsl:text>
1421    </h1>
1422  </xsl:if>
1423 
1424  <xsl:variable name="elemtype">
1425    <xsl:choose>
1426      <xsl:when test="$refseccount!=1">h2</xsl:when>
1427      <xsl:otherwise>h1</xsl:otherwise>
1428    </xsl:choose>
1429  </xsl:variable>
1430 
1431  <xsl:variable name="title">
1432    <xsl:choose>
1433      <xsl:when test="not(@title) or @title=''">References</xsl:when>
1434      <xsl:otherwise><xsl:value-of select="@title"/></xsl:otherwise>
1435    </xsl:choose>
1436  </xsl:variable>
1437 
1438  <xsl:element name="{$elemtype}"> 
1439    <xsl:if test="$name='1'">
1440      <xsl:call-template name="insert-conditional-pagebreak"/>
1441    </xsl:if>
1442    <xsl:variable name="sectionNumber">
1443      <xsl:call-template name="get-section-number"/>
1444    </xsl:variable>
1445    <xsl:variable name="anchorpref">
1446      <xsl:choose>
1447        <xsl:when test="$elemtype='h1'"></xsl:when>
1448        <xsl:otherwise>.<xsl:value-of select="$name"/></xsl:otherwise>
1449      </xsl:choose>
1450    </xsl:variable>
1451    <xsl:attribute name="id"><xsl:value-of select="concat($anchor-prefix,'.references',$anchorpref)"/></xsl:attribute>
1452    <a href="#{$anchor-prefix}.section.{$sectionNumber}" id="{$anchor-prefix}.section.{$sectionNumber}">
1453      <xsl:call-template name="emit-section-number">
1454        <xsl:with-param name="no" select="$sectionNumber"/>
1455      </xsl:call-template>
1456    </a>
1457    <xsl:text> </xsl:text>
1458    <xsl:value-of select="$title"/>
1459  </xsl:element>
1460 
1461  <table summary="{$title}">
1462    <xsl:choose>
1463      <xsl:when test="$xml2rfc-sortrefs='yes' and $xml2rfc-symrefs!='no'">
1464        <xsl:apply-templates>
1465          <xsl:sort select="@anchor|.//ed:ins//reference/@anchor" />
1466        </xsl:apply-templates>
1467      </xsl:when>
1468      <xsl:otherwise>
1469        <xsl:apply-templates />
1470      </xsl:otherwise>
1471    </xsl:choose>
1472  </table>
1473
1474</xsl:template>
1475
1476<xsl:template match="rfc">
1477 
1478  <!-- conformance checks -->
1479  <xsl:if test="$xml2rfc-symrefs!='no' and $xml2rfc-symrefs!='yes' and //reference">
1480    <xsl:call-template name="warning">
1481      <xsl:with-param name="inline" select="'no'"/>
1482      <xsl:with-param name="msg">symrefs PI not specified; default has changed from 'no' to 'yes'.</xsl:with-param>
1483    </xsl:call-template>
1484  </xsl:if>
1485 
1486  <xsl:variable name="lang">
1487    <xsl:call-template name="get-lang" />
1488  </xsl:variable>
1489
1490  <html lang="{$lang}">
1491    <head>
1492      <xsl:attribute name="profile">
1493        <xsl:text>http://www.w3.org/2006/03/hcard</xsl:text>
1494        <xsl:if test="$xml2rfc-ext-support-rfc2731!='no'">
1495          <xsl:text> </xsl:text>
1496          <xsl:text>http://dublincore.org/documents/2008/08/04/dc-html/</xsl:text>
1497        </xsl:if>
1498      </xsl:attribute>
1499      <title>
1500        <xsl:apply-templates select="front/title" mode="get-text-content" />
1501      </title>
1502      <style type="text/css" title="Xml2Rfc (sans serif)">
1503        <xsl:call-template name="insertCss" />
1504      </style>
1505      <!-- <link rel="alternate stylesheet" type="text/css" media="screen" title="Plain (typewriter)" href="rfc2629tty.css" /> -->
1506           
1507      <!-- link elements -->
1508      <xsl:if test="$xml2rfc-toc='yes'">
1509        <link rel="Contents" href="#{$anchor-prefix}.toc" />
1510      </xsl:if>
1511      <link rel="Author" href="#{$anchor-prefix}.authors" />
1512      <xsl:if test="not($xml2rfc-private)">
1513        <link rel="Copyright" href="#{$anchor-prefix}.copyright" />
1514      </xsl:if>
1515      <xsl:if test="$has-index">
1516        <link rel="Index" href="#{$anchor-prefix}.index" />
1517      </xsl:if>
1518      <xsl:apply-templates select="/" mode="links" />
1519      <xsl:for-each select="/rfc/x:link">
1520        <link><xsl:copy-of select="@*" /></link>
1521      </xsl:for-each>
1522      <xsl:if test="/rfc/@number">
1523        <xsl:variable name="number">
1524          <xsl:choose>
1525            <xsl:when test="string-length(/rfc/@number) &lt; 2">000<xsl:value-of select="/rfc/@number"/></xsl:when>
1526            <xsl:when test="string-length(/rfc/@number) &lt; 3">00<xsl:value-of select="/rfc/@number"/></xsl:when>
1527            <xsl:when test="string-length(/rfc/@number) &lt; 4">0<xsl:value-of select="/rfc/@number"/></xsl:when>
1528            <xsl:otherwise><xsl:value-of select="/rfc/@number"/></xsl:otherwise>
1529          </xsl:choose>
1530        </xsl:variable>
1531        <link rel="Alternate" title="Authorative ASCII Version" href="http://www.ietf.org/rfc/rfc{/rfc/@number}.txt" />
1532        <link rel="Help" title="Additional Information on tools.ietf.org" href="http://tools.ietf.org/html/rfc{$number}" />
1533      </xsl:if>
1534
1535      <!-- generator -->
1536      <xsl:variable name="gen">
1537        <xsl:call-template name="get-generator" />
1538      </xsl:variable>
1539      <meta name="generator" content="{$gen}" />
1540     
1541      <!-- keywords -->
1542      <xsl:if test="front/keyword">
1543        <xsl:variable name="keyw">
1544          <xsl:call-template name="get-keywords" />
1545        </xsl:variable>
1546        <meta name="keywords" content="{$keyw}" />
1547      </xsl:if>
1548
1549      <xsl:if test="$xml2rfc-ext-support-rfc2731!='no'">
1550        <!-- Dublin Core Metadata -->
1551        <link rel="schema.DC" href="http://purl.org/dc/elements/1.1/" />
1552             
1553        <!-- DC creator, see RFC2731 -->
1554        <xsl:for-each select="/rfc/front/author">
1555          <xsl:variable name="initials">
1556            <xsl:call-template name="format-initials"/>
1557          </xsl:variable>
1558          <meta name="DC.Creator" content="{concat(@surname,', ',$initials)}" />
1559        </xsl:for-each>
1560       
1561        <xsl:if test="not($xml2rfc-private)">
1562          <xsl:choose>
1563            <xsl:when test="/rfc/@number">
1564              <meta name="DC.Identifier" content="urn:ietf:rfc:{/rfc/@number}" />
1565            </xsl:when>
1566            <xsl:when test="/rfc/@docName">
1567              <meta name="DC.Identifier" content="urn:ietf:id:{/rfc/@docName}" />
1568            </xsl:when>
1569            <xsl:otherwise/>
1570          </xsl:choose>
1571          <meta name="DC.Date.Issued" scheme="ISO8601" content="{$xml2rfc-ext-pub-year}-{$xml2rfc-ext-pub-month-numeric}" />
1572 
1573          <xsl:if test="/rfc/@obsoletes!=''">
1574            <xsl:call-template name="rfclist-for-dcmeta">
1575              <xsl:with-param name="list" select="/rfc/@obsoletes"/>
1576            </xsl:call-template>
1577          </xsl:if>
1578        </xsl:if>
1579 
1580        <xsl:if test="/rfc/front/abstract">
1581          <meta name="DC.Description.Abstract" content="{normalize-space(/rfc/front/abstract)}" />
1582        </xsl:if>     
1583
1584        <xsl:if test="/rfc/@number">
1585          <meta name="DC.isPartOf" content="urn:ISSN:2070-1721" />
1586        </xsl:if>     
1587
1588      </xsl:if>     
1589    </head>
1590    <body>
1591      <!-- insert diagnostics -->
1592      <xsl:call-template name="insert-diagnostics"/>
1593
1594      <xsl:apply-templates select="front" />
1595      <xsl:apply-templates select="middle" />
1596      <xsl:apply-templates select="back" />
1597    </body>
1598  </html>
1599</xsl:template>               
1600
1601
1602<xsl:template match="t">
1603  <xsl:if test="preceding-sibling::section or preceding-sibling::appendix">
1604    <xsl:call-template name="warning">
1605      <xsl:with-param name="msg">The paragraph below is misplaced; maybe a section is closed in the wrong place: </xsl:with-param>
1606      <xsl:with-param name="msg2"><xsl:value-of select="."/></xsl:with-param>
1607    </xsl:call-template>
1608  </xsl:if>
1609  <xsl:choose>
1610    <xsl:when test="@anchor">
1611      <div id="{@anchor}"><xsl:apply-templates mode="t-content" select="node()[1]" /></div>
1612    </xsl:when>
1613    <xsl:otherwise>
1614      <xsl:apply-templates mode="t-content" select="node()[1]" />
1615    </xsl:otherwise>
1616  </xsl:choose>
1617</xsl:template>
1618
1619<!-- for t-content, dispatch to default templates if it's block-level content -->
1620<xsl:template mode="t-content" match="list|figure|texttable">
1621  <!-- <xsl:comment>t-content block-level</xsl:comment>  -->
1622  <xsl:apply-templates select="." />
1623  <xsl:apply-templates select="following-sibling::node()[1]" mode="t-content" />
1624</xsl:template>               
1625               
1626<!-- ... otherwise group into p elements -->
1627<xsl:template mode="t-content" match="*|node()">
1628  <xsl:variable name="p">
1629    <xsl:call-template name="get-paragraph-number" />
1630  </xsl:variable>
1631
1632  <!-- do not open a new p element if this is a whitespace-only text node and no siblings follow --> 
1633  <xsl:if test="not(self::text() and normalize-space(.)='' and not(following-sibling::node()))">
1634    <p>
1635      <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">
1636        <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$p"/></xsl:attribute>
1637      </xsl:if>
1638      <xsl:call-template name="insertInsDelClass"/>
1639      <xsl:call-template name="editingMark" />
1640      <xsl:apply-templates mode="t-content2" select="." />
1641    </p>
1642  </xsl:if>
1643  <xsl:apply-templates mode="t-content" select="following-sibling::*[self::list or self::figure or self::texttable][1]" />
1644</xsl:template>               
1645               
1646<xsl:template mode="t-content2" match="*">
1647  <xsl:apply-templates select="." />
1648  <xsl:if test="not(following-sibling::node()[1] [self::list or self::figure or self::texttable])">
1649    <xsl:apply-templates select="following-sibling::node()[1]" mode="t-content2" />
1650  </xsl:if>
1651</xsl:template>       
1652
1653<xsl:template mode="t-content2" match="text()">
1654  <xsl:apply-templates select="." />
1655  <xsl:if test="not(following-sibling::node()[1] [self::list or self::figure or self::texttable])">
1656    <xsl:apply-templates select="following-sibling::node()[1]" mode="t-content2" />
1657  </xsl:if>
1658</xsl:template>               
1659
1660<xsl:template mode="t-content2" match="comment()|processing-instruction()">
1661  <xsl:apply-templates select="." />
1662  <xsl:if test="not(following-sibling::node()[1] [self::list or self::figure or self::texttable])">
1663    <xsl:apply-templates select="following-sibling::node()[1]" mode="t-content2" />
1664  </xsl:if>
1665</xsl:template>               
1666
1667<xsl:template match="title">
1668  <xsl:if test="@abbrev and string-length(@abbrev) > 40">
1669    <xsl:call-template name="warning">
1670      <xsl:with-param name="inline" select="'no'"/>
1671      <xsl:with-param name="msg">title/@abbrev too long (max 40 characters)</xsl:with-param>
1672    </xsl:call-template>
1673  </xsl:if>
1674
1675  <xsl:if test="string-length(.) > 40 and (not(@abbrev) or @abbrev='')">
1676    <xsl:call-template name="warning">
1677      <xsl:with-param name="inline" select="'no'"/>
1678      <xsl:with-param name="msg">title too long, should supply title/@abbrev attribute with less than 40 characters</xsl:with-param>
1679    </xsl:call-template>
1680  </xsl:if>
1681
1682  <xsl:apply-templates />
1683</xsl:template>
1684
1685<xsl:template name="insertTitle">
1686  <xsl:choose>
1687    <xsl:when test="@ed:old-title">
1688      <del>
1689        <xsl:if test="ancestor-or-self::*[@ed:entered-by] and @ed:datetime">
1690          <xsl:attribute name="title"><xsl:value-of select="concat(@ed:datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
1691        </xsl:if>
1692        <xsl:value-of select="@ed:old-title"/>
1693      </del>
1694      <ins>
1695        <xsl:if test="ancestor-or-self::*[@ed:entered-by] and @ed:datetime">
1696          <xsl:attribute name="title"><xsl:value-of select="concat(@ed:datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
1697        </xsl:if>
1698        <xsl:value-of select="@title"/>
1699      </ins>
1700    </xsl:when>
1701    <xsl:otherwise>
1702      <xsl:value-of select="@title"/>
1703    </xsl:otherwise>
1704  </xsl:choose>
1705</xsl:template>
1706
1707<xsl:template match="section|appendix">
1708
1709  <xsl:if test="self::appendix">
1710    <xsl:call-template name="warning">
1711      <xsl:with-param name="inline" select="'no'"/>
1712      <xsl:with-param name="msg">The "appendix" element is deprecated, use "section" inside "back" instead.</xsl:with-param>
1713    </xsl:call-template>
1714  </xsl:if>
1715
1716  <xsl:variable name="sectionNumber">
1717    <xsl:choose>
1718      <xsl:when test="@myns:unnumbered"></xsl:when>
1719      <xsl:when test="ancestor::x:boilerplate"></xsl:when>
1720      <xsl:otherwise><xsl:call-template name="get-section-number" /></xsl:otherwise>
1721    </xsl:choose>
1722  </xsl:variable>
1723   
1724  <xsl:if test="not(ancestor::section) and not(ancestor::x:boilerplate) and not(@myns:notoclink)">
1725    <xsl:call-template name="insert-conditional-hrule"/>
1726  </xsl:if>
1727 
1728  <xsl:variable name="elemtype">
1729    <xsl:choose>
1730      <xsl:when test="count(ancestor::section) &lt;= 4">h<xsl:value-of select="1 + count(ancestor::section)"/></xsl:when>
1731      <xsl:otherwise>h6</xsl:otherwise>
1732    </xsl:choose>
1733  </xsl:variable>
1734 
1735  <!-- process irefs immediadetely following the section so that their anchor
1736  actually is the section heading -->
1737  <xsl:apply-templates select="iref[count(preceding-sibling::*[not(self::iref)])=0]"/>
1738
1739  <xsl:element name="{$elemtype}">
1740    <xsl:if test="$sectionNumber!=''">
1741      <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$sectionNumber"/></xsl:attribute>
1742    </xsl:if>
1743    <xsl:choose>
1744      <xsl:when test="$sectionNumber='1'">
1745        <!-- pagebreak, this the first section -->
1746        <xsl:attribute name="class">np</xsl:attribute>
1747      </xsl:when>
1748      <xsl:when test="not(ancestor::section) and not(@myns:notoclink)">
1749        <xsl:call-template name="insert-conditional-pagebreak"/>
1750      </xsl:when>
1751      <xsl:otherwise/>
1752    </xsl:choose>
1753   
1754    <xsl:call-template name="insertInsDelClass" />
1755       
1756    <xsl:if test="$sectionNumber!=''">
1757      <a href="#{$anchor-prefix}.section.{$sectionNumber}">
1758        <xsl:call-template name="emit-section-number">
1759          <xsl:with-param name="no" select="$sectionNumber"/>
1760        </xsl:call-template>
1761      </a>
1762      <xsl:text>&#0160;</xsl:text>
1763    </xsl:if>
1764   
1765    <!-- issue tracking? -->
1766    <xsl:if test="@ed:resolves">
1767      <xsl:call-template name="insert-issue-pointer"/>
1768    </xsl:if>
1769   
1770    <xsl:choose>
1771      <xsl:when test="@anchor">
1772        <xsl:call-template name="check-anchor"/>
1773        <a id="{@anchor}" href="#{@anchor}"><xsl:call-template name="insertTitle"/></a>
1774      </xsl:when>
1775      <xsl:otherwise>
1776        <xsl:call-template name="insertTitle"/>
1777      </xsl:otherwise>
1778    </xsl:choose>
1779  </xsl:element>
1780  <!-- continue with all child elements but the irefs processed above -->
1781  <xsl:apply-templates select="*[not(self::iref)]|iref[count(preceding-sibling::*[not(self::iref)])!=0]" />
1782</xsl:template>
1783
1784<xsl:template match="spanx[@style='emph' or not(@style)]">
1785  <em>
1786    <xsl:call-template name="copy-anchor"/>
1787    <xsl:apply-templates />
1788  </em>
1789</xsl:template>
1790
1791<xsl:template match="spanx[@style='verb']">
1792  <samp>
1793    <xsl:call-template name="copy-anchor"/>
1794    <xsl:apply-templates />
1795  </samp>
1796</xsl:template>
1797
1798<xsl:template match="spanx[@style='strong']">
1799  <strong>
1800    <xsl:call-template name="copy-anchor"/>
1801    <xsl:apply-templates />
1802  </strong>
1803</xsl:template>
1804
1805<xsl:template name="insert-blank-lines">
1806  <xsl:param name="no"/>
1807  <xsl:choose>
1808    <xsl:when test="$no &lt;= 0">
1809      <br/>
1810      <!-- done -->
1811    </xsl:when>
1812    <xsl:otherwise>
1813      <br/>
1814      <xsl:call-template name="insert-blank-lines">
1815        <xsl:with-param name="no" select="$no - 1"/>
1816      </xsl:call-template>
1817    </xsl:otherwise>
1818  </xsl:choose>
1819</xsl:template>
1820
1821<xsl:template match="vspace[not(@blankLines)]">
1822  <br />
1823</xsl:template>
1824
1825<xsl:template match="vspace">
1826  <xsl:call-template name="insert-blank-lines">
1827    <xsl:with-param name="no" select="@blankLines"/>
1828  </xsl:call-template>
1829</xsl:template>
1830
1831<!-- keep the root for the case when we process XSLT-inline markup -->
1832<xsl:variable name="src" select="/" />
1833
1834<xsl:template name="render-section-ref">
1835  <xsl:param name="from" />
1836  <xsl:param name="to" />
1837
1838  <xsl:variable name="refname">
1839    <xsl:for-each select="$to">
1840      <xsl:call-template name="get-section-type">
1841        <xsl:with-param name="prec" select="$from/preceding-sibling::node()[1]" />
1842      </xsl:call-template>
1843    </xsl:for-each>
1844  </xsl:variable>
1845  <xsl:variable name="refnum">
1846    <xsl:for-each select="$to">
1847      <xsl:call-template name="get-section-number" />
1848    </xsl:for-each>
1849  </xsl:variable>
1850  <xsl:attribute name="title">
1851    <xsl:value-of select="$to/@title" />
1852  </xsl:attribute>
1853  <xsl:choose>
1854    <xsl:when test="@format='counter'">
1855      <xsl:value-of select="$refnum"/>
1856    </xsl:when>
1857    <xsl:when test="@format='title'">
1858      <xsl:value-of select="$to/@title"/>
1859    </xsl:when>
1860    <xsl:otherwise>
1861      <xsl:value-of select="normalize-space(concat($refname,'&#160;',$refnum))"/>
1862    </xsl:otherwise>
1863  </xsl:choose>
1864</xsl:template>
1865
1866<xsl:template match="xref[node()]">
1867
1868  <xsl:variable name="target" select="@target" />
1869  <xsl:variable name="node" select="key('anchor-item',$target)" />
1870  <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>
1871
1872  <xsl:choose>
1873
1874    <!-- x:fmt='none': do not generate any links -->
1875    <xsl:when test="@x:fmt='none'">
1876      <xsl:choose>
1877        <xsl:when test="$node/self::reference">
1878          <cite title="{normalize-space($node/front/title)}">
1879            <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
1880              <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1881            </xsl:if>
1882            <!-- insert id when a backlink to this xref is needed in the index -->
1883            <xsl:if test="//iref[@x:for-anchor=$target] | //iref[@x:for-anchor='' and ../@anchor=$target]">
1884              <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1885            </xsl:if>
1886            <xsl:apply-templates/>
1887          </cite>
1888        </xsl:when>
1889        <xsl:otherwise>
1890          <xsl:apply-templates/>
1891        </xsl:otherwise>
1892      </xsl:choose>
1893    </xsl:when>
1894 
1895    <!-- Other x:fmt values than "none": unsupported -->
1896    <xsl:when test="@x:fmt and @x:fmt!='none'">
1897      <xsl:call-template name="error">
1898        <xsl:with-param name="msg" select="concat('unknown xref/@x:fmt extension: ',@x:fmt)"/>
1899      </xsl:call-template>
1900    </xsl:when>
1901
1902    <!-- Section links -->
1903    <xsl:when test="$node/self::section or $node/self::appendix">
1904      <xsl:apply-templates/>
1905      <xsl:text> (</xsl:text>
1906      <a href="#{@target}">
1907        <!-- insert id when a backlink to this xref is needed in the index -->
1908        <xsl:if test="//iref[@x:for-anchor=$target] | //iref[@x:for-anchor='' and ../@anchor=$target]">
1909          <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1910        </xsl:if>
1911        <xsl:call-template name="render-section-ref">
1912          <xsl:with-param name="from" select="."/>
1913          <xsl:with-param name="to" select="$node"/>
1914        </xsl:call-template>
1915      </a>
1916      <xsl:text>)</xsl:text>
1917    </xsl:when>
1918
1919    <xsl:otherwise>
1920      <a href="#{$target}"><xsl:apply-templates /></a>
1921      <xsl:if test="not(@format='none')">
1922        <xsl:for-each select="$src/rfc/back/references//reference[@anchor=$target]">
1923          <xsl:text> </xsl:text>
1924          <cite title="{normalize-space(front/title)}">
1925            <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
1926              <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1927            </xsl:if>
1928            <xsl:call-template name="referencename">
1929               <xsl:with-param name="node" select="." />
1930            </xsl:call-template>
1931          </cite>
1932        </xsl:for-each>
1933      </xsl:if>
1934    </xsl:otherwise>
1935  </xsl:choose>
1936
1937</xsl:template>
1938               
1939<xsl:key name="iref-xanch" match="iref[@x:for-anchor]" use="@x:for-anchor"/>           
1940               
1941<xsl:template match="xref[not(node())]">
1942
1943  <xsl:variable name="target" select="@target" />
1944  <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>
1945  <xsl:variable name="node" select="key('anchor-item',$target)" />
1946  <xsl:if test="count($node)=0 and not(ancestor::ed:del)">
1947    <xsl:call-template name="error">
1948      <xsl:with-param name="msg" select="concat('Undefined target: ',@target)"/>
1949    </xsl:call-template>
1950  </xsl:if>
1951
1952  <xsl:choose>
1953 
1954    <!-- Section links -->
1955    <xsl:when test="$node/self::section or $node/self::appendix">
1956      <a href="#{@target}">
1957        <!-- insert id when a backlink to this xref is needed in the index -->
1958        <xsl:if test="key('iref-xanch',$target) | key('iref-xanch','')[../@anchor=$target]">
1959          <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1960        </xsl:if>
1961        <xsl:call-template name="render-section-ref">
1962          <xsl:with-param name="from" select="."/>
1963          <xsl:with-param name="to" select="$node"/>
1964        </xsl:call-template>
1965      </a>
1966    </xsl:when>
1967
1968    <!-- Figure links -->
1969    <xsl:when test="$node/self::figure">
1970      <a href="#{$target}">
1971        <xsl:variable name="figcnt">
1972          <xsl:for-each select="$node">
1973            <xsl:number level="any" count="figure[(@title!='' or @anchor!='') and not(@suppress-title='true')]" />
1974          </xsl:for-each>
1975        </xsl:variable>
1976        <xsl:choose>
1977          <xsl:when test="@format='counter'">
1978            <xsl:value-of select="$figcnt" />
1979          </xsl:when>
1980          <xsl:when test="@format='title'">
1981            <xsl:value-of select="$node/@title" />
1982          </xsl:when>
1983          <xsl:otherwise>
1984            <xsl:value-of select="normalize-space(concat('Figure&#160;',$figcnt))"/>
1985          </xsl:otherwise>
1986        </xsl:choose>
1987      </a>
1988    </xsl:when>
1989   
1990    <!-- Table links -->
1991    <xsl:when test="$node/self::texttable">
1992      <a href="#{$target}">
1993        <xsl:variable name="tabcnt">
1994          <xsl:for-each select="$node">
1995            <xsl:number level="any" count="texttable[(@title!='' or @anchor!='') and not(@suppress-title='true')]" />
1996          </xsl:for-each>
1997        </xsl:variable>
1998        <xsl:choose>
1999          <xsl:when test="@format='counter'">
2000            <xsl:value-of select="$tabcnt" />
2001          </xsl:when>
2002          <xsl:when test="@format='title'">
2003            <xsl:value-of select="$node/@title" />
2004          </xsl:when>
2005          <xsl:otherwise>
2006            <xsl:value-of select="normalize-space(concat('Table&#160;',$tabcnt))"/>
2007          </xsl:otherwise>
2008        </xsl:choose>
2009      </a>
2010    </xsl:when>
2011   
2012    <!-- Paragraph links -->
2013    <xsl:when test="$node/self::t">
2014      <a href="#{$target}">
2015        <xsl:variable name="tcnt">
2016          <xsl:for-each select="$node">
2017            <xsl:call-template name="get-paragraph-number" />
2018          </xsl:for-each>
2019        </xsl:variable>
2020        <xsl:choose>
2021          <xsl:when test="@format='counter'">
2022            <xsl:value-of select="$tcnt" />
2023          </xsl:when>
2024          <xsl:when test="@format='title'">
2025            <xsl:value-of select="$node/@title" />
2026          </xsl:when>
2027          <xsl:otherwise>
2028            <xsl:value-of select="normalize-space(concat('Paragraph&#160;',substring-after($tcnt,'p.')))"/>
2029          </xsl:otherwise>
2030        </xsl:choose>
2031      </a>
2032    </xsl:when>
2033
2034    <!-- Comment links -->
2035    <xsl:when test="$node/self::cref">
2036      <a href="#{$target}">
2037        <xsl:variable name="name">
2038          <xsl:for-each select="$node">
2039            <xsl:call-template name="get-comment-name" />
2040          </xsl:for-each>
2041        </xsl:variable>
2042        <xsl:choose>
2043          <xsl:when test="@format='counter'">
2044            <xsl:value-of select="$name" />
2045          </xsl:when>
2046          <xsl:when test="@format='title'">
2047            <xsl:value-of select="$node/@title" />
2048          </xsl:when>
2049          <xsl:otherwise>
2050            <xsl:value-of select="normalize-space(concat('Comment&#160;',$name))"/>
2051          </xsl:otherwise>
2052        </xsl:choose>
2053      </a>
2054    </xsl:when>
2055
2056    <!-- Reference links -->
2057    <xsl:when test="$node/self::reference">
2058
2059      <xsl:variable name="href">
2060        <xsl:call-template name="computed-target">
2061          <xsl:with-param name="bib" select="$node"/>
2062          <xsl:with-param name="ref" select="."/>
2063        </xsl:call-template>
2064      </xsl:variable>
2065     
2066      <xsl:variable name="sec">
2067        <xsl:choose>
2068          <xsl:when test="starts-with(@x:rel,'#') and not(@x:sec) and $node/x:source/@href">
2069            <xsl:variable name="extdoc" select="document($node/x:source/@href)"/>
2070            <xsl:variable name="nodes" select="$extdoc//*[@anchor=substring-after(current()/@x:rel,'#')]"/>
2071            <xsl:if test="not($nodes)">
2072              <xsl:call-template name="error">
2073                <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>
2074              </xsl:call-template>
2075            </xsl:if>
2076            <xsl:for-each select="$nodes">
2077              <xsl:call-template name="get-section-number"/>
2078            </xsl:for-each>
2079          </xsl:when>
2080          <xsl:otherwise>
2081            <xsl:value-of select="@x:sec"/>
2082          </xsl:otherwise>
2083        </xsl:choose>
2084      </xsl:variable>
2085     
2086      <xsl:variable name="secterm">
2087        <xsl:choose>
2088          <!-- starts with letter? -->
2089          <xsl:when test="translate(substring($sec,1,1),$ucase,'')=''">Appendix</xsl:when>
2090          <xsl:otherwise>Section</xsl:otherwise>
2091        </xsl:choose>
2092      </xsl:variable>
2093
2094      <xsl:variable name="fmt">
2095        <xsl:choose>
2096          <xsl:when test="@x:fmt!=''"><xsl:value-of select="@x:fmt"/></xsl:when>
2097          <xsl:when test="ancestor::artwork">,</xsl:when>
2098          <xsl:otherwise>of</xsl:otherwise>
2099        </xsl:choose>
2100      </xsl:variable>
2101
2102      <xsl:variable name="title">
2103        <xsl:choose>
2104          <xsl:when test="starts-with(@x:rel,'#') and not(@x:sec) and $node/x:source/@href">
2105            <xsl:variable name="extdoc" select="document($node/x:source/@href)"/>
2106            <xsl:variable name="nodes" select="$extdoc//*[@anchor=substring-after(current()/@x:rel,'#')]"/>
2107            <xsl:if test="not($nodes)">
2108              <xsl:call-template name="error">
2109                <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>
2110              </xsl:call-template>
2111            </xsl:if>
2112            <xsl:for-each select="$nodes">
2113              <xsl:value-of select="@title"/>
2114            </xsl:for-each>
2115          </xsl:when>
2116          <xsl:otherwise />
2117        </xsl:choose>
2118      </xsl:variable>
2119
2120      <!--
2121      Formats:
2122     
2123        ()      [XXXX] (Section SS)
2124        ,       [XXXX], Section SS
2125        of      Section SS of [XXXX]
2126        sec     Section SS
2127        number  SS
2128      -->
2129     
2130      <xsl:if test="$fmt and not($fmt='()' or $fmt=',' or $fmt='of' or $fmt='sec' or $fmt='anchor' or $fmt='number')">
2131        <xsl:call-template name="error">
2132          <xsl:with-param name="msg" select="concat('unknown xref/@x:fmt extension: ',$fmt)"/>
2133        </xsl:call-template>
2134      </xsl:if>
2135
2136      <xsl:if test="$sec!=''">
2137             
2138        <xsl:choose>
2139          <xsl:when test="$fmt='of' or $fmt='sec'">
2140            <xsl:choose>
2141              <xsl:when test="$href!=''">
2142                <a href="{$href}">
2143                  <xsl:if test="$title!=''">
2144                    <xsl:attribute name="title"><xsl:value-of select="$title"/></xsl:attribute>
2145                  </xsl:if>
2146                  <xsl:if test="$fmt='sec' and $xml2rfc-ext-include-references-in-index='yes'">
2147                    <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
2148                  </xsl:if>
2149                  <xsl:value-of select="$secterm"/>
2150                  <xsl:text> </xsl:text>
2151                  <xsl:value-of select="$sec"/>
2152                </a>
2153              </xsl:when>
2154              <xsl:otherwise><xsl:value-of select="$secterm"/><xsl:text> </xsl:text><xsl:value-of select="$sec"/></xsl:otherwise>
2155            </xsl:choose>
2156            <xsl:if test="$fmt='of'">
2157              <xsl:text> of </xsl:text>
2158            </xsl:if>
2159          </xsl:when>
2160          <xsl:when test="$fmt='number'">
2161            <xsl:choose>
2162              <xsl:when test="$href!=''">
2163                <a href="{$href}">
2164                  <xsl:if test="$title!=''">
2165                    <xsl:attribute name="title"><xsl:value-of select="$title"/></xsl:attribute>
2166                  </xsl:if>
2167                  <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
2168                    <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
2169                  </xsl:if>
2170                  <xsl:value-of select="$sec"/>
2171                </a>
2172              </xsl:when>
2173              <xsl:otherwise><xsl:value-of select="$sec"/></xsl:otherwise>
2174            </xsl:choose>
2175          </xsl:when>
2176          <xsl:otherwise />
2177        </xsl:choose>
2178      </xsl:if>
2179
2180      <xsl:if test="$sec='' or ($fmt!='sec' and $fmt!='number')">
2181        <a href="#{$target}">
2182          <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
2183            <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
2184          </xsl:if>
2185          <cite title="{normalize-space($node/front/title)}">
2186            <xsl:variable name="val">
2187              <xsl:call-template name="referencename">
2188                <xsl:with-param name="node" select="$node" />
2189              </xsl:call-template>
2190            </xsl:variable>
2191            <xsl:choose>
2192              <xsl:when test="$fmt='anchor'">
2193                <!-- remove brackets -->
2194                <xsl:value-of select="substring($val,2,string-length($val)-2)"/>
2195              </xsl:when>
2196              <xsl:otherwise>
2197                <xsl:value-of select="$val"/>
2198              </xsl:otherwise>
2199            </xsl:choose>
2200          </cite>
2201        </a>
2202      </xsl:if>
2203     
2204      <xsl:if test="$sec!=''">
2205        <xsl:choose>
2206          <xsl:when test="$fmt='()'">
2207            <xsl:text> (</xsl:text>
2208            <xsl:choose>
2209              <xsl:when test="$href!=''">
2210                <a href="{$href}"><xsl:value-of select="$secterm"/><xsl:text> </xsl:text><xsl:value-of select="$sec"/></a>
2211              </xsl:when>
2212              <xsl:otherwise><xsl:value-of select="$secterm"/><xsl:text> </xsl:text><xsl:value-of select="$sec"/></xsl:otherwise>
2213            </xsl:choose>
2214            <xsl:text>)</xsl:text>
2215          </xsl:when>
2216          <xsl:when test="$fmt=','">
2217            <xsl:text>, </xsl:text>
2218            <xsl:choose>
2219              <xsl:when test="$href!=''">
2220                <a href="{$href}">
2221                  <xsl:if test="$title!=''">
2222                    <xsl:attribute name="title"><xsl:value-of select="$title"/></xsl:attribute>
2223                  </xsl:if>
2224                  <xsl:value-of select="$secterm"/>
2225                  <xsl:text> </xsl:text>
2226                  <xsl:value-of select="$sec"/>
2227                </a>
2228              </xsl:when>
2229              <xsl:otherwise><xsl:value-of select="$secterm"/><xsl:text> </xsl:text><xsl:value-of select="$sec"/></xsl:otherwise>
2230            </xsl:choose>
2231          </xsl:when>
2232          <xsl:otherwise/>
2233        </xsl:choose>
2234      </xsl:if>
2235    </xsl:when>
2236   
2237    <xsl:otherwise>
2238      <xsl:call-template name="error">
2239        <xsl:with-param name="msg" select="concat('xref to unknown element: ',name($node))"/>
2240      </xsl:call-template>
2241    </xsl:otherwise>
2242  </xsl:choose>
2243</xsl:template>
2244
2245
2246<!-- mark unmatched elements red -->
2247
2248<xsl:template match="*">
2249  <xsl:message>ERROR: no XSLT template for element: &lt;<xsl:value-of select="name()"/>&gt;</xsl:message>   
2250  <tt class="error">&lt;<xsl:value-of select="name()" />&gt;</tt>
2251  <xsl:copy><xsl:apply-templates select="node()|@*" /></xsl:copy>
2252  <tt class="error">&lt;/<xsl:value-of select="name()" />&gt;</tt>
2253</xsl:template>
2254
2255<xsl:template match="/">
2256  <xsl:apply-templates select="*" />
2257</xsl:template>
2258
2259<!-- utility templates -->
2260
2261<xsl:template name="collectLeftHeaderColumn">
2262  <xsl:param name="mode" />
2263  <!-- default case -->
2264  <xsl:if test="not($xml2rfc-private)">
2265    <xsl:choose>
2266      <xsl:when test="/rfc/front/workgroup">
2267        <xsl:for-each select="/rfc/front/workgroup">
2268          <myns:item><xsl:value-of select="."/></myns:item>
2269        </xsl:for-each>
2270      </xsl:when>
2271      <xsl:otherwise>
2272        <myns:item>Network Working Group</myns:item>
2273      </xsl:otherwise>
2274    </xsl:choose>
2275    <myns:item>
2276       <xsl:choose>
2277        <xsl:when test="/rfc/@ipr and not(/rfc/@number)">Internet Draft</xsl:when>
2278        <xsl:otherwise>Request for Comments: <xsl:value-of select="/rfc/@number"/></xsl:otherwise>
2279      </xsl:choose>
2280    </myns:item>
2281    <xsl:if test="/rfc/@docName and $mode!='nroff'">
2282      <myns:item>
2283        &lt;<xsl:value-of select="/rfc/@docName" />&gt;
2284      </myns:item>
2285    </xsl:if>
2286    <xsl:if test="/rfc/@obsoletes and /rfc/@obsoletes!=''">
2287      <myns:item>
2288        <xsl:text>Obsoletes: </xsl:text>
2289        <xsl:call-template name="rfclist">
2290          <xsl:with-param name="list" select="normalize-space(/rfc/@obsoletes)" />
2291        </xsl:call-template>
2292        <xsl:if test="not(/rfc/@number)"> (if approved)</xsl:if>
2293      </myns:item>
2294    </xsl:if>
2295    <xsl:if test="/rfc/@seriesNo">
2296       <myns:item>
2297        <xsl:choose>
2298          <xsl:when test="/rfc/@category='bcp'">BCP: <xsl:value-of select="/rfc/@seriesNo" /></xsl:when>
2299          <xsl:when test="/rfc/@category='info'">FYI: <xsl:value-of select="/rfc/@seriesNo" /></xsl:when>
2300          <xsl:when test="/rfc/@category='std'">STD: <xsl:value-of select="/rfc/@seriesNo" /></xsl:when>
2301          <xsl:otherwise><xsl:value-of select="concat(/rfc/@category,': ',/rfc/@seriesNo)" /></xsl:otherwise>
2302        </xsl:choose>
2303      </myns:item>
2304    </xsl:if>
2305    <xsl:if test="/rfc/@updates and /rfc/@updates!=''">
2306      <myns:item>
2307        <xsl:text>Updates: </xsl:text>
2308          <xsl:call-template name="rfclist">
2309             <xsl:with-param name="list" select="normalize-space(/rfc/@updates)" />
2310          </xsl:call-template>
2311          <xsl:if test="not(/rfc/@number)"> (if approved)</xsl:if>
2312      </myns:item>
2313    </xsl:if>
2314    <xsl:if test="$mode!='nroff'">
2315      <myns:item>
2316        <xsl:choose>
2317          <xsl:when test="/rfc/@number">
2318            <xsl:text>Category: </xsl:text>
2319          </xsl:when>
2320          <xsl:otherwise>
2321            <xsl:text>Intended status: </xsl:text>
2322          </xsl:otherwise>
2323        </xsl:choose>
2324        <xsl:call-template name="get-category-long" />
2325      </myns:item>
2326    </xsl:if>
2327    <xsl:if test="/rfc/@ipr and not(/rfc/@number)">
2328       <myns:item>Expires: <xsl:call-template name="expirydate" /></myns:item>
2329    </xsl:if>
2330  </xsl:if>
2331   
2332  <!-- private case -->
2333  <xsl:if test="$xml2rfc-private">
2334    <myns:item><xsl:value-of select="$xml2rfc-private" /></myns:item>
2335  </xsl:if>
2336</xsl:template>
2337
2338<xsl:template name="collectRightHeaderColumn">
2339  <xsl:for-each select="author">
2340    <xsl:variable name="initials">
2341      <xsl:call-template name="format-initials"/>
2342    </xsl:variable>
2343    <xsl:if test="@surname">
2344      <myns:item>
2345        <xsl:value-of select="concat($initials,' ',@surname)" />
2346        <xsl:if test="@role">
2347          <xsl:choose>
2348            <xsl:when test="@role='editor'">
2349              <xsl:text>, Editor</xsl:text>
2350            </xsl:when>
2351            <xsl:otherwise>
2352              <xsl:text>, </xsl:text><xsl:value-of select="@role" />
2353            </xsl:otherwise>
2354          </xsl:choose>
2355        </xsl:if>
2356      </myns:item>
2357    </xsl:if>
2358    <xsl:variable name="org">
2359      <xsl:choose>
2360        <xsl:when test="organization/@abbrev"><xsl:value-of select="organization/@abbrev" /></xsl:when>
2361        <xsl:otherwise><xsl:value-of select="organization" /></xsl:otherwise>
2362      </xsl:choose>
2363    </xsl:variable>
2364    <xsl:variable name="orgOfFollowing">
2365      <xsl:choose>
2366        <xsl:when test="following-sibling::*[1]/organization/@abbrev"><xsl:value-of select="following-sibling::*[1]/organization/@abbrev" /></xsl:when>
2367        <xsl:otherwise><xsl:value-of select="following-sibling::*/organization" /></xsl:otherwise>
2368      </xsl:choose>
2369    </xsl:variable>
2370    <xsl:if test="$org != $orgOfFollowing and $org != ''">
2371      <myns:item><xsl:value-of select="$org" /></myns:item>
2372    </xsl:if>
2373  </xsl:for-each>
2374  <myns:item>
2375    <xsl:if test="$xml2rfc-ext-pub-month!=''">
2376      <xsl:value-of select="$xml2rfc-ext-pub-month" />
2377      <xsl:if test="$xml2rfc-ext-pub-day!='' and /rfc/@ipr and not(/rfc/@number)">
2378        <xsl:text> </xsl:text>
2379        <xsl:value-of select="$xml2rfc-ext-pub-day" />
2380        <xsl:text>,</xsl:text>
2381      </xsl:if>
2382    </xsl:if>
2383    <xsl:value-of select="concat(' ',$xml2rfc-ext-pub-year)" />
2384  </myns:item>
2385</xsl:template>
2386
2387
2388<xsl:template name="emitheader">
2389  <xsl:param name="lc" />
2390  <xsl:param name="rc" />
2391
2392  <xsl:for-each select="$lc/myns:item | $rc/myns:item">
2393    <xsl:variable name="pos" select="position()" />
2394    <xsl:if test="$pos &lt; count($lc/myns:item) + 1 or $pos &lt; count($rc/myns:item) + 1"> 
2395      <tr>
2396        <td class="header left"><xsl:call-template name="copynodes"><xsl:with-param name="nodes" select="$lc/myns:item[$pos]/node()" /></xsl:call-template></td>
2397        <td class="header right"><xsl:call-template name="copynodes"><xsl:with-param name="nodes" select="$rc/myns:item[$pos]/node()" /></xsl:call-template></td>
2398      </tr>
2399    </xsl:if>
2400  </xsl:for-each>
2401</xsl:template>
2402
2403<!-- convenience template that avoids copying namespace nodes we don't want -->
2404<xsl:template name="copynodes">
2405  <xsl:param name="nodes" />
2406  <xsl:for-each select="$nodes">
2407    <xsl:choose>
2408      <xsl:when test="namespace-uri()='http://www.w3.org/1999/xhtml'">
2409        <xsl:element name="{name()}" namespace="{namespace-uri()}">
2410          <xsl:copy-of select="@*|node()" />
2411        </xsl:element>
2412      </xsl:when>
2413      <xsl:when test="self::*">
2414        <xsl:element name="{name()}">
2415          <xsl:copy-of select="@*|node()" />
2416        </xsl:element>
2417      </xsl:when>
2418      <!-- workaround for opera, remove when Opera > 9.0.x comes out -->
2419      <xsl:when test="self::text()">
2420        <xsl:value-of select="."/>
2421      </xsl:when>
2422      <xsl:otherwise>
2423        <xsl:copy-of select="." />
2424      </xsl:otherwise>
2425    </xsl:choose>
2426  </xsl:for-each>
2427</xsl:template>
2428
2429
2430<xsl:template name="expirydate">
2431  <xsl:choose>
2432    <xsl:when test="$xml2rfc-ext-pub-month='January'">July <xsl:value-of select="$xml2rfc-ext-pub-year" /></xsl:when>
2433    <xsl:when test="$xml2rfc-ext-pub-month='February'">August <xsl:value-of select="$xml2rfc-ext-pub-year" /></xsl:when>
2434    <xsl:when test="$xml2rfc-ext-pub-month='March'">September <xsl:value-of select="$xml2rfc-ext-pub-year" /></xsl:when>
2435    <xsl:when test="$xml2rfc-ext-pub-month='April'">October <xsl:value-of select="$xml2rfc-ext-pub-year" /></xsl:when>
2436    <xsl:when test="$xml2rfc-ext-pub-month='May'">November <xsl:value-of select="$xml2rfc-ext-pub-year" /></xsl:when>
2437    <xsl:when test="$xml2rfc-ext-pub-month='June'">December <xsl:value-of select="$xml2rfc-ext-pub-year" /></xsl:when>
2438    <xsl:when test="$xml2rfc-ext-pub-month='July'">January <xsl:value-of select="$xml2rfc-ext-pub-year + 1" /></xsl:when>
2439    <xsl:when test="$xml2rfc-ext-pub-month='August'">February <xsl:value-of select="$xml2rfc-ext-pub-year + 1" /></xsl:when>
2440    <xsl:when test="$xml2rfc-ext-pub-month='September'">March <xsl:value-of select="$xml2rfc-ext-pub-year + 1" /></xsl:when>
2441    <xsl:when test="$xml2rfc-ext-pub-month='October'">April <xsl:value-of select="$xml2rfc-ext-pub-year + 1" /></xsl:when>
2442    <xsl:when test="$xml2rfc-ext-pub-month='November'">May <xsl:value-of select="$xml2rfc-ext-pub-year + 1" /></xsl:when>
2443    <xsl:when test="$xml2rfc-ext-pub-month='December'">June <xsl:value-of select="$xml2rfc-ext-pub-year + 1" /></xsl:when>
2444      <xsl:otherwise>WRONG SYNTAX FOR MONTH</xsl:otherwise>
2445   </xsl:choose>
2446</xsl:template>
2447
2448<xsl:template name="get-month-as-num">
2449  <xsl:param name="month" />
2450  <xsl:choose>
2451    <xsl:when test="$month='January'">01</xsl:when>
2452    <xsl:when test="$month='February'">02</xsl:when>
2453    <xsl:when test="$month='March'">03</xsl:when>
2454    <xsl:when test="$month='April'">04</xsl:when>
2455    <xsl:when test="$month='May'">05</xsl:when>
2456    <xsl:when test="$month='June'">06</xsl:when>
2457    <xsl:when test="$month='July'">07</xsl:when>
2458    <xsl:when test="$month='August'">08</xsl:when>
2459    <xsl:when test="$month='September'">09</xsl:when>
2460    <xsl:when test="$month='October'">10</xsl:when>
2461    <xsl:when test="$month='November'">11</xsl:when>
2462    <xsl:when test="$month='December'">12</xsl:when>
2463    <xsl:otherwise>WRONG SYNTAX FOR MONTH</xsl:otherwise>
2464  </xsl:choose>
2465</xsl:template>
2466
2467<xsl:template name="get-month-as-name">
2468  <xsl:param name="month"/>
2469  <xsl:choose>
2470    <xsl:when test="$month=1">January</xsl:when>
2471    <xsl:when test="$month=2">February</xsl:when>
2472    <xsl:when test="$month=3">March</xsl:when>
2473    <xsl:when test="$month=4">April</xsl:when>
2474    <xsl:when test="$month=5">May</xsl:when>
2475    <xsl:when test="$month=6">June</xsl:when>
2476    <xsl:when test="$month=7">July</xsl:when>
2477    <xsl:when test="$month=8">August</xsl:when>
2478    <xsl:when test="$month=9">September</xsl:when>
2479    <xsl:when test="$month=10">October</xsl:when>
2480    <xsl:when test="$month=11">November</xsl:when>
2481    <xsl:when test="$month=12">December</xsl:when>
2482    <xsl:otherwise>WRONG SYNTAX FOR MONTH</xsl:otherwise>
2483   </xsl:choose>
2484</xsl:template>
2485
2486<!-- produce back section with author information -->
2487<xsl:template name="get-authors-section-title">
2488  <xsl:choose>
2489    <xsl:when test="count(/rfc/front/author)=1">Author's Address</xsl:when>
2490    <xsl:otherwise>Authors' Addresses</xsl:otherwise>
2491  </xsl:choose>
2492</xsl:template>
2493
2494<xsl:template name="get-authors-section-number">
2495  <xsl:if test="/*/x:assign-section-number[@builtin-target='authors']">
2496    <xsl:value-of select="/*/x:assign-section-number[@builtin-target='authors']/@number"/>
2497  </xsl:if>
2498</xsl:template>
2499
2500<xsl:template name="insertAuthors">
2501
2502  <xsl:variable name="number">
2503    <xsl:call-template name="get-authors-section-number"/>
2504  </xsl:variable>
2505   
2506  <xsl:if test="$number!='suppress'">
2507    <xsl:call-template name="insert-conditional-hrule"/>
2508   
2509    <h1 id="{$anchor-prefix}.authors">
2510      <xsl:call-template name="insert-conditional-pagebreak"/>
2511      <xsl:if test="$number != ''">
2512        <a href="#{$anchor-prefix}.section.{$number}" id="{$anchor-prefix}.section.{$number}"><xsl:value-of select="$number"/>.</a>
2513        <xsl:text> </xsl:text>
2514      </xsl:if>
2515      <a href="#{$anchor-prefix}.authors"><xsl:call-template name="get-authors-section-title"/></a>
2516    </h1>
2517 
2518    <xsl:apply-templates select="/rfc/front/author" />
2519  </xsl:if>
2520</xsl:template>
2521
2522
2523
2524<!-- insert copyright statement -->
2525
2526<xsl:template name="insertCopyright" myns:namespaceless-elements="xml2rfc">
2527
2528  <xsl:if test="not($no-copylong)">
2529    <section title="Full Copyright Statement" anchor="{$anchor-prefix}.copyright" myns:unnumbered="unnumbered" myns:notoclink="notoclink">
2530      <xsl:choose>
2531        <xsl:when test="$ipr-rfc3667">
2532          <t>
2533            <xsl:choose>
2534              <xsl:when test="$ipr-2007-08"/>
2535              <xsl:when test="$ipr-rfc4748">
2536                Copyright &#169; The IETF Trust (<xsl:value-of select="$xml2rfc-ext-pub-year" />).
2537              </xsl:when>
2538              <xsl:otherwise>
2539                Copyright &#169; The Internet Society (<xsl:value-of select="$xml2rfc-ext-pub-year" />).
2540              </xsl:otherwise>
2541            </xsl:choose>
2542          </t>
2543          <t>
2544            This document is subject to the rights, licenses and restrictions
2545            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
2546            retain all their rights.
2547          </t>
2548          <t>
2549            This document and the information contained herein are provided
2550            on an &#8220;AS IS&#8221; basis and THE CONTRIBUTOR,
2551            THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY),
2552            THE INTERNET SOCIETY<xsl:if test="$ipr-rfc4748">, THE IETF TRUST</xsl:if>
2553            AND THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES,
2554            EXPRESS OR IMPLIED,
2555            INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
2556            INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
2557            WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
2558          </t>
2559        </xsl:when>
2560        <xsl:otherwise>
2561          <!-- <http://tools.ietf.org/html/rfc2026#section-10.4> -->
2562          <t>
2563            Copyright &#169; The Internet Society (<xsl:value-of select="$xml2rfc-ext-pub-year" />). All Rights Reserved.
2564          </t>
2565          <t>
2566            This document and translations of it may be copied and furnished to
2567            others, and derivative works that comment on or otherwise explain it
2568            or assist in its implementation may be prepared, copied, published and
2569            distributed, in whole or in part, without restriction of any kind,
2570            provided that the above copyright notice and this paragraph are
2571            included on all such copies and derivative works. However, this
2572            document itself may not be modified in any way, such as by removing
2573            the copyright notice or references to the Internet Society or other
2574            Internet organizations, except as needed for the purpose of
2575            developing Internet standards in which case the procedures for
2576            copyrights defined in the Internet Standards process must be
2577            followed, or as required to translate it into languages other than
2578            English.
2579          </t>
2580          <t>
2581            The limited permissions granted above are perpetual and will not be
2582            revoked by the Internet Society or its successors or assignees.
2583          </t>
2584          <t>
2585            This document and the information contained herein is provided on an
2586            &#8220;AS IS&#8221; basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
2587            TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
2588            BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
2589            HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
2590            MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
2591          </t>
2592        </xsl:otherwise>
2593      </xsl:choose>
2594    </section>
2595   
2596    <section title="Intellectual Property" anchor="{$anchor-prefix}.ipr" myns:unnumbered="unnumbered">
2597      <xsl:choose>
2598        <xsl:when test="$ipr-rfc3667">
2599          <t>
2600            The IETF takes no position regarding the validity or scope of any
2601            Intellectual Property Rights or other rights that might be claimed to
2602            pertain to the implementation or use of the technology described in
2603            this document or the extent to which any license under such rights
2604            might or might not be available; nor does it represent that it has
2605            made any independent effort to identify any such rights.  Information
2606            on the procedures with respect to rights in RFC documents
2607            can be found in BCP 78 and BCP 79.
2608          </t>       
2609          <t>
2610            Copies of IPR disclosures made to the IETF Secretariat and any
2611            assurances of licenses to be made available, or the result of an
2612            attempt made to obtain a general license or permission for the use
2613            of such proprietary rights by implementers or users of this
2614            specification can be obtained from the IETF on-line IPR repository
2615            at <eref target="http://www.ietf.org/ipr"/>.
2616          </t>       
2617          <t>
2618            The IETF invites any interested party to bring to its attention any
2619            copyrights, patents or patent applications, or other proprietary
2620            rights that may cover technology that may be required to implement
2621            this standard. Please address the information to the IETF at
2622            <eref target="mailto:ietf-ipr@ietf.org">ietf-ipr@ietf.org</eref>.
2623          </t>       
2624        </xsl:when>
2625        <xsl:otherwise>
2626          <t>
2627            The IETF takes no position regarding the validity or scope of
2628            any intellectual property or other rights that might be claimed
2629            to  pertain to the implementation or use of the technology
2630            described in this document or the extent to which any license
2631            under such rights might or might not be available; neither does
2632            it represent that it has made any effort to identify any such
2633            rights. Information on the IETF's procedures with respect to
2634            rights in standards-track and standards-related documentation
2635            can be found in BCP-11. Copies of claims of rights made
2636            available for publication and any assurances of licenses to
2637            be made available, or the result of an attempt made
2638            to obtain a general license or permission for the use of such
2639            proprietary rights by implementors or users of this
2640            specification can be obtained from the IETF Secretariat.
2641          </t>
2642          <t>
2643            The IETF invites any interested party to bring to its
2644            attention any copyrights, patents or patent applications, or
2645            other proprietary rights which may cover technology that may be
2646            required to practice this standard. Please address the
2647            information to the IETF Executive Director.
2648          </t>
2649          <xsl:if test="$xml2rfc-iprnotified='yes'">
2650            <t>
2651              The IETF has been notified of intellectual property rights
2652              claimed in regard to some or all of the specification contained
2653              in this document. For more information consult the online list
2654              of claimed rights.
2655            </t>
2656          </xsl:if>
2657        </xsl:otherwise>
2658      </xsl:choose>
2659    </section>
2660   
2661    <xsl:choose>
2662      <xsl:when test="$no-funding"/>
2663      <xsl:when test="$funding1 and /rfc/@number">
2664        <section myns:unnumbered="unnumbered" myns:notoclink="notoclink">
2665          <xsl:attribute name="title">
2666            <xsl:choose>
2667              <xsl:when test="$xml2rfc-rfcedstyle='yes'">Acknowledgement</xsl:when>
2668              <xsl:otherwise>Acknowledgment</xsl:otherwise>
2669            </xsl:choose>
2670          </xsl:attribute>
2671          <t>
2672            Funding for the RFC Editor function is provided by the IETF
2673            Administrative Support Activity (IASA).
2674          </t>
2675        </section>
2676      </xsl:when>
2677      <xsl:when test="$funding0 and /rfc/@number">
2678        <section myns:unnumbered="unnumbered" myns:notoclink="notoclink">
2679          <xsl:attribute name="title">
2680            <xsl:choose>
2681              <xsl:when test="$xml2rfc-rfcedstyle='yes'">Acknowledgement</xsl:when>
2682              <xsl:otherwise>Acknowledgment</xsl:otherwise>
2683            </xsl:choose>
2684          </xsl:attribute>
2685          <t>
2686            Funding for the RFC Editor function is currently provided by
2687            the Internet Society.
2688          </t>
2689        </section>
2690      </xsl:when>
2691      <xsl:otherwise/>
2692    </xsl:choose>
2693  </xsl:if>
2694
2695</xsl:template>
2696
2697
2698<!-- insert CSS style info -->
2699
2700<xsl:template name="insertCss">
2701a {
2702  text-decoration: none;
2703}
2704a.smpl {
2705  color: black;
2706}
2707a:hover {
2708  text-decoration: underline;
2709}
2710a:active {
2711  text-decoration: underline;
2712}
2713address {
2714  margin-top: 1em;
2715  margin-left: 2em;
2716  font-style: normal;
2717}<xsl:if test="//x:blockquote">
2718blockquote {
2719  border-style: solid;
2720  border-color: gray;
2721  border-width: 0 0 0 .25em;
2722  font-style: italic;
2723  padding-left: 0.5em;
2724}</xsl:if>
2725body {<xsl:if test="$xml2rfc-background!=''">
2726  background: url(<xsl:value-of select="$xml2rfc-background" />) #ffffff left top;</xsl:if>
2727  color: black;
2728  font-family: verdana, helvetica, arial, sans-serif;
2729  font-size: 10pt;
2730}<xsl:if test="//xhtml:p">
2731br.p {
2732  line-height: 150%;
2733}</xsl:if>
2734cite {
2735  font-style: normal;
2736}<xsl:if test="//x:note">
2737div.note {
2738  margin-left: 2em;
2739}</xsl:if>
2740dd {
2741  margin-right: 2em;<xsl:if test="$xml2rfc-ext-justification='always'">
2742  text-align: justify;</xsl:if>
2743}
2744dl {
2745  margin-left: 2em;
2746}
2747<!-- spacing between two entries in definition lists -->
2748dl.empty dd {
2749  margin-top: .5em;
2750}
2751dl p {
2752  margin-left: 0em;
2753}
2754dt {
2755  margin-top: .5em;
2756}
2757h1 {
2758  font-size: 14pt;
2759  line-height: 21pt;
2760  page-break-after: avoid;
2761}
2762h1.np {
2763  page-break-before: always;
2764}
2765h1 a {
2766  color: #333333;
2767}
2768h2 {
2769  font-size: 12pt;
2770  line-height: 15pt;
2771  page-break-after: avoid;
2772}
2773h3, h4, h5, h6 {
2774  font-size: 10pt;
2775  page-break-after: avoid;
2776}
2777h2 a, h3 a, h4 a, h5 a, h6 a {
2778  color: black;
2779}
2780img {
2781  margin-left: 3em;
2782}
2783li {
2784  margin-left: 2em;
2785  margin-right: 2em;<xsl:if test="$xml2rfc-ext-justification='always'">
2786  text-align: justify;</xsl:if>
2787}
2788ol {
2789  margin-left: 2em;
2790  margin-right: 2em;
2791}
2792ol p {
2793  margin-left: 0em;
2794}<xsl:if test="//xhtml:q">
2795q {
2796  font-style: italic;
2797}</xsl:if>
2798p {
2799  margin-left: 2em;
2800  margin-right: 2em;<xsl:if test="$xml2rfc-ext-justification='always'">
2801  text-align: justify;</xsl:if>
2802}
2803pre {
2804  margin-left: 3em;
2805  background-color: lightyellow;
2806  padding: .25em;
2807}
2808pre.text2 {
2809  border-style: dotted;
2810  border-width: 1px;
2811  background-color: #f0f0f0;
2812  width: 69em;
2813}
2814pre.inline {
2815  background-color: white;
2816  padding: 0em;
2817}
2818pre.text {
2819  border-style: dotted;
2820  border-width: 1px;
2821  background-color: #f8f8f8;
2822  width: 69em;
2823}
2824pre.drawing {
2825  border-style: solid;
2826  border-width: 1px;
2827  background-color: #f8f8f8;
2828  padding: 2em;
2829}<xsl:if test="//x:q">
2830q {
2831  font-style: italic;
2832}</xsl:if>
2833<xsl:if test="//x:sup">
2834sup {
2835  font-size: 60%;
2836}</xsl:if>
2837table {
2838  margin-left: 2em;
2839}<xsl:if test="//texttable">
2840table.tt {
2841  vertical-align: top;
2842}
2843table.full {
2844  border-style: outset;
2845  border-width: 1px;
2846}
2847table.headers {
2848  border-style: outset;
2849  border-width: 1px;
2850}
2851table.tt td {
2852  vertical-align: top;
2853}
2854table.full td {
2855  border-style: inset;
2856  border-width: 1px;
2857}
2858table.tt th {
2859  vertical-align: top;
2860}
2861table.full th {
2862  border-style: inset;
2863  border-width: 1px;
2864}
2865table.headers th {
2866  border-style: none none inset none;
2867  border-width: 1px;
2868}
2869caption {
2870  caption-side: bottom;
2871  font-weight: bold;
2872  font-size: 9pt;
2873  margin-top: .5em;
2874}
2875</xsl:if>
2876table.header {
2877  width: 95%;
2878  font-size: 10pt;
2879  color: white;
2880}
2881td.top {
2882  vertical-align: top;
2883}
2884td.topnowrap {
2885  vertical-align: top;
2886  white-space: nowrap;
2887}
2888td.header {
2889  background-color: gray;
2890  width: 50%;
2891}<xsl:if test="/rfc/@obsoletes | /rfc/@updates">
2892td.header a {
2893  color: white;
2894}</xsl:if>
2895td.reference {
2896  vertical-align: top;
2897  white-space: nowrap;
2898  padding-right: 1em;
2899}
2900thead {
2901  display:table-header-group;
2902}
2903ul.toc {
2904  list-style: none;
2905  margin-left: 1.5em;
2906  margin-right: 0em;
2907  padding-left: 0em;
2908}
2909li.tocline0 {
2910  line-height: 150%;
2911  font-weight: bold;
2912  font-size: 10pt;
2913  margin-left: 0em;
2914  margin-right: 0em;
2915}
2916li.tocline1 {
2917  line-height: normal;
2918  font-weight: normal;
2919  font-size: 9pt;
2920  margin-left: 0em;
2921  margin-right: 0em;
2922}
2923li.tocline2 {
2924  font-size: 0pt;
2925}
2926ul p {
2927  margin-left: 0em;
2928}
2929<xsl:if test="$has-index">ul.ind {
2930  list-style: none;
2931  margin-left: 1.5em;
2932  margin-right: 0em;
2933  padding-left: 0em;
2934  page-break-before: avoid;
2935}
2936li.indline0 {
2937  font-weight: bold;
2938  line-height: 200%;
2939  margin-left: 0em;
2940  margin-right: 0em;
2941}
2942li.indline1 {
2943  font-weight: normal;
2944  line-height: 150%;
2945  margin-left: 0em;
2946  margin-right: 0em;
2947}
2948</xsl:if><xsl:if test="//x:bcp14">.bcp14 {
2949  font-style: normal;
2950  text-transform: lowercase;
2951  font-variant: small-caps;
2952}</xsl:if><xsl:if test="//x:blockquote">
2953blockquote > * .bcp14 {
2954  font-style: italic;
2955}</xsl:if>
2956.comment {
2957  background-color: yellow;
2958}<xsl:if test="$xml2rfc-editing='yes'">
2959.editingmark {
2960  background-color: khaki;
2961}</xsl:if>
2962.center {
2963  text-align: center;
2964}
2965.error {
2966  color: red;
2967  font-style: italic;
2968  font-weight: bold;
2969}
2970.figure {
2971  font-weight: bold;
2972  text-align: center;
2973  font-size: 9pt;
2974}
2975.filename {
2976  color: #333333;
2977  font-weight: bold;
2978  font-size: 12pt;
2979  line-height: 21pt;
2980  text-align: center;
2981}
2982.fn {
2983  font-weight: bold;
2984}
2985.hidden {
2986  display: none;
2987}
2988.left {
2989  text-align: left;
2990}
2991.right {
2992  text-align: right;
2993}
2994.title {
2995  color: #990000;
2996  font-size: 18pt;
2997  line-height: 18pt;
2998  font-weight: bold;
2999  text-align: center;
3000  margin-top: 36pt;
3001}
3002.vcardline {
3003  display: block;
3004}
3005.warning {
3006  font-size: 14pt;
3007  background-color: yellow;
3008}
3009<xsl:if test="$has-edits">del {
3010  color: red;
3011  text-decoration: line-through;
3012}
3013.del {
3014  color: red;
3015  text-decoration: line-through;
3016}
3017ins {
3018  color: green;
3019  text-decoration: underline;
3020}
3021.ins {
3022  color: green;
3023  text-decoration: underline;
3024}
3025div.issuepointer {
3026  float: left;
3027}</xsl:if><xsl:if test="//ed:issue">
3028table.openissue {
3029  background-color: khaki;
3030  border-width: thin;
3031  border-style: solid;
3032  border-color: black;
3033}
3034table.closedissue {
3035  background-color: white;
3036  border-width: thin;
3037  border-style: solid;
3038  border-color: gray;
3039  color: gray;
3040}
3041thead th {
3042  text-align: left;
3043}
3044.bg-issue {
3045  border: solid;
3046  border-width: 1px;
3047  font-size: 7pt;
3048}
3049.closed-issue {
3050  border: solid;
3051  border-width: thin;
3052  background-color: lime;
3053  font-size: smaller;
3054  font-weight: bold;
3055}
3056.open-issue {
3057  border: solid;
3058  border-width: thin;
3059  background-color: red;
3060  font-size: smaller;
3061  font-weight: bold;
3062}
3063.editor-issue {
3064  border: solid;
3065  border-width: thin;
3066  background-color: yellow;
3067  font-size: smaller;
3068  font-weight: bold;
3069}</xsl:if>
3070
3071@media print {
3072  .noprint {
3073    display: none;
3074  }
3075 
3076  a {
3077    color: black;
3078    text-decoration: none;
3079  }
3080
3081  table.header {
3082    width: 90%;
3083  }
3084
3085  td.header {
3086    width: 50%;
3087    color: black;
3088    background-color: white;
3089    vertical-align: top;
3090    font-size: 12pt;
3091  }
3092
3093  ul.toc a::after {
3094    content: leader('.') target-counter(attr(href), page);
3095  }
3096 
3097  a.iref {
3098    content: target-counter(attr(href), page);
3099  }
3100 
3101  .print2col {
3102    column-count: 2;
3103    -moz-column-count: 2;<!-- for Firefox -->
3104    column-fill: auto;<!-- for PrinceXML -->
3105  }
3106<xsl:if test="$xml2rfc-ext-justification='print'">
3107  dd {
3108    text-align: justify;
3109  }
3110  li {
3111    text-align: justify;
3112  }
3113  p {
3114    text-align: justify;
3115  }
3116</xsl:if>}
3117
3118@page {
3119  @top-left {
3120       content: "<xsl:call-template name="get-header-left"/>";
3121  }
3122  @top-right {
3123       content: "<xsl:call-template name="get-header-right"/>";
3124  }
3125  @top-center {
3126       content: "<xsl:call-template name="get-header-center"/>";
3127  }
3128  @bottom-left {
3129       content: "<xsl:call-template name="get-author-summary"/>";
3130  }
3131  @bottom-center {
3132       content: "<xsl:call-template name="get-category-long"/>";
3133  }
3134  @bottom-right {
3135       content: "[Page " counter(page) "]";
3136  }
3137}
3138
3139@page:first {
3140    @top-left {
3141      content: normal;
3142    }
3143    @top-right {
3144      content: normal;
3145    }
3146    @top-center {
3147      content: normal;
3148    }
3149}
3150</xsl:template>
3151
3152
3153<!-- generate the index section -->
3154
3155<xsl:template name="insertSingleIref">
3156  <xsl:choose>
3157    <xsl:when test="@ed:xref">
3158      <!-- special index generator mode -->
3159      <xsl:text>[</xsl:text>
3160      <a href="#{@ed:xref}"><xsl:value-of select="@ed:xref"/></a>
3161      <xsl:text>, </xsl:text>
3162      <a>
3163        <xsl:variable name="htmluri" select="//reference[@anchor=current()/@ed:xref]/format[@type='HTML']/@target"/>
3164        <xsl:if test="$htmluri">
3165          <xsl:attribute name="href"><xsl:value-of select="concat($htmluri,'#',@ed:frag)"/></xsl:attribute>
3166        </xsl:if>       
3167        <xsl:choose>
3168          <xsl:when test="@primary='true'"><b><xsl:value-of select="@ed:label" /></b></xsl:when>
3169          <xsl:otherwise><xsl:value-of select="@ed:label" /></xsl:otherwise>
3170        </xsl:choose>
3171      </a>
3172      <xsl:text>]</xsl:text>
3173      <xsl:if test="position()!=last()">, </xsl:if>
3174    </xsl:when>
3175    <xsl:otherwise>
3176      <xsl:variable name="_n">
3177        <xsl:call-template name="get-section-number" />
3178      </xsl:variable>
3179      <xsl:variable name="n">
3180        <xsl:choose>
3181          <xsl:when test="$_n!=''">
3182            <xsl:value-of select="$_n"/>
3183          </xsl:when>
3184          <xsl:otherwise>&#167;</xsl:otherwise>
3185        </xsl:choose>
3186      </xsl:variable>
3187      <xsl:variable name="backlink">
3188        <xsl:choose>
3189          <xsl:when test="self::xref">
3190            <xsl:variable name="target" select="@target"/>
3191            <xsl:text>#</xsl:text>
3192            <xsl:value-of select="$anchor-prefix"/>
3193            <xsl:text>.xref.</xsl:text>
3194            <xsl:value-of select="@target"/>.<xsl:number level="any" count="xref[@target=$target]"/>
3195          </xsl:when>
3196          <xsl:when test="self::iref">
3197            <xsl:text>#</xsl:text>
3198            <xsl:call-template name="compute-iref-anchor"/>
3199          </xsl:when>
3200          <xsl:when test="self::x:ref">
3201            <xsl:text>#</xsl:text>
3202            <xsl:call-template name="compute-extref-anchor"/>
3203          </xsl:when>
3204          <xsl:otherwise>
3205            <xsl:message>Unsupported element type for insertSingleIref</xsl:message>
3206          </xsl:otherwise>
3207        </xsl:choose>
3208      </xsl:variable>
3209      <a class="iref" href="{$backlink}">
3210        <xsl:call-template name="insertInsDelClass"/>
3211        <xsl:choose>
3212          <xsl:when test="@primary='true'"><b><xsl:value-of select="$n"/></b></xsl:when>
3213          <xsl:otherwise><xsl:value-of select="$n"/></xsl:otherwise>
3214        </xsl:choose>
3215      </a>
3216      <xsl:if test="position()!=last()">, </xsl:if>
3217    </xsl:otherwise>
3218  </xsl:choose>
3219</xsl:template>
3220
3221<xsl:template name="insertSingleXref">
3222  <xsl:variable name="_n">
3223    <xsl:call-template name="get-section-number" />
3224  </xsl:variable>
3225  <xsl:variable name="n">
3226    <xsl:choose>
3227      <xsl:when test="$_n!=''">
3228        <xsl:value-of select="$_n"/>
3229      </xsl:when>
3230      <xsl:otherwise>&#167;</xsl:otherwise>
3231    </xsl:choose>
3232  </xsl:variable>
3233  <xsl:choose>
3234    <xsl:when test="self::reference">
3235      <a class="iref" href="#{@anchor}">
3236        <xsl:call-template name="insertInsDelClass"/>
3237        <b><xsl:value-of select="$n"/></b>
3238      </a>
3239    </xsl:when>
3240    <xsl:otherwise>
3241      <xsl:variable name="target" select="@target"/>
3242      <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>
3243      <a class="iref" href="{$backlink}">
3244        <xsl:call-template name="insertInsDelClass"/>
3245        <xsl:value-of select="$n"/>
3246      </a>
3247    </xsl:otherwise>
3248  </xsl:choose>
3249  <xsl:if test="position()!=last()">, </xsl:if>
3250</xsl:template>
3251
3252<xsl:template name="insertIndex">
3253
3254  <xsl:call-template name="insert-conditional-hrule"/>
3255
3256  <h1 id="{$anchor-prefix}.index">
3257    <xsl:call-template name="insert-conditional-pagebreak"/>
3258    <a href="#{$anchor-prefix}.index">Index</a>
3259  </h1>
3260 
3261  <!-- generate navigation links to index subsections -->
3262  <p class="noprint">
3263    <xsl:variable name="irefs" select="//iref[generate-id(.) = generate-id(key('index-first-letter',translate(substring(@item,1,1),$lcase,$ucase)))]"/>
3264    <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)))]"/>
3265 
3266    <xsl:for-each select="$irefs | $xrefs">
3267   
3268      <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)" />
3269         
3270      <xsl:variable name="letter" select="translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase)"/>
3271
3272      <!-- character? -->
3273      <xsl:if test="translate($letter,concat($lcase,$ucase,'0123456789'),'')=''">
3274     
3275        <xsl:variable name="showit">
3276          <xsl:choose>
3277            <xsl:when test="$xml2rfc-ext-include-references-in-index!='yes'">
3278              <xsl:if test="$irefs[starts-with(translate(@item,$lcase,$ucase),$letter)]">
3279                <xsl:text>yes</xsl:text>
3280              </xsl:if>
3281            </xsl:when>
3282            <xsl:otherwise>
3283              <xsl:text>yes</xsl:text>
3284            </xsl:otherwise>
3285          </xsl:choose>
3286        </xsl:variable>
3287       
3288        <xsl:if test="$showit='yes'">
3289          <a href="#{$anchor-prefix}.index.{$letter}">
3290            <xsl:value-of select="$letter" />
3291          </a>
3292          <xsl:text> </xsl:text>
3293        </xsl:if>
3294     
3295      </xsl:if>
3296
3297    </xsl:for-each>
3298  </p>
3299
3300  <!-- for each index subsection -->
3301  <div class="print2col">
3302  <ul class="ind">
3303    <xsl:variable name="irefs2" select="//iref[generate-id(.) = generate-id(key('index-first-letter',translate(substring(@item,1,1),$lcase,$ucase)))]"/>
3304    <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)))]"/>
3305 
3306    <xsl:for-each select="$irefs2 | $xrefs2">
3307      <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)" />
3308      <xsl:variable name="letter" select="translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase)"/>
3309           
3310      <xsl:variable name="showit">
3311        <xsl:choose>
3312          <xsl:when test="$xml2rfc-ext-include-references-in-index!='yes'">
3313            <xsl:if test="$irefs2[starts-with(translate(@item,$lcase,$ucase),$letter)]">
3314              <xsl:text>yes</xsl:text>
3315            </xsl:if>
3316          </xsl:when>
3317          <xsl:otherwise>
3318            <xsl:text>yes</xsl:text>
3319          </xsl:otherwise>
3320        </xsl:choose>
3321      </xsl:variable>
3322
3323      <xsl:if test="$showit='yes'">
3324        <li class="indline0">
3325         
3326          <!-- make letters and digits stand out -->
3327          <xsl:choose>
3328            <xsl:when test="translate($letter,concat($lcase,$ucase,'0123456789'),'')=''">
3329              <a id="{$anchor-prefix}.index.{$letter}" href="#{$anchor-prefix}.index.{$letter}">
3330                <b><xsl:value-of select="$letter" /></b>
3331              </a>
3332            </xsl:when>
3333            <xsl:otherwise>
3334              <b><xsl:value-of select="$letter" /></b>
3335            </xsl:otherwise>
3336          </xsl:choose>
3337       
3338          <ul class="ind"> 
3339            <xsl:for-each select="key('index-first-letter',translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase))">
3340       
3341              <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)" />
3342             
3343                <xsl:choose>
3344                  <xsl:when test="self::reference">
3345                    <xsl:if test="$xml2rfc-ext-include-references-in-index='yes' and not(starts-with(@anchor,'deleted-'))">
3346                      <li class="indline1">
3347                        <em>
3348                          <xsl:value-of select="@anchor"/>
3349                        </em>
3350                        <xsl:text>&#160;&#160;</xsl:text>
3351                       
3352                        <xsl:variable name="rs" select="key('xref-item',current()/@anchor) | . | key('anchor-item',concat('deleted-',current()/@anchor))"/>
3353                       
3354                        <xsl:for-each select="$rs">
3355                          <xsl:call-template name="insertSingleXref" />
3356                        </xsl:for-each>
3357
3358                        <xsl:variable name="rs2" select="$rs[@x:sec]"/>
3359
3360                        <xsl:if test="$rs2">
3361                          <ul class="ind"> 
3362                            <xsl:for-each select="$rs2">
3363                              <xsl:sort select="substring-before(concat(@x:sec,'.'),'.')" data-type="number"/>
3364                              <xsl:sort select="substring(@x:sec,2+string-length(substring-before(@x:sec,'.')))" data-type="number"/>
3365                              <xsl:if test="generate-id(.) = generate-id(key('index-xref-by-sec',concat(@target,'..',@x:sec)))">
3366                                <li class="indline1">
3367                                  <em>
3368                                    <xsl:choose>
3369                                      <xsl:when test="translate(substring(@x:sec,1,1),$ucase,'')=''">
3370                                        <xsl:text>Appendix </xsl:text>
3371                                      </xsl:when>
3372                                      <xsl:otherwise>
3373                                        <xsl:text>Section </xsl:text>
3374                                      </xsl:otherwise>
3375                                    </xsl:choose>
3376                                    <xsl:value-of select="@x:sec"/>
3377                                  </em>
3378                                  <xsl:text>&#160;&#160;</xsl:text>
3379                                  <xsl:for-each select="key('index-xref-by-sec',concat(@target,'..',@x:sec))">
3380                                    <xsl:call-template name="insertSingleXref" />
3381                                  </xsl:for-each>
3382                                </li>
3383                              </xsl:if>
3384                            </xsl:for-each>
3385                          </ul>
3386                        </xsl:if>
3387
3388                        <xsl:if test="current()/x:source/@href">
3389                          <xsl:variable name="rs3" select="$rs[not(@x:sec) and @x:rel]"/>
3390                          <xsl:variable name="doc" select="document(current()/x:source/@href)"/>
3391                          <xsl:if test="$rs3">
3392                            <ul class="ind"> 
3393                              <xsl:for-each select="$rs3">
3394                                <xsl:sort select="count($doc//*[@anchor and following::*/@anchor=substring-after(current()/@x:rel,'#')])" order="ascending" data-type="number"/>
3395                                <xsl:if test="generate-id(.) = generate-id(key('index-xref-by-anchor',concat(@target,'..',@x:rel)))">
3396                                  <li class="indline1">
3397                                    <em>
3398                                      <xsl:variable name="sec">
3399                                        <xsl:for-each select="$doc//*[@anchor=substring-after(current()/@x:rel,'#')]">
3400                                          <xsl:call-template name="get-section-number"/>
3401                                        </xsl:for-each>
3402                                      </xsl:variable>
3403                                      <xsl:choose>
3404                                        <xsl:when test="translate(substring($sec,1,1),$ucase,'')=''">
3405                                          <xsl:text>Appendix </xsl:text>
3406                                        </xsl:when>
3407                                        <xsl:otherwise>
3408                                          <xsl:text>Section </xsl:text>
3409                                        </xsl:otherwise>
3410                                      </xsl:choose>
3411                                      <xsl:value-of select="$sec"/>
3412                                    </em>
3413                                    <xsl:text>&#160;&#160;</xsl:text>
3414                                    <xsl:for-each select="key('index-xref-by-anchor',concat(@target,'..',@x:rel))">
3415                                      <xsl:call-template name="insertSingleXref" />
3416                                    </xsl:for-each>
3417                                  </li>
3418                                </xsl:if>
3419                              </xsl:for-each>
3420                            </ul>
3421                          </xsl:if>
3422                        </xsl:if>
3423                      </li>
3424                    </xsl:if>
3425                  </xsl:when>
3426                  <xsl:otherwise>
3427                    <!-- regular iref -->
3428                    <xsl:if test="generate-id(.) = generate-id(key('index-item',concat(@item,@anchor)))">
3429                      <xsl:variable name="item" select="@item"/>
3430                      <xsl:variable name="in-artwork" select="key('index-item',$item)[@primary='true' and ancestor::artwork]"/>
3431                         
3432                      <li class="indline1">
3433                        <xsl:choose>
3434                          <xsl:when test="$in-artwork">
3435                            <tt><xsl:value-of select="@item" /></tt>
3436                          </xsl:when>
3437                          <xsl:otherwise>
3438                            <xsl:value-of select="@item" />
3439                          </xsl:otherwise>
3440                        </xsl:choose>
3441                        <xsl:text>&#160;&#160;</xsl:text>
3442                       
3443                        <xsl:variable name="irefs3" select="key('index-item',@item)[not(@subitem) or @subitem='']"/>
3444                        <xsl:variable name="xrefs3" select="key('xref-item',$irefs3[@x:for-anchor='']/../@anchor) | key('xref-item',$irefs3/@x:for-anchor)"/>
3445                        <xsl:variable name="extrefs3" select="key('extref-item',$irefs3[@x:for-anchor='']/../@anchor) | key('extref-item',$irefs3/@x:for-anchor)"/>
3446
3447                        <xsl:for-each select="$irefs3|$xrefs3|$extrefs3">
3448                          <!-- <xsl:sort select="translate(@item,$lcase,$ucase)" />  -->
3449                          <xsl:call-template name="insertSingleIref" />
3450                        </xsl:for-each>
3451         
3452                        <xsl:variable name="s2" select="key('index-item',@item)[@subitem and @subitem!='']"/>
3453                        <xsl:if test="$s2">
3454                          <ul class="ind"> 
3455                            <xsl:for-each select="$s2">
3456                              <xsl:sort select="translate(@subitem,$lcase,$ucase)" />
3457                             
3458                              <xsl:if test="generate-id(.) = generate-id(key('index-item-subitem',concat(@item,'..',@subitem)))">
3459                 
3460                                <xsl:variable name="in-artwork2" select="key('index-item-subitem',concat(@item,'..',@subitem))[@primary='true' and ancestor::artwork]" />
3461                 
3462                                <li class="indline1">
3463             
3464                                  <xsl:choose>
3465                                    <xsl:when test="$in-artwork2">
3466                                      <tt><xsl:value-of select="@subitem" /></tt>
3467                                    </xsl:when>
3468                                    <xsl:otherwise>
3469                                      <xsl:value-of select="@subitem" />
3470                                    </xsl:otherwise>
3471                                  </xsl:choose>
3472                                  <xsl:text>&#160;&#160;</xsl:text>
3473                                   
3474                                  <xsl:variable name="irefs4" select="key('index-item-subitem',concat(@item,'..',@subitem))"/>
3475                                  <xsl:variable name="xrefs4" select="key('xref-item',$irefs4[@x:for-anchor='']/../@anchor) | key('xref-item',$irefs4/@x:for-anchor)"/>
3476                                  <xsl:variable name="extrefs4" select="key('extref-item',$irefs4[@x:for-anchor='']/../@anchor) | key('extref-item',$irefs4/@x:for-anchor)"/>
3477
3478                                  <xsl:for-each select="$irefs4|$xrefs4|$extrefs4">
3479                                    <!--<xsl:sort select="translate(@item,$lcase,$ucase)" />-->                   
3480                                    <xsl:call-template name="insertSingleIref" />
3481                                  </xsl:for-each>
3482               
3483                                </li>
3484                              </xsl:if>
3485                            </xsl:for-each>
3486                          </ul>
3487                        </xsl:if>
3488                      </li>
3489                    </xsl:if>
3490                  </xsl:otherwise>
3491                </xsl:choose>
3492             
3493                     
3494            </xsl:for-each>           
3495          </ul>
3496        </li>
3497      </xsl:if>
3498     
3499    </xsl:for-each>
3500  </ul>
3501  </div>
3502 
3503</xsl:template>
3504
3505
3506
3507
3508<xsl:template name="insertPreamble" myns:namespaceless-elements="xml2rfc">
3509
3510  <section myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.status">
3511  <xsl:attribute name="title">
3512    <xsl:choose>
3513      <xsl:when test="$xml2rfc-rfcedstyle='yes'">Status of This Memo</xsl:when>
3514      <xsl:otherwise>Status of this Memo</xsl:otherwise>
3515    </xsl:choose>
3516  </xsl:attribute>
3517
3518  <xsl:choose>
3519    <xsl:when test="/rfc/@ipr and not(/rfc/@number)">
3520      <t>
3521        <xsl:choose>
3522         
3523          <!-- RFC2026 -->
3524          <xsl:when test="/rfc/@ipr = 'full2026'">
3525            This document is an Internet-Draft and is
3526            in full conformance with all provisions of Section 10 of RFC2026.   
3527          </xsl:when>
3528          <xsl:when test="/rfc/@ipr = 'noDerivativeWorks2026'">
3529            This document is an Internet-Draft and is
3530            in full conformance with all provisions of Section 10 of RFC2026
3531            except that the right to produce derivative works is not granted.   
3532          </xsl:when>
3533          <xsl:when test="/rfc/@ipr = 'noDerivativeWorksNow'">
3534            This document is an Internet-Draft and is
3535            in full conformance with all provisions of Section 10 of RFC2026
3536            except that the right to produce derivative works is not granted.
3537            (If this document becomes part of an IETF working group activity,
3538            then it will be brought into full compliance with Section 10 of RFC2026.) 
3539          </xsl:when>
3540          <xsl:when test="/rfc/@ipr = 'none'">
3541            This document is an Internet-Draft and is
3542            NOT offered in accordance with Section 10 of RFC2026,
3543            and the author does not provide the IETF with any rights other
3544            than to publish as an Internet-Draft.
3545          </xsl:when>
3546         
3547          <!-- RFC3667 -->
3548          <xsl:when test="/rfc/@ipr = 'full3667'">
3549            This document is an Internet-Draft and is subject to all provisions
3550            of section 3 of RFC 3667.  By submitting this Internet-Draft, each
3551            author represents that any applicable patent or other IPR claims of
3552            which he or she is aware have been or will be disclosed, and any of
3553            which he or she become aware will be disclosed, in accordance with
3554            RFC 3668.
3555          </xsl:when>
3556          <xsl:when test="/rfc/@ipr = 'noModification3667'">
3557            This document is an Internet-Draft and is subject to all provisions
3558            of section 3 of RFC 3667.  By submitting this Internet-Draft, each
3559            author represents that any applicable patent or other IPR claims of
3560            which he or she is aware have been or will be disclosed, and any of
3561            which he or she become aware will be disclosed, in accordance with
3562            RFC 3668.  This document may not be modified, and derivative works of
3563            it may not be created, except to publish it as an RFC and to
3564            translate it into languages other than English<xsl:if test="/rfc/@iprExtract">,
3565            other than to extract <xref target="{/rfc/@iprExtract}"/> as-is
3566            for separate use.</xsl:if>.
3567          </xsl:when>
3568          <xsl:when test="/rfc/@ipr = 'noDerivatives3667'">
3569            This document is an Internet-Draft and is subject to all provisions
3570            of section 3 of RFC 3667 except for the right to produce derivative
3571            works.  By submitting this Internet-Draft, each author represents
3572            that any applicable patent or other IPR claims of which he or she
3573            is aware have been or will be disclosed, and any of which he or she
3574            become aware will be disclosed, in accordance with RFC 3668.  This
3575            document may not be modified, and derivative works of it may
3576            not be created<xsl:if test="/rfc/@iprExtract">, other than to extract
3577            <xref target="{/rfc/@iprExtract}"/> as-is for separate use.</xsl:if>.
3578          </xsl:when>
3579         
3580          <!-- RFC3978 -->
3581          <xsl:when test="/rfc/@ipr = 'full3978'">
3582            By submitting this Internet-Draft, each
3583            author represents that any applicable patent or other IPR claims of
3584            which he or she is aware have been or will be disclosed, and any of
3585            which he or she becomes aware will be disclosed, in accordance with
3586            Section 6 of BCP 79.
3587          </xsl:when>
3588          <xsl:when test="/rfc/@ipr = 'noModification3978'">
3589            By submitting this Internet-Draft, each
3590            author represents that any applicable patent or other IPR claims of
3591            which he or she is aware have been or will be disclosed, and any of
3592            which he or she becomes aware will be disclosed, in accordance with
3593            Section 6 of BCP 79.  This document may not be modified, and derivative works of
3594            it may not be created, except to publish it as an RFC and to
3595            translate it into languages other than English<xsl:if test="/rfc/@iprExtract">,
3596            other than to extract <xref target="{/rfc/@iprExtract}"/> as-is
3597            for separate use.</xsl:if>.
3598          </xsl:when>
3599          <xsl:when test="/rfc/@ipr = 'noDerivatives3978'">
3600            By submitting this Internet-Draft, each author represents
3601            that any applicable patent or other IPR claims of which he or she
3602            is aware have been or will be disclosed, and any of which he or she
3603            becomes aware will be disclosed, in accordance with Section 6 of BCP 79.  This
3604            document may not be modified, and derivative works of it may
3605            not be created<xsl:if test="/rfc/@iprExtract">, other than to extract
3606            <xref target="{/rfc/@iprExtract}"/> as-is for separate use.</xsl:if>.
3607          </xsl:when>
3608 
3609          <!-- as of Nov 2008 -->
3610          <xsl:when test="/rfc/@ipr = 'trust200811'
3611                          or /rfc/@ipr = 'noModificationTrust200811'
3612                          or  /rfc/@ipr = 'noDerivativesTrust200811'">
3613            This Internet-Draft is submitted to IETF pursuant to, and in full
3614            conformance with, the provisions of BCP 78 and BCP 79.
3615          </xsl:when>
3616 
3617          <!-- as of Feb 2009 -->
3618          <xsl:when test="/rfc/@ipr = 'trust200902'
3619                          or /rfc/@ipr = 'noModificationTrust200902'
3620                          or /rfc/@ipr = 'noDerivativesTrust200902'
3621                          or /rfc/@ipr = 'pre5378Trust200902'">
3622            This Internet-Draft is submitted to IETF pursuant to, and in full
3623            conformance with, the provisions of BCP 78 and BCP 79.
3624          </xsl:when>
3625          <xsl:when test="/rfc/@ipr = 'noModificationTrust200902'">
3626            This document may not be modified, and derivative works of it may
3627            not be created, except to format it for publication as an RFC or
3628            to translate it into languages other than English.
3629          </xsl:when>
3630          <xsl:when test="/rfc/@ipr = 'noDerivativesTrust200902'">
3631            This document may not be modified, and derivative works of it may
3632            not be created, and it may not be published except as an Internet-Draft.
3633          </xsl:when>
3634          <xsl:when test="/rfc/@ipr = 'pre5378Trust200902'">
3635            This document may contain material from IETF Documents or IETF Contributions published or
3636            made publicly available before November 10, 2008. The person(s) controlling the copyright in
3637            some of this material may not have granted the IETF Trust the right to allow modifications of such
3638            material outside the IETF Standards Process. Without obtaining an adequate license from the
3639            person(s) controlling the copyright in such materials, this document may not be modified outside
3640            the IETF Standards Process, and derivative works of it may not be created outside the IETF
3641            Standards Process, except to format it for publication as an RFC or to translate it into languages
3642            other than English.
3643          </xsl:when>
3644 
3645          <xsl:otherwise>
3646            CONFORMANCE UNDEFINED.
3647          </xsl:otherwise>
3648        </xsl:choose>
3649       
3650        <!-- restrictions -->
3651        <xsl:choose>
3652          <xsl:when test="/rfc/@ipr = 'noModificationTrust200811'">
3653            This document may not be modified, and derivative works of it may
3654            not be created, except to format it for publication as an RFC and
3655            to translate it into languages other than English.
3656          </xsl:when>
3657          <xsl:when test="/rfc/@ipr = 'noDerivativesTrust200811'">
3658            This document may not be modified, and derivative works of it may
3659            not be created, and it may not be published except as an Internet-Draft.
3660          </xsl:when>
3661
3662          <xsl:when test="/rfc/@ipr = 'noModificationTrust200902'">
3663            This document may not be modified, and derivative works of it may
3664            not be created, except to format it for publication as an RFC or
3665            to translate it into languages other than English.
3666          </xsl:when>
3667          <xsl:when test="/rfc/@ipr = 'noDerivativesTrust200902'">
3668            This document may not be modified, and derivative works of it may
3669            not be created, and it may not be published except as an Internet-Draft.
3670          </xsl:when>
3671          <xsl:when test="/rfc/@ipr = 'pre5378Trust200902'">
3672            This document may contain material from IETF Documents or IETF Contributions published or
3673            made publicly available before November 10, 2008. The person(s) controlling the copyright in
3674            some of this material may not have granted the IETF Trust the right to allow modifications of such
3675            material outside the IETF Standards Process. Without obtaining an adequate license from the
3676            person(s) controlling the copyright in such materials, this document may not be modified outside
3677            the IETF Standards Process, and derivative works of it may not be created outside the IETF
3678            Standards Process, except to format it for publication as an RFC or to translate it into languages
3679            other than English.
3680          </xsl:when>
3681
3682          <xsl:otherwise />
3683        </xsl:choose>
3684      </t>
3685      <t>
3686        Internet-Drafts are working documents of the Internet Engineering
3687        Task Force (IETF), its areas, and its working groups.
3688        Note that other groups may also distribute working documents as
3689        Internet-Drafts.
3690      </t>
3691      <t>
3692        Internet-Drafts are draft documents valid for a maximum of six months
3693        and may be updated, replaced, or obsoleted by other documents at any time.
3694        It is inappropriate to use Internet-Drafts as reference material or to cite
3695        them other than as &#8220;work in progress&#8221;.
3696      </t>
3697      <t>
3698        The list of current Internet-Drafts can be accessed at
3699        <eref target='http://www.ietf.org/ietf/1id-abstracts.txt'/>.
3700      </t>
3701      <t>
3702        The list of Internet-Draft Shadow Directories can be accessed at
3703        <eref target='http://www.ietf.org/shadow.html'/>.
3704      </t>
3705      <t>
3706        This Internet-Draft will expire in <xsl:call-template name="expirydate" />.
3707      </t>
3708    </xsl:when>
3709
3710    <xsl:when test="/rfc/@category='bcp'">
3711      <t>
3712        This document specifies an Internet Best Current Practices for the Internet
3713        Community, and requests discussion and suggestions for improvements.
3714        Distribution of this memo is unlimited.
3715      </t>
3716    </xsl:when>
3717    <xsl:when test="/rfc/@category='exp'">
3718      <t>
3719        This memo defines an Experimental Protocol for the Internet community.
3720        It does not specify an Internet standard of any kind.
3721        Discussion and suggestions for improvement are requested.
3722        Distribution of this memo is unlimited.
3723      </t>
3724    </xsl:when>
3725    <xsl:when test="/rfc/@category='historic'">
3726      <t>
3727        This memo describes a historic protocol for the Internet community.
3728        It does not specify an Internet standard of any kind.
3729        Distribution of this memo is unlimited.
3730      </t>
3731    </xsl:when>
3732    <xsl:when test="/rfc/@category='info' or not(/rfc/@category)">
3733      <t>
3734        This memo provides information for the Internet community.
3735        It does not specify an Internet standard of any kind.
3736        Distribution of this memo is unlimited.
3737      </t>
3738    </xsl:when>
3739    <xsl:when test="/rfc/@category='std'">
3740      <t>
3741        This document specifies an Internet standards track protocol for the Internet
3742        community, and requests discussion and suggestions for improvements.
3743        Please refer to the current edition of the &#8220;Internet Official Protocol
3744        Standards&#8221; (STD 1) for the standardization state and status of this
3745        protocol. Distribution of this memo is unlimited.
3746      </t>
3747    </xsl:when>
3748    <xsl:otherwise>
3749      <t>UNSUPPORTED CATEGORY.</t>
3750    </xsl:otherwise>
3751  </xsl:choose>
3752  </section>
3753 
3754  <xsl:choose>
3755    <xsl:when test="$ipr-2008-11">
3756      <section title="Copyright Notice" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.copyrightnotice">
3757        <t>
3758          Copyright &#169; <xsl:value-of select="$xml2rfc-ext-pub-year" /> IETF Trust and the persons identified
3759          as the document authors.  All rights reserved.
3760        </t>
3761        <xsl:choose>
3762          <xsl:when test="$ipr-2009-02">
3763            <t>
3764              This document is subject to BCP 78 and the IETF Trust's Legal
3765              Provisions Relating to IETF Documents in effect on the date of
3766              publication of this document
3767              (<eref target="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</eref>).
3768              Please review these documents carefully, as they describe your rights and restrictions with
3769              respect to this document.
3770            </t>
3771          </xsl:when>
3772          <xsl:otherwise>
3773            <t>
3774              This document is subject to BCP 78 and the IETF Trust's Legal
3775              Provisions Relating to IETF Documents
3776              (<eref target="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</eref>) in effect on the date of
3777              publication of this document.  Please review these documents
3778              carefully, as they describe your rights and restrictions with respect
3779              to this document.
3780            </t>
3781          </xsl:otherwise>
3782        </xsl:choose>
3783       
3784        <!-- special case: RFC5378 escape applies to RFCs as well -->
3785        <!-- <xsl:if test="/rfc/@ipr = 'pre5378Trust200902'">
3786          <t>
3787            This document may contain material from IETF Documents or IETF Contributions published or
3788            made publicly available before November 10, 2008. The person(s) controlling the copyright in
3789            some of this material may not have granted the IETF Trust the right to allow modifications of such
3790            material outside the IETF Standards Process. Without obtaining an adequate license from the
3791            person(s) controlling the copyright in such materials, this document may not be modified outside
3792            the IETF Standards Process, and derivative works of it may not be created outside the IETF
3793            Standards Process, except to format it for publication as an RFC or to translate it into languages
3794            other than English.
3795          </t>
3796        </xsl:if> -->
3797       
3798      </section>
3799    </xsl:when>
3800    <xsl:when test="$ipr-2007-08">
3801      <!-- no copyright notice -->
3802    </xsl:when>
3803    <xsl:when test="$ipr-rfc4748">
3804      <section title="Copyright Notice" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.copyrightnotice">
3805        <t>
3806          Copyright &#169; The IETF Trust (<xsl:value-of select="$xml2rfc-ext-pub-year" />).  All Rights Reserved.
3807        </t>
3808      </section>
3809    </xsl:when>
3810    <xsl:otherwise>
3811      <section title="Copyright Notice" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.copyrightnotice">
3812        <t>
3813          Copyright &#169; The Internet Society (<xsl:value-of select="$xml2rfc-ext-pub-year" />).  All Rights Reserved.
3814        </t>
3815      </section>
3816    </xsl:otherwise>
3817  </xsl:choose>
3818 
3819</xsl:template>
3820
3821<!-- TOC generation -->
3822
3823<xsl:template match="/" mode="toc">
3824  <hr class="noprint"/>
3825
3826  <h1 class="np" id="{$anchor-prefix}.toc"> <!-- this pagebreak occurs always -->
3827    <a href="#{$anchor-prefix}.toc">Table of Contents</a>
3828  </h1>
3829
3830  <ul class="toc">
3831    <xsl:apply-templates mode="toc" />
3832  </ul>
3833</xsl:template>
3834
3835<xsl:template name="insert-toc-line">
3836  <xsl:param name="number" />
3837  <xsl:param name="target" />
3838  <xsl:param name="title" />
3839  <xsl:param name="tocparam" />
3840  <xsl:param name="oldtitle" />
3841  <xsl:param name="waschanged" />
3842
3843  <!-- handle tocdepth parameter -->
3844  <xsl:choose>
3845    <xsl:when test="($tocparam='' or $tocparam='default') and string-length(translate($number,'.ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890&#167;','.')) &gt;= $parsedTocDepth">
3846      <!-- dropped entry because excluded -->
3847      <xsl:attribute name="class">tocline2</xsl:attribute>
3848    </xsl:when>
3849    <xsl:when test="$tocparam='exclude'">
3850      <!-- dropped entry because excluded -->
3851      <xsl:attribute name="class">tocline2</xsl:attribute>
3852    </xsl:when>
3853    <xsl:otherwise>
3854      <xsl:choose>
3855        <xsl:when test="starts-with($number,'del-')">
3856          <del>
3857            <xsl:value-of select="$number" />
3858            <a href="#{$target}"><xsl:value-of select="$title"/></a>
3859          </del>
3860        </xsl:when>
3861        <xsl:otherwise>
3862          <xsl:choose>
3863            <xsl:when test="not(contains($number,'.'))">
3864              <xsl:attribute name="class">tocline0</xsl:attribute>
3865            </xsl:when>
3866            <xsl:otherwise>
3867              <xsl:attribute name="class">tocline1</xsl:attribute>
3868            </xsl:otherwise>
3869          </xsl:choose>
3870          <xsl:if test="$number != ''">
3871            <xsl:call-template name="emit-section-number">
3872              <xsl:with-param name="no" select="$number"/>
3873            </xsl:call-template>
3874            <xsl:text>&#160;&#160;&#160;</xsl:text>
3875          </xsl:if>
3876          <a href="#{$target}">
3877            <xsl:choose>
3878              <xsl:when test="$waschanged!=''">
3879                <ins><xsl:value-of select="$title"/></ins>
3880                <del><xsl:value-of select="$oldtitle"/></del>
3881              </xsl:when>
3882              <xsl:otherwise>
3883                <xsl:value-of select="$title"/>
3884              </xsl:otherwise>
3885            </xsl:choose>
3886          </a>
3887        </xsl:otherwise>
3888      </xsl:choose>
3889    </xsl:otherwise>
3890  </xsl:choose>
3891</xsl:template>
3892
3893<xsl:template match="back" mode="toc">
3894
3895  <!-- <xsl:apply-templates select="references" mode="toc" /> -->
3896
3897  <xsl:if test="//cref and $xml2rfc-comments='yes' and $xml2rfc-inline!='yes'">
3898    <li>
3899      <xsl:call-template name="insert-toc-line">
3900        <xsl:with-param name="target" select="concat($anchor-prefix,'.comments')"/>
3901        <xsl:with-param name="title" select="'Editorial Comments'"/>
3902      </xsl:call-template>
3903    </li>
3904  </xsl:if>
3905
3906  <xsl:if test="$xml2rfc-ext-authors-section!='end'">
3907    <xsl:apply-templates select="/rfc/front" mode="toc" />
3908  </xsl:if>
3909  <xsl:apply-templates select="*[not(self::references)]" mode="toc" />
3910
3911  <xsl:if test="$xml2rfc-ext-authors-section='end'">
3912    <xsl:apply-templates select="/rfc/front" mode="toc" />
3913  </xsl:if>
3914
3915  <!-- copyright statements -->
3916  <xsl:if test="not($xml2rfc-private) and not($no-copylong)">
3917    <li>
3918      <xsl:call-template name="insert-toc-line">
3919        <xsl:with-param name="target" select="concat($anchor-prefix,'.ipr')"/>
3920        <xsl:with-param name="title" select="'Intellectual Property and Copyright Statements'"/>
3921      </xsl:call-template>
3922    </li>
3923  </xsl:if>
3924 
3925  <!-- insert the index if index entries exist -->
3926  <xsl:if test="//iref">
3927    <li>
3928      <xsl:call-template name="insert-toc-line">
3929        <xsl:with-param name="target" select="concat($anchor-prefix,'.index')"/>
3930        <xsl:with-param name="title" select="'Index'"/>
3931      </xsl:call-template>
3932    </li>
3933  </xsl:if>
3934
3935</xsl:template>
3936
3937<xsl:template match="front" mode="toc">
3938 
3939  <xsl:variable name="authors-title">
3940    <xsl:call-template name="get-authors-section-title"/>
3941  </xsl:variable>
3942  <xsl:variable name="authors-number">
3943    <xsl:call-template name="get-authors-section-number"/>
3944  </xsl:variable>
3945
3946  <xsl:if test="$authors-number!='suppress'">
3947    <li>
3948      <xsl:call-template name="insert-toc-line">
3949        <xsl:with-param name="target" select="concat($anchor-prefix,'.authors')"/>
3950        <xsl:with-param name="title" select="$authors-title"/>
3951        <xsl:with-param name="number" select="$authors-number"/>
3952      </xsl:call-template>
3953    </li>
3954  </xsl:if>
3955
3956</xsl:template>
3957
3958<xsl:template name="references-toc">
3959
3960  <!-- distinguish two cases: (a) single references element (process
3961  as toplevel section; (b) multiple references sections (add one toplevel
3962  container with subsection) -->
3963
3964  <xsl:variable name="refsecs" select="/rfc/back/references|/rfc/back/ed:replace/ed:ins/references"/>
3965   
3966  <xsl:choose>
3967    <xsl:when test="count($refsecs) = 0">
3968      <!-- nop -->
3969    </xsl:when>
3970    <xsl:when test="count($refsecs) = 1">
3971      <xsl:for-each select="$refsecs">
3972        <xsl:variable name="title">
3973          <xsl:choose>
3974            <xsl:when test="@title!=''"><xsl:value-of select="@title" /></xsl:when>
3975            <xsl:otherwise>References</xsl:otherwise>
3976          </xsl:choose>
3977        </xsl:variable>
3978     
3979        <li>
3980          <xsl:call-template name="insert-toc-line">
3981            <xsl:with-param name="number">
3982              <xsl:call-template name="get-references-section-number"/>
3983            </xsl:with-param>
3984            <xsl:with-param name="target" select="concat($anchor-prefix,'.references')"/>
3985            <xsl:with-param name="title" select="$title"/>
3986          </xsl:call-template>
3987        </li>
3988      </xsl:for-each>
3989    </xsl:when>
3990    <xsl:otherwise>
3991      <li>
3992        <!-- insert pseudo container -->   
3993        <xsl:call-template name="insert-toc-line">
3994          <xsl:with-param name="number">
3995            <xsl:call-template name="get-references-section-number"/>
3996          </xsl:with-param>
3997          <xsl:with-param name="target" select="concat($anchor-prefix,'.references')"/>
3998          <xsl:with-param name="title" select="'References'"/>
3999        </xsl:call-template>
4000 
4001        <ul class="toc">
4002          <!-- ...with subsections... -->   
4003          <xsl:for-each select="$refsecs">
4004            <xsl:variable name="title">
4005              <xsl:choose>
4006                <xsl:when test="@title!=''"><xsl:value-of select="@title" /></xsl:when>
4007                <xsl:otherwise>References</xsl:otherwise>
4008              </xsl:choose>
4009            </xsl:variable>
4010         
4011            <xsl:variable name="sectionNumber">
4012              <xsl:call-template name="get-section-number" />
4013            </xsl:variable>
4014   
4015            <xsl:variable name="num">
4016              <xsl:number level="any"/>
4017            </xsl:variable>
4018   
4019            <li>
4020              <xsl:call-template name="insert-toc-line">
4021                <xsl:with-param name="number" select="$sectionNumber"/>
4022                <xsl:with-param name="target" select="concat($anchor-prefix,'.references','.',$num)"/>
4023                <xsl:with-param name="title" select="$title"/>
4024              </xsl:call-template>
4025            </li>
4026          </xsl:for-each>
4027        </ul>
4028      </li>
4029    </xsl:otherwise>
4030  </xsl:choose>
4031</xsl:template>
4032
4033<xsl:template match="section|appendix" mode="toc">
4034  <xsl:variable name="sectionNumber">
4035    <xsl:call-template name="get-section-number" />
4036  </xsl:variable>
4037
4038  <xsl:variable name="target">
4039    <xsl:choose>
4040      <xsl:when test="@anchor"><xsl:value-of select="@anchor" /></xsl:when>
4041       <xsl:otherwise><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$sectionNumber" /></xsl:otherwise>
4042    </xsl:choose>
4043  </xsl:variable>
4044
4045  <!-- obtain content, just to check whether we need to recurse at all -->
4046  <xsl:variable name="content">
4047    <li>
4048      <xsl:call-template name="insert-toc-line">
4049        <xsl:with-param name="number" select="$sectionNumber"/>
4050        <xsl:with-param name="target" select="$target"/>
4051        <xsl:with-param name="title" select="@title"/>
4052        <xsl:with-param name="tocparam" select="@toc"/>
4053        <xsl:with-param name="oldtitle" select="@ed:old-title"/>
4054        <xsl:with-param name="waschanged" select="@ed:resolves"/>
4055      </xsl:call-template>
4056   
4057      <ul class="toc">
4058        <xsl:apply-templates mode="toc" />
4059      </ul>
4060    </li>
4061  </xsl:variable>
4062 
4063  <xsl:if test="$content!=''">
4064    <li>
4065      <xsl:call-template name="insert-toc-line">
4066        <xsl:with-param name="number" select="$sectionNumber"/>
4067        <xsl:with-param name="target" select="$target"/>
4068        <xsl:with-param name="title" select="@title"/>
4069        <xsl:with-param name="tocparam" select="@toc"/>
4070        <xsl:with-param name="oldtitle" select="@ed:old-title"/>
4071        <xsl:with-param name="waschanged" select="@ed:resolves"/>
4072      </xsl:call-template>
4073   
4074      <!-- obtain nested content, just to check whether we need to recurse at all -->
4075      <xsl:variable name="nested-content">
4076        <ul class="toc">
4077          <xsl:apply-templates mode="toc" />
4078        </ul>
4079      </xsl:variable>
4080     
4081      <!-- only recurse if we need to (do not produce useless list container) -->     
4082      <xsl:if test="$nested-content!=''">
4083        <ul class="toc">
4084          <xsl:apply-templates mode="toc" />
4085        </ul>
4086      </xsl:if>
4087    </li>
4088  </xsl:if>
4089</xsl:template>
4090
4091<xsl:template match="middle" mode="toc">
4092  <xsl:apply-templates mode="toc" />
4093  <xsl:call-template name="references-toc" />
4094</xsl:template>
4095
4096<xsl:template match="rfc" mode="toc">
4097  <xsl:apply-templates select="middle|back" mode="toc" />
4098</xsl:template>
4099
4100<xsl:template match="ed:del|ed:ins|ed:replace" mode="toc">
4101  <xsl:apply-templates mode="toc" />
4102</xsl:template>
4103
4104<xsl:template match="*|text()" mode="toc" />
4105
4106
4107<xsl:template name="insertTocAppendix">
4108 
4109  <xsl:if test="//figure[@title!='' or @anchor!='']">
4110    <ul class="toc">
4111      <xsl:for-each select="//figure[@title!='' or @anchor!='']">
4112        <xsl:variable name="title">Figure <xsl:value-of select="position()"/><xsl:if test="@title">: <xsl:value-of select="@title"/></xsl:if>
4113        </xsl:variable>
4114        <li>
4115          <xsl:call-template name="insert-toc-line">
4116            <xsl:with-param name="target" select="concat($anchor-prefix,'.figure.',position())" />
4117            <xsl:with-param name="title" select="$title" />
4118          </xsl:call-template>
4119        </li>
4120      </xsl:for-each>
4121    </ul>
4122  </xsl:if>
4123 
4124  <!-- experimental -->
4125  <xsl:if test="//ed:issue">
4126    <xsl:call-template name="insertIssuesList" />
4127  </xsl:if>
4128
4129</xsl:template>
4130
4131<xsl:template name="referencename">
4132  <xsl:param name="node" />
4133 
4134  <xsl:for-each select="$node">
4135    <xsl:choose>
4136      <xsl:when test="$xml2rfc-symrefs!='no' and ancestor::ed:del">
4137        <xsl:variable name="unprefixed" select="substring-after(@anchor,'deleted-')"/>
4138        <xsl:choose>
4139          <xsl:when test="$unprefixed!=''">
4140            <xsl:value-of select="concat('[',$unprefixed,']')"/>
4141          </xsl:when>
4142          <xsl:otherwise>
4143            <xsl:if test="count(//reference[@anchor=current()/@anchor])!=1">
4144              <xsl:message>Deleted duplicate anchors should have the prefix "deleted-": <xsl:value-of select="@anchor"/></xsl:message>
4145            </xsl:if>
4146            <xsl:value-of select="concat('[',@anchor,']')"/>
4147          </xsl:otherwise>
4148        </xsl:choose>
4149      </xsl:when>
4150      <xsl:when test="$xml2rfc-symrefs!='no'">[<xsl:value-of select="@anchor" />]</xsl:when>
4151      <xsl:when test="ancestor::ed:del">
4152        <xsl:text>[del]</xsl:text>
4153      </xsl:when>
4154      <xsl:otherwise>[<xsl:number level="any" count="reference[not(ancestor::ed:del)]"/>]</xsl:otherwise>
4155    </xsl:choose>
4156  </xsl:for-each> 
4157</xsl:template>
4158
4159
4160
4161<xsl:template name="replace-substring">
4162
4163  <xsl:param name="string" />
4164  <xsl:param name="replace" />
4165  <xsl:param name="by" />
4166
4167  <xsl:choose>
4168    <xsl:when test="contains($string,$replace)">
4169      <xsl:value-of select="concat(substring-before($string, $replace),$by)" />
4170      <xsl:call-template name="replace-substring">
4171        <xsl:with-param name="string" select="substring-after($string,$replace)" />
4172        <xsl:with-param name="replace" select="$replace" />
4173        <xsl:with-param name="by" select="$by" />
4174      </xsl:call-template>
4175    </xsl:when>
4176    <xsl:otherwise><xsl:value-of select="$string" /></xsl:otherwise>
4177  </xsl:choose>
4178
4179</xsl:template>
4180
4181
4182<xsl:template name="rfclist">
4183  <xsl:param name="list" />
4184  <xsl:choose>
4185    <xsl:when test="contains($list,',')">
4186      <xsl:variable name="rfcNo" select="substring-before($list,',')" />
4187      <xsl:call-template name="check-front-matter-ref">
4188        <xsl:with-param name="name" select="$rfcNo"/>
4189      </xsl:call-template>
4190      <a href="{concat($rfcUrlPrefix,$rfcNo,$rfcUrlPostfix)}"><xsl:value-of select="$rfcNo" /></a>,
4191      <xsl:call-template name="rfclist">
4192        <xsl:with-param name="list" select="normalize-space(substring-after($list,','))" />
4193      </xsl:call-template>
4194    </xsl:when>
4195    <xsl:otherwise>
4196      <xsl:variable name="rfcNo" select="$list" />
4197      <xsl:call-template name="check-front-matter-ref">
4198        <xsl:with-param name="name" select="$rfcNo"/>
4199      </xsl:call-template>
4200      <a href="{concat($rfcUrlPrefix,$rfcNo,$rfcUrlPostfix)}"><xsl:value-of select="$rfcNo" /></a>
4201    </xsl:otherwise>
4202  </xsl:choose>
4203</xsl:template>
4204
4205<xsl:template name="check-front-matter-ref">
4206  <xsl:param name="name"/>
4207  <xsl:choose>
4208    <xsl:when test="starts-with($name,'draft-')">
4209      <xsl:if test="not(//references//reference/seriesInfo[@name='Internet-Draft' and @value=$name])">
4210        <xsl:call-template name="warning">
4211          <xsl:with-param name="inline" select="'no'"/>
4212          <xsl:with-param name="msg" select="concat('front matter mentions I-D ',$name,' for which there is no reference element')"/>
4213        </xsl:call-template>
4214      </xsl:if>
4215    </xsl:when>
4216    <xsl:otherwise>
4217      <xsl:if test="not(//references//reference/seriesInfo[@name='RFC' and @value=$name])">
4218        <xsl:call-template name="warning">
4219          <xsl:with-param name="inline" select="'no'"/>
4220          <xsl:with-param name="msg" select="concat('front matter mentions RFC ',$name,' for which there is no reference element')"/>
4221        </xsl:call-template>
4222      </xsl:if>
4223    </xsl:otherwise>
4224  </xsl:choose>
4225</xsl:template>
4226
4227<xsl:template name="check-anchor">
4228  <xsl:if test="@anchor and @anchor!=''">
4229    <!-- check validity of anchor name -->
4230    <xsl:variable name="test">
4231      <xsl:element name="{@anchor}"/>
4232    </xsl:variable>
4233    <xsl:if test="count(exslt:node-set($test)//*) = 0">
4234      <xsl:call-template name="error">
4235        <xsl:with-param name="msg" select="concat('&quot;',@anchor,'&quot; is not a valid XML name')"/>
4236      </xsl:call-template>
4237    </xsl:if>
4238  </xsl:if>
4239</xsl:template>
4240
4241<xsl:template name="copy-anchor">
4242  <xsl:call-template name="check-anchor"/>
4243  <xsl:if test="@anchor and @anchor!=''">
4244    <xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute>
4245  </xsl:if>
4246</xsl:template>
4247
4248<xsl:template name="rfclist-for-dcmeta">
4249  <xsl:param name="list" />
4250  <xsl:choose>
4251    <xsl:when test="contains($list,',')">
4252      <xsl:variable name="rfcNo" select="substring-before($list,',')" />
4253      <meta name="DC.Relation.Replaces" content="urn:ietf:rfc:{$rfcNo}" />
4254      <xsl:call-template name="rfclist-for-dcmeta">
4255        <xsl:with-param name="list" select="normalize-space(substring-after($list,','))" />
4256      </xsl:call-template>
4257    </xsl:when>
4258    <xsl:otherwise>
4259      <xsl:variable name="rfcNo" select="$list" />
4260      <meta name="DC.Relation.Replaces" content="urn:ietf:rfc:{$rfcNo}" />
4261    </xsl:otherwise>
4262  </xsl:choose>
4263</xsl:template>
4264
4265<xsl:template name="get-paragraph-number">
4266  <!-- get section number of ancestor section element, then add t or figure number -->
4267  <xsl:if test="ancestor::section and not(ancestor::section[@myns:unnumbered='unnumbered']) and not(ancestor::x:blockquote) and not(ancestor::x:note)">
4268    <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" />
4269  </xsl:if>
4270</xsl:template>
4271
4272<xsl:template name="editingMark">
4273  <xsl:if test="$xml2rfc-editing='yes' and ancestor::rfc">
4274    <sup class="editingmark"><span><xsl:number level="any" count="postamble|preamble|t"/></span>&#0160;</sup>
4275  </xsl:if>
4276</xsl:template>
4277
4278<!-- internal ref support -->
4279<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"/>
4280
4281<xsl:template match="x:ref">
4282  <xsl:variable name="val" select="."/>
4283<!--  <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)]"/> -->
4284  <xsl:variable name="target" select="key('anchor-item',$val) | key('anchor-item-alias',$val)"/>
4285  <xsl:variable name="irefs" select="//iref[@x:for-anchor=$val]"/>
4286  <xsl:choose>
4287    <xsl:when test="$target">
4288      <a href="#{$target/@anchor}" class="smpl">
4289        <xsl:call-template name="copy-anchor"/>
4290        <!-- to be indexed? -->
4291        <xsl:if test="$irefs">
4292          <xsl:attribute name="id"><xsl:call-template name="compute-extref-anchor"/></xsl:attribute>
4293        </xsl:if>
4294        <xsl:value-of select="."/>
4295      </a>
4296    </xsl:when>
4297    <xsl:otherwise>
4298      <xsl:call-template name="warning">
4299        <xsl:with-param name="inline" select="'no'"/>
4300        <xsl:with-param name="msg">internal link target for '<xsl:value-of select="."/>' does not exist.</xsl:with-param>
4301      </xsl:call-template>
4302      <xsl:value-of select="."/>
4303    </xsl:otherwise>
4304  </xsl:choose>
4305</xsl:template>
4306
4307<!-- Nothing to do here -->
4308<xsl:template match="x:anchor-alias" />
4309
4310<!-- Quotes -->
4311<xsl:template match="x:q">
4312  <q>
4313    <xsl:copy-of select="@cite"/>
4314    <xsl:apply-templates/>
4315  </q>
4316</xsl:template>
4317
4318<!-- Notes -->
4319<xsl:template match="x:note">
4320  <div class="note">
4321    <xsl:apply-templates/>
4322  </div>
4323</xsl:template>
4324
4325<xsl:template match="x:bcp14">
4326  <!-- check valid BCP14 keywords, then emphasize them -->
4327  <xsl:variable name="c" select="normalize-space(.)"/>
4328  <xsl:choose>
4329    <xsl:when test="$c='MUST' or $c='REQUIRED' or $c='SHALL'">
4330      <em class="bcp14"><xsl:value-of select="."/></em>
4331    </xsl:when>
4332    <xsl:when test="$c='MUST NOT' or $c='SHALL NOT'">
4333      <em class="bcp14"><xsl:value-of select="."/></em>
4334    </xsl:when>
4335    <xsl:when test="$c='SHOULD' or $c='RECOMMENDED'">
4336      <em class="bcp14"><xsl:value-of select="."/></em>
4337    </xsl:when>
4338    <xsl:when test="$c='SHOULD NOT' or $c='NOT RECOMMENDED'">
4339      <em class="bcp14"><xsl:value-of select="."/></em>
4340    </xsl:when>
4341    <xsl:when test="$c='MAY' or $c='OPTIONAL'">
4342      <em class="bcp14"><xsl:value-of select="."/></em>
4343    </xsl:when>
4344    <xsl:otherwise>
4345      <xsl:value-of select="."/>
4346      <xsl:message>ERROR: unknown BCP14 keyword: <xsl:value-of select="."/></xsl:message>
4347    </xsl:otherwise>
4348  </xsl:choose>
4349</xsl:template>
4350
4351<xsl:template match="x:blockquote">
4352  <xsl:variable name="p">
4353    <xsl:call-template name="get-paragraph-number" />
4354  </xsl:variable>
4355
4356  <blockquote>
4357    <xsl:if test="string-length($p) &gt; 0 and not(ancestor::ed:del) and not(ancestor::ed:ins)">
4358      <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$p"/></xsl:attribute>
4359    </xsl:if>
4360    <xsl:call-template name="insertInsDelClass"/>
4361    <xsl:call-template name="editingMark" />
4362    <xsl:copy-of select="@cite"/>
4363    <xsl:apply-templates/>
4364  </blockquote>
4365</xsl:template>
4366
4367<!-- Definitions -->
4368<xsl:template match="x:dfn">
4369  <dfn>
4370    <xsl:call-template name="copy-anchor"/>
4371    <xsl:apply-templates/>
4372  </dfn>
4373</xsl:template>
4374
4375<!-- headings -->
4376<xsl:template match="x:h">
4377  <b>
4378    <xsl:call-template name="copy-anchor"/>
4379    <xsl:apply-templates/>
4380  </b>
4381</xsl:template>
4382
4383<!-- superscripts -->
4384<xsl:template match="x:sup">
4385  <sup>
4386    <xsl:apply-templates/>
4387  </sup>
4388</xsl:template>
4389
4390<!-- bold -->
4391<xsl:template match="x:highlight">
4392  <b>
4393    <xsl:call-template name="copy-anchor"/>
4394    <xsl:apply-templates/>
4395  </b>
4396</xsl:template>
4397
4398<!-- measuring lengths -->
4399<xsl:template match="x:length-of">
4400  <xsl:variable name="target" select="//*[@anchor=current()/@target]"/>
4401  <xsl:if test="count($target)!=1">
4402    <xsl:call-template name="error">
4403      <xsl:with-param name="msg" select="concat('@target ',@target,' defined ',count($target),' times.')"/>
4404    </xsl:call-template>
4405  </xsl:if>
4406  <xsl:variable name="content">
4407    <xsl:apply-templates select="$target"/>
4408  </xsl:variable>
4409  <xsl:variable name="lineends" select="string-length($content) - string-length(translate($content,'&#10;',''))"/>
4410  <xsl:variable name="indents">
4411    <xsl:choose>
4412      <xsl:when test="@indented">
4413        <xsl:value-of select="number(@indented) * $lineends"/>
4414      </xsl:when>
4415      <xsl:otherwise>0</xsl:otherwise>
4416    </xsl:choose>
4417  </xsl:variable>
4418  <xsl:value-of select="string-length($content) + $lineends - $indents"/>
4419</xsl:template>
4420
4421<!-- Nop -->
4422<xsl:template match="x:span">
4423  <span>
4424    <xsl:call-template name="copy-anchor"/>
4425    <xsl:apply-templates/>
4426  </span>
4427</xsl:template>
4428
4429<xsl:template match="x:parse-xml">
4430  <xsl:apply-templates/>
4431
4432  <xsl:if test="function-available('exslt:node-set')">
4433    <xsl:variable name="cleaned">
4434      <xsl:apply-templates mode="cleanup-edits"/>
4435    </xsl:variable>
4436    <xsl:choose>
4437      <xsl:when test="function-available('myns:parseXml')">
4438        <xsl:if test="myns:parseXml(concat($cleaned,''))!=''">
4439          <xsl:call-template name="error">
4440            <xsl:with-param name="msg" select="concat('Parse error in XML: ', myns:parseXml(concat($cleaned,'')))"/>
4441          </xsl:call-template>
4442        </xsl:if>
4443      </xsl:when>
4444      <xsl:when test="function-available('saxon:parse')">
4445        <xsl:variable name="parsed" select="saxon:parse(concat($cleaned,''))"/>
4446        <xsl:if test="$parsed='foo'">
4447          <xsl:comment>should not get here</xsl:comment>
4448        </xsl:if>
4449      </xsl:when>
4450      <xsl:otherwise></xsl:otherwise>
4451    </xsl:choose>
4452  </xsl:if>
4453</xsl:template>
4454
4455<!-- inlined RDF support -->
4456<xsl:template match="rdf:Description">
4457  <!-- ignore -->
4458</xsl:template>
4459
4460<!-- cleanup for ins/del -->
4461
4462<xsl:template match="comment()|@*" mode="cleanup-edits"><xsl:copy/></xsl:template>
4463
4464<xsl:template match="text()" mode="cleanup-edits"><xsl:copy/></xsl:template>
4465
4466<xsl:template match="/" mode="cleanup-edits">
4467        <xsl:copy><xsl:apply-templates select="node()" mode="cleanup-edits" /></xsl:copy>
4468</xsl:template>
4469
4470<xsl:template match="ed:del" mode="cleanup-edits"/>
4471
4472<xsl:template match="ed:replace" mode="cleanup-edits">
4473  <xsl:apply-templates mode="cleanup-edits"/>
4474</xsl:template>
4475
4476<xsl:template match="ed:ins" mode="cleanup-edits">
4477  <xsl:apply-templates mode="cleanup-edits"/>
4478</xsl:template>
4479
4480
4481<!-- ABNF support -->
4482<xsl:template name="to-abnf-char-sequence">
4483  <xsl:param name="chars"/>
4484 
4485  <xsl:variable name="c" select="substring($chars,1,1)"/>
4486  <xsl:variable name="r" select="substring($chars,2)"/>
4487   
4488  <xsl:choose>
4489    <xsl:when test="$c='-'">2D</xsl:when>
4490    <xsl:when test="$c='/'">2F</xsl:when>
4491    <xsl:when test="$c='0'">30</xsl:when>
4492    <xsl:when test="$c='1'">31</xsl:when>
4493    <xsl:when test="$c='2'">32</xsl:when>
4494    <xsl:when test="$c='3'">33</xsl:when>
4495    <xsl:when test="$c='4'">34</xsl:when>
4496    <xsl:when test="$c='5'">35</xsl:when>
4497    <xsl:when test="$c='6'">36</xsl:when>
4498    <xsl:when test="$c='7'">37</xsl:when>
4499    <xsl:when test="$c='8'">38</xsl:when>
4500    <xsl:when test="$c='9'">39</xsl:when>
4501    <xsl:when test="$c='A'">41</xsl:when>
4502    <xsl:when test="$c='B'">42</xsl:when>
4503    <xsl:when test="$c='C'">43</xsl:when>
4504    <xsl:when test="$c='D'">44</xsl:when>
4505    <xsl:when test="$c='E'">45</xsl:when>
4506    <xsl:when test="$c='F'">46</xsl:when>
4507    <xsl:when test="$c='G'">47</xsl:when>
4508    <xsl:when test="$c='H'">48</xsl:when>
4509    <xsl:when test="$c='I'">49</xsl:when>
4510    <xsl:when test="$c='J'">4A</xsl:when>
4511    <xsl:when test="$c='K'">4B</xsl:when>
4512    <xsl:when test="$c='L'">4C</xsl:when>
4513    <xsl:when test="$c='M'">4D</xsl:when>
4514    <xsl:when test="$c='N'">4E</xsl:when>
4515    <xsl:when test="$c='O'">4F</xsl:when>
4516    <xsl:when test="$c='P'">50</xsl:when>
4517    <xsl:when test="$c='Q'">51</xsl:when>
4518    <xsl:when test="$c='R'">52</xsl:when>
4519    <xsl:when test="$c='S'">53</xsl:when>
4520    <xsl:when test="$c='T'">54</xsl:when>
4521    <xsl:when test="$c='U'">55</xsl:when>
4522    <xsl:when test="$c='V'">56</xsl:when>
4523    <xsl:when test="$c='W'">57</xsl:when>
4524    <xsl:when test="$c='X'">58</xsl:when>
4525    <xsl:when test="$c='Y'">59</xsl:when>
4526    <xsl:when test="$c='Z'">5A</xsl:when>
4527    <xsl:when test="$c='a'">61</xsl:when>
4528    <xsl:when test="$c='b'">62</xsl:when>
4529    <xsl:when test="$c='c'">63</xsl:when>
4530    <xsl:when test="$c='d'">64</xsl:when>
4531    <xsl:when test="$c='e'">65</xsl:when>
4532    <xsl:when test="$c='f'">66</xsl:when>
4533    <xsl:when test="$c='g'">67</xsl:when>
4534    <xsl:when test="$c='h'">68</xsl:when>
4535    <xsl:when test="$c='i'">69</xsl:when>
4536    <xsl:when test="$c='j'">6A</xsl:when>
4537    <xsl:when test="$c='k'">6B</xsl:when>
4538    <xsl:when test="$c='l'">6C</xsl:when>
4539    <xsl:when test="$c='m'">6D</xsl:when>
4540    <xsl:when test="$c='n'">6E</xsl:when>
4541    <xsl:when test="$c='o'">6F</xsl:when>
4542    <xsl:when test="$c='p'">70</xsl:when>
4543    <xsl:when test="$c='q'">71</xsl:when>
4544    <xsl:when test="$c='r'">72</xsl:when>
4545    <xsl:when test="$c='s'">73</xsl:when>
4546    <xsl:when test="$c='t'">74</xsl:when>
4547    <xsl:when test="$c='u'">75</xsl:when>
4548    <xsl:when test="$c='v'">76</xsl:when>
4549    <xsl:when test="$c='w'">77</xsl:when>
4550    <xsl:when test="$c='x'">78</xsl:when>
4551    <xsl:when test="$c='y'">79</xsl:when>
4552    <xsl:when test="$c='z'">7A</xsl:when>
4553    <xsl:otherwise>
4554      <xsl:text>??</xsl:text>
4555      <xsl:call-template name="error">
4556        <xsl:with-param name="msg" select="concat('unexpected character in ABNF char sequence: ',substring($chars,1,1))" />
4557      </xsl:call-template>
4558    </xsl:otherwise>
4559  </xsl:choose>
4560
4561  <xsl:if test="$r!=''">
4562    <xsl:text>.</xsl:text>
4563    <xsl:call-template name="to-abnf-char-sequence">
4564      <xsl:with-param name="chars" select="$r"/>
4565    </xsl:call-template>
4566  </xsl:if>
4567 
4568</xsl:template>
4569
4570<xsl:template match="x:abnf-char-sequence">
4571  <xsl:choose>
4572    <xsl:when test="substring(.,1,1) != '&quot;' or substring(.,string-length(.),1) != '&quot;'">
4573      <xsl:call-template name="error">
4574        <xsl:with-param name="msg" select="'contents of x:abnf-char-sequence needs to be quoted.'" />
4575      </xsl:call-template>
4576    </xsl:when>
4577    <xsl:otherwise>
4578      <xsl:text>%x</xsl:text>
4579      <xsl:call-template name="to-abnf-char-sequence">
4580        <xsl:with-param name="chars" select="substring(.,2,string-length(.)-2)"/>
4581      </xsl:call-template>
4582    </xsl:otherwise>
4583  </xsl:choose>
4584</xsl:template>
4585
4586<!-- box drawing -->
4587
4588<!-- nop for alignment -->
4589<xsl:template match="x:x"/>
4590
4591<!-- box (top) -->
4592<xsl:template match="x:bt">
4593  <xsl:text>&#x250c;</xsl:text>
4594  <xsl:value-of select="translate(substring(.,2,string-length(.)-2),'-','&#x2500;')"/>
4595  <xsl:text>&#x2510;</xsl:text>
4596</xsl:template>
4597
4598<!-- box (center) -->
4599<xsl:template match="x:bc">
4600  <xsl:variable name="first" select="substring(.,1)"/>
4601  <xsl:variable name="content" select="substring(.,2,string-length(.)-2)"/>
4602  <xsl:variable name="is-delimiter" select="translate($content,'-','')=''"/>
4603 
4604  <xsl:choose>
4605    <xsl:when test="$is-delimiter">
4606      <xsl:text>&#x251c;</xsl:text>
4607      <xsl:value-of select="translate($content,'-','&#x2500;')"/>
4608      <xsl:text>&#x2524;</xsl:text>
4609    </xsl:when>
4610    <xsl:when test="*">
4611      <xsl:for-each select="node()">
4612        <xsl:choose>
4613          <xsl:when test="position()=1">
4614            <xsl:text>&#x2502;</xsl:text>
4615            <xsl:value-of select="substring(.,2)"/>
4616          </xsl:when>
4617          <xsl:when test="position()=last()">
4618            <xsl:value-of select="substring(.,1,string-length(.)-1)"/>
4619            <xsl:text>&#x2502;</xsl:text>
4620          </xsl:when>
4621          <xsl:otherwise>
4622            <xsl:apply-templates select="."/>
4623          </xsl:otherwise>
4624        </xsl:choose>
4625      </xsl:for-each>
4626    </xsl:when>
4627    <xsl:otherwise>
4628      <xsl:text>&#x2502;</xsl:text>
4629      <xsl:value-of select="$content"/>
4630      <xsl:text>&#x2502;</xsl:text>
4631    </xsl:otherwise>
4632  </xsl:choose>
4633 
4634</xsl:template>
4635
4636<!-- box (bottom) -->
4637<xsl:template match="x:bb">
4638  <xsl:text>&#x2514;</xsl:text>
4639  <xsl:value-of select="translate(substring(.,2,string-length(.)-2),'-','&#x2500;')"/>
4640  <xsl:text>&#x2518;</xsl:text>
4641</xsl:template>
4642
4643<!-- author handling extensions -->
4644<xsl:template match="x:include-author">
4645  <xsl:for-each select="/*/front/author[@anchor=current()/@target]">
4646    <xsl:apply-templates select="."/>
4647  </xsl:for-each>
4648</xsl:template>
4649
4650<!-- boilerplate -->
4651<xsl:template match="x:boilerplate">
4652  <xsl:apply-templates/>
4653</xsl:template>
4654
4655<!-- experimental annotation support -->
4656
4657<xsl:template match="ed:issueref">
4658  <xsl:choose>
4659    <xsl:when test=".=//ed:issue/@name">
4660      <a href="#{$anchor-prefix}.issue.{.}">
4661        <xsl:apply-templates/>
4662      </a>
4663    </xsl:when>
4664    <xsl:otherwise>
4665      <xsl:call-template name="warning">
4666        <xsl:with-param name="msg">Dangling ed:issueref: <xsl:value-of select="."/></xsl:with-param>
4667      </xsl:call-template>
4668      <xsl:apply-templates/>
4669    </xsl:otherwise>
4670  </xsl:choose>
4671</xsl:template>
4672
4673<xsl:template match="ed:issue">
4674  <xsl:variable name="class">
4675    <xsl:choose>
4676      <xsl:when test="@status='closed'">closedissue</xsl:when>
4677      <xsl:otherwise>openissue</xsl:otherwise>
4678    </xsl:choose>
4679  </xsl:variable>
4680 
4681  <table summary="issue {@name}" class="{$class}">
4682    <tr>
4683      <td colspan="3">
4684        <a id="{$anchor-prefix}.issue.{@name}">
4685          <xsl:choose>
4686            <xsl:when test="@status='closed'">
4687              <xsl:attribute name="class">closed-issue</xsl:attribute>
4688            </xsl:when>
4689            <xsl:when test="@status='editor'">
4690              <xsl:attribute name="class">editor-issue</xsl:attribute>
4691            </xsl:when>
4692            <xsl:otherwise>
4693              <xsl:attribute name="class">open-issue</xsl:attribute>
4694            </xsl:otherwise>
4695          </xsl:choose>
4696          <xsl:text>&#160;I&#160;</xsl:text>
4697        </a>
4698        <xsl:text>&#160;</xsl:text>
4699        <xsl:choose>
4700          <xsl:when test="@href">
4701            <em><a href="{@href}"><xsl:value-of select="@name" /></a></em>
4702          </xsl:when>
4703          <xsl:when test="@alternate-href">
4704            <em>[<a href="{@alternate-href}">alternate link</a>]</em>
4705          </xsl:when>
4706          <xsl:otherwise>
4707            <em><xsl:value-of select="@name" /></em>
4708          </xsl:otherwise>
4709        </xsl:choose>
4710        &#0160;
4711        (type: <xsl:value-of select="@type"/>, status: <xsl:value-of select="@status"/>)
4712      </td>
4713    </tr>
4714
4715    <xsl:apply-templates select="ed:item"/>
4716    <xsl:apply-templates select="ed:resolution"/>
4717
4718    <xsl:variable name="changes" select="//*[@ed:resolves=current()/@name or ed:resolves=current()/@name]" />
4719    <xsl:if test="$changes">
4720      <tr>
4721        <td class="top" colspan="3">
4722          Associated changes in this document:
4723          <xsl:variable name="issue" select="@name"/>
4724          <xsl:for-each select="$changes">
4725            <a href="#{$anchor-prefix}.change.{$issue}.{position()}">
4726              <xsl:variable name="label">
4727                <xsl:call-template name="get-section-number"/>
4728              </xsl:variable>
4729              <xsl:choose>
4730                <xsl:when test="$label!=''"><xsl:value-of select="$label"/></xsl:when>
4731                <xsl:otherwise>&lt;<xsl:value-of select="concat('#',$anchor-prefix,'.change.',$issue,'.',position())"/>&gt;</xsl:otherwise>
4732              </xsl:choose>
4733            </a>
4734            <xsl:if test="position()!=last()">, </xsl:if>
4735          </xsl:for-each>
4736          <xsl:text>.</xsl:text>
4737        </td>
4738      </tr>
4739    </xsl:if>
4740  </table>
4741   
4742</xsl:template>
4743
4744<xsl:template match="ed:item">
4745  <tr>
4746    <td class="top">
4747      <xsl:if test="@entered-by">
4748        <a href="mailto:{@entered-by}?subject={/rfc/@docName},%20{../@name}">
4749          <i><xsl:value-of select="@entered-by"/></i>
4750        </a>
4751      </xsl:if>
4752    </td>
4753    <td class="topnowrap">
4754      <xsl:value-of select="@date"/>
4755    </td>
4756    <td class="top">
4757      <xsl:apply-templates select="node()" mode="issuehtml"/>
4758    </td>
4759  </tr>
4760</xsl:template>
4761
4762<xsl:template match="ed:resolution">
4763  <tr>
4764    <td class="top">
4765      <xsl:if test="@entered-by">
4766        <a href="mailto:{@entered-by}?subject={/rfc/@docName},%20{../@name}"><i><xsl:value-of select="@entered-by"/></i></a>
4767      </xsl:if>
4768    </td>
4769    <td class="topnowrap">
4770      <xsl:value-of select="@datetime"/>
4771    </td>
4772    <td class="top">
4773      <em>Resolution:</em>
4774      <xsl:apply-templates select="node()" mode="issuehtml"/>
4775    </td>
4776  </tr>
4777</xsl:template>
4778
4779<xsl:template match="ed:annotation">
4780  <em>
4781    <xsl:apply-templates/>
4782  </em>
4783</xsl:template>
4784
4785<!-- special templates for handling XHTML in issues -->
4786<xsl:template match="text()" mode="issuehtml">
4787  <xsl:value-of select="."/>
4788</xsl:template>
4789
4790<xsl:template match="*|@*" mode="issuehtml">
4791  <xsl:message terminate="yes">Unexpected node in issue HTML: <xsl:value-of select="name(.)"/></xsl:message>
4792</xsl:template>
4793
4794<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">
4795  <xsl:element name="{local-name()}">
4796    <xsl:apply-templates select="@*|node()" mode="issuehtml"/>
4797  </xsl:element>
4798</xsl:template>
4799
4800<xsl:template match="xhtml:p" mode="issuehtml">
4801  <xsl:apply-templates select="node()" mode="issuehtml"/>
4802  <br class="p"/>
4803</xsl:template>
4804
4805<xsl:template match="xhtml:a/@href|xhtml:q/@cite" mode="issuehtml">
4806  <xsl:attribute name="{local-name(.)}">
4807    <xsl:value-of select="."/>
4808  </xsl:attribute>
4809</xsl:template>
4810
4811<xsl:template match="ed:issueref" mode="issuehtml">
4812  <xsl:apply-templates select="."/>
4813</xsl:template>
4814
4815<xsl:template match="ed:eref" mode="issuehtml">
4816  <xsl:text>&lt;</xsl:text>
4817  <a href="{.}"><xsl:value-of select="."/></a>
4818  <xsl:text>&gt;</xsl:text>
4819</xsl:template>
4820
4821<xsl:template name="insertIssuesList">
4822
4823  <h2 id="{$anchor-prefix}.issues-list" ><a href="#{$anchor-prefix}.issues-list">Issues list</a></h2>
4824  <table summary="Issues list">
4825    <thead>
4826      <tr>
4827        <th>Id</th>
4828        <th>Type</th>
4829        <th>Status</th>
4830        <th>Date</th>
4831        <th>Raised By</th>
4832      </tr>
4833    </thead>
4834    <tbody>
4835      <xsl:for-each select="//ed:issue">
4836        <xsl:sort select="@status" />
4837        <xsl:sort select="@name" />
4838        <tr>
4839          <td><a href="#{$anchor-prefix}.issue.{@name}"><xsl:value-of select="@name" /></a></td>
4840          <td><xsl:value-of select="@type" /></td>
4841          <td><xsl:value-of select="@status" /></td>
4842          <td><xsl:value-of select="ed:item[1]/@date" /></td>
4843          <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>
4844        </tr>
4845      </xsl:for-each>
4846    </tbody>
4847  </table>
4848 
4849</xsl:template>
4850
4851<xsl:template name="insert-diagnostics">
4852 
4853  <!-- check anchor names -->
4854  <xsl:variable name="badAnchors"
4855    select="//*[starts-with(@anchor,concat($anchor-prefix,'.'))][@anchor!=concat($anchor-prefix,'.authors') and /*/x:assign-section-number[@number='suppress' and @builtin-target='authors']]" />
4856 
4857  <xsl:if test="$badAnchors">
4858    <xsl:variable name="text">
4859      The following anchor names may collide with internally generated anchors because of their prefix "<xsl:value-of select="$anchor-prefix" />":
4860      <xsl:for-each select="$badAnchors">
4861        <xsl:value-of select="@anchor"/><xsl:if test="position()!=last()">, </xsl:if>
4862      </xsl:for-each>
4863    </xsl:variable>
4864    <xsl:call-template name="warning">
4865      <xsl:with-param name="msg"><xsl:value-of select="$text"/></xsl:with-param>
4866    </xsl:call-template>
4867  </xsl:if>
4868 
4869  <!-- check ABNF syntax references -->
4870  <xsl:if test="//artwork[@type='abnf2616']">
4871    <xsl:if test="not(//reference/seriesInfo[@name='RFC' and (@value='2068' or @value='2616')])">
4872      <xsl:call-template name="warning">
4873        <xsl:with-param name="inline">no</xsl:with-param>
4874        <xsl:with-param name="msg">document uses HTTP-style ABNF syntax, but doesn't reference RFC 2068 or 2616.</xsl:with-param>
4875      </xsl:call-template>
4876    </xsl:if>
4877  </xsl:if>
4878  <xsl:if test="//artwork[@type='abnf']">
4879    <xsl:if test="not(//reference/seriesInfo[@name='RFC' and (@value='2234' or @value='4234' or @value='5234')])">
4880      <xsl:call-template name="warning">
4881        <xsl:with-param name="inline">no</xsl:with-param>
4882        <xsl:with-param name="msg">document uses ABNF syntax, but doesn't reference RFC 2234, 4234 or 5234.</xsl:with-param>
4883      </xsl:call-template>
4884    </xsl:if>
4885  </xsl:if>
4886 
4887  <!-- check IDs -->
4888  <xsl:variable name="badTargets" select="//xref[not(@target=//@anchor) and not(ancestor::ed:del)]" />
4889  <xsl:if test="$badTargets">
4890    <xsl:variable name="text">
4891      The following target names do not exist:
4892      <xsl:for-each select="$badTargets">
4893        <xsl:value-of select="@target"/><xsl:if test="position()!=last()">, </xsl:if>
4894      </xsl:for-each>
4895    </xsl:variable>
4896    <xsl:call-template name="warning">
4897      <xsl:with-param name="msg"><xsl:value-of select="$text"/></xsl:with-param>
4898    </xsl:call-template>
4899  </xsl:if>
4900 
4901 
4902</xsl:template>
4903
4904<!-- special change mark support, not supported by RFC2629 yet -->
4905
4906<xsl:template match="@ed:*" />
4907
4908<xsl:template match="ed:del">
4909  <xsl:call-template name="insert-issue-pointer"/>
4910  <del>
4911    <xsl:copy-of select="@*[namespace-uri()='']"/>
4912    <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
4913      <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4914    </xsl:if>
4915    <xsl:apply-templates />
4916  </del>
4917</xsl:template>
4918
4919<xsl:template match="ed:ins">
4920  <xsl:call-template name="insert-issue-pointer"/>
4921  <ins>
4922    <xsl:copy-of select="@*[namespace-uri()='']"/>
4923    <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
4924      <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4925    </xsl:if>
4926    <xsl:apply-templates />
4927  </ins>
4928</xsl:template>
4929
4930<xsl:template name="insert-issue-pointer">
4931  <xsl:param name="deleted-anchor"/>
4932  <xsl:variable name="change" select="."/>
4933  <xsl:for-each select="@ed:resolves|ed:resolves">
4934    <xsl:variable name="resolves" select="."/>
4935    <!-- need the right context node for proper numbering -->
4936    <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>
4937    <xsl:variable name="total" select="count(//*[@ed:resolves=$resolves or ed:resolves=$resolves])" />
4938    <xsl:variable name="id">
4939      <xsl:value-of select="$anchor-prefix"/>.change.<xsl:value-of select="$resolves"/>.<xsl:value-of select="$count" />
4940    </xsl:variable>
4941    <xsl:choose>
4942      <!-- block level? -->
4943      <xsl:when test="not(ancestor::t) and not(ancestor::title) and not(ancestor::figure) and not($change/@ed:old-title)">
4944        <div class="issuepointer noprint">
4945          <xsl:if test="not($deleted-anchor)">
4946            <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
4947          </xsl:if>
4948          <xsl:if test="$count > 1">
4949            <a class="bg-issue" title="previous change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count - 1}">&#x2191;</a>
4950          </xsl:if>
4951          <a class="open-issue" href="#{$anchor-prefix}.issue.{$resolves}" title="resolves: {$resolves}">
4952            <xsl:choose>
4953              <xsl:when test="//ed:issue[@name=$resolves and @status='closed']">
4954                <xsl:attribute name="class">closed-issue</xsl:attribute>
4955              </xsl:when>
4956              <xsl:when test="//ed:issue[@name=$resolves and @status='editor']">
4957                <xsl:attribute name="class">editor-issue</xsl:attribute>
4958              </xsl:when>
4959              <xsl:otherwise>
4960                <xsl:attribute name="class">open-issue</xsl:attribute>
4961              </xsl:otherwise>
4962            </xsl:choose>
4963            <xsl:text>&#160;I&#160;</xsl:text>
4964          </a>
4965          <xsl:if test="$count &lt; $total">
4966            <a class="bg-issue" title="next change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count + 1}">&#x2193;</a>
4967          </xsl:if>
4968          <xsl:text>&#160;</xsl:text>
4969        </div>
4970      </xsl:when>
4971      <xsl:otherwise>
4972        <xsl:if test="$count > 1">
4973          <a class="bg-issue" title="previous change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count - 1}">&#x2191;</a>
4974        </xsl:if>
4975        <a title="resolves: {$resolves}" href="#{$anchor-prefix}.issue.{$resolves}">
4976          <xsl:if test="not($deleted-anchor)">
4977            <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
4978          </xsl:if>
4979          <xsl:choose>
4980            <xsl:when test="//ed:issue[@name=$resolves and @status='closed']">
4981              <xsl:attribute name="class">closed-issue noprint</xsl:attribute>
4982            </xsl:when>
4983            <xsl:when test="//ed:issue[@name=$resolves and @status='editor']">
4984              <xsl:attribute name="class">editor-issue noprint</xsl:attribute>
4985            </xsl:when>
4986            <xsl:otherwise>
4987              <xsl:attribute name="class">open-issue noprint</xsl:attribute>
4988            </xsl:otherwise>
4989          </xsl:choose>
4990          <xsl:text>&#160;I&#160;</xsl:text>
4991        </a>
4992        <xsl:if test="$count &lt; $total">
4993          <a class="bg-issue" title="next change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count + 1}">&#x2193;</a>
4994        </xsl:if>
4995      </xsl:otherwise>
4996    </xsl:choose>
4997  </xsl:for-each>
4998</xsl:template>
4999
5000<xsl:template match="ed:replace">
5001  <!-- we need to special-case things like lists and tables -->
5002  <xsl:choose>
5003    <xsl:when test="parent::list">
5004      <xsl:apply-templates select="ed:del/node()" />
5005      <xsl:apply-templates select="ed:ins/node()" />
5006    </xsl:when>
5007    <xsl:when test="parent::references">
5008      <xsl:apply-templates select="ed:del/node()" />
5009      <xsl:apply-templates select="ed:ins/node()" />
5010    </xsl:when>
5011    <xsl:otherwise>
5012      <xsl:if test="@cite">
5013        <a class="editor-issue" href="{@cite}" target="_blank" title="see {@cite}">
5014          <xsl:text>&#160;i&#160;</xsl:text>
5015        </a>
5016      </xsl:if>
5017      <xsl:call-template name="insert-issue-pointer"/>
5018      <xsl:if test="ed:del">
5019        <del>
5020          <xsl:copy-of select="@*[namespace-uri()='']"/>
5021          <xsl:if test="not(@title) and ancestor-or-self::xsl:template[@ed:entered-by] and @datetime">
5022            <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
5023          </xsl:if>
5024          <xsl:apply-templates select="ed:del/node()" />
5025        </del>
5026      </xsl:if>
5027      <xsl:if test="ed:ins">
5028        <ins>
5029          <xsl:copy-of select="@*[namespace-uri()='']"/>
5030          <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
5031            <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
5032          </xsl:if>
5033          <xsl:apply-templates select="ed:ins/node()" />
5034        </ins>
5035      </xsl:if>
5036    </xsl:otherwise>
5037  </xsl:choose>
5038</xsl:template>
5039
5040<!-- convenience template for helping Mozilla (pre/ins inheritance problem) -->
5041<xsl:template name="insertInsDelClass">
5042  <xsl:if test="ancestor::ed:del">
5043    <xsl:attribute name="class">del</xsl:attribute>
5044  </xsl:if>
5045  <xsl:if test="ancestor::ed:ins">
5046    <xsl:attribute name="class">ins</xsl:attribute>
5047  </xsl:if>
5048</xsl:template>
5049
5050
5051<xsl:template name="sectionnumberAndEdits">
5052  <xsl:choose>
5053    <xsl:when test="ancestor::ed:del">del-<xsl:number count="ed:del//section" level="any"/></xsl:when>
5054    <xsl:when test="@x:fixed-section-number">
5055      <xsl:value-of select="@x:fixed-section-number"/>
5056    </xsl:when>
5057    <xsl:when test="self::section and parent::ed:ins and local-name(../..)='replace'">
5058      <xsl:for-each select="../.."><xsl:call-template name="sectionnumberAndEdits" /></xsl:for-each>
5059      <xsl:for-each select="..">
5060        <xsl:if test="parent::ed:replace">
5061          <xsl:for-each select="..">
5062            <xsl:if test="parent::section">.</xsl:if>
5063            <xsl:variable name="cnt" select="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)" />
5064            <xsl:choose>
5065              <xsl:when test="ancestor::back and not(ancestor::section)"><xsl:number format="A" value="$cnt"/></xsl:when>
5066              <xsl:otherwise><xsl:value-of select="$cnt"/></xsl:otherwise>
5067            </xsl:choose>
5068          </xsl:for-each>
5069        </xsl:if>
5070      </xsl:for-each>
5071    </xsl:when>
5072    <xsl:when test="self::section[parent::ed:ins]">
5073      <xsl:for-each select="../.."><xsl:call-template name="sectionnumberAndEdits" /></xsl:for-each>
5074      <xsl:for-each select="..">
5075        <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)" />
5076      </xsl:for-each>
5077    </xsl:when>
5078    <xsl:when test="self::section">
5079      <xsl:for-each select=".."><xsl:call-template name="sectionnumberAndEdits" /></xsl:for-each>
5080      <xsl:if test="parent::section">.</xsl:if>
5081      <xsl:choose>
5082        <xsl:when test="parent::back">
5083          <xsl:number format="A" value="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)" />
5084        </xsl:when>
5085        <xsl:otherwise>
5086          <xsl:number value="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)" />
5087        </xsl:otherwise>
5088      </xsl:choose>
5089    </xsl:when>
5090    <xsl:when test="self::references">
5091      <xsl:choose>
5092        <xsl:when test="count(/*/back/references)+count(/*/back/ed:replace/ed:ins/references)=1"><xsl:call-template name="get-references-section-number"/></xsl:when>
5093        <xsl:otherwise><xsl:call-template name="get-references-section-number"/>.<xsl:number level="any"/></xsl:otherwise>
5094      </xsl:choose>
5095    </xsl:when>
5096    <xsl:when test="self::middle or self::back"><!-- done --></xsl:when>
5097    <xsl:otherwise>
5098      <!-- go up one level -->
5099      <xsl:for-each select=".."><xsl:call-template name="sectionnumberAndEdits" /></xsl:for-each>
5100    </xsl:otherwise>
5101  </xsl:choose>
5102</xsl:template>
5103
5104<!-- utilities for warnings -->
5105
5106<xsl:template name="warning">
5107  <xsl:param name="msg"/>
5108  <xsl:param name="msg2"/>
5109  <xsl:param name="inline"/>
5110  <xsl:call-template name="emit-message">
5111    <xsl:with-param name="level">WARNING</xsl:with-param>
5112    <xsl:with-param name="msg" select="$msg"/>
5113    <xsl:with-param name="msg2" select="$msg2"/>
5114    <xsl:with-param name="inline" select="$inline"/>
5115  </xsl:call-template>
5116</xsl:template>
5117
5118<xsl:template name="error">
5119  <xsl:param name="msg"/>
5120  <xsl:param name="msg2"/>
5121  <xsl:param name="inline"/>
5122  <xsl:call-template name="emit-message">
5123    <xsl:with-param name="level">ERROR</xsl:with-param>
5124    <xsl:with-param name="msg" select="$msg"/>
5125    <xsl:with-param name="msg2" select="$msg2"/>
5126    <xsl:with-param name="inline" select="$inline"/>
5127  </xsl:call-template>
5128</xsl:template>
5129
5130<xsl:template name="emit-message">
5131  <xsl:param name="level"/>
5132  <xsl:param name="msg"/>
5133  <xsl:param name="msg2"/>
5134  <xsl:param name="inline"/>
5135  <xsl:variable name="message"><xsl:value-of select="$level"/>: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/><xsl:call-template name="lineno"/></xsl:variable>
5136  <xsl:choose>
5137    <xsl:when test="$inline!='no'">
5138      <div class="error"><xsl:value-of select="$message"/></div>
5139    </xsl:when>
5140    <xsl:otherwise>
5141      <xsl:comment><xsl:value-of select="$message"/></xsl:comment>
5142    </xsl:otherwise>
5143  </xsl:choose>
5144  <xsl:message><xsl:value-of select="$message"/></xsl:message>
5145</xsl:template>
5146
5147<!-- table formatting -->
5148
5149<xsl:template match="texttable">
5150
5151  <xsl:variable name="anch">
5152    <xsl:call-template name="get-table-anchor"/>
5153  </xsl:variable>
5154
5155  <div id="{$anch}">
5156    <xsl:if test="@anchor!=''">
5157      <div id="{@anchor}"/>
5158    </xsl:if>
5159    <xsl:apply-templates select="preamble" />
5160    <xsl:variable name="style">
5161      <xsl:text>tt </xsl:text>
5162      <xsl:choose>
5163        <xsl:when test="@style!=''">
5164          <xsl:value-of select="@style"/>
5165        </xsl:when>
5166        <xsl:otherwise>full</xsl:otherwise>
5167      </xsl:choose>
5168    </xsl:variable>
5169
5170    <table summary="{preamble}" class="{$style}" cellpadding="3" cellspacing="0">
5171
5172      <xsl:if test="(@title!='' or @anchor!='') and not(@suppress-title='true')">
5173        <xsl:variable name="n"><xsl:number level="any" count="texttable[(@title!='' or @anchor!='') and not(@suppress-title='true')]" /></xsl:variable>
5174        <caption>Table <xsl:value-of select="$n"/><xsl:if test="@title!=''">: <xsl:value-of select="@title" /></xsl:if></caption>
5175      </xsl:if>
5176
5177      <xsl:if test="ttcol!=''">
5178        <!-- skip header when all column titles are empty -->
5179        <thead>
5180          <tr>
5181            <xsl:apply-templates select="ttcol" />
5182          </tr>
5183        </thead>
5184      </xsl:if>
5185      <tbody>
5186        <xsl:variable name="columns" select="count(ttcol)" />
5187        <xsl:variable name="fields" select="c | ed:replace/ed:ins/c | ed:replace/ed:del/c" />
5188        <xsl:for-each select="$fields[(position() mod $columns) = 1]">
5189          <tr>
5190            <xsl:for-each select=". | following-sibling::c[position() &lt; $columns]">
5191              <td>
5192                <xsl:call-template name="insertInsDelClass"/>
5193                <xsl:variable name="pos" select="position()" />
5194                <xsl:variable name="col" select="../ttcol[position() = $pos]" />
5195                <xsl:choose>
5196                  <xsl:when test="$col/@align='right' or $col/@align='center'">
5197                    <xsl:attribute name="class"><xsl:value-of select="$col/@align"/></xsl:attribute>
5198                  </xsl:when>
5199                  <xsl:when test="$col/@align='left' or not($col/@align)">
5200                    <!-- that's the default, nothing to do here -->
5201                  </xsl:when>
5202                  <xsl:otherwise>
5203                    <xsl:message>Unknown align attribute on ttcol: <xsl:value-of select="$col/@align"/></xsl:message>
5204                  </xsl:otherwise>
5205                </xsl:choose>
5206                <xsl:apply-templates select="node()" />
5207              </td>
5208            </xsl:for-each>
5209          </tr>
5210        </xsl:for-each>
5211      </tbody>
5212    </table>
5213    <xsl:apply-templates select="postamble" />
5214  </div>
5215 
5216</xsl:template>
5217
5218<xsl:template match="ttcol">
5219  <th>
5220   
5221    <xsl:choose>
5222      <xsl:when test="@align='right' or @align='center' or @align='left'">
5223        <xsl:attribute name="class"><xsl:value-of select="@align"/></xsl:attribute>
5224      </xsl:when>
5225      <xsl:when test="not(@align)">
5226        <!-- that's the default, nothing to do here -->
5227      </xsl:when>
5228      <xsl:otherwise>
5229        <xsl:message>Unknown align attribute on ttcol: <xsl:value-of select="@align"/></xsl:message>
5230      </xsl:otherwise>
5231    </xsl:choose>
5232   
5233    <xsl:if test="@width">
5234      <xsl:attribute name="style">width: <xsl:value-of select="@width" />;</xsl:attribute>
5235    </xsl:if>
5236
5237    <xsl:apply-templates />
5238  </th>
5239</xsl:template>
5240
5241<!-- cref support -->
5242
5243<xsl:template name="get-comment-name">
5244  <xsl:choose>
5245    <xsl:when test="@anchor">
5246      <xsl:value-of select="@anchor"/>
5247    </xsl:when>
5248    <xsl:otherwise>
5249      <xsl:value-of select="$anchor-prefix"/>
5250      <xsl:text>.comment.</xsl:text>
5251      <xsl:number count="cref[not(@anchor)]" level="any"/>
5252    </xsl:otherwise>
5253  </xsl:choose>
5254</xsl:template>
5255
5256<xsl:template match="cref">
5257  <xsl:if test="$xml2rfc-comments!='no'">
5258    <xsl:variable name="cid">
5259      <xsl:call-template name="get-comment-name"/>
5260    </xsl:variable>
5261   
5262    <span class="comment">
5263      <xsl:choose>
5264        <xsl:when test="$xml2rfc-inline='yes'">
5265          <xsl:attribute name="id">
5266            <xsl:value-of select="$cid"/>
5267          </xsl:attribute>
5268          <xsl:text>[</xsl:text>
5269          <a href="#{$cid}" class="smpl">
5270            <xsl:value-of select="$cid"/>
5271          </a>
5272          <xsl:text>: </xsl:text>
5273          <xsl:apply-templates select="text()|eref"/>
5274          <xsl:if test="@source"> --<xsl:value-of select="@source"/></xsl:if>
5275          <xsl:text>]</xsl:text>
5276        </xsl:when>
5277        <xsl:otherwise>
5278          <xsl:attribute name="title">
5279            <xsl:if test="@source"><xsl:value-of select="@source"/>: </xsl:if>
5280            <xsl:apply-templates select="text()|eref"/>
5281          </xsl:attribute>
5282          <xsl:text>[</xsl:text>
5283          <a href="#{$cid}">
5284            <xsl:value-of select="$cid"/>
5285          </a>
5286          <xsl:text>]</xsl:text>
5287        </xsl:otherwise>
5288      </xsl:choose>
5289    </span>
5290  </xsl:if>
5291</xsl:template>
5292
5293<xsl:template name="insertComments">
5294
5295  <xsl:call-template name="insert-conditional-hrule"/>
5296   
5297  <h1>
5298    <xsl:call-template name="insert-conditional-pagebreak"/>
5299    <a id="{$anchor-prefix}.comments" href="#{$anchor-prefix}.comments">Editorial Comments</a>
5300  </h1>
5301
5302  <dl>
5303    <xsl:for-each select="//cref">
5304      <xsl:variable name="cid">
5305        <xsl:choose>
5306          <xsl:when test="@anchor">
5307            <xsl:value-of select="@anchor"/>
5308          </xsl:when>
5309          <xsl:otherwise>
5310            <xsl:value-of select="$anchor-prefix"/>
5311            <xsl:text>.comment.</xsl:text>
5312            <xsl:number count="cref[not(@anchor)]" level="any"/>
5313          </xsl:otherwise>
5314        </xsl:choose>
5315      </xsl:variable>
5316      <dt id="{$cid}">
5317        [<xsl:value-of select="$cid"/>]
5318      </dt>
5319      <dd>
5320        <xsl:apply-templates select="node()"/>
5321        <xsl:if test="@source"> --<xsl:value-of select="@source"/></xsl:if>
5322      </dd>
5323    </xsl:for-each>
5324  </dl>
5325</xsl:template>
5326
5327
5328<!-- Chapter Link Generation -->
5329
5330<xsl:template match="*" mode="links"><xsl:apply-templates mode="links"/></xsl:template>
5331<xsl:template match="text()" mode="links" />
5332
5333<xsl:template match="/*/middle//section[not(myns:unnumbered) and not(ancestor::section)]" mode="links">
5334  <xsl:variable name="sectionNumber"><xsl:call-template name="get-section-number" /></xsl:variable>
5335  <link rel="Chapter" title="{$sectionNumber} {@title}" href="#{$anchor-prefix}.section.{$sectionNumber}" />
5336  <xsl:apply-templates mode="links" />
5337</xsl:template>
5338
5339<xsl:template match="/*/back//section[not(myns:unnumbered) and not(ancestor::section)]" mode="links">
5340  <xsl:variable name="sectionNumber"><xsl:call-template name="get-section-number" /></xsl:variable>
5341  <link rel="Appendix" title="{$sectionNumber} {@title}" href="#{$anchor-prefix}.section.{$sectionNumber}" />
5342  <xsl:apply-templates mode="links" />
5343</xsl:template>
5344
5345<xsl:template match="/*/back/references[position()=1]" mode="links">
5346  <xsl:variable name="sectionNumber"><xsl:call-template name="get-references-section-number" /></xsl:variable>
5347  <link rel="Chapter" href="#{$anchor-prefix}.section.{$sectionNumber}">
5348    <xsl:choose>
5349      <xsl:when test="@title and count(/*/back/references)=1">
5350        <xsl:attribute name="title">
5351          <xsl:call-template name="get-references-section-number"/>
5352          <xsl:text> </xsl:text>
5353          <xsl:value-of select="@title"/>
5354        </xsl:attribute>
5355      </xsl:when>
5356      <xsl:otherwise>
5357        <xsl:attribute name="title">
5358          <xsl:call-template name="get-references-section-number"/>
5359          <xsl:text> References</xsl:text>
5360        </xsl:attribute>
5361      </xsl:otherwise>
5362    </xsl:choose>
5363  </link>
5364</xsl:template>
5365
5366<!-- convenience templates -->
5367
5368<xsl:template name="get-author-summary">
5369  <xsl:choose>
5370    <xsl:when test="count(/rfc/front/author)=1">
5371      <xsl:value-of select="/rfc/front/author[1]/@surname" />
5372    </xsl:when>
5373    <xsl:when test="count(/rfc/front/author)=2">
5374      <xsl:value-of select="concat(/rfc/front/author[1]/@surname,' &amp; ',/rfc/front/author[2]/@surname)" />
5375    </xsl:when>
5376    <xsl:otherwise>
5377      <xsl:value-of select="concat(/rfc/front/author[1]/@surname,', et al.')" />
5378    </xsl:otherwise>
5379  </xsl:choose>
5380</xsl:template>
5381
5382<xsl:template name="get-category-long">
5383  <xsl:choose>
5384    <xsl:when test="$xml2rfc-footer"><xsl:value-of select="$xml2rfc-footer" /></xsl:when>
5385    <xsl:when test="$xml2rfc-private"/> <!-- private draft, footer not set -->
5386    <xsl:when test="/rfc/@category='bcp'">Best Current Practice</xsl:when>
5387    <xsl:when test="/rfc/@category='historic'">Historic</xsl:when>
5388    <xsl:when test="/rfc/@category='info' or not(/rfc/@category)">Informational</xsl:when>
5389    <xsl:when test="/rfc/@category='std'">Standards Track</xsl:when>
5390    <xsl:when test="/rfc/@category='exp'">Experimental</xsl:when>
5391    <xsl:otherwise>(category unknown)</xsl:otherwise>
5392  </xsl:choose>
5393</xsl:template>
5394
5395<xsl:template name="get-header-center">
5396  <xsl:choose>
5397    <xsl:when test="string-length(/rfc/front/title/@abbrev) &gt; 0">
5398      <xsl:value-of select="/rfc/front/title/@abbrev" />
5399    </xsl:when>
5400    <xsl:otherwise>
5401      <xsl:apply-templates select="/rfc/front/title" mode="get-text-content" />
5402    </xsl:otherwise>
5403  </xsl:choose>
5404</xsl:template>
5405
5406<xsl:template name="get-header-left">
5407  <xsl:choose>
5408    <xsl:when test="$xml2rfc-header"><xsl:value-of select="$xml2rfc-header" /></xsl:when>
5409    <xsl:when test="$xml2rfc-private"/> <!-- private draft, header not set -->
5410    <xsl:when test="/rfc/@ipr and not(/rfc/@number)">INTERNET DRAFT</xsl:when>
5411    <xsl:otherwise>RFC <xsl:value-of select="/rfc/@number"/></xsl:otherwise>
5412  </xsl:choose>
5413</xsl:template>
5414
5415<xsl:template name="get-generator">
5416  <xsl:variable name="gen">
5417    <xsl:text>http://greenbytes.de/tech/webdav/rfc2629.xslt, </xsl:text>
5418    <!-- when RCS keyword substitution in place, add version info -->
5419    <xsl:if test="contains('$Revision: 1.438 $',':')">
5420      <xsl:value-of select="concat('Revision ',normalize-space(translate(substring-after('$Revision: 1.438 $', 'Revision: '),'$','')),', ')" />
5421    </xsl:if>
5422    <xsl:if test="contains('$Date: 2009-05-27 13:34:05 $',':')">
5423      <xsl:value-of select="concat(normalize-space(translate(substring-after('$Date: 2009-05-27 13:34:05 $', 'Date: '),'$','')),', ')" />
5424    </xsl:if>
5425    <xsl:value-of select="concat('XSLT vendor: ',system-property('xsl:vendor'),' ',system-property('xsl:vendor-url'))" />
5426  </xsl:variable>
5427  <xsl:value-of select="$gen" />
5428</xsl:template>
5429
5430<xsl:template name="get-header-right">
5431  <xsl:value-of select="concat($xml2rfc-ext-pub-month, ' ', $xml2rfc-ext-pub-year)" />
5432</xsl:template>
5433
5434<xsl:template name="get-keywords">
5435  <xsl:variable name="keyw">
5436    <xsl:for-each select="/rfc/front/keyword">
5437      <xsl:value-of select="translate(.,',',' ')" />
5438      <xsl:if test="position()!=last()">, </xsl:if>
5439    </xsl:for-each>
5440  </xsl:variable>
5441  <xsl:value-of select="normalize-space($keyw)" />
5442</xsl:template>
5443
5444<!-- get language from context node. nearest ancestor or return the default of "en" -->
5445<xsl:template name="get-lang">
5446  <xsl:choose>
5447    <xsl:when test="ancestor-or-self::*[@xml:lang]"><xsl:value-of select="ancestor-or-self::*/@xml:lang" /></xsl:when>
5448    <xsl:otherwise>en</xsl:otherwise>
5449  </xsl:choose>
5450</xsl:template>
5451
5452<xsl:template name="get-section-number">
5453  <xsl:variable name="anchor" select="@anchor"/>
5454  <xsl:choose>
5455    <xsl:when test="@x:fixed-section-number">
5456      <xsl:value-of select="@x:fixed-section-number"/>
5457    </xsl:when>
5458    <xsl:when test="$has-edits or ancestor::*/@x:fixed-section-number">
5459      <xsl:call-template name="sectionnumberAndEdits" />
5460    </xsl:when>
5461    <xsl:otherwise>
5462      <xsl:choose>
5463        <xsl:when test="self::references">
5464          <xsl:choose>
5465            <xsl:when test="count(/*/back/references)=1">
5466              <xsl:call-template name="get-references-section-number"/>
5467            </xsl:when>
5468            <xsl:otherwise>
5469              <xsl:call-template name="get-references-section-number"/>.<xsl:number count="references"/>
5470            </xsl:otherwise>
5471          </xsl:choose>
5472        </xsl:when>
5473        <xsl:when test="self::reference">
5474          <xsl:for-each select="parent::references">
5475            <xsl:choose>
5476              <xsl:when test="count(/*/back/references)=1">
5477                <xsl:call-template name="get-references-section-number"/>
5478              </xsl:when>
5479              <xsl:otherwise>
5480                <xsl:call-template name="get-references-section-number"/>.<xsl:number count="references"/>
5481              </xsl:otherwise>
5482            </xsl:choose>
5483          </xsl:for-each>
5484        </xsl:when>
5485        <xsl:when test="ancestor::reference">
5486          <xsl:for-each select="ancestor::reference">
5487            <xsl:call-template name="get-section-number"/>
5488          </xsl:for-each>
5489        </xsl:when>
5490        <xsl:when test="ancestor::back"><xsl:number count="section|appendix" level="multiple" format="A.1.1.1.1.1.1.1" /></xsl:when>
5491        <xsl:when test="self::appendix"><xsl:number count="appendix" level="multiple" format="A.1.1.1.1.1.1.1" /></xsl:when>
5492        <xsl:otherwise><xsl:number count="section" level="multiple"/></xsl:otherwise>
5493      </xsl:choose>
5494    </xsl:otherwise>
5495  </xsl:choose>
5496</xsl:template>
5497
5498<!-- get the section number for the references section -->
5499<xsl:template name="get-references-section-number">
5500  <xsl:value-of select="count(/rfc/middle/section) + count(/rfc/middle/ed:replace/ed:ins/section) + 1"/>
5501</xsl:template>
5502
5503<xsl:template name="emit-section-number">
5504  <xsl:param name="no"/>
5505  <xsl:value-of select="$no"/><xsl:if test="not(contains($no,'.')) or $xml2rfc-ext-sec-no-trailing-dots='yes'">.</xsl:if>
5506</xsl:template>
5507
5508<xsl:template name="get-section-type">
5509  <xsl:param name="prec" /> <!-- TODO: check this, it's unused -->
5510  <xsl:choose>
5511    <xsl:when test="ancestor::back">Appendix</xsl:when>
5512    <xsl:otherwise>Section</xsl:otherwise>
5513  </xsl:choose>
5514</xsl:template>
5515
5516<xsl:template name="get-table-anchor">
5517  <xsl:value-of select="$anchor-prefix"/>
5518  <xsl:text>.table.</xsl:text>
5519  <xsl:choose>
5520    <xsl:when test="@title!='' or @anchor!=''">
5521      <xsl:number level="any" count="texttable[@title!='' or @anchor!='']" />
5522    </xsl:when>
5523    <xsl:otherwise>
5524      <xsl:text>u.</xsl:text>
5525      <xsl:number level="any" count="texttable[not(@title!='' or @anchor!='')]" />
5526    </xsl:otherwise>
5527  </xsl:choose>
5528</xsl:template>
5529
5530<xsl:template name="get-figure-anchor">
5531  <xsl:value-of select="$anchor-prefix"/>
5532  <xsl:text>.figure.</xsl:text>
5533  <xsl:choose>
5534    <xsl:when test="@title!='' or @anchor!=''">
5535      <xsl:number level="any" count="figure[@title!='' or @anchor!='']" />
5536    </xsl:when>
5537    <xsl:otherwise>
5538      <xsl:text>u.</xsl:text>
5539      <xsl:number level="any" count="figure[not(@title!='' or @anchor!='')]" />
5540    </xsl:otherwise>
5541  </xsl:choose>
5542</xsl:template>
5543
5544<!-- reformat contents of author/@initials -->
5545<xsl:template name="format-initials">
5546  <xsl:choose>
5547    <xsl:when test="string-length(@initials)=1">
5548      <xsl:value-of select="concat(@initials,'.')"/>
5549    </xsl:when>
5550    <xsl:otherwise>
5551      <xsl:value-of select="@initials"/>
5552    </xsl:otherwise>
5553  </xsl:choose>
5554</xsl:template>
5555
5556<!-- checking for email element -->
5557<xsl:template name="extract-email">
5558  <xsl:variable name="email" select="normalize-space(.)"/>
5559  <xsl:if test="string-length(.) != string-length($email) or contains($email,' ')">
5560    <xsl:call-template name="warning">
5561      <xsl:with-param name="inline" select="'no'"/>
5562      <xsl:with-param name="msg">excessive whitespace in email address: '<xsl:value-of select="."/>'</xsl:with-param>
5563    </xsl:call-template>
5564  </xsl:if>
5565 
5566  <xsl:variable name="email2">
5567    <xsl:choose>
5568      <xsl:when test="starts-with($email,'mailto:')">
5569        <xsl:call-template name="warning">
5570          <xsl:with-param name="inline" select="'no'"/>
5571          <xsl:with-param name="msg">email should not include URI scheme: '<xsl:value-of select="."/>'</xsl:with-param>
5572        </xsl:call-template>
5573        <xsl:value-of select="substring($email, 1 + string-length('mailto:'))"/>
5574      </xsl:when>
5575      <xsl:otherwise>
5576        <xsl:value-of select="$email"/>
5577      </xsl:otherwise>
5578    </xsl:choose>
5579  </xsl:variable>
5580 
5581  <xsl:value-of select="$email2"/>
5582</xsl:template>
5583
5584<!-- checking for uri element -->
5585<xsl:template name="extract-uri">
5586  <xsl:variable name="uri" select="normalize-space(.)"/>
5587  <xsl:if test="string-length(.) != string-length($uri) or contains($uri,' ')">
5588    <xsl:call-template name="warning">
5589      <xsl:with-param name="inline" select="'no'"/>
5590      <xsl:with-param name="msg">excessive whitespace in URI: '<xsl:value-of select="."/>'</xsl:with-param>
5591    </xsl:call-template>
5592  </xsl:if>
5593 
5594  <xsl:value-of select="$uri"/>
5595</xsl:template>
5596
5597<xsl:template name="insert-conditional-pagebreak">
5598  <xsl:if test="$xml2rfc-compact!='yes'">
5599    <xsl:attribute name="class">np</xsl:attribute>
5600  </xsl:if>
5601</xsl:template>
5602
5603<xsl:template name="insert-conditional-hrule">
5604  <xsl:if test="$xml2rfc-compact!='yes'">
5605    <hr class="noprint" />
5606  </xsl:if>
5607</xsl:template>
5608
5609<!-- get text content from marked-up text -->
5610
5611<xsl:template match="text()" mode="get-text-content">
5612  <xsl:value-of select="."/>
5613</xsl:template>
5614
5615<xsl:template match="*" mode="get-text-content">
5616  <xsl:apply-templates mode="get-text-content"/>
5617</xsl:template>
5618
5619<xsl:template match="ed:del" mode="get-text-content">
5620</xsl:template>
5621
5622<!-- diag support -->
5623<xsl:template name="lineno">
5624  <xsl:if test="function-available('saxon-old:line-number')">
5625    <xsl:if test="saxon-old:line-number() > 0">
5626      <xsl:text> (at line </xsl:text>
5627      <xsl:value-of select="saxon-old:line-number()"/>
5628      <xsl:text>)</xsl:text>
5629    </xsl:if>
5630  </xsl:if>
5631  <xsl:if test="function-available('saxon:line-number')">
5632    <xsl:if test="saxon:line-number() > 0">
5633      <xsl:text> (at line </xsl:text>
5634      <xsl:value-of select="saxon:line-number()"/>
5635      <xsl:text>)</xsl:text>
5636    </xsl:if>
5637  </xsl:if>
5638</xsl:template>
5639
5640<!-- define exslt:node-set for msxml -->       
5641<msxsl:script language="JScript" implements-prefix="exslt">
5642  this['node-set'] = function (x) {
5643    return x;
5644  }
5645</msxsl:script>
5646
5647<!-- date handling -->
5648
5649<msxsl:script language="JScript" implements-prefix="date">
5650  this['year'] = function (x) {
5651    if (x) {throw "not supported"};
5652    return (new Date()).getFullYear();
5653  }
5654
5655  this['month-in-year'] = function (x) {
5656    if (x) {throw "not supported"};
5657    return 1 + (new Date()).getMonth();
5658  }
5659
5660  this['day-in-month'] = function (x) {
5661    if (x) {throw "not supported"};
5662    return (new Date()).getDate();
5663  }
5664</msxsl:script>
5665
5666<xsl:variable name="may-default-dates">
5667  <xsl:choose>
5668    <xsl:when test="function-available('date:year') and function-available('date:month-in-year') and date:day-in-month()">
5669      <xsl:variable name="year-specified" select="/rfc/front/date/@year and /rfc/front/date/@year!=''"/>
5670      <xsl:variable name="month-specified" select="/rfc/front/date/@month and /rfc/front/date/@month!=''"/>
5671      <xsl:variable name="day-specified" select="/rfc/front/date/@day and /rfc/front/date/@day!=''"/>
5672      <xsl:variable name="system-month">
5673        <xsl:call-template name="get-month-as-name">
5674          <xsl:with-param name="month" select="date:month-in-year()"/>
5675        </xsl:call-template>
5676      </xsl:variable>
5677      <xsl:choose>
5678        <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>
5679        <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>
5680        <xsl:when test="$day-specified and /rfc/front/date/@day!=date:day-in-month()">Specified day does not match system date</xsl:when>
5681        <xsl:when test="not($year-specified) and ($month-specified or $day-specified)">Can't default year when month or day is specified</xsl:when>
5682        <xsl:when test="not($month-specified) and $day-specified">Can't default month when day is specified</xsl:when>
5683        <xsl:otherwise>yes</xsl:otherwise>
5684      </xsl:choose>
5685    </xsl:when>
5686    <!-- may, but won't -->
5687    <xsl:otherwise>yes</xsl:otherwise> 
5688  </xsl:choose>
5689</xsl:variable>
5690
5691<xsl:param name="xml2rfc-ext-pub-year">
5692  <xsl:choose>
5693    <xsl:when test="/rfc/front/date/@year and /rfc/front/date/@year!=''">
5694      <xsl:value-of select="/rfc/front/date/@year"/>
5695    </xsl:when>
5696    <xsl:when test="function-available('date:year')">
5697      <xsl:if test="/rfc/front/date/@month and /rfc/front/date/@month!=''">
5698        <xsl:call-template name="error">
5699          <xsl:with-param name="msg" select="'defaulting publication year although month was specified'"/>
5700        </xsl:call-template>
5701      </xsl:if>
5702      <xsl:if test="/rfc/front/date/@day and /rfc/front/date/@day!=''">
5703        <xsl:call-template name="error">
5704          <xsl:with-param name="msg" select="'defaulting publication year although day was specified'"/>
5705        </xsl:call-template>
5706      </xsl:if>
5707      <xsl:value-of select="date:year()"/>
5708    </xsl:when>
5709    <xsl:otherwise>
5710      <xsl:call-template name="error">
5711        <xsl:with-param name="msg" select="'/rfc/front/date/@year missing (and XSLT processor cannot compute the system date)'"/>
5712      </xsl:call-template>
5713    </xsl:otherwise>
5714  </xsl:choose>
5715</xsl:param>
5716
5717<xsl:param name="xml2rfc-ext-pub-month">
5718  <xsl:choose>
5719    <xsl:when test="/rfc/front/date/@month and /rfc/front/date/@month!=''">
5720      <xsl:value-of select="/rfc/front/date/@month"/>
5721    </xsl:when>
5722    <xsl:when test="function-available('date:month-in-year') and $may-default-dates='yes'">
5723      <xsl:call-template name="get-month-as-name">
5724        <xsl:with-param name="month" select="date:month-in-year()"/>
5725      </xsl:call-template>
5726    </xsl:when>
5727    <xsl:when test="function-available('date:month-in-year') and $may-default-dates!='yes'">
5728      <xsl:call-template name="warning">
5729        <xsl:with-param name="inline" select="'no'"/>
5730        <xsl:with-param name="msg" select="$may-default-dates"/>
5731      </xsl:call-template>
5732    </xsl:when>
5733    <xsl:otherwise>
5734      <xsl:call-template name="error">
5735        <xsl:with-param name="msg" select="'/rfc/front/date/@month missing (and XSLT processor cannot compute the system date)'"/>
5736      </xsl:call-template>
5737    </xsl:otherwise>
5738  </xsl:choose>
5739</xsl:param>
5740
5741<xsl:param name="xml2rfc-ext-pub-month-numeric">
5742  <xsl:call-template name="get-month-as-num">
5743    <xsl:with-param name="month" select="$xml2rfc-ext-pub-month" />
5744  </xsl:call-template>
5745</xsl:param>
5746
5747<xsl:param name="xml2rfc-ext-pub-day">
5748  <xsl:choose>
5749    <xsl:when test="/rfc/front/date/@day and /rfc/front/date/@day!=''">
5750      <xsl:value-of select="/rfc/front/date/@day"/>
5751    </xsl:when>
5752    <xsl:when test="function-available('date:day-in-month') and $may-default-dates='yes'">
5753      <xsl:value-of select="date:day-in-month()"/>
5754    </xsl:when>
5755    <xsl:otherwise /> <!-- harmless, we just don't have it -->
5756  </xsl:choose>
5757</xsl:param>
5758
5759</xsl:transform>
Note: See TracBrowser for help on using the repository browser.