source: rfc2629xslt/rfc2629.xslt @ 276

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

Update to latest version of rfc2629.xslt, and take advantage of it.

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