source: rfc2629xslt/rfc2629.xslt @ 713

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

upgrade to latest version of rfc2629.xslt/xml2rfc.tcl; remove now superfluous empty <organization/> elements in references

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