source: rfc2629xslt/rfc2629.xslt @ 764

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

latest version of rfc2629.xslt, bump up document dates

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