source: rfc2629xslt/rfc2629.xslt @ 830

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

latest versions of rfc2629.xslt and xml2rfc.tcl, bump up document dates

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