source: rfc2629xslt/rfc2629.xslt @ 971

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

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

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