source: rfc2629xslt/rfc2629.xslt @ 981

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

bump up document dates, update to latest version of rfc2629.xslt

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