source: rfc2629xslt/rfc2629.xslt @ 285

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

Upgrade to latest version of rfc2629.xslt

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