source: rfc2629xslt/rfc2629.xslt @ 723

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

Update to latest version of xml2rfc and rfc2629.xslt, bump document dates

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