source: rfc2629xslt/rfc2629.xslt @ 929

Last change on this file since 929 was 832, 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.4 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:choose>
2821    <xsl:when test="$xml2rfc-ext-pub-day >= 1">
2822      <xsl:call-template name="normalize-date">
2823        <xsl:with-param name="year" select="$xml2rfc-ext-pub-year"/>
2824        <xsl:with-param name="month" select="$pub-month-numeric"/>
2825        <xsl:with-param name="day" select="$xml2rfc-ext-pub-day + 185"/>
2826      </xsl:call-template>
2827    </xsl:when>
2828    <xsl:when test="$xml2rfc-ext-pub-month='January'">July <xsl:value-of select="$xml2rfc-ext-pub-year" /></xsl:when>
2829    <xsl:when test="$xml2rfc-ext-pub-month='February'">August <xsl:value-of select="$xml2rfc-ext-pub-year" /></xsl:when>
2830    <xsl:when test="$xml2rfc-ext-pub-month='March'">September <xsl:value-of select="$xml2rfc-ext-pub-year" /></xsl:when>
2831    <xsl:when test="$xml2rfc-ext-pub-month='April'">October <xsl:value-of select="$xml2rfc-ext-pub-year" /></xsl:when>
2832    <xsl:when test="$xml2rfc-ext-pub-month='May'">November <xsl:value-of select="$xml2rfc-ext-pub-year" /></xsl:when>
2833    <xsl:when test="$xml2rfc-ext-pub-month='June'">December <xsl:value-of select="$xml2rfc-ext-pub-year" /></xsl:when>
2834    <xsl:when test="$xml2rfc-ext-pub-month='July'">January <xsl:value-of select="$xml2rfc-ext-pub-year + 1" /></xsl:when>
2835    <xsl:when test="$xml2rfc-ext-pub-month='August'">February <xsl:value-of select="$xml2rfc-ext-pub-year + 1" /></xsl:when>
2836    <xsl:when test="$xml2rfc-ext-pub-month='September'">March <xsl:value-of select="$xml2rfc-ext-pub-year + 1" /></xsl:when>
2837    <xsl:when test="$xml2rfc-ext-pub-month='October'">April <xsl:value-of select="$xml2rfc-ext-pub-year + 1" /></xsl:when>
2838    <xsl:when test="$xml2rfc-ext-pub-month='November'">May <xsl:value-of select="$xml2rfc-ext-pub-year + 1" /></xsl:when>
2839    <xsl:when test="$xml2rfc-ext-pub-month='December'">June <xsl:value-of select="$xml2rfc-ext-pub-year + 1" /></xsl:when>
2840      <xsl:otherwise>WRONG SYNTAX FOR MONTH</xsl:otherwise>
2841   </xsl:choose>
2842</xsl:template>
2843
2844<xsl:template name="normalize-date">
2845  <xsl:param name="year"/>
2846  <xsl:param name="month"/>
2847  <xsl:param name="day"/>
2848
2849  <xsl:variable name="isleap" select="(($year mod 4) = 0 and ($year mod 100 != 0)) or ($year mod 400) = 0" />
2850
2851  <!--<xsl:message>
2852    <xsl:value-of select="concat($year,' ',$month,' ',$day)"/>
2853  </xsl:message>-->
2854 
2855  <xsl:variable name="dim">
2856    <xsl:choose>
2857      <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>
2858      <xsl:when test="$month=2 and $isleap">29</xsl:when>
2859      <xsl:when test="$month=2 and not($isleap)">28</xsl:when>
2860      <xsl:otherwise>30</xsl:otherwise>
2861    </xsl:choose>
2862  </xsl:variable>
2863 
2864  <xsl:choose>
2865    <xsl:when test="$day > $dim and $month=12">
2866      <xsl:call-template name="normalize-date">
2867        <xsl:with-param name="year" select="$year + 1"/>
2868        <xsl:with-param name="month" select="1"/>
2869        <xsl:with-param name="day" select="$day - $dim"/>
2870      </xsl:call-template>
2871    </xsl:when>
2872    <xsl:when test="$day > $dim">
2873      <xsl:call-template name="normalize-date">
2874        <xsl:with-param name="year" select="$year"/>
2875        <xsl:with-param name="month" select="$month + 1"/>
2876        <xsl:with-param name="day" select="$day - $dim"/>
2877      </xsl:call-template>
2878    </xsl:when>
2879    <xsl:otherwise>
2880      <xsl:call-template name="get-month-as-name">
2881        <xsl:with-param name="month" select="$month"/>
2882      </xsl:call-template>
2883      <xsl:value-of select="concat(' ',$day,', ',$year)"/>
2884    </xsl:otherwise>
2885  </xsl:choose>
2886
2887</xsl:template>
2888 
2889<xsl:template name="get-month-as-num">
2890  <xsl:param name="month" />
2891  <xsl:choose>
2892    <xsl:when test="$month='January'">01</xsl:when>
2893    <xsl:when test="$month='February'">02</xsl:when>
2894    <xsl:when test="$month='March'">03</xsl:when>
2895    <xsl:when test="$month='April'">04</xsl:when>
2896    <xsl:when test="$month='May'">05</xsl:when>
2897    <xsl:when test="$month='June'">06</xsl:when>
2898    <xsl:when test="$month='July'">07</xsl:when>
2899    <xsl:when test="$month='August'">08</xsl:when>
2900    <xsl:when test="$month='September'">09</xsl:when>
2901    <xsl:when test="$month='October'">10</xsl:when>
2902    <xsl:when test="$month='November'">11</xsl:when>
2903    <xsl:when test="$month='December'">12</xsl:when>
2904    <xsl:otherwise>WRONG SYNTAX FOR MONTH</xsl:otherwise>
2905  </xsl:choose>
2906</xsl:template>
2907
2908<xsl:template name="get-month-as-name">
2909  <xsl:param name="month"/>
2910  <xsl:choose>
2911    <xsl:when test="$month=1">January</xsl:when>
2912    <xsl:when test="$month=2">February</xsl:when>
2913    <xsl:when test="$month=3">March</xsl:when>
2914    <xsl:when test="$month=4">April</xsl:when>
2915    <xsl:when test="$month=5">May</xsl:when>
2916    <xsl:when test="$month=6">June</xsl:when>
2917    <xsl:when test="$month=7">July</xsl:when>
2918    <xsl:when test="$month=8">August</xsl:when>
2919    <xsl:when test="$month=9">September</xsl:when>
2920    <xsl:when test="$month=10">October</xsl:when>
2921    <xsl:when test="$month=11">November</xsl:when>
2922    <xsl:when test="$month=12">December</xsl:when>
2923    <xsl:otherwise>WRONG SYNTAX FOR MONTH</xsl:otherwise>
2924   </xsl:choose>
2925</xsl:template>
2926
2927<!-- produce back section with author information -->
2928<xsl:template name="get-authors-section-title">
2929  <xsl:choose>
2930    <xsl:when test="count(/rfc/front/author)=1">Author's Address</xsl:when>
2931    <xsl:otherwise>Authors' Addresses</xsl:otherwise>
2932  </xsl:choose>
2933</xsl:template>
2934
2935<xsl:template name="get-authors-section-number">
2936  <xsl:if test="/*/x:assign-section-number[@builtin-target='authors']">
2937    <xsl:value-of select="/*/x:assign-section-number[@builtin-target='authors']/@number"/>
2938  </xsl:if>
2939</xsl:template>
2940
2941<xsl:template name="insertAuthors">
2942
2943  <xsl:variable name="number">
2944    <xsl:call-template name="get-authors-section-number"/>
2945  </xsl:variable>
2946   
2947  <xsl:if test="$number!='suppress'">
2948    <xsl:call-template name="insert-conditional-hrule"/>
2949   
2950    <div class="avoidbreak">
2951      <h1 id="{$anchor-prefix}.authors">
2952        <xsl:call-template name="insert-conditional-pagebreak"/>
2953        <xsl:if test="$number != ''">
2954          <a href="#{$anchor-prefix}.section.{$number}" id="{$anchor-prefix}.section.{$number}"><xsl:value-of select="$number"/>.</a>
2955          <xsl:text> </xsl:text>
2956        </xsl:if>
2957        <a href="#{$anchor-prefix}.authors"><xsl:call-template name="get-authors-section-title"/></a>
2958      </h1>
2959   
2960      <xsl:apply-templates select="/rfc/front/author" />
2961    </div>
2962  </xsl:if>
2963</xsl:template>
2964
2965
2966
2967<!-- insert copyright statement -->
2968
2969<xsl:template name="insertCopyright" myns:namespaceless-elements="xml2rfc">
2970
2971  <xsl:if test="not($no-copylong)">
2972    <section title="Full Copyright Statement" anchor="{$anchor-prefix}.copyright" myns:unnumbered="unnumbered" myns:notoclink="notoclink">
2973      <xsl:choose>
2974        <xsl:when test="$ipr-rfc3667">
2975          <t>
2976            <xsl:choose>
2977              <xsl:when test="$ipr-rfc4748">
2978                Copyright &#169; The IETF Trust (<xsl:value-of select="$xml2rfc-ext-pub-year" />).
2979              </xsl:when>
2980              <xsl:otherwise>
2981                Copyright &#169; The Internet Society (<xsl:value-of select="$xml2rfc-ext-pub-year" />).
2982              </xsl:otherwise>
2983            </xsl:choose>
2984          </t>
2985          <t>
2986            This document is subject to the rights, licenses and restrictions
2987            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
2988            retain all their rights.
2989          </t>
2990          <t>
2991            This document and the information contained herein are provided
2992            on an &#8220;AS IS&#8221; basis and THE CONTRIBUTOR,
2993            THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY),
2994            THE INTERNET SOCIETY<xsl:if test="$ipr-rfc4748">, THE IETF TRUST</xsl:if>
2995            AND THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES,
2996            EXPRESS OR IMPLIED,
2997            INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
2998            INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
2999            WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
3000          </t>
3001        </xsl:when>
3002        <xsl:otherwise>
3003          <!-- <http://tools.ietf.org/html/rfc2026#section-10.4> -->
3004          <t>
3005            Copyright &#169; The Internet Society (<xsl:value-of select="$xml2rfc-ext-pub-year" />). All Rights Reserved.
3006          </t>
3007          <t>
3008            This document and translations of it may be copied and furnished to
3009            others, and derivative works that comment on or otherwise explain it
3010            or assist in its implementation may be prepared, copied, published and
3011            distributed, in whole or in part, without restriction of any kind,
3012            provided that the above copyright notice and this paragraph are
3013            included on all such copies and derivative works. However, this
3014            document itself may not be modified in any way, such as by removing
3015            the copyright notice or references to the Internet Society or other
3016            Internet organizations, except as needed for the purpose of
3017            developing Internet standards in which case the procedures for
3018            copyrights defined in the Internet Standards process must be
3019            followed, or as required to translate it into languages other than
3020            English.
3021          </t>
3022          <t>
3023            The limited permissions granted above are perpetual and will not be
3024            revoked by the Internet Society or its successors or assigns.
3025          </t>
3026          <t>
3027            This document and the information contained herein is provided on an
3028            &#8220;AS IS&#8221; basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
3029            TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
3030            BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
3031            HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
3032            MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
3033          </t>
3034        </xsl:otherwise>
3035      </xsl:choose>
3036    </section>
3037   
3038    <section title="Intellectual Property" anchor="{$anchor-prefix}.ipr" myns:unnumbered="unnumbered">
3039      <xsl:choose>
3040        <xsl:when test="$ipr-rfc3667">
3041          <t>
3042            The IETF takes no position regarding the validity or scope of any
3043            Intellectual Property Rights or other rights that might be claimed to
3044            pertain to the implementation or use of the technology described in
3045            this document or the extent to which any license under such rights
3046            might or might not be available; nor does it represent that it has
3047            made any independent effort to identify any such rights.  Information
3048            on the procedures with respect to rights in RFC documents
3049            can be found in BCP 78 and BCP 79.
3050          </t>       
3051          <t>
3052            Copies of IPR disclosures made to the IETF Secretariat and any
3053            assurances of licenses to be made available, or the result of an
3054            attempt made to obtain a general license or permission for the use
3055            of such proprietary rights by implementers or users of this
3056            specification can be obtained from the IETF on-line IPR repository
3057            at <eref target="http://www.ietf.org/ipr">http://www.ietf.org/ipr</eref>.
3058          </t>       
3059          <t>
3060            The IETF invites any interested party to bring to its attention any
3061            copyrights, patents or patent applications, or other proprietary
3062            rights that may cover technology that may be required to implement
3063            this standard. Please address the information to the IETF at
3064            <eref target="mailto:ietf-ipr@ietf.org">ietf-ipr@ietf.org</eref>.
3065          </t>       
3066        </xsl:when>
3067        <xsl:otherwise>
3068          <t>
3069            The IETF takes no position regarding the validity or scope of
3070            any intellectual property or other rights that might be claimed
3071            to  pertain to the implementation or use of the technology
3072            described in this document or the extent to which any license
3073            under such rights might or might not be available; neither does
3074            it represent that it has made any effort to identify any such
3075            rights. Information on the IETF's procedures with respect to
3076            rights in standards-track and standards-related documentation
3077            can be found in BCP-11. Copies of claims of rights made
3078            available for publication and any assurances of licenses to
3079            be made available, or the result of an attempt made
3080            to obtain a general license or permission for the use of such
3081            proprietary rights by implementors or users of this
3082            specification can be obtained from the IETF Secretariat.
3083          </t>
3084          <t>
3085            The IETF invites any interested party to bring to its
3086            attention any copyrights, patents or patent applications, or
3087            other proprietary rights which may cover technology that may be
3088            required to practice this standard. Please address the
3089            information to the IETF Executive Director.
3090          </t>
3091          <xsl:if test="$xml2rfc-iprnotified='yes'">
3092            <t>
3093              The IETF has been notified of intellectual property rights
3094              claimed in regard to some or all of the specification contained
3095              in this document. For more information consult the online list
3096              of claimed rights.
3097            </t>
3098          </xsl:if>
3099        </xsl:otherwise>
3100      </xsl:choose>
3101    </section>
3102   
3103    <xsl:choose>
3104      <xsl:when test="$no-funding"/>
3105      <xsl:when test="$funding1 and /rfc/@number">
3106        <section myns:unnumbered="unnumbered" myns:notoclink="notoclink">
3107          <xsl:attribute name="title">
3108            <xsl:choose>
3109              <xsl:when test="$xml2rfc-rfcedstyle='yes'">Acknowledgement</xsl:when>
3110              <xsl:otherwise>Acknowledgment</xsl:otherwise>
3111            </xsl:choose>
3112          </xsl:attribute>
3113          <t>
3114            Funding for the RFC Editor function is provided by the IETF
3115            Administrative Support Activity (IASA).
3116          </t>
3117        </section>
3118      </xsl:when>
3119      <xsl:when test="$funding0 and /rfc/@number">
3120        <section myns:unnumbered="unnumbered" myns:notoclink="notoclink">
3121          <xsl:attribute name="title">
3122            <xsl:choose>
3123              <xsl:when test="$xml2rfc-rfcedstyle='yes'">Acknowledgement</xsl:when>
3124              <xsl:otherwise>Acknowledgment</xsl:otherwise>
3125            </xsl:choose>
3126          </xsl:attribute>
3127          <t>
3128            Funding for the RFC Editor function is currently provided by
3129            the Internet Society.
3130          </t>
3131        </section>
3132      </xsl:when>
3133      <xsl:otherwise/>
3134    </xsl:choose>
3135  </xsl:if>
3136
3137</xsl:template>
3138
3139
3140<!-- insert CSS style info -->
3141
3142<xsl:template name="insertCss">
3143<style type="text/css" title="Xml2Rfc (sans serif)">
3144a {
3145  text-decoration: none;
3146}
3147a.smpl {
3148  color: black;
3149}
3150a:hover {
3151  text-decoration: underline;
3152}
3153a:active {
3154  text-decoration: underline;
3155}
3156address {
3157  margin-top: 1em;
3158  margin-left: 2em;
3159  font-style: normal;
3160}<xsl:if test="//x:blockquote">
3161blockquote {
3162  border-style: solid;
3163  border-color: gray;
3164  border-width: 0 0 0 .25em;
3165  font-style: italic;
3166  padding-left: 0.5em;
3167}</xsl:if>
3168body {<xsl:if test="$xml2rfc-background!=''">
3169  background: url(<xsl:value-of select="$xml2rfc-background" />) #ffffff left top;</xsl:if>
3170  color: black;
3171  font-family: verdana, helvetica, arial, sans-serif;
3172  font-size: 10pt;
3173}<xsl:if test="//xhtml:p">
3174br.p {
3175  line-height: 150%;
3176}</xsl:if>
3177cite {
3178  font-style: normal;
3179}<xsl:if test="//x:note">
3180div.note {
3181  margin-left: 2em;
3182}</xsl:if>
3183dd {
3184  margin-right: 2em;<xsl:if test="$xml2rfc-ext-justification='always'">
3185  text-align: justify;</xsl:if>
3186}
3187dl {
3188  margin-left: 2em;
3189}
3190<!-- spacing between two entries in definition lists -->
3191ul.empty {
3192  list-style-type: none;
3193}
3194ul.empty li {
3195  margin-top: .5em;
3196}
3197dl p {
3198  margin-left: 0em;
3199}
3200dt {
3201  margin-top: .5em;
3202}
3203h1 {
3204  font-size: 14pt;
3205  line-height: 21pt;
3206  page-break-after: avoid;
3207}
3208h1.np {
3209  page-break-before: always;
3210}
3211h1 a {
3212  color: #333333;
3213}
3214h2 {
3215  font-size: 12pt;
3216  line-height: 15pt;
3217  page-break-after: avoid;
3218}
3219h3, h4, h5, h6 {
3220  font-size: 10pt;
3221  page-break-after: avoid;
3222}
3223h2 a, h3 a, h4 a, h5 a, h6 a {
3224  color: black;
3225}
3226img {
3227  margin-left: 3em;
3228}
3229li {
3230  margin-left: 2em;
3231  margin-right: 2em;<xsl:if test="$xml2rfc-ext-justification='always'">
3232  text-align: justify;</xsl:if>
3233}
3234ol {
3235  margin-left: 2em;
3236  margin-right: 2em;
3237}
3238ol p {
3239  margin-left: 0em;
3240}<xsl:if test="//xhtml:q">
3241q {
3242  font-style: italic;
3243}</xsl:if>
3244p {
3245  margin-left: 2em;
3246  margin-right: 2em;<xsl:if test="$xml2rfc-ext-justification='always'">
3247  text-align: justify;</xsl:if>
3248}
3249pre {
3250  margin-left: 3em;
3251  background-color: lightyellow;
3252  padding: .25em;
3253}<xsl:if test="//artwork[@x:isCodeComponent='yes']"><!-- support "<CODE BEGINS>" and "<CODE ENDS>" markers-->
3254pre.ccmarker {
3255  background-color: white;
3256  color: gray;
3257}
3258pre.ccmarker > span {
3259  font-size: small;
3260}
3261pre.cct {
3262  margin-bottom: -1em;
3263}
3264pre.ccb {
3265  margin-top: -1em;
3266}</xsl:if>
3267pre.text2 {
3268  border-style: dotted;
3269  border-width: 1px;
3270  background-color: #f0f0f0;
3271  width: 69em;
3272}
3273pre.inline {
3274  background-color: white;
3275  padding: 0em;
3276}
3277pre.text {
3278  border-style: dotted;
3279  border-width: 1px;
3280  background-color: #f8f8f8;
3281  width: 69em;
3282}
3283pre.drawing {
3284  border-style: solid;
3285  border-width: 1px;
3286  background-color: #f8f8f8;
3287  padding: 2em;
3288}<xsl:if test="//x:q">
3289q {
3290  font-style: italic;
3291}</xsl:if>
3292<xsl:if test="//x:sup">
3293sup {
3294  font-size: 60%;
3295}</xsl:if>
3296table {
3297  margin-left: 2em;
3298}<xsl:if test="//texttable">
3299table.tt {
3300  vertical-align: top;
3301}
3302table.full {
3303  border-style: outset;
3304  border-width: 1px;
3305}
3306table.headers {
3307  border-style: outset;
3308  border-width: 1px;
3309}
3310table.tt td {
3311  vertical-align: top;
3312}
3313table.full td {
3314  border-style: inset;
3315  border-width: 1px;
3316}
3317table.tt th {
3318  vertical-align: top;
3319}
3320table.full th {
3321  border-style: inset;
3322  border-width: 1px;
3323}
3324table.headers th {
3325  border-style: none none inset none;
3326  border-width: 1px;
3327}
3328table.left {
3329  margin-right: auto;
3330}
3331table.right {
3332  margin-left: auto;
3333}
3334table.center {
3335  margin-left: auto;
3336  margin-right: auto;
3337}
3338caption {
3339  caption-side: bottom;
3340  font-weight: bold;
3341  font-size: 9pt;
3342  margin-top: .5em;
3343}
3344</xsl:if>
3345table.header {
3346  border-spacing: 1px;
3347  width: 95%;
3348  font-size: 10pt;
3349  color: white;
3350}
3351td.top {
3352  vertical-align: top;
3353}
3354td.topnowrap {
3355  vertical-align: top;
3356  white-space: nowrap;
3357}
3358table.header td {
3359  background-color: gray;
3360  width: 50%;
3361}<xsl:if test="/rfc/@obsoletes | /rfc/@updates">
3362table.header a {
3363  color: white;
3364}</xsl:if>
3365td.reference {
3366  vertical-align: top;
3367  white-space: nowrap;
3368  padding-right: 1em;
3369}
3370thead {
3371  display:table-header-group;
3372}
3373ul.toc {
3374  list-style: none;
3375  margin-left: 1.5em;
3376  margin-right: 0em;
3377  padding-left: 0em;
3378}
3379li.tocline0 {
3380  line-height: 150%;
3381  font-weight: bold;
3382  font-size: 10pt;
3383  margin-left: 0em;
3384  margin-right: 0em;
3385}
3386li.tocline1 {
3387  line-height: normal;
3388  font-weight: normal;
3389  font-size: 9pt;
3390  margin-left: 0em;
3391  margin-right: 0em;
3392}
3393li.tocline2 {
3394  font-size: 0pt;
3395}
3396ul p {
3397  margin-left: 0em;
3398}
3399<xsl:if test="$has-index">ul.ind {
3400  list-style: none;
3401  margin-left: 1.5em;
3402  margin-right: 0em;
3403  padding-left: 0em;
3404  page-break-before: avoid;
3405}
3406li.indline0 {
3407  font-weight: bold;
3408  line-height: 200%;
3409  margin-left: 0em;
3410  margin-right: 0em;
3411}
3412li.indline1 {
3413  font-weight: normal;
3414  line-height: 150%;
3415  margin-left: 0em;
3416  margin-right: 0em;
3417}
3418.avoidbreak {
3419  page-break-inside: avoid;
3420}
3421</xsl:if><xsl:if test="//x:bcp14">.bcp14 {
3422  font-style: normal;
3423  text-transform: lowercase;
3424  font-variant: small-caps;
3425}</xsl:if><xsl:if test="//x:blockquote">
3426blockquote > * .bcp14 {
3427  font-style: italic;
3428}</xsl:if>
3429.comment {
3430  background-color: yellow;
3431}<xsl:if test="$xml2rfc-editing='yes'">
3432.editingmark {
3433  background-color: khaki;
3434}</xsl:if>
3435.center {
3436  text-align: center;
3437}
3438.error {
3439  color: red;
3440  font-style: italic;
3441  font-weight: bold;
3442}
3443.figure {
3444  font-weight: bold;
3445  text-align: center;
3446  font-size: 9pt;
3447}
3448.filename {
3449  color: #333333;
3450  font-weight: bold;
3451  font-size: 12pt;
3452  line-height: 21pt;
3453  text-align: center;
3454}
3455.fn {
3456  font-weight: bold;
3457}
3458.hidden {
3459  display: none;
3460}
3461.left {
3462  text-align: left;
3463}
3464.right {
3465  text-align: right;
3466}
3467.title {
3468  color: #990000;
3469  font-size: 18pt;
3470  line-height: 18pt;
3471  font-weight: bold;
3472  text-align: center;
3473  margin-top: 36pt;
3474}
3475.vcardline {
3476  display: block;
3477}
3478.warning {
3479  font-size: 14pt;
3480  background-color: yellow;
3481}
3482<xsl:if test="$has-edits">del {
3483  color: red;
3484  text-decoration: line-through;
3485}
3486.del {
3487  color: red;
3488  text-decoration: line-through;
3489}
3490ins {
3491  color: green;
3492  text-decoration: underline;
3493}
3494.ins {
3495  color: green;
3496  text-decoration: underline;
3497}
3498div.issuepointer {
3499  float: left;
3500}</xsl:if><xsl:if test="//ed:issue">
3501table.openissue {
3502  background-color: khaki;
3503  border-width: thin;
3504  border-style: solid;
3505  border-color: black;
3506}
3507table.closedissue {
3508  background-color: white;
3509  border-width: thin;
3510  border-style: solid;
3511  border-color: gray;
3512  color: gray;
3513}
3514thead th {
3515  text-align: left;
3516}
3517.bg-issue {
3518  border: solid;
3519  border-width: 1px;
3520  font-size: 7pt;
3521}
3522.closed-issue {
3523  border: solid;
3524  border-width: thin;
3525  background-color: lime;
3526  font-size: smaller;
3527  font-weight: bold;
3528}
3529.open-issue {
3530  border: solid;
3531  border-width: thin;
3532  background-color: red;
3533  font-size: smaller;
3534  font-weight: bold;
3535}
3536.editor-issue {
3537  border: solid;
3538  border-width: thin;
3539  background-color: yellow;
3540  font-size: smaller;
3541  font-weight: bold;
3542}</xsl:if>
3543
3544@media print {
3545  .noprint {
3546    display: none;
3547  }
3548 
3549  a {
3550    color: black;
3551    text-decoration: none;
3552  }
3553
3554  table.header {
3555    width: 90%;
3556  }
3557
3558  td.header {
3559    width: 50%;
3560    color: black;
3561    background-color: white;
3562    vertical-align: top;
3563    font-size: 12pt;
3564  }
3565
3566  ul.toc a::after {
3567    content: leader('.') target-counter(attr(href), page);
3568  }
3569 
3570  a.iref {
3571    content: target-counter(attr(href), page);
3572  }
3573 
3574  .print2col {
3575    column-count: 2;
3576    -moz-column-count: 2;<!-- for Firefox -->
3577    column-fill: auto;<!-- for PrinceXML -->
3578  }
3579<xsl:if test="$xml2rfc-ext-justification='print'">
3580  dd {
3581    text-align: justify;
3582  }
3583  li {
3584    text-align: justify;
3585  }
3586  p {
3587    text-align: justify;
3588  }
3589</xsl:if>}
3590<xsl:choose><xsl:when test="$xml2rfc-ext-duplex='yes'">
3591@page:right {
3592  @top-left {
3593       content: "<xsl:call-template name="get-header-left"/>";
3594  }
3595  @top-right {
3596       content: "<xsl:call-template name="get-header-right"/>";
3597  }
3598  @top-center {
3599       content: "<xsl:call-template name="get-header-center"/>";
3600  }
3601  @bottom-left {
3602       content: "<xsl:call-template name="get-author-summary"/>";
3603  }
3604  @bottom-center {
3605       content: "<xsl:call-template name="get-category-long"/>";
3606  }
3607  @bottom-right {
3608       content: "[Page " counter(page) "]";
3609  }
3610}
3611@page:left {
3612  @top-left {
3613       content: "<xsl:call-template name="get-header-right"/>";
3614  }
3615  @top-right {
3616       content: "<xsl:call-template name="get-header-left"/>";
3617  }
3618  @top-center {
3619       content: "<xsl:call-template name="get-header-center"/>";
3620  }
3621  @bottom-left {
3622       content: "[Page " counter(page) "]";
3623  }
3624  @bottom-center {
3625       content: "<xsl:call-template name="get-category-long"/>";
3626  }
3627  @bottom-right {
3628       content: "<xsl:call-template name="get-author-summary"/>";
3629  }
3630}
3631</xsl:when><xsl:otherwise>
3632@page {
3633  @top-left {
3634       content: "<xsl:call-template name="get-header-left"/>";
3635  }
3636  @top-right {
3637       content: "<xsl:call-template name="get-header-right"/>";
3638  }
3639  @top-center {
3640       content: "<xsl:call-template name="get-header-center"/>";
3641  }
3642  @bottom-left {
3643       content: "<xsl:call-template name="get-author-summary"/>";
3644  }
3645  @bottom-center {
3646       content: "<xsl:call-template name="get-category-long"/>";
3647  }
3648  @bottom-right {
3649       content: "[Page " counter(page) "]";
3650  }
3651}
3652</xsl:otherwise></xsl:choose>
3653@page:first {
3654    @top-left {
3655      content: normal;
3656    }
3657    @top-right {
3658      content: normal;
3659    }
3660    @top-center {
3661      content: normal;
3662    }
3663}
3664</style>
3665</xsl:template>
3666
3667
3668<!-- generate the index section -->
3669
3670<xsl:template name="insertSingleIref">
3671  <xsl:choose>
3672    <xsl:when test="@ed:xref">
3673      <!-- special index generator mode -->
3674      <xsl:text>[</xsl:text>
3675      <a href="#{@ed:xref}"><xsl:value-of select="@ed:xref"/></a>
3676      <xsl:text>, </xsl:text>
3677      <a>
3678        <xsl:variable name="htmluri" select="//reference[@anchor=current()/@ed:xref]/format[@type='HTML']/@target"/>
3679        <xsl:if test="$htmluri">
3680          <xsl:attribute name="href"><xsl:value-of select="concat($htmluri,'#',@ed:frag)"/></xsl:attribute>
3681        </xsl:if>       
3682        <xsl:choose>
3683          <xsl:when test="@primary='true'"><b><xsl:value-of select="@ed:label" /></b></xsl:when>
3684          <xsl:otherwise><xsl:value-of select="@ed:label" /></xsl:otherwise>
3685        </xsl:choose>
3686      </a>
3687      <xsl:text>]</xsl:text>
3688      <xsl:if test="position()!=last()">, </xsl:if>
3689    </xsl:when>
3690    <xsl:otherwise>
3691      <xsl:variable name="_n">
3692        <xsl:call-template name="get-section-number" />
3693      </xsl:variable>
3694      <xsl:variable name="n">
3695        <xsl:choose>
3696          <xsl:when test="$_n!=''">
3697            <xsl:value-of select="$_n"/>
3698          </xsl:when>
3699          <xsl:otherwise>&#167;</xsl:otherwise>
3700        </xsl:choose>
3701      </xsl:variable>
3702      <xsl:variable name="backlink">
3703        <xsl:choose>
3704          <xsl:when test="self::xref">
3705            <xsl:variable name="target" select="@target"/>
3706            <xsl:text>#</xsl:text>
3707            <xsl:value-of select="$anchor-prefix"/>
3708            <xsl:text>.xref.</xsl:text>
3709            <xsl:value-of select="@target"/>.<xsl:number level="any" count="xref[@target=$target]"/>
3710          </xsl:when>
3711          <xsl:when test="self::iref">
3712            <xsl:text>#</xsl:text>
3713            <xsl:call-template name="compute-iref-anchor"/>
3714          </xsl:when>
3715          <xsl:when test="self::x:ref">
3716            <xsl:text>#</xsl:text>
3717            <xsl:call-template name="compute-extref-anchor"/>
3718          </xsl:when>
3719          <xsl:otherwise>
3720            <xsl:message>Unsupported element type for insertSingleIref</xsl:message>
3721          </xsl:otherwise>
3722        </xsl:choose>
3723      </xsl:variable>
3724      <a class="iref" href="{$backlink}">
3725        <xsl:call-template name="insertInsDelClass"/>
3726        <xsl:choose>
3727          <xsl:when test="@primary='true'"><b><xsl:value-of select="$n"/></b></xsl:when>
3728          <xsl:otherwise><xsl:value-of select="$n"/></xsl:otherwise>
3729        </xsl:choose>
3730      </a>
3731      <xsl:if test="position()!=last()">, </xsl:if>
3732    </xsl:otherwise>
3733  </xsl:choose>
3734</xsl:template>
3735
3736<xsl:template name="insertSingleXref">
3737  <xsl:variable name="_n">
3738    <xsl:call-template name="get-section-number" />
3739  </xsl:variable>
3740  <xsl:variable name="n">
3741    <xsl:choose>
3742      <xsl:when test="$_n!=''">
3743        <xsl:value-of select="$_n"/>
3744      </xsl:when>
3745      <xsl:otherwise>&#167;</xsl:otherwise>
3746    </xsl:choose>
3747  </xsl:variable>
3748  <xsl:choose>
3749    <xsl:when test="self::reference">
3750      <a class="iref" href="#{@anchor}">
3751        <xsl:call-template name="insertInsDelClass"/>
3752        <b><xsl:value-of select="$n"/></b>
3753      </a>
3754    </xsl:when>
3755    <xsl:otherwise>
3756      <xsl:variable name="target" select="@target"/>
3757      <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>
3758      <a class="iref" href="{$backlink}">
3759        <xsl:call-template name="insertInsDelClass"/>
3760        <xsl:value-of select="$n"/>
3761      </a>
3762    </xsl:otherwise>
3763  </xsl:choose>
3764  <xsl:if test="position()!=last()">, </xsl:if>
3765</xsl:template>
3766
3767<xsl:template name="insertIndex">
3768
3769  <xsl:call-template name="insert-conditional-hrule"/>
3770
3771  <h1 id="{$anchor-prefix}.index">
3772    <xsl:call-template name="insert-conditional-pagebreak"/>
3773    <a href="#{$anchor-prefix}.index">Index</a>
3774  </h1>
3775 
3776  <!-- generate navigation links to index subsections -->
3777  <p class="noprint">
3778    <xsl:variable name="irefs" select="//iref[generate-id(.) = generate-id(key('index-first-letter',translate(substring(@item,1,1),$lcase,$ucase)))]"/>
3779    <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)))]"/>
3780 
3781    <xsl:for-each select="$irefs | $xrefs">
3782   
3783      <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)" />
3784         
3785      <xsl:variable name="letter" select="translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase)"/>
3786
3787      <!-- character? -->
3788      <xsl:if test="translate($letter,concat($lcase,$ucase,'0123456789'),'')=''">
3789     
3790        <xsl:variable name="showit">
3791          <xsl:choose>
3792            <xsl:when test="$xml2rfc-ext-include-references-in-index!='yes'">
3793              <xsl:if test="$irefs[starts-with(translate(@item,$lcase,$ucase),$letter)]">
3794                <xsl:text>yes</xsl:text>
3795              </xsl:if>
3796            </xsl:when>
3797            <xsl:otherwise>
3798              <xsl:text>yes</xsl:text>
3799            </xsl:otherwise>
3800          </xsl:choose>
3801        </xsl:variable>
3802       
3803        <xsl:if test="$showit='yes'">
3804          <a href="#{$anchor-prefix}.index.{$letter}">
3805            <xsl:value-of select="$letter" />
3806          </a>
3807          <xsl:text> </xsl:text>
3808        </xsl:if>
3809     
3810      </xsl:if>
3811
3812    </xsl:for-each>
3813  </p>
3814
3815  <!-- for each index subsection -->
3816  <div class="print2col">
3817  <ul class="ind">
3818    <xsl:variable name="irefs2" select="//iref[generate-id(.) = generate-id(key('index-first-letter',translate(substring(@item,1,1),$lcase,$ucase)))]"/>
3819    <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)))]"/>
3820 
3821    <xsl:for-each select="$irefs2 | $xrefs2">
3822      <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)" />
3823      <xsl:variable name="letter" select="translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase)"/>
3824           
3825      <xsl:variable name="showit">
3826        <xsl:choose>
3827          <xsl:when test="$xml2rfc-ext-include-references-in-index!='yes'">
3828            <xsl:if test="$irefs2[starts-with(translate(@item,$lcase,$ucase),$letter)]">
3829              <xsl:text>yes</xsl:text>
3830            </xsl:if>
3831          </xsl:when>
3832          <xsl:otherwise>
3833            <xsl:text>yes</xsl:text>
3834          </xsl:otherwise>
3835        </xsl:choose>
3836      </xsl:variable>
3837
3838      <xsl:if test="$showit='yes'">
3839        <li class="indline0">
3840         
3841          <!-- make letters and digits stand out -->
3842          <xsl:choose>
3843            <xsl:when test="translate($letter,concat($lcase,$ucase,'0123456789'),'')=''">
3844              <a id="{$anchor-prefix}.index.{$letter}" href="#{$anchor-prefix}.index.{$letter}">
3845                <b><xsl:value-of select="$letter" /></b>
3846              </a>
3847            </xsl:when>
3848            <xsl:otherwise>
3849              <b><xsl:value-of select="$letter" /></b>
3850            </xsl:otherwise>
3851          </xsl:choose>
3852       
3853          <ul class="ind"> 
3854            <xsl:for-each select="key('index-first-letter',translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase))">
3855       
3856              <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)" />
3857             
3858                <xsl:choose>
3859                  <xsl:when test="self::reference">
3860                    <xsl:if test="$xml2rfc-ext-include-references-in-index='yes' and not(starts-with(@anchor,'deleted-'))">
3861                      <li class="indline1">
3862                        <em>
3863                          <xsl:value-of select="@anchor"/>
3864                        </em>
3865                        <xsl:text>&#160;&#160;</xsl:text>
3866                       
3867                        <xsl:variable name="rs" select="key('xref-item',current()/@anchor) | . | key('anchor-item',concat('deleted-',current()/@anchor))"/>
3868                       
3869                        <xsl:for-each select="$rs">
3870                          <xsl:call-template name="insertSingleXref" />
3871                        </xsl:for-each>
3872
3873                        <xsl:variable name="rs2" select="$rs[@x:sec]"/>
3874
3875                        <xsl:if test="$rs2">
3876                          <ul class="ind"> 
3877                            <xsl:for-each select="$rs2">
3878                              <xsl:sort select="substring-before(concat(@x:sec,'.'),'.')" data-type="number"/>
3879                              <xsl:sort select="substring(@x:sec,2+string-length(substring-before(@x:sec,'.')))" data-type="number"/>
3880                              <xsl:if test="generate-id(.) = generate-id(key('index-xref-by-sec',concat(@target,'..',@x:sec)))">
3881                                <li class="indline1">
3882                                  <em>
3883                                    <xsl:choose>
3884                                      <xsl:when test="translate(substring(@x:sec,1,1),$ucase,'')=''">
3885                                        <xsl:text>Appendix </xsl:text>
3886                                      </xsl:when>
3887                                      <xsl:otherwise>
3888                                        <xsl:text>Section </xsl:text>
3889                                      </xsl:otherwise>
3890                                    </xsl:choose>
3891                                    <xsl:value-of select="@x:sec"/>
3892                                  </em>
3893                                  <xsl:text>&#160;&#160;</xsl:text>
3894                                  <xsl:for-each select="key('index-xref-by-sec',concat(@target,'..',@x:sec))">
3895                                    <xsl:call-template name="insertSingleXref" />
3896                                  </xsl:for-each>
3897                                </li>
3898                              </xsl:if>
3899                            </xsl:for-each>
3900                          </ul>
3901                        </xsl:if>
3902
3903                        <xsl:if test="current()/x:source/@href">
3904                          <xsl:variable name="rs3" select="$rs[not(@x:sec) and @x:rel]"/>
3905                          <xsl:variable name="doc" select="document(current()/x:source/@href)"/>
3906                          <xsl:if test="$rs3">
3907                            <ul class="ind"> 
3908                              <xsl:for-each select="$rs3">
3909                                <xsl:sort select="count($doc//*[@anchor and following::*/@anchor=substring-after(current()/@x:rel,'#')])" order="ascending" data-type="number"/>
3910                                <xsl:if test="generate-id(.) = generate-id(key('index-xref-by-anchor',concat(@target,'..',@x:rel)))">
3911                                  <li class="indline1">
3912                                    <em>
3913                                      <xsl:variable name="sec">
3914                                        <xsl:for-each select="$doc//*[@anchor=substring-after(current()/@x:rel,'#')]">
3915                                          <xsl:call-template name="get-section-number"/>
3916                                        </xsl:for-each>
3917                                      </xsl:variable>
3918                                      <xsl:choose>
3919                                        <xsl:when test="translate(substring($sec,1,1),$ucase,'')=''">
3920                                          <xsl:text>Appendix </xsl:text>
3921                                        </xsl:when>
3922                                        <xsl:otherwise>
3923                                          <xsl:text>Section </xsl:text>
3924                                        </xsl:otherwise>
3925                                      </xsl:choose>
3926                                      <xsl:value-of select="$sec"/>
3927                                    </em>
3928                                    <xsl:text>&#160;&#160;</xsl:text>
3929                                    <xsl:for-each select="key('index-xref-by-anchor',concat(@target,'..',@x:rel))">
3930                                      <xsl:call-template name="insertSingleXref" />
3931                                    </xsl:for-each>
3932                                  </li>
3933                                </xsl:if>
3934                              </xsl:for-each>
3935                            </ul>
3936                          </xsl:if>
3937                        </xsl:if>
3938                      </li>
3939                    </xsl:if>
3940                  </xsl:when>
3941                  <xsl:otherwise>
3942                    <!-- regular iref -->
3943                    <xsl:if test="generate-id(.) = generate-id(key('index-item',concat(@item,@anchor)))">
3944                      <xsl:variable name="item" select="@item"/>
3945                      <xsl:variable name="in-artwork" select="key('index-item',$item)[@primary='true' and ancestor::artwork]"/>
3946                         
3947                      <li class="indline1">
3948                        <xsl:choose>
3949                          <xsl:when test="$in-artwork">
3950                            <tt><xsl:value-of select="@item" /></tt>
3951                          </xsl:when>
3952                          <xsl:otherwise>
3953                            <xsl:value-of select="@item" />
3954                          </xsl:otherwise>
3955                        </xsl:choose>
3956                        <xsl:text>&#160;&#160;</xsl:text>
3957                       
3958                        <xsl:variable name="irefs3" select="key('index-item',@item)[not(@subitem) or @subitem='']"/>
3959                        <xsl:variable name="xrefs3" select="key('xref-item',$irefs3[@x:for-anchor='']/../@anchor) | key('xref-item',$irefs3/@x:for-anchor)"/>
3960                        <xsl:variable name="extrefs3" select="key('extref-item',$irefs3[@x:for-anchor='']/../@anchor) | key('extref-item',$irefs3/@x:for-anchor)"/>
3961
3962                        <xsl:for-each select="$irefs3|$xrefs3|$extrefs3">
3963                          <!-- <xsl:sort select="translate(@item,$lcase,$ucase)" />  -->
3964                          <xsl:call-template name="insertSingleIref" />
3965                        </xsl:for-each>
3966         
3967                        <xsl:variable name="s2" select="key('index-item',@item)[@subitem and @subitem!='']"/>
3968                        <xsl:if test="$s2">
3969                          <ul class="ind"> 
3970                            <xsl:for-each select="$s2">
3971                              <xsl:sort select="translate(@subitem,$lcase,$ucase)" />
3972                             
3973                              <xsl:if test="generate-id(.) = generate-id(key('index-item-subitem',concat(@item,'..',@subitem)))">
3974                 
3975                                <xsl:variable name="in-artwork2" select="key('index-item-subitem',concat(@item,'..',@subitem))[@primary='true' and ancestor::artwork]" />
3976                 
3977                                <li class="indline1">
3978             
3979                                  <xsl:choose>
3980                                    <xsl:when test="$in-artwork2">
3981                                      <tt><xsl:value-of select="@subitem" /></tt>
3982                                    </xsl:when>
3983                                    <xsl:otherwise>
3984                                      <xsl:value-of select="@subitem" />
3985                                    </xsl:otherwise>
3986                                  </xsl:choose>
3987                                  <xsl:text>&#160;&#160;</xsl:text>
3988                                   
3989                                  <xsl:variable name="irefs4" select="key('index-item-subitem',concat(@item,'..',@subitem))"/>
3990                                  <xsl:variable name="xrefs4" select="key('xref-item',$irefs4[@x:for-anchor='']/../@anchor) | key('xref-item',$irefs4/@x:for-anchor)"/>
3991                                  <xsl:variable name="extrefs4" select="key('extref-item',$irefs4[@x:for-anchor='']/../@anchor) | key('extref-item',$irefs4/@x:for-anchor)"/>
3992
3993                                  <xsl:for-each select="$irefs4|$xrefs4|$extrefs4">
3994                                    <!--<xsl:sort select="translate(@item,$lcase,$ucase)" />-->                   
3995                                    <xsl:call-template name="insertSingleIref" />
3996                                  </xsl:for-each>
3997               
3998                                </li>
3999                              </xsl:if>
4000                            </xsl:for-each>
4001                          </ul>
4002                        </xsl:if>
4003                      </li>
4004                    </xsl:if>
4005                  </xsl:otherwise>
4006                </xsl:choose>
4007             
4008                     
4009            </xsl:for-each>           
4010          </ul>
4011        </li>
4012      </xsl:if>
4013     
4014    </xsl:for-each>
4015  </ul>
4016  </div>
4017 
4018</xsl:template>
4019
4020<xsl:template name="insertPreamble" myns:namespaceless-elements="xml2rfc">
4021
4022  <xsl:variable name="escapeclause">
4023    This document may contain material from IETF Documents or IETF Contributions published or
4024    made publicly available before November 10, 2008. The person(s) controlling the copyright in
4025    some of this material may not have granted the IETF Trust the right to allow modifications of such
4026    material outside the IETF Standards Process. Without obtaining an adequate license from the
4027    person(s) controlling the copyright in such materials, this document may not be modified outside
4028    the IETF Standards Process, and derivative works of it may not be created outside the IETF
4029    Standards Process, except to format it for publication as an RFC or to translate it into languages
4030    other than English.
4031  </xsl:variable>
4032
4033  <section myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.status">
4034  <xsl:attribute name="title">
4035    <xsl:choose>
4036      <xsl:when test="$xml2rfc-rfcedstyle='yes'">Status of This Memo</xsl:when>
4037      <xsl:otherwise>Status of this Memo</xsl:otherwise>
4038    </xsl:choose>
4039  </xsl:attribute>
4040
4041  <xsl:choose>
4042    <xsl:when test="/rfc/@ipr and not(/rfc/@number)">
4043      <t>
4044        <xsl:choose>
4045         
4046          <!-- RFC2026 -->
4047          <xsl:when test="/rfc/@ipr = 'full2026'">
4048            This document is an Internet-Draft and is
4049            in full conformance with all provisions of Section 10 of RFC2026.   
4050          </xsl:when>
4051          <xsl:when test="/rfc/@ipr = 'noDerivativeWorks2026'">
4052            This document is an Internet-Draft and is
4053            in full conformance with all provisions of Section 10 of RFC2026
4054            except that the right to produce derivative works is not granted.   
4055          </xsl:when>
4056          <xsl:when test="/rfc/@ipr = 'noDerivativeWorksNow'">
4057            This document is an Internet-Draft and is
4058            in full conformance with all provisions of Section 10 of RFC2026
4059            except that the right to produce derivative works is not granted.
4060            (If this document becomes part of an IETF working group activity,
4061            then it will be brought into full compliance with Section 10 of RFC2026.) 
4062          </xsl:when>
4063          <xsl:when test="/rfc/@ipr = 'none'">
4064            This document is an Internet-Draft and is
4065            NOT offered in accordance with Section 10 of RFC2026,
4066            and the author does not provide the IETF with any rights other
4067            than to publish as an Internet-Draft.
4068          </xsl:when>
4069         
4070          <!-- RFC3667 -->
4071          <xsl:when test="/rfc/@ipr = 'full3667'">
4072            This document is an Internet-Draft and is subject to all provisions
4073            of section 3 of RFC 3667.  By submitting this Internet-Draft, each
4074            author represents that any applicable patent or other IPR claims of
4075            which he or she is aware have been or will be disclosed, and any of
4076            which he or she become aware will be disclosed, in accordance with
4077            RFC 3668.
4078          </xsl:when>
4079          <xsl:when test="/rfc/@ipr = 'noModification3667'">
4080            This document is an Internet-Draft and is subject to all provisions
4081            of section 3 of RFC 3667.  By submitting this Internet-Draft, each
4082            author represents that any applicable patent or other IPR claims of
4083            which he or she is aware have been or will be disclosed, and any of
4084            which he or she become aware will be disclosed, in accordance with
4085            RFC 3668.  This document may not be modified, and derivative works of
4086            it may not be created, except to publish it as an RFC and to
4087            translate it into languages other than English<xsl:if test="/rfc/@iprExtract">,
4088            other than to extract <xref target="{/rfc/@iprExtract}"/> as-is
4089            for separate use</xsl:if>.
4090          </xsl:when>
4091          <xsl:when test="/rfc/@ipr = 'noDerivatives3667'">
4092            This document is an Internet-Draft and is subject to all provisions
4093            of section 3 of RFC 3667 except for the right to produce derivative
4094            works.  By submitting this Internet-Draft, each author represents
4095            that any applicable patent or other IPR claims of which he or she
4096            is aware have been or will be disclosed, and any of which he or she
4097            become aware will be disclosed, in accordance with RFC 3668.  This
4098            document may not be modified, and derivative works of it may
4099            not be created<xsl:if test="/rfc/@iprExtract">, other than to extract
4100            <xref target="{/rfc/@iprExtract}"/> as-is for separate use</xsl:if>.
4101          </xsl:when>
4102         
4103          <!-- RFC3978 -->
4104          <xsl:when test="/rfc/@ipr = 'full3978'">
4105            By submitting this Internet-Draft, each
4106            author represents that any applicable patent or other IPR claims of
4107            which he or she is aware have been or will be disclosed, and any of
4108            which he or she becomes aware will be disclosed, in accordance with
4109            Section 6 of BCP 79.
4110          </xsl:when>
4111          <xsl:when test="/rfc/@ipr = 'noModification3978'">
4112            By submitting this Internet-Draft, each
4113            author represents that any applicable patent or other IPR claims of
4114            which he or she is aware have been or will be disclosed, and any of
4115            which he or she becomes aware will be disclosed, in accordance with
4116            Section 6 of BCP 79.  This document may not be modified, and derivative works of
4117            it may not be created, except to publish it as an RFC and to
4118            translate it into languages other than English<xsl:if test="/rfc/@iprExtract">,
4119            other than to extract <xref target="{/rfc/@iprExtract}"/> as-is
4120            for separate use</xsl:if>.
4121          </xsl:when>
4122          <xsl:when test="/rfc/@ipr = 'noDerivatives3978'">
4123            By submitting this Internet-Draft, each author represents
4124            that any applicable patent or other IPR claims of which he or she
4125            is aware have been or will be disclosed, and any of which he or she
4126            becomes aware will be disclosed, in accordance with Section 6 of BCP 79.  This
4127            document may not be modified, and derivative works of it may
4128            not be created<xsl:if test="/rfc/@iprExtract">, other than to extract
4129            <xref target="{/rfc/@iprExtract}"/> as-is for separate use</xsl:if>.
4130          </xsl:when>
4131 
4132          <!-- as of Jan 2010, TLP 4.0 -->
4133          <xsl:when test="$ipr-2010-01 and (/rfc/@ipr = 'trust200902'
4134                          or /rfc/@ipr = 'noModificationTrust200902'
4135                          or /rfc/@ipr = 'noDerivativesTrust200902'
4136                          or /rfc/@ipr = 'pre5378Trust200902')">
4137            This Internet-Draft is submitted in full conformance with
4138            the provisions of BCP 78 and BCP 79.
4139          </xsl:when>
4140 
4141          <!-- as of Nov 2008, Feb 2009 and Sep 2009 -->
4142          <xsl:when test="/rfc/@ipr = 'trust200811'
4143                          or /rfc/@ipr = 'noModificationTrust200811'
4144                          or /rfc/@ipr = 'noDerivativesTrust200811'
4145                          or /rfc/@ipr = 'trust200902'
4146                          or /rfc/@ipr = 'noModificationTrust200902'
4147                          or /rfc/@ipr = 'noDerivativesTrust200902'
4148                          or /rfc/@ipr = 'pre5378Trust200902'">
4149            This Internet-Draft is submitted to IETF in full conformance with
4150            the provisions of BCP 78 and BCP 79.
4151          </xsl:when>
4152          <xsl:otherwise>
4153            CONFORMANCE UNDEFINED.
4154          </xsl:otherwise>
4155        </xsl:choose>
4156       
4157        <!-- restrictions -->
4158        <xsl:choose>
4159          <xsl:when test="/rfc/@ipr = 'noModificationTrust200811'">
4160            This document may not be modified, and derivative works of it may
4161            not be created, except to format it for publication as an RFC and
4162            to translate it into languages other than English.
4163          </xsl:when>
4164          <xsl:when test="/rfc/@ipr = 'noDerivativesTrust200811'">
4165            This document may not be modified, and derivative works of it may
4166            not be created, and it may not be published except as an Internet-Draft.
4167          </xsl:when>
4168          <xsl:when test="/rfc/@ipr = 'noModificationTrust200902'">
4169            This document may not be modified, and derivative works of it may
4170            not be created, except to format it for publication as an RFC or
4171            to translate it into languages other than English.
4172          </xsl:when>
4173          <xsl:when test="/rfc/@ipr = 'noDerivativesTrust200902'">
4174            This document may not be modified, and derivative works of it may
4175            not be created, and it may not be published except as an Internet-Draft.
4176          </xsl:when>
4177          <!-- escape clause moved to Copyright Notice as of 2009-11 -->
4178          <xsl:when test="/rfc/@ipr = 'pre5378Trust200902' and $pub-yearmonth &lt; 200911">
4179            <xsl:value-of select="$escapeclause"/>
4180          </xsl:when>
4181
4182          <xsl:otherwise />
4183        </xsl:choose>
4184      </t>
4185      <xsl:choose>
4186        <xsl:when test="$id-boilerplate='2010'">
4187          <t>
4188            Internet-Drafts are working documents of the Internet Engineering
4189            Task Force (IETF). Note that other groups may also distribute
4190            working documents as Internet-Drafts. The list of current
4191            Internet-Drafts is at <eref target='http://datatracker.ietf.org/drafts/current/'>http://datatracker.ietf.org/drafts/current/</eref>.
4192          </t>
4193        </xsl:when>
4194        <xsl:otherwise>
4195          <t>
4196            Internet-Drafts are working documents of the Internet Engineering
4197            Task Force (IETF), its areas, and its working groups.
4198            Note that other groups may also distribute working documents as
4199            Internet-Drafts.
4200          </t>
4201        </xsl:otherwise>
4202      </xsl:choose>
4203      <t>
4204        Internet-Drafts are draft documents valid for a maximum of six months
4205        and may be updated, replaced, or obsoleted by other documents at any time.
4206        It is inappropriate to use Internet-Drafts as reference material or to cite
4207        them other than as &#8220;work in progress&#8221;.
4208      </t>
4209      <xsl:if test="$id-boilerplate=''">
4210        <t>
4211          The list of current Internet-Drafts can be accessed at
4212          <eref target='http://www.ietf.org/ietf/1id-abstracts.txt'>http://www.ietf.org/ietf/1id-abstracts.txt</eref>.
4213        </t>
4214        <t>
4215          The list of Internet-Draft Shadow Directories can be accessed at
4216          <eref target='http://www.ietf.org/shadow.html'>http://www.ietf.org/shadow.html</eref>.
4217        </t>
4218      </xsl:if>
4219      <t>
4220        This Internet-Draft will expire in <xsl:call-template name="expirydate" />.
4221      </t>
4222    </xsl:when>
4223
4224    <xsl:when test="/rfc/@category='bcp' and $rfc-boilerplate='2010'">
4225      <t>
4226        This memo documents an Internet Best Current Practice.
4227      </t>
4228    </xsl:when>
4229    <xsl:when test="/rfc/@category='bcp'">
4230      <t>
4231        This document specifies an Internet Best Current Practices for the Internet
4232        Community, and requests discussion and suggestions for improvements.
4233        Distribution of this memo is unlimited.
4234      </t>
4235    </xsl:when>
4236    <xsl:when test="/rfc/@category='exp' and $rfc-boilerplate='2010'">
4237      <t>
4238        This document is not an Internet Standards Track specification; it is
4239        published for examination, experimental implementation, and evaluation.
4240      </t>
4241    </xsl:when>
4242    <xsl:when test="/rfc/@category='exp'">
4243      <t>
4244        This memo defines an Experimental Protocol for the Internet community.
4245        It does not specify an Internet standard of any kind.
4246        Discussion and suggestions for improvement are requested.
4247        Distribution of this memo is unlimited.
4248      </t>
4249    </xsl:when>
4250    <xsl:when test="/rfc/@category='historic' and $rfc-boilerplate='2010'">
4251      <t>
4252        This document is not an Internet Standards Track specification; it is
4253        published for the historical record.
4254      </t>
4255    </xsl:when>
4256    <xsl:when test="/rfc/@category='historic'">
4257      <t>
4258        This memo describes a historic protocol for the Internet community.
4259        It does not specify an Internet standard of any kind.
4260        Distribution of this memo is unlimited.
4261      </t>
4262    </xsl:when>
4263    <xsl:when test="/rfc/@category='std' and $rfc-boilerplate='2010'">
4264      <t>
4265        This is an Internet Standards Track document.
4266      </t>
4267    </xsl:when>
4268    <xsl:when test="/rfc/@category='std'">
4269      <t>
4270        This document specifies an Internet standards track protocol for the Internet
4271        community, and requests discussion and suggestions for improvements.
4272        Please refer to the current edition of the &#8220;Internet Official Protocol
4273        Standards&#8221; (STD 1) for the standardization state and status of this
4274        protocol. Distribution of this memo is unlimited.
4275      </t>
4276    </xsl:when>
4277    <xsl:when test="(/rfc/@category='info' or not(/rfc/@category)) and $rfc-boilerplate='2010'">
4278      <t>
4279        This document is not an Internet Standards Track specification; it is
4280        published for informational purposes.
4281      </t>
4282    </xsl:when>
4283    <xsl:when test="/rfc/@category='info' or not(/rfc/@category)">
4284      <t>
4285        This memo provides information for the Internet community.
4286        It does not specify an Internet standard of any kind.
4287        Distribution of this memo is unlimited.
4288      </t>
4289    </xsl:when>
4290    <xsl:otherwise>
4291      <t>
4292        UNSUPPORTED CATEGORY.
4293      </t>
4294      <xsl:call-template name="error">
4295        <xsl:with-param name="msg" select="concat('Unsupported value for /rfc/@category: ', /rfc/@category)"/>
4296        <xsl:with-param name="inline" select="'no'"/>
4297      </xsl:call-template>
4298    </xsl:otherwise>
4299  </xsl:choose>
4300   
4301  <!-- 2nd and 3rd paragraph -->
4302  <xsl:if test="$rfc-boilerplate='2010' and /rfc/@number">
4303    <t>
4304      <xsl:if test="/rfc/@category='exp'">
4305        This document defines an Experimental Protocol for the Internet
4306        community.
4307      </xsl:if>
4308      <xsl:if test="/rfc/@category='historic'">
4309        This document defines a Historic Document for the Internet community.
4310      </xsl:if>
4311      <xsl:choose>
4312        <xsl:when test="$submissionType='IETF'">
4313          This document is a product of the Internet Engineering Task Force
4314          (IETF).
4315          <xsl:choose>
4316            <xsl:when test="not(/rfc/@consensus) or /rfc/@consensus='yes'">
4317              It represents the consensus of the IETF community.  It has
4318              received public review and has been approved for publication by
4319              the Internet Engineering Steering Group (IESG).
4320            </xsl:when>
4321            <xsl:otherwise>
4322              It has been approved for publication by the Internet Engineering
4323              Steering Group (IESG).
4324            </xsl:otherwise>
4325          </xsl:choose>
4326        </xsl:when>
4327        <xsl:when test="$submissionType='IAB'">
4328          This document is a product of the Internet Architecture Board (IAB)
4329          and represents information that the IAB has deemed valuable to
4330          provide for permanent record.
4331        </xsl:when>
4332        <xsl:when test="$submissionType='IRTF'">
4333          This document is a product of the Internet Research Task Force (IRTF).
4334          The IRTF publishes the results of Internet-related research and
4335          development activities.  These results might not be suitable for
4336          deployment.
4337          <xsl:choose>
4338            <xsl:when test="(not(/rfc/@consensus) or /rfc/@consensus='yes') and /rfc/front/workgroup!=''">
4339              This RFC represents the consensus of the
4340              <xsl:value-of select="/rfc/front/workgroup"/> Research Group of the Internet
4341              Research Task Force (IRTF).
4342            </xsl:when>
4343            <xsl:when test="/rfc/@consensus='no' and /rfc/front/workgroup!=''">
4344              This RFC represents the individual opinion(s) of one or more
4345              members of the <xsl:value-of select="/rfc/front/workgroup"/> Research Group of the
4346              Internet Research Task Force (IRTF).
4347            </xsl:when>
4348            <xsl:otherwise>
4349              <!-- no research group -->
4350            </xsl:otherwise>
4351          </xsl:choose>
4352        </xsl:when>
4353        <xsl:when test="$submissionType='independent'">
4354          This is a contribution to the RFC Series, independently of any other
4355          RFC stream.  The RFC Editor has chosen to publish this document at
4356          its discretion and makes no statement about its value for
4357          implementation or deployment.
4358        </xsl:when>
4359        <xsl:otherwise>
4360          <!-- will contain error message already -->
4361          <xsl:value-of select="$submissionType"/>
4362        </xsl:otherwise>
4363      </xsl:choose>
4364      <xsl:choose>
4365        <xsl:when test="$submissionType='IETF'">
4366          <xsl:choose>
4367            <xsl:when test="/rfc/@category='bcp'">
4368              Further information on BCPs is available in Section 2 of RFC 5741.
4369            </xsl:when>
4370            <xsl:when test="/rfc/@category='std'">
4371              Further information on Internet Standards is available in Section
4372              2 of RFC 5741.
4373            </xsl:when>
4374            <xsl:otherwise>
4375              Not all documents approved by the IESG are a candidate for any
4376              level of Internet Standard; see Section 2 of RFC 5741.
4377            </xsl:otherwise>
4378          </xsl:choose>
4379        </xsl:when>
4380        <xsl:otherwise>
4381          <xsl:variable name="approver">
4382            <xsl:choose>
4383              <xsl:when test="$submissionType='IAB'">IAB</xsl:when>
4384              <xsl:when test="$submissionType='IRTF'">IRSG</xsl:when>
4385              <xsl:otherwise>RFC Editor</xsl:otherwise>
4386            </xsl:choose>
4387          </xsl:variable>
4388       
4389          Documents approved for publication by the
4390          <xsl:value-of select="$approver"/> are not a candidate for any level
4391          of Internet Standard; see Section 2 of RFC 5741.
4392        </xsl:otherwise>
4393      </xsl:choose>
4394    </t>
4395    <t>
4396      Information about the current status of this document, any errata, and
4397      how to provide feedback on it may be obtained at
4398      <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>.
4399    </t>
4400  </xsl:if>
4401   
4402  </section>
4403 
4404  <xsl:choose>
4405    <xsl:when test="$ipr-2008-11">
4406      <section title="Copyright Notice" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.copyrightnotice">
4407        <t>
4408          Copyright &#169; <xsl:value-of select="$xml2rfc-ext-pub-year" /> IETF Trust and the persons identified
4409          as the document authors.  All rights reserved.
4410        </t>
4411        <xsl:choose>
4412          <xsl:when test="$ipr-2010-01">
4413            <t>
4414              This document is subject to BCP 78 and the IETF Trust's Legal
4415              Provisions Relating to IETF Documents (<eref target="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</eref>)
4416              in effect on the date of publication of this document. Please
4417              review these documents carefully, as they describe your rights
4418              and restrictions with respect to this document.
4419              <xsl:if test="$submissionType='IETF'">
4420                Code Components extracted from this document must include
4421                Simplified BSD License text as described in Section 4.e of the
4422                Trust Legal Provisions and are provided without warranty as
4423                described in the Simplified BSD License.
4424              </xsl:if>
4425            </t>
4426          </xsl:when>
4427          <xsl:when test="$ipr-2009-09">
4428            <t>
4429              This document is subject to BCP 78 and the IETF Trust's Legal
4430              Provisions Relating to IETF Documents (<eref target="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</eref>)
4431              in effect on the date of publication of this document. Please
4432              review these documents carefully, as they describe your rights
4433              and restrictions with respect to this document. Code Components
4434              extracted from this document must include Simplified BSD License
4435              text as described in Section 4.e of the Trust Legal Provisions
4436              and are provided without warranty as described in the BSD License.
4437            </t>
4438          </xsl:when>
4439          <xsl:when test="$ipr-2009-02">
4440            <t>
4441              This document is subject to BCP 78 and the IETF Trust's Legal
4442              Provisions Relating to IETF Documents in effect on the date of
4443              publication of this document
4444              (<eref target="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</eref>).
4445              Please review these documents carefully, as they describe your rights and restrictions with
4446              respect to this document.
4447            </t>
4448          </xsl:when>
4449          <xsl:otherwise>
4450            <t>
4451              This document is subject to BCP 78 and the IETF Trust's Legal
4452              Provisions Relating to IETF Documents
4453              (<eref target="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</eref>) in effect on the date of
4454              publication of this document.  Please review these documents
4455              carefully, as they describe your rights and restrictions with respect
4456              to this document.
4457            </t>
4458          </xsl:otherwise>
4459        </xsl:choose>
4460       
4461        <!-- special case: RFC5378 escape applies to RFCs as well -->
4462        <!-- for IDs historically in Status Of This Memo, over here starting 2009-11 -->
4463        <xsl:if test="(/rfc/@number or $pub-yearmonth >= 200911) and /rfc/@ipr = 'pre5378Trust200902'">
4464          <t>
4465            <xsl:value-of select="$escapeclause"/>
4466          </t>
4467        </xsl:if>
4468       
4469      </section>
4470    </xsl:when>
4471    <xsl:when test="$ipr-2007-08">
4472      <!-- no copyright notice -->
4473    </xsl:when>
4474    <xsl:when test="$ipr-rfc4748">
4475      <section title="Copyright Notice" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.copyrightnotice">
4476        <t>
4477          Copyright &#169; The IETF Trust (<xsl:value-of select="$xml2rfc-ext-pub-year" />).  All Rights Reserved.
4478        </t>
4479      </section>
4480    </xsl:when>
4481    <xsl:otherwise>
4482      <section title="Copyright Notice" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.copyrightnotice">
4483        <t>
4484          Copyright &#169; The Internet Society (<xsl:value-of select="$xml2rfc-ext-pub-year" />).  All Rights Reserved.
4485        </t>
4486      </section>
4487    </xsl:otherwise>
4488  </xsl:choose>
4489 
4490</xsl:template>
4491
4492<!-- TOC generation -->
4493
4494<xsl:template match="/" mode="toc">
4495  <hr class="noprint"/>
4496
4497  <h1 class="np" id="{$anchor-prefix}.toc"> <!-- this pagebreak occurs always -->
4498    <a href="#{$anchor-prefix}.toc">Table of Contents</a>
4499  </h1>
4500
4501  <ul class="toc">
4502    <xsl:apply-templates mode="toc" />
4503  </ul>
4504</xsl:template>
4505
4506<xsl:template name="insert-toc-line">
4507  <xsl:param name="number" />
4508  <xsl:param name="target" />
4509  <xsl:param name="title" />
4510  <xsl:param name="tocparam" />
4511  <xsl:param name="oldtitle" />
4512  <xsl:param name="waschanged" />
4513
4514  <!-- handle tocdepth parameter -->
4515  <xsl:choose>
4516    <xsl:when test="($tocparam='' or $tocparam='default') and string-length(translate($number,'.ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890&#167;','.')) &gt;= $parsedTocDepth">
4517      <!-- dropped entry because excluded -->
4518      <xsl:attribute name="class">tocline2</xsl:attribute>
4519    </xsl:when>
4520    <xsl:when test="$tocparam='exclude'">
4521      <!-- dropped entry because excluded -->
4522      <xsl:attribute name="class">tocline2</xsl:attribute>
4523    </xsl:when>
4524    <xsl:otherwise>
4525      <xsl:choose>
4526        <xsl:when test="starts-with($number,'del-')">
4527          <del>
4528            <xsl:value-of select="$number" />
4529            <a href="#{$target}"><xsl:value-of select="$title"/></a>
4530          </del>
4531        </xsl:when>
4532        <xsl:otherwise>
4533          <xsl:choose>
4534            <xsl:when test="not(contains($number,'.'))">
4535              <xsl:attribute name="class">tocline0</xsl:attribute>
4536            </xsl:when>
4537            <xsl:otherwise>
4538              <xsl:attribute name="class">tocline1</xsl:attribute>
4539            </xsl:otherwise>
4540          </xsl:choose>
4541          <xsl:if test="$number != '' and not(contains($number,'unnumbered-'))">
4542            <xsl:call-template name="emit-section-number">
4543              <xsl:with-param name="no" select="$number"/>
4544            </xsl:call-template>
4545            <xsl:text>&#160;&#160;&#160;</xsl:text>
4546          </xsl:if>
4547          <a href="#{$target}">
4548            <xsl:choose>
4549              <xsl:when test="$waschanged!=''">
4550                <ins><xsl:value-of select="$title"/></ins>
4551                <del><xsl:value-of select="$oldtitle"/></del>
4552              </xsl:when>
4553              <xsl:otherwise>
4554                <xsl:value-of select="$title"/>
4555              </xsl:otherwise>
4556            </xsl:choose>
4557          </a>
4558        </xsl:otherwise>
4559      </xsl:choose>
4560    </xsl:otherwise>
4561  </xsl:choose>
4562</xsl:template>
4563
4564<xsl:template name="back-toc">
4565
4566  <xsl:if test="//cref and $xml2rfc-comments='yes' and $xml2rfc-inline!='yes'">
4567    <li>
4568      <xsl:call-template name="insert-toc-line">
4569        <xsl:with-param name="target" select="concat($anchor-prefix,'.comments')"/>
4570        <xsl:with-param name="title" select="'Editorial Comments'"/>
4571      </xsl:call-template>
4572    </li>
4573  </xsl:if>
4574
4575  <xsl:if test="$xml2rfc-ext-authors-section!='end'">
4576    <xsl:apply-templates select="/rfc/front" mode="toc" />
4577  </xsl:if>
4578  <xsl:apply-templates select="back/*[not(self::references)]" mode="toc" />
4579
4580  <!-- insert the index if index entries exist -->
4581  <xsl:if test="$has-index">
4582    <li>
4583      <xsl:call-template name="insert-toc-line">
4584        <xsl:with-param name="target" select="concat($anchor-prefix,'.index')"/>
4585        <xsl:with-param name="title" select="'Index'"/>
4586      </xsl:call-template>
4587    </li>
4588  </xsl:if>
4589
4590  <xsl:if test="$xml2rfc-ext-authors-section='end'">
4591    <xsl:apply-templates select="/rfc/front" mode="toc" />
4592  </xsl:if>
4593
4594  <!-- copyright statements -->
4595  <xsl:if test="$xml2rfc-private='' and not($no-copylong)">
4596    <li>
4597      <xsl:call-template name="insert-toc-line">
4598        <xsl:with-param name="target" select="concat($anchor-prefix,'.ipr')"/>
4599        <xsl:with-param name="title" select="'Intellectual Property and Copyright Statements'"/>
4600      </xsl:call-template>
4601    </li>
4602  </xsl:if>
4603 
4604</xsl:template>
4605
4606<xsl:template match="front" mode="toc">
4607 
4608  <xsl:variable name="authors-title">
4609    <xsl:call-template name="get-authors-section-title"/>
4610  </xsl:variable>
4611  <xsl:variable name="authors-number">
4612    <xsl:call-template name="get-authors-section-number"/>
4613  </xsl:variable>
4614
4615  <xsl:if test="$authors-number!='suppress'">
4616    <li>
4617      <xsl:call-template name="insert-toc-line">
4618        <xsl:with-param name="target" select="concat($anchor-prefix,'.authors')"/>
4619        <xsl:with-param name="title" select="$authors-title"/>
4620        <xsl:with-param name="number" select="$authors-number"/>
4621      </xsl:call-template>
4622    </li>
4623  </xsl:if>
4624
4625</xsl:template>
4626
4627<xsl:template name="references-toc">
4628
4629  <!-- distinguish two cases: (a) single references element (process
4630  as toplevel section; (b) multiple references sections (add one toplevel
4631  container with subsection) -->
4632
4633  <xsl:variable name="refsecs" select="/rfc/back/references|/rfc/back/ed:replace/ed:ins/references"/>
4634   
4635  <xsl:choose>
4636    <xsl:when test="count($refsecs) = 0">
4637      <!-- nop -->
4638    </xsl:when>
4639    <xsl:when test="count($refsecs) = 1">
4640      <xsl:for-each select="$refsecs">
4641        <xsl:variable name="title">
4642          <xsl:choose>
4643            <xsl:when test="@title!=''"><xsl:value-of select="@title" /></xsl:when>
4644            <xsl:otherwise><xsl:value-of select="$xml2rfc-refparent"/></xsl:otherwise>
4645          </xsl:choose>
4646        </xsl:variable>
4647     
4648        <li>
4649          <xsl:call-template name="insert-toc-line">
4650            <xsl:with-param name="number">
4651              <xsl:call-template name="get-references-section-number"/>
4652            </xsl:with-param>
4653            <xsl:with-param name="target" select="concat($anchor-prefix,'.references')"/>
4654            <xsl:with-param name="title" select="$title"/>
4655          </xsl:call-template>
4656        </li>
4657      </xsl:for-each>
4658    </xsl:when>
4659    <xsl:otherwise>
4660      <li>
4661        <!-- insert pseudo container -->   
4662        <xsl:call-template name="insert-toc-line">
4663          <xsl:with-param name="number">
4664            <xsl:call-template name="get-references-section-number"/>
4665          </xsl:with-param>
4666          <xsl:with-param name="target" select="concat($anchor-prefix,'.references')"/>
4667          <xsl:with-param name="title" select="$xml2rfc-refparent"/>
4668        </xsl:call-template>
4669 
4670        <ul class="toc">
4671          <!-- ...with subsections... -->   
4672          <xsl:for-each select="$refsecs">
4673            <xsl:variable name="title">
4674              <xsl:choose>
4675                <xsl:when test="@title!=''"><xsl:value-of select="@title" /></xsl:when>
4676                <xsl:otherwise><xsl:value-of select="$xml2rfc-refparent"/></xsl:otherwise>
4677              </xsl:choose>
4678            </xsl:variable>
4679         
4680            <xsl:variable name="sectionNumber">
4681              <xsl:call-template name="get-section-number" />
4682            </xsl:variable>
4683   
4684            <xsl:variable name="num">
4685              <xsl:number level="any"/>
4686            </xsl:variable>
4687   
4688            <li>
4689              <xsl:call-template name="insert-toc-line">
4690                <xsl:with-param name="number" select="$sectionNumber"/>
4691                <xsl:with-param name="target" select="concat($anchor-prefix,'.references','.',$num)"/>
4692                <xsl:with-param name="title" select="$title"/>
4693              </xsl:call-template>
4694            </li>
4695          </xsl:for-each>
4696        </ul>
4697      </li>
4698    </xsl:otherwise>
4699  </xsl:choose>
4700</xsl:template>
4701
4702<xsl:template match="section|appendix" mode="toc">
4703  <xsl:variable name="sectionNumber">
4704    <xsl:call-template name="get-section-number" />
4705  </xsl:variable>
4706
4707  <xsl:variable name="target">
4708    <xsl:choose>
4709      <xsl:when test="@anchor"><xsl:value-of select="@anchor" /></xsl:when>
4710       <xsl:otherwise><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$sectionNumber" /></xsl:otherwise>
4711    </xsl:choose>
4712  </xsl:variable>
4713
4714  <!-- obtain content, just to check whether we need to recurse at all -->
4715  <xsl:variable name="content">
4716    <li>
4717      <xsl:call-template name="insert-toc-line">
4718        <xsl:with-param name="number" select="$sectionNumber"/>
4719        <xsl:with-param name="target" select="$target"/>
4720        <xsl:with-param name="title" select="@title"/>
4721        <xsl:with-param name="tocparam" select="@toc"/>
4722        <xsl:with-param name="oldtitle" select="@ed:old-title"/>
4723        <xsl:with-param name="waschanged" select="@ed:resolves"/>
4724      </xsl:call-template>
4725   
4726      <ul class="toc">
4727        <xsl:apply-templates mode="toc" />
4728      </ul>
4729    </li>
4730  </xsl:variable>
4731 
4732  <xsl:if test="$content!=''">
4733    <li>
4734      <xsl:call-template name="insert-toc-line">
4735        <xsl:with-param name="number" select="$sectionNumber"/>
4736        <xsl:with-param name="target" select="$target"/>
4737        <xsl:with-param name="title" select="@title"/>
4738        <xsl:with-param name="tocparam" select="@toc"/>
4739        <xsl:with-param name="oldtitle" select="@ed:old-title"/>
4740        <xsl:with-param name="waschanged" select="@ed:resolves"/>
4741      </xsl:call-template>
4742   
4743      <!-- obtain nested content, just to check whether we need to recurse at all -->
4744      <xsl:variable name="nested-content">
4745        <ul class="toc">
4746          <xsl:apply-templates mode="toc" />
4747        </ul>
4748      </xsl:variable>
4749     
4750      <!-- only recurse if we need to (do not produce useless list container) -->     
4751      <xsl:if test="$nested-content!=''">
4752        <ul class="toc">
4753          <xsl:apply-templates mode="toc" />
4754        </ul>
4755      </xsl:if>
4756    </li>
4757  </xsl:if>
4758</xsl:template>
4759
4760<xsl:template match="middle" mode="toc">
4761  <xsl:apply-templates mode="toc" />
4762  <xsl:call-template name="references-toc" />
4763</xsl:template>
4764
4765<xsl:template match="rfc" mode="toc">
4766  <xsl:apply-templates select="middle" mode="toc" />
4767  <xsl:call-template name="back-toc" />
4768</xsl:template>
4769
4770<xsl:template match="ed:del|ed:ins|ed:replace" mode="toc">
4771  <xsl:apply-templates mode="toc" />
4772</xsl:template>
4773
4774<xsl:template match="*|text()" mode="toc" />
4775
4776
4777<xsl:template name="insertTocAppendix">
4778 
4779  <xsl:if test="//figure[@title!='' or @anchor!='']">
4780    <ul class="toc">
4781      <xsl:for-each select="//figure[@title!='' or @anchor!='']">
4782        <xsl:variable name="title">Figure <xsl:value-of select="position()"/><xsl:if test="@title">: <xsl:value-of select="@title"/></xsl:if>
4783        </xsl:variable>
4784        <li>
4785          <xsl:call-template name="insert-toc-line">
4786            <xsl:with-param name="target" select="concat($anchor-prefix,'.figure.',position())" />
4787            <xsl:with-param name="title" select="$title" />
4788          </xsl:call-template>
4789        </li>
4790      </xsl:for-each>
4791    </ul>
4792  </xsl:if>
4793 
4794  <!-- experimental -->
4795  <xsl:if test="//ed:issue">
4796    <xsl:call-template name="insertIssuesList" />
4797  </xsl:if>
4798
4799</xsl:template>
4800
4801<xsl:template name="referencename">
4802  <xsl:param name="node" />
4803 
4804  <xsl:for-each select="$node">
4805    <xsl:choose>
4806      <xsl:when test="$xml2rfc-symrefs!='no' and ancestor::ed:del">
4807        <xsl:variable name="unprefixed" select="substring-after(@anchor,'deleted-')"/>
4808        <xsl:choose>
4809          <xsl:when test="$unprefixed!=''">
4810            <xsl:value-of select="concat('[',$unprefixed,']')"/>
4811          </xsl:when>
4812          <xsl:otherwise>
4813            <xsl:if test="count(//reference[@anchor=current()/@anchor])!=1">
4814              <xsl:message>Deleted duplicate anchors should have the prefix "deleted-": <xsl:value-of select="@anchor"/></xsl:message>
4815            </xsl:if>
4816            <xsl:value-of select="concat('[',@anchor,']')"/>
4817          </xsl:otherwise>
4818        </xsl:choose>
4819      </xsl:when>
4820      <xsl:when test="$xml2rfc-symrefs!='no'">[<xsl:value-of select="@anchor" />]</xsl:when>
4821      <xsl:when test="ancestor::ed:del">
4822        <xsl:text>[del]</xsl:text>
4823      </xsl:when>
4824      <xsl:otherwise>[<xsl:number level="any" count="reference[not(ancestor::ed:del)]"/>]</xsl:otherwise>
4825    </xsl:choose>
4826  </xsl:for-each> 
4827</xsl:template>
4828
4829
4830
4831<xsl:template name="replace-substring">
4832
4833  <xsl:param name="string" />
4834  <xsl:param name="replace" />
4835  <xsl:param name="by" />
4836
4837  <xsl:choose>
4838    <xsl:when test="contains($string,$replace)">
4839      <xsl:value-of select="concat(substring-before($string, $replace),$by)" />
4840      <xsl:call-template name="replace-substring">
4841        <xsl:with-param name="string" select="substring-after($string,$replace)" />
4842        <xsl:with-param name="replace" select="$replace" />
4843        <xsl:with-param name="by" select="$by" />
4844      </xsl:call-template>
4845    </xsl:when>
4846    <xsl:otherwise><xsl:value-of select="$string" /></xsl:otherwise>
4847  </xsl:choose>
4848
4849</xsl:template>
4850
4851<xsl:template name="rfc-or-id-link">
4852  <xsl:param name="name" />
4853 
4854  <xsl:choose>
4855    <xsl:when test="starts-with($name,'draft-')">
4856      <a href="{concat($internetDraftUrlPrefix,$name,$internetDraftUrlPostfix)}"><xsl:value-of select="$name"/></a>
4857      <xsl:call-template name="check-front-matter-ref">
4858        <xsl:with-param name="name" select="$name"/>
4859      </xsl:call-template>
4860    </xsl:when>
4861    <xsl:when test="number($name)=$name">
4862      <a href="{concat($rfcUrlPrefix,$name,$rfcUrlPostfix)}"><xsl:value-of select="$name"/></a>
4863      <xsl:call-template name="check-front-matter-ref">
4864        <xsl:with-param name="name" select="$name"/>
4865      </xsl:call-template>
4866    </xsl:when>
4867    <xsl:otherwise>
4868      <xsl:value-of select="$name"/>
4869      <xsl:call-template name="warning">
4870        <xsl:with-param name="inline" select="'no'"/>
4871        <xsl:with-param name="msg" select="concat('In metadata obsoletes/updates, RFC number of draft name is expected - found: ',$name)"/>
4872      </xsl:call-template>
4873    </xsl:otherwise>
4874  </xsl:choose>
4875</xsl:template>
4876
4877<xsl:template name="rfclist">
4878  <xsl:param name="list" />
4879  <xsl:choose>
4880    <xsl:when test="contains($list,',')">
4881      <xsl:variable name="rfcNo" select="substring-before($list,',')" />
4882      <xsl:call-template name="rfc-or-id-link">
4883        <xsl:with-param name="name" select="$rfcNo"/>
4884      </xsl:call-template>
4885      <xsl:text>, </xsl:text>
4886      <xsl:call-template name="rfclist">
4887        <xsl:with-param name="list" select="normalize-space(substring-after($list,','))" />
4888      </xsl:call-template>
4889    </xsl:when>
4890    <xsl:otherwise>
4891      <xsl:variable name="rfcNo" select="$list" />
4892      <xsl:call-template name="rfc-or-id-link">
4893        <xsl:with-param name="name" select="$rfcNo"/>
4894      </xsl:call-template>
4895    </xsl:otherwise>
4896  </xsl:choose>
4897</xsl:template>
4898
4899<xsl:template name="check-front-matter-ref">
4900  <xsl:param name="name"/>
4901  <xsl:choose>
4902    <xsl:when test="starts-with($name,'draft-')">
4903      <xsl:if test="not(//references//reference/seriesInfo[@name='Internet-Draft' and @value=$name])">
4904        <xsl:call-template name="warning">
4905          <xsl:with-param name="inline" select="'no'"/>
4906          <xsl:with-param name="msg" select="concat('front matter mentions I-D ',$name,' for which there is no reference element')"/>
4907        </xsl:call-template>
4908      </xsl:if>
4909    </xsl:when>
4910    <xsl:otherwise>
4911      <xsl:if test="not(//references//reference/seriesInfo[@name='RFC' and @value=$name])">
4912        <xsl:call-template name="warning">
4913          <xsl:with-param name="inline" select="'no'"/>
4914          <xsl:with-param name="msg" select="concat('front matter mentions RFC ',$name,' for which there is no reference element')"/>
4915        </xsl:call-template>
4916      </xsl:if>
4917    </xsl:otherwise>
4918  </xsl:choose>
4919</xsl:template>
4920
4921<xsl:template name="check-anchor">
4922  <xsl:if test="@anchor and @anchor!=''">
4923    <!-- check validity of anchor name -->
4924    <xsl:variable name="test">
4925      <xsl:element name="{@anchor}"/>
4926    </xsl:variable>
4927    <xsl:if test="count(exslt:node-set($test)//*) = 0">
4928      <xsl:call-template name="error">
4929        <xsl:with-param name="msg" select="concat('&quot;',@anchor,'&quot; is not a valid XML name')"/>
4930      </xsl:call-template>
4931    </xsl:if>
4932  </xsl:if>
4933</xsl:template>
4934
4935<xsl:template name="copy-anchor">
4936  <xsl:call-template name="check-anchor"/>
4937  <xsl:if test="@anchor and @anchor!=''">
4938    <xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute>
4939  </xsl:if>
4940</xsl:template>
4941
4942<xsl:template name="rfclist-for-dcmeta">
4943  <xsl:param name="list" />
4944  <xsl:choose>
4945    <xsl:when test="contains($list,',')">
4946      <xsl:variable name="rfcNo" select="substring-before($list,',')" />
4947      <meta name="dct.replaces" content="urn:ietf:rfc:{$rfcNo}" />
4948      <xsl:call-template name="rfclist-for-dcmeta">
4949        <xsl:with-param name="list" select="normalize-space(substring-after($list,','))" />
4950      </xsl:call-template>
4951    </xsl:when>
4952    <xsl:otherwise>
4953      <xsl:variable name="rfcNo" select="$list" />
4954      <meta name="dct.replaces" content="urn:ietf:rfc:{$rfcNo}" />
4955    </xsl:otherwise>
4956  </xsl:choose>
4957</xsl:template>
4958
4959<xsl:template name="get-paragraph-number">
4960  <!-- get section number of ancestor section element, then add t or figure number -->
4961  <xsl:if test="ancestor::section and not(ancestor::section[@myns:unnumbered='unnumbered']) and not(ancestor::x:blockquote) and not(ancestor::x:note)">
4962    <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" />
4963  </xsl:if>
4964</xsl:template>
4965
4966<xsl:template name="editingMark">
4967  <xsl:if test="$xml2rfc-editing='yes' and ancestor::rfc">
4968    <sup class="editingmark"><span><xsl:number level="any" count="postamble|preamble|t"/></span>&#0160;</sup>
4969  </xsl:if>
4970</xsl:template>
4971
4972<!-- internal ref support -->
4973<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"/>
4974
4975<xsl:template match="x:ref">
4976  <xsl:variable name="val" select="."/>
4977<!--  <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)]"/> -->
4978  <xsl:variable name="target" select="key('anchor-item',$val) | key('anchor-item-alias',$val)"/>
4979  <xsl:variable name="irefs" select="//iref[@x:for-anchor=$val]"/>
4980  <xsl:choose>
4981    <xsl:when test="$target">
4982      <a href="#{$target/@anchor}" class="smpl">
4983        <xsl:call-template name="copy-anchor"/>
4984        <!-- to be indexed? -->
4985        <xsl:if test="$irefs">
4986          <xsl:attribute name="id"><xsl:call-template name="compute-extref-anchor"/></xsl:attribute>
4987        </xsl:if>
4988        <xsl:value-of select="."/>
4989      </a>
4990    </xsl:when>
4991    <xsl:otherwise>
4992      <xsl:call-template name="warning">
4993        <xsl:with-param name="inline" select="'no'"/>
4994        <xsl:with-param name="msg">internal link target for '<xsl:value-of select="."/>' does not exist.</xsl:with-param>
4995      </xsl:call-template>
4996      <xsl:value-of select="."/>
4997    </xsl:otherwise>
4998  </xsl:choose>
4999</xsl:template>
5000
5001<!-- Nothing to do here -->
5002<xsl:template match="x:anchor-alias" />
5003
5004<!-- Quotes -->
5005<xsl:template match="x:q">
5006  <q>
5007    <xsl:copy-of select="@cite"/>
5008    <xsl:apply-templates/>
5009  </q>
5010</xsl:template>
5011
5012<!-- Notes -->
5013<xsl:template match="x:note">
5014  <xsl:variable name="p">
5015    <xsl:call-template name="get-paragraph-number" />
5016  </xsl:variable>
5017
5018  <div class="note">
5019    <xsl:if test="$p!='' and not(ancestor::ed:del) and not(ancestor::ed:ins)">
5020      <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$p"/></xsl:attribute>
5021    </xsl:if>
5022    <xsl:apply-templates/>
5023  </div>
5024</xsl:template>
5025
5026<xsl:template match="x:bcp14">
5027  <!-- check valid BCP14 keywords, then emphasize them -->
5028  <xsl:variable name="c" select="normalize-space(.)"/>
5029  <xsl:choose>
5030    <xsl:when test="$c='MUST' or $c='REQUIRED' or $c='SHALL'">
5031      <em class="bcp14"><xsl:value-of select="."/></em>
5032    </xsl:when>
5033    <xsl:when test="$c='MUST NOT' or $c='SHALL NOT'">
5034      <em class="bcp14"><xsl:value-of select="."/></em>
5035    </xsl:when>
5036    <xsl:when test="$c='SHOULD' or $c='RECOMMENDED'">
5037      <em class="bcp14"><xsl:value-of select="."/></em>
5038    </xsl:when>
5039    <xsl:when test="$c='SHOULD NOT' or $c='NOT RECOMMENDED'">
5040      <em class="bcp14"><xsl:value-of select="."/></em>
5041    </xsl:when>
5042    <xsl:when test="$c='MAY' or $c='OPTIONAL'">
5043      <em class="bcp14"><xsl:value-of select="."/></em>
5044    </xsl:when>
5045    <xsl:otherwise>
5046      <xsl:value-of select="."/>
5047      <xsl:message>ERROR: unknown BCP14 keyword: <xsl:value-of select="."/></xsl:message>
5048    </xsl:otherwise>
5049  </xsl:choose>
5050</xsl:template>
5051
5052<xsl:template match="x:blockquote">
5053  <xsl:variable name="p">
5054    <xsl:call-template name="get-paragraph-number" />
5055  </xsl:variable>
5056
5057  <blockquote>
5058    <xsl:if test="string-length($p) &gt; 0 and not(ancestor::ed:del) and not(ancestor::ed:ins)">
5059      <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$p"/></xsl:attribute>
5060    </xsl:if>
5061    <xsl:call-template name="insertInsDelClass"/>
5062    <xsl:call-template name="editingMark" />
5063    <xsl:copy-of select="@cite"/>
5064    <xsl:apply-templates/>
5065  </blockquote>
5066</xsl:template>
5067
5068<!-- Definitions -->
5069<xsl:template match="x:dfn">
5070  <dfn>
5071    <xsl:call-template name="copy-anchor"/>
5072    <xsl:apply-templates/>
5073  </dfn>
5074</xsl:template>
5075
5076<!-- headings -->
5077<xsl:template match="x:h">
5078  <b>
5079    <xsl:call-template name="copy-anchor"/>
5080    <xsl:apply-templates/>
5081  </b>
5082</xsl:template>
5083
5084<!-- superscripts -->
5085<xsl:template match="x:sup">
5086  <sup>
5087    <xsl:apply-templates/>
5088  </sup>
5089</xsl:template>
5090
5091<!-- bold -->
5092<xsl:template match="x:highlight">
5093  <b>
5094    <xsl:call-template name="copy-anchor"/>
5095    <xsl:apply-templates/>
5096  </b>
5097</xsl:template>
5098
5099<!-- measuring lengths -->
5100<xsl:template match="x:length-of">
5101  <xsl:variable name="target" select="//*[@anchor=current()/@target]"/>
5102  <xsl:if test="count($target)!=1">
5103    <xsl:call-template name="error">
5104      <xsl:with-param name="msg" select="concat('@target ',@target,' defined ',count($target),' times.')"/>
5105    </xsl:call-template>
5106  </xsl:if>
5107  <xsl:variable name="content">
5108    <xsl:apply-templates select="$target"/>
5109  </xsl:variable>
5110  <xsl:variable name="lineends" select="string-length($content) - string-length(translate($content,'&#10;',''))"/>
5111  <xsl:variable name="indents">
5112    <xsl:choose>
5113      <xsl:when test="@indented">
5114        <xsl:value-of select="number(@indented) * $lineends"/>
5115      </xsl:when>
5116      <xsl:otherwise>0</xsl:otherwise>
5117    </xsl:choose>
5118  </xsl:variable>
5119  <xsl:value-of select="string-length($content) + $lineends - $indents"/>
5120</xsl:template>
5121
5122<!-- Nop -->
5123<xsl:template match="x:span">
5124  <span>
5125    <xsl:call-template name="copy-anchor"/>
5126    <xsl:apply-templates/>
5127  </span>
5128</xsl:template>
5129
5130<xsl:template match="x:parse-xml">
5131  <xsl:apply-templates/>
5132
5133  <xsl:if test="function-available('exslt:node-set')">
5134    <xsl:variable name="cleaned">
5135      <xsl:apply-templates mode="cleanup-edits"/>
5136    </xsl:variable>
5137    <xsl:if test="$xml2rfc-ext-trace-parse-xml='yes'">
5138      <xsl:call-template name="trace">
5139        <xsl:with-param name="msg" select="concat('Parsing XML: ', $cleaned)"/>
5140      </xsl:call-template>
5141    </xsl:if>
5142    <xsl:choose>
5143      <xsl:when test="function-available('myns:parseXml')">
5144        <xsl:if test="myns:parseXml(concat($cleaned,''))!=''">
5145          <xsl:call-template name="error">
5146            <xsl:with-param name="msg" select="concat('Parse error in XML: ', myns:parseXml(concat($cleaned,'')))"/>
5147          </xsl:call-template>
5148        </xsl:if>
5149      </xsl:when>
5150      <xsl:when test="function-available('saxon:parse')">
5151        <xsl:variable name="parsed" select="saxon:parse(concat($cleaned,''))"/>
5152        <xsl:if test="$parsed='foo'">
5153          <xsl:comment>should not get here</xsl:comment>
5154        </xsl:if>
5155      </xsl:when>
5156      <xsl:otherwise></xsl:otherwise>
5157    </xsl:choose>
5158  </xsl:if>
5159</xsl:template>
5160
5161<!-- inlined RDF support -->
5162<xsl:template match="rdf:Description">
5163  <!-- ignore -->
5164</xsl:template>
5165
5166<!-- cleanup for ins/del -->
5167
5168<xsl:template match="comment()|@*" mode="cleanup-edits"><xsl:copy/></xsl:template>
5169
5170<xsl:template match="text()" mode="cleanup-edits"><xsl:copy/></xsl:template>
5171
5172<xsl:template match="/" mode="cleanup-edits">
5173  <xsl:copy><xsl:apply-templates select="node()" mode="cleanup-edits" /></xsl:copy>
5174</xsl:template>
5175
5176<xsl:template match="ed:del" mode="cleanup-edits"/>
5177
5178<xsl:template match="ed:replace" mode="cleanup-edits">
5179  <xsl:apply-templates mode="cleanup-edits"/>
5180</xsl:template>
5181
5182<xsl:template match="ed:ins" mode="cleanup-edits">
5183  <xsl:apply-templates mode="cleanup-edits"/>
5184</xsl:template>
5185
5186
5187<!-- ABNF support -->
5188<xsl:template name="to-abnf-char-sequence">
5189  <xsl:param name="chars"/>
5190 
5191  <xsl:variable name="c" select="substring($chars,1,1)"/>
5192  <xsl:variable name="r" select="substring($chars,2)"/>
5193   
5194  <xsl:choose>
5195    <xsl:when test="$c='-'">2D</xsl:when>
5196    <xsl:when test="$c='/'">2F</xsl:when>
5197    <xsl:when test="$c='0'">30</xsl:when>
5198    <xsl:when test="$c='1'">31</xsl:when>
5199    <xsl:when test="$c='2'">32</xsl:when>
5200    <xsl:when test="$c='3'">33</xsl:when>
5201    <xsl:when test="$c='4'">34</xsl:when>
5202    <xsl:when test="$c='5'">35</xsl:when>
5203    <xsl:when test="$c='6'">36</xsl:when>
5204    <xsl:when test="$c='7'">37</xsl:when>
5205    <xsl:when test="$c='8'">38</xsl:when>
5206    <xsl:when test="$c='9'">39</xsl:when>
5207    <xsl:when test="$c='A'">41</xsl:when>
5208    <xsl:when test="$c='B'">42</xsl:when>
5209    <xsl:when test="$c='C'">43</xsl:when>
5210    <xsl:when test="$c='D'">44</xsl:when>
5211    <xsl:when test="$c='E'">45</xsl:when>
5212    <xsl:when test="$c='F'">46</xsl:when>
5213    <xsl:when test="$c='G'">47</xsl:when>
5214    <xsl:when test="$c='H'">48</xsl:when>
5215    <xsl:when test="$c='I'">49</xsl:when>
5216    <xsl:when test="$c='J'">4A</xsl:when>
5217    <xsl:when test="$c='K'">4B</xsl:when>
5218    <xsl:when test="$c='L'">4C</xsl:when>
5219    <xsl:when test="$c='M'">4D</xsl:when>
5220    <xsl:when test="$c='N'">4E</xsl:when>
5221    <xsl:when test="$c='O'">4F</xsl:when>
5222    <xsl:when test="$c='P'">50</xsl:when>
5223    <xsl:when test="$c='Q'">51</xsl:when>
5224    <xsl:when test="$c='R'">52</xsl:when>
5225    <xsl:when test="$c='S'">53</xsl:when>
5226    <xsl:when test="$c='T'">54</xsl:when>
5227    <xsl:when test="$c='U'">55</xsl:when>
5228    <xsl:when test="$c='V'">56</xsl:when>
5229    <xsl:when test="$c='W'">57</xsl:when>
5230    <xsl:when test="$c='X'">58</xsl:when>
5231    <xsl:when test="$c='Y'">59</xsl:when>
5232    <xsl:when test="$c='Z'">5A</xsl:when>
5233    <xsl:when test="$c='a'">61</xsl:when>
5234    <xsl:when test="$c='b'">62</xsl:when>
5235    <xsl:when test="$c='c'">63</xsl:when>
5236    <xsl:when test="$c='d'">64</xsl:when>
5237    <xsl:when test="$c='e'">65</xsl:when>
5238    <xsl:when test="$c='f'">66</xsl:when>
5239    <xsl:when test="$c='g'">67</xsl:when>
5240    <xsl:when test="$c='h'">68</xsl:when>
5241    <xsl:when test="$c='i'">69</xsl:when>
5242    <xsl:when test="$c='j'">6A</xsl:when>
5243    <xsl:when test="$c='k'">6B</xsl:when>
5244    <xsl:when test="$c='l'">6C</xsl:when>
5245    <xsl:when test="$c='m'">6D</xsl:when>
5246    <xsl:when test="$c='n'">6E</xsl:when>
5247    <xsl:when test="$c='o'">6F</xsl:when>
5248    <xsl:when test="$c='p'">70</xsl:when>
5249    <xsl:when test="$c='q'">71</xsl:when>
5250    <xsl:when test="$c='r'">72</xsl:when>
5251    <xsl:when test="$c='s'">73</xsl:when>
5252    <xsl:when test="$c='t'">74</xsl:when>
5253    <xsl:when test="$c='u'">75</xsl:when>
5254    <xsl:when test="$c='v'">76</xsl:when>
5255    <xsl:when test="$c='w'">77</xsl:when>
5256    <xsl:when test="$c='x'">78</xsl:when>
5257    <xsl:when test="$c='y'">79</xsl:when>
5258    <xsl:when test="$c='z'">7A</xsl:when>
5259    <xsl:otherwise>
5260      <xsl:text>??</xsl:text>
5261      <xsl:call-template name="error">
5262        <xsl:with-param name="msg" select="concat('unexpected character in ABNF char sequence: ',substring($chars,1,1))" />
5263      </xsl:call-template>
5264    </xsl:otherwise>
5265  </xsl:choose>
5266
5267  <xsl:if test="$r!=''">
5268    <xsl:text>.</xsl:text>
5269    <xsl:call-template name="to-abnf-char-sequence">
5270      <xsl:with-param name="chars" select="$r"/>
5271    </xsl:call-template>
5272  </xsl:if>
5273 
5274</xsl:template>
5275
5276<xsl:template match="x:abnf-char-sequence">
5277  <xsl:choose>
5278    <xsl:when test="substring(.,1,1) != '&quot;' or substring(.,string-length(.),1) != '&quot;'">
5279      <xsl:call-template name="error">
5280        <xsl:with-param name="msg" select="'contents of x:abnf-char-sequence needs to be quoted.'" />
5281      </xsl:call-template>
5282    </xsl:when>
5283    <xsl:otherwise>
5284      <xsl:text>%x</xsl:text>
5285      <xsl:call-template name="to-abnf-char-sequence">
5286        <xsl:with-param name="chars" select="substring(.,2,string-length(.)-2)"/>
5287      </xsl:call-template>
5288    </xsl:otherwise>
5289  </xsl:choose>
5290</xsl:template>
5291
5292<!-- box drawing -->
5293
5294<!-- nop for alignment -->
5295<xsl:template match="x:x"/>
5296
5297<!-- box (top) -->
5298<xsl:template match="x:bt">
5299  <xsl:text>&#x250c;</xsl:text>
5300  <xsl:value-of select="translate(substring(.,2,string-length(.)-2),'-','&#x2500;')"/>
5301  <xsl:text>&#x2510;</xsl:text>
5302</xsl:template>
5303
5304<!-- box (center) -->
5305<xsl:template match="x:bc">
5306  <xsl:variable name="first" select="substring(.,1)"/>
5307  <xsl:variable name="content" select="substring(.,2,string-length(.)-2)"/>
5308  <xsl:variable name="is-delimiter" select="translate($content,'-','')=''"/>
5309 
5310  <xsl:choose>
5311    <xsl:when test="$is-delimiter">
5312      <xsl:text>&#x251c;</xsl:text>
5313      <xsl:value-of select="translate($content,'-','&#x2500;')"/>
5314      <xsl:text>&#x2524;</xsl:text>
5315    </xsl:when>
5316    <xsl:when test="*">
5317      <xsl:for-each select="node()">
5318        <xsl:choose>
5319          <xsl:when test="position()=1">
5320            <xsl:text>&#x2502;</xsl:text>
5321            <xsl:value-of select="substring(.,2)"/>
5322          </xsl:when>
5323          <xsl:when test="position()=last()">
5324            <xsl:value-of select="substring(.,1,string-length(.)-1)"/>
5325            <xsl:text>&#x2502;</xsl:text>
5326          </xsl:when>
5327          <xsl:otherwise>
5328            <xsl:apply-templates select="."/>
5329          </xsl:otherwise>
5330        </xsl:choose>
5331      </xsl:for-each>
5332    </xsl:when>
5333    <xsl:otherwise>
5334      <xsl:text>&#x2502;</xsl:text>
5335      <xsl:value-of select="$content"/>
5336      <xsl:text>&#x2502;</xsl:text>
5337    </xsl:otherwise>
5338  </xsl:choose>
5339 
5340</xsl:template>
5341
5342<!-- box (bottom) -->
5343<xsl:template match="x:bb">
5344  <xsl:text>&#x2514;</xsl:text>
5345  <xsl:value-of select="translate(substring(.,2,string-length(.)-2),'-','&#x2500;')"/>
5346  <xsl:text>&#x2518;</xsl:text>
5347</xsl:template>
5348
5349<!-- author handling extensions -->
5350<xsl:template match="x:include-author">
5351  <xsl:for-each select="/*/front/author[@anchor=current()/@target]">
5352    <xsl:apply-templates select="."/>
5353  </xsl:for-each>
5354</xsl:template>
5355
5356<!-- boilerplate -->
5357<xsl:template match="x:boilerplate">
5358  <xsl:apply-templates/>
5359</xsl:template>
5360
5361<!-- experimental annotation support -->
5362
5363<xsl:template match="ed:issueref">
5364  <xsl:choose>
5365    <xsl:when test=".=//ed:issue/@name">
5366      <a href="#{$anchor-prefix}.issue.{.}">
5367        <xsl:apply-templates/>
5368      </a>
5369    </xsl:when>
5370    <xsl:otherwise>
5371      <xsl:call-template name="warning">
5372        <xsl:with-param name="msg">Dangling ed:issueref: <xsl:value-of select="."/></xsl:with-param>
5373      </xsl:call-template>
5374      <xsl:apply-templates/>
5375    </xsl:otherwise>
5376  </xsl:choose>
5377</xsl:template>
5378
5379<xsl:template match="ed:issue">
5380  <xsl:variable name="class">
5381    <xsl:choose>
5382      <xsl:when test="@status='closed'">closedissue</xsl:when>
5383      <xsl:otherwise>openissue</xsl:otherwise>
5384    </xsl:choose>
5385  </xsl:variable>
5386 
5387  <table class="{$class}">
5388    <tr>
5389      <td colspan="3">
5390        <a id="{$anchor-prefix}.issue.{@name}">
5391          <xsl:choose>
5392            <xsl:when test="@status='closed'">
5393              <xsl:attribute name="class">closed-issue</xsl:attribute>
5394            </xsl:when>
5395            <xsl:when test="@status='editor'">
5396              <xsl:attribute name="class">editor-issue</xsl:attribute>
5397            </xsl:when>
5398            <xsl:otherwise>
5399              <xsl:attribute name="class">open-issue</xsl:attribute>
5400            </xsl:otherwise>
5401          </xsl:choose>
5402          <xsl:text>&#160;I&#160;</xsl:text>
5403        </a>
5404        <xsl:text>&#160;</xsl:text>
5405        <xsl:choose>
5406          <xsl:when test="@href">
5407            <em><a href="{@href}"><xsl:value-of select="@name" /></a></em>
5408          </xsl:when>
5409          <xsl:when test="@alternate-href">
5410            <em>[<a href="{@alternate-href}">alternate link</a>]</em>
5411          </xsl:when>
5412          <xsl:otherwise>
5413            <em><xsl:value-of select="@name" /></em>
5414          </xsl:otherwise>
5415        </xsl:choose>
5416        &#0160;
5417        (type: <xsl:value-of select="@type"/>, status: <xsl:value-of select="@status"/>)
5418      </td>
5419    </tr>
5420
5421    <xsl:apply-templates select="ed:item"/>
5422    <xsl:apply-templates select="ed:resolution"/>
5423
5424    <xsl:variable name="changes" select="//*[@ed:resolves=current()/@name or ed:resolves=current()/@name]" />
5425    <xsl:if test="$changes">
5426      <tr>
5427        <td class="top" colspan="3">
5428          Associated changes in this document:
5429          <xsl:variable name="issue" select="@name"/>
5430          <xsl:for-each select="$changes">
5431            <a href="#{$anchor-prefix}.change.{$issue}.{position()}">
5432              <xsl:variable name="label">
5433                <xsl:call-template name="get-section-number"/>
5434              </xsl:variable>
5435              <xsl:choose>
5436                <xsl:when test="$label!=''"><xsl:value-of select="$label"/></xsl:when>
5437                <xsl:otherwise>&lt;<xsl:value-of select="concat('#',$anchor-prefix,'.change.',$issue,'.',position())"/>&gt;</xsl:otherwise>
5438              </xsl:choose>
5439            </a>
5440            <xsl:if test="position()!=last()">, </xsl:if>
5441          </xsl:for-each>
5442          <xsl:text>.</xsl:text>
5443        </td>
5444      </tr>
5445    </xsl:if>
5446  </table>
5447   
5448</xsl:template>
5449
5450<xsl:template match="ed:item">
5451  <tr>
5452    <td class="top">
5453      <xsl:if test="@entered-by">
5454        <a href="mailto:{@entered-by}?subject={/rfc/@docName},%20{../@name}">
5455          <i><xsl:value-of select="@entered-by"/></i>
5456        </a>
5457      </xsl:if>
5458    </td>
5459    <td class="topnowrap">
5460      <xsl:value-of select="@date"/>
5461    </td>
5462    <td class="top">
5463      <xsl:apply-templates select="node()" mode="issuehtml"/>
5464    </td>
5465  </tr>
5466</xsl:template>
5467
5468<xsl:template match="ed:resolution">
5469  <tr>
5470    <td class="top">
5471      <xsl:if test="@entered-by">
5472        <a href="mailto:{@entered-by}?subject={/rfc/@docName},%20{../@name}"><i><xsl:value-of select="@entered-by"/></i></a>
5473      </xsl:if>
5474    </td>
5475    <td class="topnowrap">
5476      <xsl:value-of select="@datetime"/>
5477    </td>
5478    <td class="top">
5479      <em>Resolution:</em>
5480      <xsl:apply-templates select="node()" mode="issuehtml"/>
5481    </td>
5482  </tr>
5483</xsl:template>
5484
5485<xsl:template match="ed:annotation">
5486  <em>
5487    <xsl:apply-templates/>
5488  </em>
5489</xsl:template>
5490
5491<!-- special templates for handling XHTML in issues -->
5492<xsl:template match="text()" mode="issuehtml">
5493  <xsl:value-of select="."/>
5494</xsl:template>
5495
5496<xsl:template match="*|@*" mode="issuehtml">
5497  <xsl:message terminate="yes">Unexpected node in issue HTML: <xsl:value-of select="name(.)"/></xsl:message>
5498</xsl:template>
5499
5500<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">
5501  <xsl:element name="{local-name()}">
5502    <xsl:apply-templates select="@*|node()" mode="issuehtml"/>
5503  </xsl:element>
5504</xsl:template>
5505
5506<xsl:template match="xhtml:p" mode="issuehtml">
5507  <xsl:apply-templates select="node()" mode="issuehtml"/>
5508  <br class="p"/>
5509</xsl:template>
5510
5511<xsl:template match="xhtml:a/@href|xhtml:q/@cite" mode="issuehtml">
5512  <xsl:attribute name="{local-name(.)}">
5513    <xsl:value-of select="."/>
5514  </xsl:attribute>
5515</xsl:template>
5516
5517<xsl:template match="ed:issueref" mode="issuehtml">
5518  <xsl:apply-templates select="."/>
5519</xsl:template>
5520
5521<xsl:template match="ed:eref" mode="issuehtml">
5522  <xsl:text>&lt;</xsl:text>
5523  <a href="{.}"><xsl:value-of select="."/></a>
5524  <xsl:text>&gt;</xsl:text>
5525</xsl:template>
5526
5527<xsl:template name="insertIssuesList">
5528
5529  <h2 id="{$anchor-prefix}.issues-list" ><a href="#{$anchor-prefix}.issues-list">Issues list</a></h2>
5530  <table>
5531    <thead>
5532      <tr>
5533        <th>Id</th>
5534        <th>Type</th>
5535        <th>Status</th>
5536        <th>Date</th>
5537        <th>Raised By</th>
5538      </tr>
5539    </thead>
5540    <tbody>
5541      <xsl:for-each select="//ed:issue">
5542        <xsl:sort select="@status" />
5543        <xsl:sort select="@name" />
5544        <tr>
5545          <td><a href="#{$anchor-prefix}.issue.{@name}"><xsl:value-of select="@name" /></a></td>
5546          <td><xsl:value-of select="@type" /></td>
5547          <td><xsl:value-of select="@status" /></td>
5548          <td><xsl:value-of select="ed:item[1]/@date" /></td>
5549          <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>
5550        </tr>
5551      </xsl:for-each>
5552    </tbody>
5553  </table>
5554 
5555</xsl:template>
5556
5557<xsl:template name="insert-diagnostics">
5558 
5559  <!-- check anchor names -->
5560  <xsl:variable name="badAnchors"
5561    select="//*[starts-with(@anchor,concat($anchor-prefix,'.'))][@anchor!=concat($anchor-prefix,'.authors') and /*/x:assign-section-number[@number='suppress' and @builtin-target='authors']]" />
5562 
5563  <xsl:if test="$badAnchors">
5564    <xsl:variable name="text">
5565      The following anchor names may collide with internally generated anchors because of their prefix "<xsl:value-of select="$anchor-prefix" />":
5566      <xsl:for-each select="$badAnchors">
5567        <xsl:value-of select="@anchor"/><xsl:if test="position()!=last()">, </xsl:if>
5568      </xsl:for-each>
5569    </xsl:variable>
5570    <xsl:call-template name="warning">
5571      <xsl:with-param name="msg"><xsl:value-of select="$text"/></xsl:with-param>
5572    </xsl:call-template>
5573  </xsl:if>
5574 
5575  <!-- check ABNF syntax references -->
5576  <xsl:if test="//artwork[@type='abnf2616']">
5577    <xsl:if test="not(//reference/seriesInfo[@name='RFC' and (@value='2068' or @value='2616')])">
5578      <xsl:call-template name="warning">
5579        <xsl:with-param name="inline">no</xsl:with-param>
5580        <xsl:with-param name="msg">document uses HTTP-style ABNF syntax, but doesn't reference RFC 2068 or 2616.</xsl:with-param>
5581      </xsl:call-template>
5582    </xsl:if>
5583  </xsl:if>
5584  <xsl:if test="//artwork[@type='abnf']">
5585    <xsl:if test="not(//reference/seriesInfo[@name='RFC' and (@value='2234' or @value='4234' or @value='5234')])">
5586      <xsl:call-template name="warning">
5587        <xsl:with-param name="inline">no</xsl:with-param>
5588        <xsl:with-param name="msg">document uses ABNF syntax, but doesn't reference RFC 2234, 4234 or 5234.</xsl:with-param>
5589      </xsl:call-template>
5590    </xsl:if>
5591  </xsl:if>
5592 
5593  <!-- check IDs -->
5594  <xsl:variable name="badTargets" select="//xref[not(@target=//@anchor) and not(ancestor::ed:del)]" />
5595  <xsl:if test="$badTargets">
5596    <xsl:variable name="text">
5597      The following target names do not exist:
5598      <xsl:for-each select="$badTargets">
5599        <xsl:value-of select="@target"/><xsl:if test="position()!=last()">, </xsl:if>
5600      </xsl:for-each>
5601    </xsl:variable>
5602    <xsl:call-template name="warning">
5603      <xsl:with-param name="msg"><xsl:value-of select="$text"/></xsl:with-param>
5604    </xsl:call-template>
5605  </xsl:if>
5606 
5607 
5608</xsl:template>
5609
5610<!-- special change mark support, not supported by RFC2629 yet -->
5611
5612<xsl:template match="@ed:*" />
5613
5614<xsl:template match="ed:del">
5615  <xsl:call-template name="insert-issue-pointer"/>
5616  <del>
5617    <xsl:copy-of select="@*[namespace-uri()='']"/>
5618    <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
5619      <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
5620    </xsl:if>
5621    <xsl:apply-templates />
5622  </del>
5623</xsl:template>
5624
5625<xsl:template match="ed:ins">
5626  <xsl:call-template name="insert-issue-pointer"/>
5627  <ins>
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  </ins>
5634</xsl:template>
5635
5636<xsl:template name="insert-issue-pointer">
5637  <xsl:param name="deleted-anchor"/>
5638  <xsl:variable name="change" select="."/>
5639  <xsl:for-each select="@ed:resolves|ed:resolves">
5640    <xsl:variable name="resolves" select="."/>
5641    <!-- need the right context node for proper numbering -->
5642    <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>
5643    <xsl:variable name="total" select="count(//*[@ed:resolves=$resolves or ed:resolves=$resolves])" />
5644    <xsl:variable name="id">
5645      <xsl:value-of select="$anchor-prefix"/>.change.<xsl:value-of select="$resolves"/>.<xsl:value-of select="$count" />
5646    </xsl:variable>
5647    <xsl:choose>
5648      <!-- block level? -->
5649      <xsl:when test="not(ancestor::t) and not(ancestor::title) and not(ancestor::figure) and not($change/@ed:old-title)">
5650        <div class="issuepointer noprint">
5651          <xsl:if test="not($deleted-anchor)">
5652            <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
5653          </xsl:if>
5654          <xsl:if test="$count > 1">
5655            <a class="bg-issue" title="previous change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count - 1}">&#x2191;</a>
5656          </xsl:if>
5657          <a class="open-issue" href="#{$anchor-prefix}.issue.{$resolves}" title="resolves: {$resolves}">
5658            <xsl:choose>
5659              <xsl:when test="//ed:issue[@name=$resolves and @status='closed']">
5660                <xsl:attribute name="class">closed-issue</xsl:attribute>
5661              </xsl:when>
5662              <xsl:when test="//ed:issue[@name=$resolves and @status='editor']">
5663                <xsl:attribute name="class">editor-issue</xsl:attribute>
5664              </xsl:when>
5665              <xsl:otherwise>
5666                <xsl:attribute name="class">open-issue</xsl:attribute>
5667              </xsl:otherwise>
5668            </xsl:choose>
5669            <xsl:text>&#160;I&#160;</xsl:text>
5670          </a>
5671          <xsl:if test="$count &lt; $total">
5672            <a class="bg-issue" title="next change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count + 1}">&#x2193;</a>
5673          </xsl:if>
5674          <xsl:text>&#160;</xsl:text>
5675        </div>
5676      </xsl:when>
5677      <xsl:otherwise>
5678        <xsl:if test="$count > 1">
5679          <a class="bg-issue" title="previous change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count - 1}">&#x2191;</a>
5680        </xsl:if>
5681        <a title="resolves: {$resolves}" href="#{$anchor-prefix}.issue.{$resolves}">
5682          <xsl:if test="not($deleted-anchor)">
5683            <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
5684          </xsl:if>
5685          <xsl:choose>
5686            <xsl:when test="//ed:issue[@name=$resolves and @status='closed']">
5687              <xsl:attribute name="class">closed-issue noprint</xsl:attribute>
5688            </xsl:when>
5689            <xsl:when test="//ed:issue[@name=$resolves and @status='editor']">
5690              <xsl:attribute name="class">editor-issue noprint</xsl:attribute>
5691            </xsl:when>
5692            <xsl:otherwise>
5693              <xsl:attribute name="class">open-issue noprint</xsl:attribute>
5694            </xsl:otherwise>
5695          </xsl:choose>
5696          <xsl:text>&#160;I&#160;</xsl:text>
5697        </a>
5698        <xsl:if test="$count &lt; $total">
5699          <a class="bg-issue" title="next change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count + 1}">&#x2193;</a>
5700        </xsl:if>
5701      </xsl:otherwise>
5702    </xsl:choose>
5703  </xsl:for-each>
5704</xsl:template>
5705
5706<xsl:template match="ed:replace">
5707  <!-- we need to special-case things like lists and tables -->
5708  <xsl:choose>
5709    <xsl:when test="parent::list">
5710      <xsl:apply-templates select="ed:del/node()" />
5711      <xsl:apply-templates select="ed:ins/node()" />
5712    </xsl:when>
5713    <xsl:when test="parent::references">
5714      <xsl:apply-templates select="ed:del/node()" />
5715      <xsl:apply-templates select="ed:ins/node()" />
5716    </xsl:when>
5717    <xsl:otherwise>
5718      <xsl:if test="@cite">
5719        <a class="editor-issue" href="{@cite}" target="_blank" title="see {@cite}">
5720          <xsl:text>&#160;i&#160;</xsl:text>
5721        </a>
5722      </xsl:if>
5723      <xsl:call-template name="insert-issue-pointer"/>
5724      <xsl:if test="ed:del">
5725        <del>
5726          <xsl:copy-of select="@*[namespace-uri()='']"/>
5727          <xsl:if test="not(@title) and ancestor-or-self::xsl:template[@ed:entered-by] and @datetime">
5728            <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
5729          </xsl:if>
5730          <xsl:apply-templates select="ed:del/node()" />
5731        </del>
5732      </xsl:if>
5733      <xsl:if test="ed:ins">
5734        <ins>
5735          <xsl:copy-of select="@*[namespace-uri()='']"/>
5736          <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
5737            <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
5738          </xsl:if>
5739          <xsl:apply-templates select="ed:ins/node()" />
5740        </ins>
5741      </xsl:if>
5742    </xsl:otherwise>
5743  </xsl:choose>
5744</xsl:template>
5745
5746<!-- convenience template for helping Mozilla (pre/ins inheritance problem) -->
5747<xsl:template name="insertInsDelClass">
5748  <xsl:if test="ancestor::ed:del">
5749    <xsl:attribute name="class">del</xsl:attribute>
5750  </xsl:if>
5751  <xsl:if test="ancestor::ed:ins">
5752    <xsl:attribute name="class">ins</xsl:attribute>
5753  </xsl:if>
5754</xsl:template>
5755
5756
5757<xsl:template name="sectionnumberAndEdits">
5758  <xsl:choose>
5759    <xsl:when test="ancestor::ed:del">
5760      <xsl:text>del-</xsl:text>
5761      <xsl:number count="ed:del//section" level="any"/>
5762    </xsl:when>
5763    <xsl:when test="@x:fixed-section-number and @x:fixed-section-number!=''">
5764      <xsl:value-of select="@x:fixed-section-number"/>
5765    </xsl:when>
5766    <xsl:when test="@x:fixed-section-number and @x:fixed-section-number=''">
5767      <xsl:text>unnumbered-</xsl:text>
5768      <xsl:number count="section[@x:fixed-section-number='']" level="any"/>
5769    </xsl:when>
5770    <xsl:when test="self::section and parent::ed:ins and local-name(../..)='replace'">
5771      <xsl:for-each select="../.."><xsl:call-template name="sectionnumberAndEdits" /></xsl:for-each>
5772      <xsl:for-each select="..">
5773        <xsl:if test="parent::ed:replace">
5774          <xsl:for-each select="..">
5775            <xsl:if test="parent::section">.</xsl:if>
5776            <xsl:variable name="cnt" select="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)" />
5777            <xsl:choose>
5778              <xsl:when test="ancestor::back and not(ancestor::section)"><xsl:number format="A" value="$cnt"/></xsl:when>
5779              <xsl:otherwise><xsl:value-of select="$cnt"/></xsl:otherwise>
5780            </xsl:choose>
5781          </xsl:for-each>
5782        </xsl:if>
5783      </xsl:for-each>
5784    </xsl:when>
5785    <xsl:when test="self::section[parent::ed:ins]">
5786      <xsl:for-each select="../.."><xsl:call-template name="sectionnumberAndEdits" /></xsl:for-each>
5787      <xsl:for-each select="..">
5788        <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)" />
5789      </xsl:for-each>
5790    </xsl:when>
5791    <xsl:when test="self::section">
5792      <xsl:for-each select=".."><xsl:call-template name="sectionnumberAndEdits" /></xsl:for-each>
5793      <xsl:if test="parent::section">.</xsl:if>
5794      <xsl:choose>
5795        <xsl:when test="parent::back">
5796          <xsl:number format="A" value="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)" />
5797        </xsl:when>
5798        <xsl:otherwise>
5799          <xsl:number value="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)" />
5800        </xsl:otherwise>
5801      </xsl:choose>
5802    </xsl:when>
5803    <xsl:when test="self::references">
5804      <xsl:choose>
5805        <xsl:when test="count(/*/back/references)+count(/*/back/ed:replace/ed:ins/references)=1"><xsl:call-template name="get-references-section-number"/></xsl:when>
5806        <xsl:otherwise><xsl:call-template name="get-references-section-number"/>.<xsl:number level="any"/></xsl:otherwise>
5807      </xsl:choose>
5808    </xsl:when>
5809    <xsl:when test="self::middle or self::back"><!-- done --></xsl:when>
5810    <xsl:otherwise>
5811      <!-- go up one level -->
5812      <xsl:for-each select=".."><xsl:call-template name="sectionnumberAndEdits" /></xsl:for-each>
5813    </xsl:otherwise>
5814  </xsl:choose>
5815</xsl:template>
5816
5817<!-- utilities for warnings -->
5818
5819<xsl:template name="trace">
5820  <xsl:param name="msg"/>
5821  <xsl:param name="msg2"/>
5822  <xsl:param name="inline"/>
5823  <xsl:call-template name="emit-message">
5824    <xsl:with-param name="level">TRACE</xsl:with-param>
5825    <xsl:with-param name="msg" select="$msg"/>
5826    <xsl:with-param name="msg2" select="$msg2"/>
5827    <xsl:with-param name="inline" select="$inline"/>
5828  </xsl:call-template>
5829</xsl:template>
5830
5831<xsl:template name="warning">
5832  <xsl:param name="msg"/>
5833  <xsl:param name="msg2"/>
5834  <xsl:param name="inline"/>
5835  <xsl:call-template name="emit-message">
5836    <xsl:with-param name="level">WARNING</xsl:with-param>
5837    <xsl:with-param name="msg" select="$msg"/>
5838    <xsl:with-param name="msg2" select="$msg2"/>
5839    <xsl:with-param name="inline" select="$inline"/>
5840  </xsl:call-template>
5841</xsl:template>
5842
5843<xsl:template name="info">
5844  <xsl:param name="msg"/>
5845  <xsl:param name="msg2"/>
5846  <xsl:param name="inline"/>
5847  <xsl:call-template name="emit-message">
5848    <xsl:with-param name="level">INFO</xsl:with-param>
5849    <xsl:with-param name="msg" select="$msg"/>
5850    <xsl:with-param name="msg2" select="$msg2"/>
5851    <xsl:with-param name="inline" select="$inline"/>
5852  </xsl:call-template>
5853</xsl:template>
5854
5855<xsl:template name="error">
5856  <xsl:param name="msg"/>
5857  <xsl:param name="msg2"/>
5858  <xsl:param name="inline"/>
5859  <xsl:call-template name="emit-message">
5860    <xsl:with-param name="level">ERROR</xsl:with-param>
5861    <xsl:with-param name="msg" select="$msg"/>
5862    <xsl:with-param name="msg2" select="$msg2"/>
5863    <xsl:with-param name="inline" select="$inline"/>
5864  </xsl:call-template>
5865</xsl:template>
5866
5867<xsl:template name="emit-message">
5868  <xsl:param name="level"/>
5869  <xsl:param name="msg"/>
5870  <xsl:param name="msg2"/>
5871  <xsl:param name="inline"/>
5872  <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>
5873  <xsl:choose>
5874    <xsl:when test="$inline!='no'">
5875      <div class="error"><xsl:value-of select="$message"/></div>
5876    </xsl:when>
5877    <xsl:otherwise>
5878      <!-- this fails when the message contains characters not encodable in the output encoding -->
5879      <!-- <xsl:comment><xsl:value-of select="$message"/></xsl:comment> -->
5880    </xsl:otherwise>
5881  </xsl:choose>
5882  <xsl:message><xsl:value-of select="$message"/></xsl:message>
5883</xsl:template>
5884
5885<!-- table formatting -->
5886
5887<xsl:template match="texttable">
5888
5889  <xsl:variable name="anch">
5890    <xsl:call-template name="get-table-anchor"/>
5891  </xsl:variable>
5892
5893  <div id="{$anch}">
5894
5895    <xsl:if test="@anchor!=''">
5896      <div id="{@anchor}"/>
5897    </xsl:if>
5898    <xsl:apply-templates select="preamble" />
5899    <xsl:variable name="style">
5900      <xsl:text>tt </xsl:text>
5901      <xsl:choose>
5902        <xsl:when test="@style!=''">
5903          <xsl:value-of select="@style"/>
5904        </xsl:when>
5905        <xsl:otherwise>full</xsl:otherwise>
5906      </xsl:choose>
5907      <xsl:choose>
5908        <xsl:when test="@align='left'"> left</xsl:when>
5909        <xsl:when test="@align='right'"> right</xsl:when>
5910        <xsl:when test="@align='center' or not(@align) or @align=''"> center</xsl:when>
5911        <xsl:otherwise/>
5912      </xsl:choose>
5913
5914    </xsl:variable>
5915
5916    <table class="{$style}" cellpadding="3" cellspacing="0">
5917      <xsl:if test="(@title!='' or @anchor!='') and not(@suppress-title='true')">
5918        <xsl:variable name="n"><xsl:number level="any" count="texttable[(@title!='' or @anchor!='') and not(@suppress-title='true')]" /></xsl:variable>
5919        <caption>Table <xsl:value-of select="$n"/><xsl:if test="@title!=''">: <xsl:value-of select="@title" /></xsl:if></caption>
5920      </xsl:if>
5921
5922      <xsl:if test="ttcol!=''">
5923        <!-- skip header when all column titles are empty -->
5924        <thead>
5925          <tr>
5926            <xsl:apply-templates select="ttcol" />
5927          </tr>
5928        </thead>
5929      </xsl:if>
5930      <tbody>
5931        <xsl:variable name="columns" select="count(ttcol)" />
5932        <xsl:variable name="fields" select="c | ed:replace/ed:ins/c | ed:replace/ed:del/c" />
5933        <xsl:for-each select="$fields[$columns=1 or (position() mod $columns) = 1]">
5934          <tr>
5935            <xsl:for-each select=". | following-sibling::c[position() &lt; $columns]">
5936              <td>
5937                <xsl:call-template name="insertInsDelClass"/>
5938                <xsl:variable name="pos" select="position()" />
5939                <xsl:variable name="col" select="../ttcol[position() = $pos]" />
5940                <xsl:choose>
5941                  <xsl:when test="$col/@align='right' or $col/@align='center'">
5942                    <xsl:attribute name="class"><xsl:value-of select="$col/@align"/></xsl:attribute>
5943                  </xsl:when>
5944                  <xsl:when test="$col/@align='left' or not($col/@align)">
5945                    <xsl:attribute name="class">left</xsl:attribute>
5946                  </xsl:when>
5947                  <xsl:otherwise>
5948                    <xsl:call-template name="warning">
5949                      <xsl:with-param name="inline" select="'no'"/>
5950                      <xsl:with-param name="msg">Unknown align attribute on ttcol: <xsl:value-of select="$col/@align"/></xsl:with-param>                     
5951                    </xsl:call-template>
5952                  </xsl:otherwise>
5953                </xsl:choose>
5954                <xsl:apply-templates select="node()" />
5955              </td>
5956            </xsl:for-each>
5957          </tr>
5958        </xsl:for-each>
5959      </tbody>
5960    </table>
5961    <xsl:apply-templates select="postamble" />
5962  </div>
5963 
5964</xsl:template>
5965
5966<xsl:template match="ttcol">
5967  <th>
5968   
5969    <xsl:choose>
5970      <xsl:when test="@align='right' or @align='center' or @align='left'">
5971        <xsl:attribute name="class"><xsl:value-of select="@align"/></xsl:attribute>
5972      </xsl:when>
5973      <xsl:when test="not(@align)">
5974        <!-- that's the default, nothing to do here -->
5975      </xsl:when>
5976      <xsl:otherwise>
5977        <xsl:message>Unknown align attribute on ttcol: <xsl:value-of select="@align"/></xsl:message>
5978      </xsl:otherwise>
5979    </xsl:choose>
5980   
5981    <xsl:if test="@width">
5982      <xsl:attribute name="style">width: <xsl:value-of select="@width" />;</xsl:attribute>
5983    </xsl:if>
5984
5985    <xsl:apply-templates />
5986  </th>
5987</xsl:template>
5988
5989<!-- cref support -->
5990
5991<xsl:template name="get-comment-name">
5992  <xsl:choose>
5993    <xsl:when test="@anchor">
5994      <xsl:value-of select="@anchor"/>
5995    </xsl:when>
5996    <xsl:otherwise>
5997      <xsl:value-of select="$anchor-prefix"/>
5998      <xsl:text>.comment.</xsl:text>
5999      <xsl:number count="cref[not(@anchor)]" level="any"/>
6000    </xsl:otherwise>
6001  </xsl:choose>
6002</xsl:template>
6003
6004<xsl:template match="cref">
6005  <xsl:if test="$xml2rfc-comments!='no'">
6006    <xsl:variable name="cid">
6007      <xsl:call-template name="get-comment-name"/>
6008    </xsl:variable>
6009   
6010    <span class="comment">
6011      <xsl:choose>
6012        <xsl:when test="$xml2rfc-inline='yes'">
6013          <xsl:attribute name="id">
6014            <xsl:value-of select="$cid"/>
6015          </xsl:attribute>
6016          <xsl:text>[</xsl:text>
6017          <a href="#{$cid}" class="smpl">
6018            <xsl:value-of select="$cid"/>
6019          </a>
6020          <xsl:text>: </xsl:text>
6021          <xsl:apply-templates select="text()|eref|xref"/>
6022          <xsl:if test="@source"> --<xsl:value-of select="@source"/></xsl:if>
6023          <xsl:text>]</xsl:text>
6024        </xsl:when>
6025        <xsl:otherwise>
6026          <xsl:attribute name="title">
6027            <xsl:if test="@source"><xsl:value-of select="@source"/>: </xsl:if>
6028            <xsl:apply-templates select="text()|eref|xref"/>
6029          </xsl:attribute>
6030          <xsl:text>[</xsl:text>
6031          <a href="#{$cid}">
6032            <xsl:value-of select="$cid"/>
6033          </a>
6034          <xsl:text>]</xsl:text>
6035        </xsl:otherwise>
6036      </xsl:choose>
6037    </span>
6038  </xsl:if>
6039</xsl:template>
6040
6041<xsl:template name="insertComments">
6042
6043  <xsl:call-template name="insert-conditional-hrule"/>
6044   
6045  <h1>
6046    <xsl:call-template name="insert-conditional-pagebreak"/>
6047    <a id="{$anchor-prefix}.comments" href="#{$anchor-prefix}.comments">Editorial Comments</a>
6048  </h1>
6049
6050  <dl>
6051    <xsl:for-each select="//cref">
6052      <xsl:variable name="cid">
6053        <xsl:choose>
6054          <xsl:when test="@anchor">
6055            <xsl:value-of select="@anchor"/>
6056          </xsl:when>
6057          <xsl:otherwise>
6058            <xsl:value-of select="$anchor-prefix"/>
6059            <xsl:text>.comment.</xsl:text>
6060            <xsl:number count="cref[not(@anchor)]" level="any"/>
6061          </xsl:otherwise>
6062        </xsl:choose>
6063      </xsl:variable>
6064      <dt id="{$cid}">
6065        [<xsl:value-of select="$cid"/>]
6066      </dt>
6067      <dd>
6068        <xsl:apply-templates select="node()"/>
6069        <xsl:if test="@source"> --<xsl:value-of select="@source"/></xsl:if>
6070      </dd>
6071    </xsl:for-each>
6072  </dl>
6073</xsl:template>
6074
6075
6076<!-- Chapter Link Generation -->
6077
6078<xsl:template match="*" mode="links"><xsl:apply-templates mode="links"/></xsl:template>
6079<xsl:template match="text()" mode="links" />
6080
6081<xsl:template match="/*/middle//section[not(myns:unnumbered) and not(ancestor::section)]" mode="links">
6082  <xsl:variable name="sectionNumber"><xsl:call-template name="get-section-number" /></xsl:variable>
6083  <xsl:variable name="title">
6084    <xsl:if test="$sectionNumber!='' and not(contains($sectionNumber,'unnumbered-'))">
6085      <xsl:value-of select="$sectionNumber"/>
6086      <xsl:text> </xsl:text>
6087    </xsl:if>
6088    <xsl:value-of select="@title"/>
6089  </xsl:variable>
6090  <link rel="Chapter" title="{$title}" href="#{$anchor-prefix}.section.{$sectionNumber}"/>
6091  <xsl:apply-templates mode="links" />
6092</xsl:template>
6093
6094<xsl:template match="/*/back//section[not(myns:unnumbered) and not(ancestor::section)]" mode="links">
6095  <xsl:variable name="sectionNumber"><xsl:call-template name="get-section-number" /></xsl:variable>
6096  <xsl:variable name="title">
6097    <xsl:if test="$sectionNumber!='' and not(contains($sectionNumber,'unnumbered-'))">
6098      <xsl:value-of select="$sectionNumber"/>
6099      <xsl:text> </xsl:text>
6100    </xsl:if>
6101    <xsl:value-of select="@title"/>
6102  </xsl:variable>
6103  <link rel="Appendix" title="{$title}" href="#{$anchor-prefix}.section.{$sectionNumber}"/>
6104  <xsl:apply-templates mode="links" />
6105</xsl:template>
6106
6107<xsl:template match="/*/back/references[position()=1]" mode="links">
6108  <xsl:variable name="sectionNumber"><xsl:call-template name="get-references-section-number" /></xsl:variable>
6109  <link rel="Chapter" href="#{$anchor-prefix}.section.{$sectionNumber}">
6110    <xsl:choose>
6111      <xsl:when test="@title and count(/*/back/references)=1">
6112        <xsl:attribute name="title">
6113          <xsl:call-template name="get-references-section-number"/>
6114          <xsl:text> </xsl:text>
6115          <xsl:value-of select="@title"/>
6116        </xsl:attribute>
6117      </xsl:when>
6118      <xsl:otherwise>
6119        <xsl:attribute name="title">
6120          <xsl:call-template name="get-references-section-number"/>
6121          <xsl:text> </xsl:text>
6122          <xsl:value-of select="$xml2rfc-refparent"/>
6123        </xsl:attribute>
6124      </xsl:otherwise>
6125    </xsl:choose>
6126  </link>
6127</xsl:template>
6128
6129<!-- convenience templates -->
6130
6131<xsl:template name="get-author-summary">
6132  <xsl:choose>
6133    <xsl:when test="count(/rfc/front/author)=1">
6134      <xsl:value-of select="/rfc/front/author[1]/@surname" />
6135    </xsl:when>
6136    <xsl:when test="count(/rfc/front/author)=2">
6137      <xsl:value-of select="concat(/rfc/front/author[1]/@surname,' &amp; ',/rfc/front/author[2]/@surname)" />
6138    </xsl:when>
6139    <xsl:otherwise>
6140      <xsl:value-of select="concat(/rfc/front/author[1]/@surname,', et al.')" />
6141    </xsl:otherwise>
6142  </xsl:choose>
6143</xsl:template>
6144
6145<xsl:template name="get-category-long">
6146  <xsl:choose>
6147    <xsl:when test="$xml2rfc-footer!=''"><xsl:value-of select="$xml2rfc-footer" /></xsl:when>
6148    <xsl:when test="$xml2rfc-private!=''"/> <!-- private draft, footer not set -->
6149    <xsl:when test="/rfc/@category='bcp'">Best Current Practice</xsl:when>
6150    <xsl:when test="/rfc/@category='historic'">Historic</xsl:when>
6151    <xsl:when test="/rfc/@category='info' or not(/rfc/@category)">Informational</xsl:when>
6152    <xsl:when test="/rfc/@category='std'">Standards Track</xsl:when>
6153    <xsl:when test="/rfc/@category='exp'">Experimental</xsl:when>
6154    <xsl:otherwise>(category unknown)</xsl:otherwise>
6155  </xsl:choose>
6156</xsl:template>
6157
6158<xsl:template name="get-header-center">
6159  <xsl:choose>
6160    <xsl:when test="string-length(/rfc/front/title/@abbrev) &gt; 0">
6161      <xsl:value-of select="/rfc/front/title/@abbrev" />
6162    </xsl:when>
6163    <xsl:otherwise>
6164      <xsl:apply-templates select="/rfc/front/title" mode="get-text-content" />
6165    </xsl:otherwise>
6166  </xsl:choose>
6167</xsl:template>
6168
6169<xsl:template name="get-header-left">
6170  <xsl:choose>
6171    <xsl:when test="$xml2rfc-header!=''"><xsl:value-of select="$xml2rfc-header" /></xsl:when>
6172    <xsl:when test="$xml2rfc-private!=''"/> <!-- private draft, header not set -->
6173    <xsl:when test="/rfc/@ipr and not(/rfc/@number)">Internet-Draft</xsl:when>
6174    <xsl:otherwise>RFC <xsl:value-of select="/rfc/@number"/></xsl:otherwise>
6175  </xsl:choose>
6176</xsl:template>
6177
6178<xsl:template name="get-generator">
6179  <xsl:variable name="gen">
6180    <xsl:text>http://greenbytes.de/tech/webdav/rfc2629.xslt, </xsl:text>
6181    <!-- when RCS keyword substitution in place, add version info -->
6182    <xsl:if test="contains('$Revision: 1.518 $',':')">
6183      <xsl:value-of select="concat('Revision ',normalize-space(translate(substring-after('$Revision: 1.518 $', 'Revision: '),'$','')),', ')" />
6184    </xsl:if>
6185    <xsl:if test="contains('$Date: 2010-06-27 12:07:31 $',':')">
6186      <xsl:value-of select="concat(normalize-space(translate(substring-after('$Date: 2010-06-27 12:07:31 $', 'Date: '),'$','')),', ')" />
6187    </xsl:if>
6188    <xsl:value-of select="concat('XSLT vendor: ',system-property('xsl:vendor'),' ',system-property('xsl:vendor-url'))" />
6189  </xsl:variable>
6190  <xsl:value-of select="$gen" />
6191</xsl:template>
6192
6193<xsl:template name="get-header-right">
6194  <xsl:value-of select="concat($xml2rfc-ext-pub-month, ' ', $xml2rfc-ext-pub-year)" />
6195</xsl:template>
6196
6197<xsl:template name="get-keywords">
6198  <xsl:for-each select="/rfc/front/keyword">
6199    <xsl:if test="contains(.,',')">
6200      <xsl:call-template name="warning">
6201        <xsl:with-param name="inline" select="'no'"/>
6202        <xsl:with-param name="msg">keyword element appears to contain a comma-separated list, split into multiple elements instead.</xsl:with-param>
6203      </xsl:call-template>
6204    </xsl:if>
6205    <xsl:value-of select="normalize-space(.)" />
6206    <xsl:if test="position()!=last()">, </xsl:if>
6207  </xsl:for-each>
6208</xsl:template>
6209
6210<!-- get language from context node. nearest ancestor or return the default of "en" -->
6211<xsl:template name="get-lang">
6212  <xsl:choose>
6213    <xsl:when test="ancestor-or-self::*[@xml:lang]"><xsl:value-of select="ancestor-or-self::*/@xml:lang" /></xsl:when>
6214    <xsl:otherwise>en</xsl:otherwise>
6215  </xsl:choose>
6216</xsl:template>
6217
6218<xsl:template name="get-section-number">
6219  <xsl:variable name="anchor" select="@anchor"/>
6220  <xsl:choose>
6221    <xsl:when test="@x:fixed-section-number and @x:fixed-section-number!=''">
6222      <xsl:value-of select="@x:fixed-section-number"/>
6223    </xsl:when>
6224    <xsl:when test="@x:fixed-section-number and @x:fixed-section-number=''">
6225      <xsl:text>unnumbered-</xsl:text>
6226      <xsl:number count="section[@x:fixed-section-number='']" level="any"/>
6227    </xsl:when>
6228    <xsl:when test="$has-edits or ancestor::*/@x:fixed-section-number">
6229      <xsl:call-template name="sectionnumberAndEdits" />
6230    </xsl:when>
6231    <xsl:otherwise>
6232      <xsl:choose>
6233        <xsl:when test="self::references">
6234          <xsl:choose>
6235            <xsl:when test="count(/*/back/references)=1">
6236              <xsl:call-template name="get-references-section-number"/>
6237            </xsl:when>
6238            <xsl:otherwise>
6239              <xsl:call-template name="get-references-section-number"/>.<xsl:number count="references"/>
6240            </xsl:otherwise>
6241          </xsl:choose>
6242        </xsl:when>
6243        <xsl:when test="self::reference">
6244          <xsl:for-each select="parent::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:for-each>
6254        </xsl:when>
6255        <xsl:when test="ancestor::reference">
6256          <xsl:for-each select="ancestor::reference">
6257            <xsl:call-template name="get-section-number"/>
6258          </xsl:for-each>
6259        </xsl:when>
6260        <xsl:when test="ancestor::back"><xsl:number count="section|appendix" level="multiple" format="A.1.1.1.1.1.1.1" /></xsl:when>
6261        <xsl:when test="self::appendix"><xsl:number count="appendix" level="multiple" format="A.1.1.1.1.1.1.1" /></xsl:when>
6262        <xsl:otherwise><xsl:number count="section" level="multiple"/></xsl:otherwise>
6263      </xsl:choose>
6264    </xsl:otherwise>
6265  </xsl:choose>
6266</xsl:template>
6267
6268<!-- get the section number for the references section -->
6269<xsl:template name="get-references-section-number">
6270  <xsl:value-of select="count(/rfc/middle/section) + count(/rfc/middle/ed:replace/ed:ins/section) + 1"/>
6271</xsl:template>
6272
6273<xsl:template name="emit-section-number">
6274  <xsl:param name="no"/>
6275  <xsl:value-of select="$no"/><xsl:if test="not(contains($no,'.')) or $xml2rfc-ext-sec-no-trailing-dots='yes'">.</xsl:if>
6276</xsl:template>
6277
6278<xsl:template name="get-section-type">
6279  <xsl:param name="prec" /> <!-- TODO: check this, it's unused -->
6280  <xsl:choose>
6281    <xsl:when test="ancestor::back">Appendix</xsl:when>
6282    <xsl:otherwise>Section</xsl:otherwise>
6283  </xsl:choose>
6284</xsl:template>
6285
6286<xsl:template name="get-table-anchor">
6287  <xsl:value-of select="$anchor-prefix"/>
6288  <xsl:text>.table.</xsl:text>
6289  <xsl:choose>
6290    <xsl:when test="@title!='' or @anchor!=''">
6291      <xsl:number level="any" count="texttable[@title!='' or @anchor!='']" />
6292    </xsl:when>
6293    <xsl:otherwise>
6294      <xsl:text>u.</xsl:text>
6295      <xsl:number level="any" count="texttable[not(@title!='' or @anchor!='')]" />
6296    </xsl:otherwise>
6297  </xsl:choose>
6298</xsl:template>
6299
6300<xsl:template name="get-figure-anchor">
6301  <xsl:value-of select="$anchor-prefix"/>
6302  <xsl:text>.figure.</xsl:text>
6303  <xsl:choose>
6304    <xsl:when test="@title!='' or @anchor!=''">
6305      <xsl:number level="any" count="figure[@title!='' or @anchor!='']" />
6306    </xsl:when>
6307    <xsl:otherwise>
6308      <xsl:text>u.</xsl:text>
6309      <xsl:number level="any" count="figure[not(@title!='' or @anchor!='')]" />
6310    </xsl:otherwise>
6311  </xsl:choose>
6312</xsl:template>
6313
6314<!-- reformat contents of author/@initials -->
6315<xsl:template name="format-initials">
6316  <xsl:variable name="r">
6317    <xsl:call-template name="t-format-initials">
6318      <xsl:with-param name="remainder" select="normalize-space(@initials)"/>
6319    </xsl:call-template>
6320  </xsl:variable>
6321 
6322  <xsl:if test="$r!=@initials">
6323    <xsl:call-template name="warning">
6324      <xsl:with-param name="inline" select="'no'"/>
6325      <xsl:with-param name="msg">@initials '<xsl:value-of select="@initials"/>': did you mean '<xsl:value-of select="$r"/>'?</xsl:with-param>
6326    </xsl:call-template>
6327  </xsl:if>
6328 
6329  <xsl:value-of select="$r"/>
6330</xsl:template>
6331
6332<xsl:template name="t-format-initials">
6333  <xsl:param name="have"/>
6334  <xsl:param name="remainder"/>
6335 
6336  <xsl:variable name="first" select="substring($remainder,1,1)"/>
6337  <xsl:variable name="prev" select="substring($have,string-length($have))"/>
6338
6339<!--<xsl:message>
6340have: <xsl:value-of select="$have"/>
6341remainder: <xsl:value-of select="$remainder"/>
6342first: <xsl:value-of select="$first"/>
6343prev: <xsl:value-of select="$prev"/>
6344</xsl:message>-->
6345
6346  <xsl:choose>
6347    <xsl:when test="$remainder='' and $prev!='.'">
6348      <xsl:value-of select="concat($have,'.')"/>
6349    </xsl:when>
6350    <xsl:when test="$remainder=''">
6351      <xsl:value-of select="$have"/>
6352    </xsl:when>
6353    <xsl:when test="$prev='.' and $first='.'">
6354      <!-- repeating dots -->
6355      <xsl:call-template name="t-format-initials">
6356        <xsl:with-param name="have" select="$have"/>
6357        <xsl:with-param name="remainder" select="substring($remainder,2)"/>
6358      </xsl:call-template>
6359    </xsl:when>
6360    <!-- missing dot before '-' -->
6361<!--    <xsl:when test="$prev!='.' and $first='-'">
6362      <xsl:call-template name="t-format-initials">
6363        <xsl:with-param name="have" select="concat($have,'.-')"/>
6364        <xsl:with-param name="remainder" select="substring($remainder,2)"/>
6365      </xsl:call-template>
6366    </xsl:when>-->
6367    <!-- missing space after '.' -->
6368<!--    <xsl:when test="$prev='.' and $first!=' '">
6369      <xsl:call-template name="t-format-initials">
6370        <xsl:with-param name="have" select="concat($have,' ',$first)"/>
6371        <xsl:with-param name="remainder" select="substring($remainder,2)"/>
6372      </xsl:call-template>
6373    </xsl:when>-->
6374    <xsl:otherwise>
6375      <xsl:call-template name="t-format-initials">
6376        <xsl:with-param name="have" select="concat($have,$first)"/>
6377        <xsl:with-param name="remainder" select="substring($remainder,2)"/>
6378      </xsl:call-template>
6379    </xsl:otherwise>
6380  </xsl:choose>
6381 
6382</xsl:template>
6383
6384<xsl:template name="extract-normalized">
6385  <xsl:param name="node"/>
6386  <xsl:param name="name"/>
6387  <xsl:variable name="text" select="normalize-space($node)"/>
6388  <xsl:if test="string-length($node) != string-length($text)">
6389    <xsl:call-template name="warning">
6390      <xsl:with-param name="inline" select="'no'"/>
6391      <xsl:with-param name="msg">excessive whitespace in <xsl:value-of select="$name"/>: '<xsl:value-of select="$node"/>'</xsl:with-param>
6392    </xsl:call-template>
6393  </xsl:if>
6394  <xsl:value-of select="$text"/>
6395</xsl:template>
6396
6397<!-- checking for email element -->
6398<xsl:template name="extract-email">
6399  <xsl:variable name="email" select="normalize-space(.)"/>
6400  <xsl:if test="string-length(.) != string-length($email) or contains($email,' ')">
6401    <xsl:call-template name="warning">
6402      <xsl:with-param name="inline" select="'no'"/>
6403      <xsl:with-param name="msg">excessive whitespace in email address: '<xsl:value-of select="."/>'</xsl:with-param>
6404    </xsl:call-template>
6405  </xsl:if>
6406 
6407  <xsl:variable name="email2">
6408    <xsl:choose>
6409      <xsl:when test="starts-with($email,'mailto:')">
6410        <xsl:call-template name="warning">
6411          <xsl:with-param name="inline" select="'no'"/>
6412          <xsl:with-param name="msg">email should not include URI scheme: '<xsl:value-of select="."/>'</xsl:with-param>
6413        </xsl:call-template>
6414        <xsl:value-of select="substring($email, 1 + string-length('mailto:'))"/>
6415      </xsl:when>
6416      <xsl:otherwise>
6417        <xsl:value-of select="$email"/>
6418      </xsl:otherwise>
6419    </xsl:choose>
6420  </xsl:variable>
6421 
6422  <xsl:value-of select="$email2"/>
6423</xsl:template>
6424
6425<!-- checking for uri element -->
6426<xsl:template name="extract-uri">
6427  <xsl:variable name="uri" select="normalize-space(.)"/>
6428  <xsl:if test="string-length(.) != string-length($uri) or contains($uri,' ')">
6429    <xsl:call-template name="warning">
6430      <xsl:with-param name="inline" select="'no'"/>
6431      <xsl:with-param name="msg">excessive whitespace in URI: '<xsl:value-of select="."/>'</xsl:with-param>
6432    </xsl:call-template>
6433  </xsl:if>
6434 
6435  <xsl:value-of select="$uri"/>
6436</xsl:template>
6437
6438<xsl:template name="insert-conditional-pagebreak">
6439  <xsl:if test="$xml2rfc-compact!='yes'">
6440    <xsl:attribute name="class">np</xsl:attribute>
6441  </xsl:if>
6442</xsl:template>
6443
6444<xsl:template name="insert-conditional-hrule">
6445  <xsl:if test="$xml2rfc-compact!='yes'">
6446    <hr class="noprint" />
6447  </xsl:if>
6448</xsl:template>
6449
6450<!-- get text content from marked-up text -->
6451
6452<xsl:template match="text()" mode="get-text-content">
6453  <xsl:value-of select="."/>
6454</xsl:template>
6455
6456<xsl:template match="*" mode="get-text-content">
6457  <xsl:apply-templates mode="get-text-content"/>
6458</xsl:template>
6459
6460<xsl:template match="ed:del" mode="get-text-content">
6461</xsl:template>
6462
6463<!-- parsing of processing instructions -->
6464<xsl:template name="parse-pis">
6465  <xsl:param name="nodes"/>
6466  <xsl:param name="attr"/>
6467  <xsl:param name="sep"/>
6468  <xsl:param name="ret"/>
6469  <xsl:param name="default"/>
6470 
6471  <xsl:choose>
6472    <xsl:when test="count($nodes)=0">
6473      <xsl:choose>
6474        <xsl:when test="$ret!=''">
6475          <xsl:value-of select="$ret"/>
6476        </xsl:when>
6477        <xsl:otherwise>
6478          <xsl:value-of select="$default"/>
6479        </xsl:otherwise>   
6480      </xsl:choose>
6481    </xsl:when>
6482    <xsl:otherwise>
6483      <xsl:variable name="ret2">
6484        <xsl:for-each select="$nodes[1]">
6485          <xsl:call-template name="parse-one-pi">
6486            <xsl:with-param name="str" select="."/>
6487            <xsl:with-param name="attr" select="$attr"/>
6488            <xsl:with-param name="sep" select="$sep"/>
6489            <xsl:with-param name="ret" select="$ret"/>
6490          </xsl:call-template>
6491        </xsl:for-each>
6492      </xsl:variable>
6493     
6494      <xsl:call-template name="parse-pis">
6495        <xsl:with-param name="nodes" select="$nodes[position()!=1]"/>
6496        <xsl:with-param name="attr" select="$attr"/>
6497        <xsl:with-param name="sep" select="$sep"/>
6498        <xsl:with-param name="ret" select="$ret2"/>
6499        <xsl:with-param name="default" select="$default"/>
6500      </xsl:call-template>
6501     
6502    </xsl:otherwise>
6503  </xsl:choose>
6504
6505</xsl:template>
6506
6507<xsl:template name="parse-one-pi">
6508  <xsl:param name="str"/>
6509  <xsl:param name="attr"/>
6510  <xsl:param name="sep"/>
6511  <xsl:param name="ret"/>
6512
6513  <xsl:variable name="str2">
6514    <xsl:call-template name="eat-leading-whitespace">
6515      <xsl:with-param name="str" select="$str"/>
6516    </xsl:call-template>
6517  </xsl:variable>
6518 
6519  <xsl:choose>
6520    <xsl:when test="$str2=''">
6521      <!-- done -->
6522      <xsl:value-of select="$ret"/>
6523    </xsl:when>
6524    <xsl:otherwise>
6525      <xsl:variable name="attrname" select="substring-before($str2,'=')"/>
6526     
6527      <xsl:choose>
6528        <xsl:when test="$attrname=''">
6529          <xsl:call-template name="warning">
6530            <xsl:with-param name="msg">bad PI syntax: <xsl:value-of select="$str2"/></xsl:with-param>
6531            <xsl:with-param name="inline" select="'no'"/>
6532          </xsl:call-template>
6533          <xsl:value-of select="$ret"/>
6534        </xsl:when>
6535        <xsl:otherwise>
6536          <xsl:variable name="remainder" select="substring($str2,2+string-length($attrname))"/>
6537          <xsl:choose>
6538            <xsl:when test="string-length($remainder) &lt; 2">
6539              <xsl:call-template name="warning">
6540                <xsl:with-param name="msg">bad PI value syntax: <xsl:value-of select="$remainder"/></xsl:with-param>
6541                <xsl:with-param name="inline" select="'no'"/>
6542              </xsl:call-template>
6543              <xsl:value-of select="$ret"/>
6544            </xsl:when>
6545            <xsl:otherwise>
6546              <xsl:variable name="rem">
6547                <xsl:call-template name="eat-leading-whitespace">
6548                  <xsl:with-param name="str" select="$remainder"/>
6549                </xsl:call-template>
6550              </xsl:variable>
6551              <xsl:variable name="qchars">&apos;&quot;</xsl:variable>
6552              <xsl:variable name="qchar" select="substring($rem,1,1)"/>
6553              <xsl:variable name="rem2" select="substring($rem,2)"/>
6554              <xsl:choose>
6555                <xsl:when test="not(contains($qchars,$qchar))">
6556                  <xsl:call-template name="warning">
6557                    <xsl:with-param name="msg">pseudo-attribute value needs to be quoted: <xsl:value-of select="$rem"/></xsl:with-param>
6558                    <xsl:with-param name="inline" select="'no'"/>
6559                  </xsl:call-template>
6560                  <xsl:value-of select="$ret"/>
6561                </xsl:when>
6562                <xsl:when test="not(contains($rem2,$qchar))">
6563                  <xsl:call-template name="warning">
6564                    <xsl:with-param name="msg">unmatched quote in: <xsl:value-of select="$rem2"/></xsl:with-param>
6565                    <xsl:with-param name="inline" select="'no'"/>
6566                  </xsl:call-template>
6567                  <xsl:value-of select="$ret"/>
6568                </xsl:when>
6569                <xsl:otherwise>
6570                  <xsl:variable name="value" select="substring-before($rem2,$qchar)"/>
6571
6572                  <!-- check pseudo-attribute names -->
6573                  <xsl:if test="name()='rfc-ext' and $attr='SANITYCHECK'">
6574                    <xsl:choose>
6575                      <xsl:when test="$attrname='allow-markup-in-artwork'"/>
6576                      <xsl:when test="$attrname='authors-section'"/>
6577                      <xsl:when test="$attrname='duplex'"/>
6578                      <xsl:when test="$attrname='include-references-in-index'"/>
6579                      <xsl:when test="$attrname='justification'"/>
6580                      <xsl:when test="$attrname='parse-xml-in-artwork'"/>
6581                      <xsl:when test="$attrname='sec-no-trailing-dots'"/>
6582                      <xsl:when test="$attrname='trace-parse-xml'"/>
6583                      <xsl:otherwise>
6584                        <xsl:call-template name="warning">
6585                          <xsl:with-param name="msg">unsupported rfc-ext pseudo-attribute '<xsl:value-of select="$attrname"/>'</xsl:with-param>
6586                          <xsl:with-param name="inline" select="'no'"/>
6587                        </xsl:call-template>
6588                      </xsl:otherwise>
6589                    </xsl:choose>
6590                  </xsl:if>
6591                 
6592                  <xsl:if test="name()='rfc' and $attr='SANITYCHECK'">
6593                    <xsl:choose>
6594                      <xsl:when test="$attrname='include'">
6595                        <xsl:call-template name="warning">
6596                          <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>
6597                          <xsl:with-param name="inline" select="'no'"/>
6598                        </xsl:call-template>
6599                      </xsl:when>
6600                      <xsl:otherwise/>
6601                    </xsl:choose>
6602                  </xsl:if>
6603
6604                  <xsl:choose>
6605                    <xsl:when test="$attrname != $attr">
6606                      <!-- pseudo-attr does not match, continue -->
6607                      <xsl:call-template name="parse-one-pi">
6608                        <xsl:with-param name="str" select="substring($rem2, 2 + string-length($value))"/>
6609                        <xsl:with-param name="attr" select="$attr"/>
6610                        <xsl:with-param name="sep" select="$sep"/>
6611                        <xsl:with-param name="ret" select="$ret"/>
6612                      </xsl:call-template>
6613                    </xsl:when>
6614                    <xsl:when test="$sep='' and $ret!=''">
6615                      <!-- pseudo-attr does match, but we only want one value -->
6616                      <xsl:if test="$ret != $value">
6617                        <xsl:call-template name="warning">
6618                          <xsl:with-param name="msg">duplicate pseudo-attribute <xsl:value-of select="$attr"/>, overwriting value <xsl:value-of select="$ret"/></xsl:with-param>
6619                          <xsl:with-param name="inline" select="'no'"/>
6620                        </xsl:call-template>
6621                      </xsl:if>
6622                      <xsl:call-template name="parse-one-pi">
6623                        <xsl:with-param name="str" select="substring($rem2, 2 + string-length($value))"/>
6624                        <xsl:with-param name="attr" select="$attr"/>
6625                        <xsl:with-param name="sep" select="$sep"/>
6626                        <xsl:with-param name="ret" select="$value"/>
6627                      </xsl:call-template>
6628                    </xsl:when>
6629                    <xsl:otherwise>
6630                      <!-- pseudo-attr does match -->
6631                      <xsl:call-template name="parse-one-pi">
6632                        <xsl:with-param name="str" select="substring($rem2, 2 + string-length($value))"/>
6633                        <xsl:with-param name="attr" select="$attr"/>
6634                        <xsl:with-param name="sep" select="$sep"/>
6635                        <xsl:with-param name="ret">
6636                          <xsl:choose> 
6637                            <xsl:when test="$ret!=''">
6638                              <xsl:value-of select="concat($ret,$sep,$value)"/>
6639                            </xsl:when>
6640                            <xsl:otherwise>
6641                              <xsl:value-of select="$value"/>
6642                            </xsl:otherwise>
6643                          </xsl:choose>
6644                        </xsl:with-param>
6645                      </xsl:call-template>
6646                    </xsl:otherwise>                 
6647                 
6648                  </xsl:choose>
6649                 
6650                </xsl:otherwise>
6651              </xsl:choose>
6652            </xsl:otherwise>
6653          </xsl:choose>
6654        </xsl:otherwise>
6655      </xsl:choose>
6656    </xsl:otherwise>
6657  </xsl:choose>
6658 
6659</xsl:template>
6660
6661<xsl:template name="eat-leading-whitespace">
6662  <xsl:param name="str"/>
6663
6664  <xsl:choose>
6665    <xsl:when test="$str=''">
6666    </xsl:when>
6667    <xsl:when test="translate(substring($str,1,1),' &#10;&#13;&#9;',' ')=' '">
6668      <xsl:call-template name="eat-leading-whitespace">
6669        <xsl:with-param name="str" select="substring($str,2)"/>
6670      </xsl:call-template>
6671    </xsl:when>
6672    <xsl:otherwise>
6673      <xsl:value-of select="$str"/>
6674    </xsl:otherwise>
6675  </xsl:choose>
6676 
6677</xsl:template>
6678
6679<!-- diag support -->
6680<xsl:template name="lineno">
6681  <xsl:if test="function-available('saxon-old:line-number')">
6682    <xsl:if test="saxon-old:line-number() > 0">
6683      <xsl:text> (at line </xsl:text>
6684      <xsl:value-of select="saxon-old:line-number()"/>
6685      <xsl:text>)</xsl:text>
6686    </xsl:if>
6687  </xsl:if>
6688  <xsl:if test="function-available('saxon:line-number')">
6689    <xsl:if test="saxon:line-number() > 0">
6690      <xsl:text> (at line </xsl:text>
6691      <xsl:value-of select="saxon:line-number()"/>
6692      <xsl:text>)</xsl:text>
6693    </xsl:if>
6694  </xsl:if>
6695</xsl:template>
6696
6697<!-- define exslt:node-set for msxml -->       
6698<msxsl:script language="JScript" implements-prefix="exslt">
6699  this['node-set'] = function (x) {
6700    return x;
6701  }
6702</msxsl:script>
6703
6704<!-- date handling -->
6705
6706<msxsl:script language="JScript" implements-prefix="date">
6707  this['year'] = function (x) {
6708    if (x) {throw "not supported"};
6709    return (new Date()).getFullYear();
6710  }
6711
6712  this['month-in-year'] = function (x) {
6713    if (x) {throw "not supported"};
6714    return 1 + (new Date()).getMonth();
6715  }
6716
6717  this['day-in-month'] = function (x) {
6718    if (x) {throw "not supported"};
6719    return (new Date()).getDate();
6720  }
6721</msxsl:script>
6722
6723<xsl:variable name="may-default-dates">
6724  <xsl:choose>
6725    <xsl:when test="function-available('date:year') and function-available('date:month-in-year') and function-available('date:day-in-month')">
6726      <xsl:variable name="year-specified" select="/rfc/front/date/@year and /rfc/front/date/@year!=''"/>
6727      <xsl:variable name="month-specified" select="/rfc/front/date/@month and /rfc/front/date/@month!=''"/>
6728      <xsl:variable name="day-specified" select="/rfc/front/date/@day and /rfc/front/date/@day!=''"/>
6729      <xsl:variable name="system-month">
6730        <xsl:call-template name="get-month-as-name">
6731          <xsl:with-param name="month" select="date:month-in-year()"/>
6732        </xsl:call-template>
6733      </xsl:variable>
6734      <xsl:choose>
6735        <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>
6736        <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>
6737        <xsl:when test="$day-specified and /rfc/front/date/@day!=date:day-in-month()">Specified day does not match system date</xsl:when>
6738        <xsl:when test="not($year-specified) and ($month-specified or $day-specified)">Can't default year when month or day is specified</xsl:when>
6739        <xsl:when test="not($month-specified) and $day-specified">Can't default month when day is specified</xsl:when>
6740        <xsl:otherwise>yes</xsl:otherwise>
6741      </xsl:choose>
6742    </xsl:when>
6743    <!-- may, but won't -->
6744    <xsl:otherwise>yes</xsl:otherwise>
6745  </xsl:choose>
6746</xsl:variable>
6747
6748<xsl:param name="xml2rfc-ext-pub-year">
6749  <xsl:choose>
6750    <xsl:when test="/rfc/front/date/@year and /rfc/front/date/@year!=''">
6751      <xsl:value-of select="/rfc/front/date/@year"/>
6752    </xsl:when>
6753    <xsl:when test="function-available('date:year') and $may-default-dates='yes'">
6754      <xsl:value-of select="date:year()"/>
6755    </xsl:when>
6756    <xsl:when test="function-available('date:year') and $may-default-dates!='yes'">
6757      <xsl:call-template name="warning">
6758        <xsl:with-param name="inline" select="'no'"/>
6759        <xsl:with-param name="msg" select="$may-default-dates"/>
6760      </xsl:call-template>
6761    </xsl:when>
6762    <xsl:otherwise>
6763      <xsl:call-template name="error">
6764        <xsl:with-param name="msg" select="'/rfc/front/date/@year missing (and XSLT processor cannot compute the system date)'"/>
6765      </xsl:call-template>
6766    </xsl:otherwise>
6767  </xsl:choose>
6768</xsl:param>
6769
6770<xsl:param name="xml2rfc-ext-pub-month">
6771  <xsl:choose>
6772    <xsl:when test="/rfc/front/date/@month and /rfc/front/date/@month!=''">
6773      <xsl:value-of select="/rfc/front/date/@month"/>
6774    </xsl:when>
6775    <xsl:when test="function-available('date:month-in-year') and $may-default-dates='yes'">
6776      <xsl:call-template name="get-month-as-name">
6777        <xsl:with-param name="month" select="date:month-in-year()"/>
6778      </xsl:call-template>
6779    </xsl:when>
6780    <xsl:when test="function-available('date:month-in-year') and $may-default-dates!='yes'">
6781      <xsl:call-template name="warning">
6782        <xsl:with-param name="inline" select="'no'"/>
6783        <xsl:with-param name="msg" select="$may-default-dates"/>
6784      </xsl:call-template>
6785    </xsl:when>
6786    <xsl:otherwise>
6787      <xsl:call-template name="error">
6788        <xsl:with-param name="msg" select="'/rfc/front/date/@month missing (and XSLT processor cannot compute the system date)'"/>
6789      </xsl:call-template>
6790    </xsl:otherwise>
6791  </xsl:choose>
6792</xsl:param>
6793
6794<xsl:param name="pub-month-numeric">
6795  <xsl:call-template name="get-month-as-num">
6796    <xsl:with-param name="month" select="$xml2rfc-ext-pub-month" />
6797  </xsl:call-template>
6798</xsl:param>
6799
6800<xsl:param name="xml2rfc-ext-pub-day">
6801  <xsl:choose>
6802    <xsl:when test="/rfc/front/date/@day and /rfc/front/date/@day!=''">
6803      <xsl:value-of select="/rfc/front/date/@day"/>
6804    </xsl:when>
6805    <xsl:when test="function-available('date:day-in-month') and $may-default-dates='yes'">
6806      <xsl:value-of select="date:day-in-month()"/>
6807    </xsl:when>
6808    <xsl:otherwise /> <!-- harmless, we just don't have it -->
6809  </xsl:choose>
6810</xsl:param>
6811
6812<xsl:param name="pub-yearmonth">
6813  <!-- year or 0000 -->
6814  <xsl:choose>
6815    <xsl:when test="$xml2rfc-ext-pub-year!=''">
6816      <xsl:value-of select="format-number($xml2rfc-ext-pub-year,'0000')"/>
6817    </xsl:when>
6818    <xsl:otherwise>0000</xsl:otherwise>
6819  </xsl:choose>
6820  <!-- month or 00 -->
6821  <xsl:choose>
6822    <xsl:when test="$pub-month-numeric &gt; 0">
6823      <xsl:value-of select="format-number($pub-month-numeric,'00')"/>
6824    </xsl:when>
6825    <xsl:otherwise>00</xsl:otherwise>
6826  </xsl:choose>
6827
6828</xsl:param>
6829
6830</xsl:transform>
Note: See TracBrowser for help on using the repository browser.