source: rfc2629xslt/rfc2629.xslt @ 440

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

update to latest version of rfc2629.xslt, add <workgroup> element throughout

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