source: rfc2629xslt/rfc2629.xslt @ 1072

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

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

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