source: rfc2629xslt/rfc2629.xslt @ 329

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

update to latest version of rfc2629.xslt

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