source: rfc2629xslt/rfc2629toXHTML.xslt @ 230

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

Update to xml2rfc 1.33 (only affects Makefiles), update to latest version of rfc2629.xslt, change Makefile to allow Saxon to keep line numbers from source files.

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