source: rfc2629xslt/rfc2629.xslt @ 662

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

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

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