source: rfc2629xslt/rfc2629.xslt @ 754

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

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

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