source: rfc2629xslt/rfc2629toXHTML.xslt @ 246

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

Update to latest version of rfc2629xslt.

  • Property svn:eol-style set to native
File size: 187.2 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>
2451<xsl:if test="//x:sup">
2452sup {
2453  font-size: 60%;
2454}</xsl:if>
2455table {
2456  margin-left: 2em;
2457}<xsl:if test="//texttable">
2458table.tt {
2459  vertical-align: top;
2460}
2461table.full {
2462  border-style: outset;
2463  border-width: 1px;
2464}
2465table.headers {
2466  border-style: outset;
2467  border-width: 1px;
2468}
2469table.tt td {
2470  vertical-align: top;
2471}
2472table.full td {
2473  border-style: inset;
2474  border-width: 1px;
2475}
2476table.tt th {
2477  vertical-align: top;
2478}
2479table.full th {
2480  border-style: inset;
2481  border-width: 1px;
2482}
2483table.headers th {
2484  border-style: none none inset none;
2485  border-width: 1px;
2486}</xsl:if>
2487table.header {
2488  width: 95%;
2489  font-size: 10pt;
2490  color: white;
2491}
2492td.top {
2493  vertical-align: top;
2494}
2495td.topnowrap {
2496  vertical-align: top;
2497  white-space: nowrap;
2498}
2499td.header {
2500  background-color: gray;
2501  width: 50%;
2502}<xsl:if test="/rfc/@obsoletes | /rfc/@updates">
2503td.header a {
2504  color: white;
2505}</xsl:if>
2506td.reference {
2507  vertical-align: top;
2508  white-space: nowrap;
2509  padding-right: 1em;
2510}
2511thead {
2512  display:table-header-group;
2513}
2514ul.toc {
2515  list-style: none;
2516  margin-left: 1.5em;
2517  margin-right: 0em;
2518  padding-left: 0em;
2519}
2520li.tocline0 {
2521  line-height: 150%;
2522  font-weight: bold;
2523  font-size: 10pt;
2524  margin-left: 0em;
2525  margin-right: 0em;
2526}
2527li.tocline1 {
2528  line-height: normal;
2529  font-weight: normal;
2530  font-size: 9pt;
2531  margin-left: 0em;
2532  margin-right: 0em;
2533}
2534li.tocline2 {
2535  font-size: 0pt;
2536}
2537ul p {
2538  margin-left: 0em;
2539}
2540ul.ind {
2541  list-style: none;
2542  margin-left: 1.5em;
2543  margin-right: 0em;
2544  padding-left: 0em;
2545}
2546li.indline0 {
2547  font-weight: bold;
2548  line-height: 200%;
2549  margin-left: 0em;
2550  margin-right: 0em;
2551}
2552li.indline1 {
2553  font-weight: normal;
2554  line-height: 150%;
2555  margin-left: 0em;
2556  margin-right: 0em;
2557}
2558<xsl:if test="//x:bcp14">.bcp14 {
2559  font-style: normal;
2560  text-transform: lowercase;
2561  font-variant: small-caps;
2562}</xsl:if><xsl:if test="//x:blockquote">
2563blockquote &gt; * .bcp14 {
2564  font-style: italic;
2565}</xsl:if>
2566.comment {
2567  background-color: yellow;
2568}<xsl:if test="$xml2rfc-editing='yes'">
2569.editingmark {
2570  background-color: khaki;
2571}</xsl:if>
2572.center {
2573  text-align: center;
2574}
2575.error {
2576  color: red;
2577  font-style: italic;
2578  font-weight: bold;
2579}
2580.figure {
2581  font-weight: bold;
2582  text-align: center;
2583  font-size: 9pt;
2584}
2585.filename {
2586  color: #333333;
2587  font-weight: bold;
2588  font-size: 12pt;
2589  line-height: 21pt;
2590  text-align: center;
2591}
2592.fn {
2593  font-weight: bold;
2594}
2595.hidden {
2596  display: none;
2597}
2598.left {
2599  text-align: left;
2600}
2601.right {
2602  text-align: right;
2603}
2604.title {
2605  color: #990000;
2606  font-size: 18pt;
2607  line-height: 18pt;
2608  font-weight: bold;
2609  text-align: center;
2610  margin-top: 36pt;
2611}
2612.vcardline {
2613  display: block;
2614}
2615.warning {
2616  font-size: 14pt;
2617  background-color: yellow;
2618}
2619<xsl:if test="//ed:del|//ed:replace|//ed:ins">del {
2620  color: red;
2621  text-decoration: line-through;
2622}
2623.del {
2624  color: red;
2625  text-decoration: line-through;
2626}
2627ins {
2628  color: green;
2629  text-decoration: underline;
2630}
2631.ins {
2632  color: green;
2633  text-decoration: underline;
2634}
2635div.issuepointer {
2636  float: left;
2637}</xsl:if><xsl:if test="//ed:issue">
2638table.openissue {
2639  background-color: khaki;
2640  border-width: thin;
2641  border-style: solid;
2642  border-color: black;
2643}
2644table.closedissue {
2645  background-color: white;
2646  border-width: thin;
2647  border-style: solid;
2648  border-color: gray;
2649  color: gray;
2650}
2651thead th {
2652  text-align: left;
2653}
2654.bg-issue {
2655  border: solid;
2656  border-width: 1px;
2657  font-size: 7pt;
2658}
2659.closed-issue {
2660  border: solid;
2661  border-width: thin;
2662  background-color: lime;
2663  font-size: smaller;
2664  font-weight: bold;
2665}
2666.open-issue {
2667  border: solid;
2668  border-width: thin;
2669  background-color: red;
2670  font-size: smaller;
2671  font-weight: bold;
2672}
2673.editor-issue {
2674  border: solid;
2675  border-width: thin;
2676  background-color: yellow;
2677  font-size: smaller;
2678  font-weight: bold;
2679}</xsl:if>
2680
2681@media print {
2682  .noprint {
2683    display: none;
2684  }
2685 
2686  a {
2687    color: black;
2688    text-decoration: none;
2689  }
2690
2691  table.header {
2692    width: 90%;
2693  }
2694
2695  td.header {
2696    width: 50%;
2697    color: black;
2698    background-color: white;
2699    vertical-align: top;
2700    font-size: 12pt;
2701  }
2702
2703  ul.toc a::after {
2704    content: leader('.') target-counter(attr(href), page);
2705  }
2706 
2707  a.iref {
2708    content: target-counter(attr(href), page);
2709  }
2710 
2711  .print2col {
2712    column-count: 2;
2713    -moz-column-count: 2;<!-- for Firefox -->
2714    column-fill: auto;<!-- for PrinceXML -->
2715  }
2716<xsl:if test="$xml2rfc-ext-justification='print'">
2717  dd {
2718    text-align: justify;
2719  }
2720  li {
2721    text-align: justify;
2722  }
2723  p {
2724    text-align: justify;
2725  }
2726</xsl:if>}
2727
2728@page {
2729  @top-left {
2730       content: "<xsl:call-template name="get-header-left"/>";
2731  }
2732  @top-right {
2733       content: "<xsl:call-template name="get-header-right"/>";
2734  }
2735  @top-center {
2736       content: "<xsl:call-template name="get-header-center"/>";
2737  }
2738  @bottom-left {
2739       content: "<xsl:call-template name="get-author-summary"/>";
2740  }
2741  @bottom-center {
2742       content: "<xsl:call-template name="get-category-long"/>";
2743  }
2744  @bottom-right {
2745       content: "[Page " counter(page) "]";
2746  }
2747}
2748
2749@page:first {
2750    @top-left {
2751      content: normal;
2752    }
2753    @top-right {
2754      content: normal;
2755    }
2756    @top-center {
2757      content: normal;
2758    }
2759}
2760</xsl:template>
2761
2762
2763<!-- generate the index section -->
2764
2765<xsl:template name="insertSingleIref">
2766  <xsl:choose>
2767    <xsl:when test="@ed:xref">
2768      <!-- special index generator mode -->
2769      <xsl:text>[</xsl:text>
2770      <a xmlns="http://www.w3.org/1999/xhtml" href="#{@ed:xref}"><xsl:value-of select="@ed:xref"/></a>
2771      <xsl:text>, </xsl:text>
2772      <a xmlns="http://www.w3.org/1999/xhtml">
2773        <xsl:variable name="htmluri" select="//reference[@anchor=current()/@ed:xref]/format[@type='HTML']/@target"/>
2774        <xsl:if test="$htmluri">
2775          <xsl:attribute name="href"><xsl:value-of select="concat($htmluri,'#',@ed:frag)"/></xsl:attribute>
2776        </xsl:if>       
2777        <xsl:choose>
2778          <xsl:when test="@primary='true'"><b><xsl:value-of select="@ed:label"/></b></xsl:when>
2779          <xsl:otherwise><xsl:value-of select="@ed:label"/></xsl:otherwise>
2780        </xsl:choose>
2781      </a>
2782      <xsl:text>]</xsl:text>
2783      <xsl:if test="position()!=last()">, </xsl:if>
2784    </xsl:when>
2785    <xsl:otherwise>
2786      <xsl:variable name="_n">
2787        <xsl:call-template name="get-section-number"/>
2788      </xsl:variable>
2789      <xsl:variable name="n">
2790        <xsl:choose>
2791          <xsl:when test="$_n!=''">
2792            <xsl:value-of select="$_n"/>
2793          </xsl:when>
2794          <xsl:otherwise>§</xsl:otherwise>
2795        </xsl:choose>
2796      </xsl:variable>
2797      <xsl:variable name="backlink">
2798        <xsl:choose>
2799          <xsl:when test="self::xref">
2800            <xsl:variable name="target" select="@target"/>
2801            <xsl:text>#</xsl:text>
2802            <xsl:value-of select="$anchor-prefix"/>
2803            <xsl:text>.xref.</xsl:text>
2804            <xsl:value-of select="@target"/>.<xsl:number level="any" count="xref[@target=$target]"/>
2805          </xsl:when>
2806          <xsl:when test="self::iref">
2807            <xsl:text>#</xsl:text>
2808            <xsl:call-template name="compute-iref-anchor"/>
2809          </xsl:when>
2810          <xsl:when test="self::x:ref">
2811            <xsl:text>#</xsl:text>
2812            <xsl:call-template name="compute-extref-anchor"/>
2813          </xsl:when>
2814          <xsl:otherwise>
2815            <xsl:message>Unsupported element type for insertSingleIref</xsl:message>
2816          </xsl:otherwise>
2817        </xsl:choose>
2818      </xsl:variable>
2819      <a xmlns="http://www.w3.org/1999/xhtml" class="iref" href="{$backlink}">
2820        <xsl:call-template name="insertInsDelClass"/>
2821        <xsl:choose>
2822          <xsl:when test="@primary='true'"><b><xsl:value-of select="$n"/></b></xsl:when>
2823          <xsl:otherwise><xsl:value-of select="$n"/></xsl:otherwise>
2824        </xsl:choose>
2825      </a>
2826      <xsl:if test="position()!=last()">, </xsl:if>
2827    </xsl:otherwise>
2828  </xsl:choose>
2829</xsl:template>
2830
2831<xsl:template name="insertSingleXref">
2832  <xsl:variable name="_n">
2833    <xsl:call-template name="get-section-number"/>
2834  </xsl:variable>
2835  <xsl:variable name="n">
2836    <xsl:choose>
2837      <xsl:when test="$_n!=''">
2838        <xsl:value-of select="$_n"/>
2839      </xsl:when>
2840      <xsl:otherwise>§</xsl:otherwise>
2841    </xsl:choose>
2842  </xsl:variable>
2843  <xsl:choose>
2844    <xsl:when test="self::reference">
2845      <a xmlns="http://www.w3.org/1999/xhtml" class="iref" href="#{@anchor}">
2846        <xsl:call-template name="insertInsDelClass"/>
2847        <b><xsl:value-of select="$n"/></b>
2848      </a>
2849    </xsl:when>
2850    <xsl:otherwise>
2851      <xsl:variable name="target" select="@target"/>
2852      <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>
2853      <a xmlns="http://www.w3.org/1999/xhtml" class="iref" href="{$backlink}">
2854        <xsl:call-template name="insertInsDelClass"/>
2855        <xsl:value-of select="$n"/>
2856      </a>
2857    </xsl:otherwise>
2858  </xsl:choose>
2859  <xsl:if test="position()!=last()">, </xsl:if>
2860</xsl:template>
2861
2862<xsl:template name="insertIndex">
2863
2864  <xsl:call-template name="insert-conditional-hrule"/>
2865
2866  <h1 xmlns="http://www.w3.org/1999/xhtml" id="{$anchor-prefix}.index">
2867    <xsl:call-template name="insert-conditional-pagebreak"/>
2868    <a href="#{$anchor-prefix}.index">Index</a>
2869  </h1>
2870 
2871  <!-- generate navigation links to index subsections -->
2872  <p xmlns="http://www.w3.org/1999/xhtml" class="noprint">
2873    <xsl:variable name="irefs" select="//iref[generate-id(.) = generate-id(key('index-first-letter',translate(substring(@item,1,1),$lcase,$ucase)))]"/>
2874    <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)))]"/>
2875 
2876    <xsl:for-each select="$irefs | $xrefs">
2877   
2878      <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)"/>
2879         
2880      <xsl:variable name="letter" select="translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase)"/>
2881
2882      <!-- character? -->
2883      <xsl:if test="translate($letter,concat($lcase,$ucase,'0123456789'),'')=''">
2884     
2885        <xsl:variable name="showit">
2886          <xsl:choose>
2887            <xsl:when test="$xml2rfc-ext-include-references-in-index!='yes'">
2888              <xsl:if test="$irefs[starts-with(translate(@item,$lcase,$ucase),$letter)]">
2889                <xsl:text>yes</xsl:text>
2890              </xsl:if>
2891            </xsl:when>
2892            <xsl:otherwise>
2893              <xsl:text>yes</xsl:text>
2894            </xsl:otherwise>
2895          </xsl:choose>
2896        </xsl:variable>
2897       
2898        <xsl:if test="$showit='yes'">
2899          <a href="#{$anchor-prefix}.index.{$letter}">
2900            <xsl:value-of select="$letter"/>
2901          </a>
2902          <xsl:text> </xsl:text>
2903        </xsl:if>
2904     
2905      </xsl:if>
2906
2907    </xsl:for-each>
2908  </p>
2909
2910  <!-- for each index subsection -->
2911  <div xmlns="http://www.w3.org/1999/xhtml" class="print2col">
2912  <ul class="ind">
2913    <xsl:variable name="irefs2" select="//iref[generate-id(.) = generate-id(key('index-first-letter',translate(substring(@item,1,1),$lcase,$ucase)))]"/>
2914    <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)))]"/>
2915 
2916    <xsl:for-each select="$irefs2 | $xrefs2">
2917      <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)"/>
2918      <xsl:variable name="letter" select="translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase)"/>
2919           
2920      <xsl:variable name="showit">
2921        <xsl:choose>
2922          <xsl:when test="$xml2rfc-ext-include-references-in-index!='yes'">
2923            <xsl:if test="$irefs2[starts-with(translate(@item,$lcase,$ucase),$letter)]">
2924              <xsl:text>yes</xsl:text>
2925            </xsl:if>
2926          </xsl:when>
2927          <xsl:otherwise>
2928            <xsl:text>yes</xsl:text>
2929          </xsl:otherwise>
2930        </xsl:choose>
2931      </xsl:variable>
2932
2933      <xsl:if test="$showit='yes'">
2934        <li class="indline0">
2935         
2936          <!-- make letters and digits stand out -->
2937          <xsl:choose>
2938            <xsl:when test="translate($letter,concat($lcase,$ucase,'0123456789'),'')=''">
2939              <a id="{$anchor-prefix}.index.{$letter}" href="#{$anchor-prefix}.index.{$letter}">
2940                <b><xsl:value-of select="$letter"/></b>
2941              </a>
2942            </xsl:when>
2943            <xsl:otherwise>
2944              <b><xsl:value-of select="$letter"/></b>
2945            </xsl:otherwise>
2946          </xsl:choose>
2947       
2948          <ul class="ind"> 
2949            <xsl:for-each select="key('index-first-letter',translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase))">
2950       
2951              <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)"/>
2952             
2953                <xsl:choose>
2954                  <xsl:when test="self::reference">
2955                    <xsl:if test="$xml2rfc-ext-include-references-in-index='yes' and not(starts-with(@anchor,'deleted-'))">
2956                      <li class="indline1">
2957                        <em>
2958                          <xsl:value-of select="@anchor"/>
2959                        </em>
2960                        <xsl:text>  </xsl:text>
2961                       
2962                        <xsl:variable name="rs" select="//xref[@target=current()/@anchor] | . | //reference[@anchor=concat('deleted-',current()/@anchor)]"/>
2963                        <xsl:for-each select="$rs">
2964                          <xsl:call-template name="insertSingleXref"/>
2965                        </xsl:for-each>
2966
2967                        <xsl:variable name="rs2" select="$rs[@x:sec]"/>
2968
2969                        <xsl:if test="$rs2">
2970                          <ul class="ind"> 
2971                            <xsl:for-each select="$rs2">
2972                              <xsl:sort select="substring-before(concat(@x:sec,'.'),'.')" data-type="number"/>
2973                              <xsl:sort select="substring(@x:sec,1+string-length(substring-before(@x:sec,'.')))" data-type="number"/>
2974                              <xsl:if test="generate-id(.) = generate-id(key('index-xref-by-sec',concat(@target,'..',@x:sec)))">
2975                                <li class="indline1">
2976                                  <em>
2977                                    <xsl:text>Section </xsl:text>
2978                                    <xsl:value-of select="@x:sec"/>
2979                                  </em>
2980                                  <xsl:text>  </xsl:text>
2981                                  <xsl:for-each select="key('index-xref-by-sec',concat(@target,'..',@x:sec))">
2982                                    <xsl:call-template name="insertSingleXref"/>
2983                                  </xsl:for-each>
2984                                </li>
2985                              </xsl:if>
2986                            </xsl:for-each>
2987                          </ul>
2988                        </xsl:if>
2989
2990                        <xsl:if test="current()/x:source/@href">
2991                          <xsl:variable name="rs3" select="$rs[not(@x:sec) and @x:rel]"/>
2992                          <xsl:variable name="doc" select="document(current()/x:source/@href)"/>
2993                          <xsl:if test="$rs3">
2994                            <ul class="ind"> 
2995                              <xsl:for-each select="$rs3">
2996                                <xsl:sort select="count($doc//*[@anchor and following::*/@anchor=substring-after(current()/@x:rel,'#')])" order="ascending" data-type="number"/>
2997                                <xsl:if test="generate-id(.) = generate-id(key('index-xref-by-anchor',concat(@target,'..',@x:rel)))">
2998                                  <li class="indline1">
2999                                    <em>
3000                                      <xsl:text>Section </xsl:text>
3001                                      <xsl:for-each select="$doc//*[@anchor=substring-after(current()/@x:rel,'#')]">
3002                                        <xsl:call-template name="get-section-number"/>
3003                                      </xsl:for-each>
3004                                    </em>
3005                                    <xsl:text>  </xsl:text>
3006                                    <xsl:for-each select="key('index-xref-by-anchor',concat(@target,'..',@x:rel))">
3007                                      <xsl:call-template name="insertSingleXref"/>
3008                                    </xsl:for-each>
3009                                  </li>
3010                                </xsl:if>
3011                              </xsl:for-each>
3012                            </ul>
3013                          </xsl:if>
3014                        </xsl:if>
3015                      </li>
3016                    </xsl:if>
3017                  </xsl:when>
3018                  <xsl:otherwise>
3019                    <!-- regular iref -->
3020                    <xsl:if test="generate-id(.) = generate-id(key('index-item',concat(@item,@anchor)))">
3021                      <xsl:variable name="item" select="@item"/>
3022                      <xsl:variable name="in-artwork" select="count(//iref[@item=$item and @primary='true' and ancestor::artwork])!=0"/>
3023                         
3024                      <li class="indline1">
3025                        <xsl:choose>
3026                          <xsl:when test="$in-artwork">
3027                            <tt><xsl:value-of select="@item"/></tt>
3028                          </xsl:when>
3029                          <xsl:otherwise>
3030                            <xsl:value-of select="@item"/>
3031                          </xsl:otherwise>
3032                        </xsl:choose>
3033                        <xsl:text>  </xsl:text>
3034                       
3035                        <xsl:variable name="irefs3" select="key('index-item',@item)[not(@subitem) or @subitem='']"/>
3036                        <xsl:variable name="xrefs3" select="//xref[@target=$irefs3[@x:for-anchor='']/../@anchor or @target=$irefs3/@x:for-anchor]"/>
3037                        <xsl:variable name="extrefs3" select="//x:ref[.=$irefs3[@x:for-anchor='']/../@anchor or .=$irefs3/@x:for-anchor]"/>
3038
3039                        <xsl:for-each select="$irefs3|$xrefs3|$extrefs3">
3040                          <!-- <xsl:sort select="translate(@item,$lcase,$ucase)" />  -->
3041                          <xsl:call-template name="insertSingleIref"/>
3042                        </xsl:for-each>
3043         
3044                        <xsl:variable name="s2" select="key('index-item',@item)[@subitem and @subitem!='']"/>
3045                        <xsl:if test="$s2">
3046                          <ul class="ind"> 
3047                            <xsl:for-each select="$s2">
3048                              <xsl:sort select="translate(@subitem,$lcase,$ucase)"/>
3049                             
3050                              <xsl:if test="generate-id(.) = generate-id(key('index-item-subitem',concat(@item,'..',@subitem)))">
3051                 
3052                                <xsl:variable name="itemsubitem" select="concat(@item,'..',@subitem)"/>
3053                                <xsl:variable name="in-artwork2" select="count(//iref[concat(@item,'..',@subitem)=$itemsubitem and @primary='true' and ancestor::artwork])!=0"/>
3054                 
3055                                <li class="indline1">
3056             
3057                                  <xsl:choose>
3058                                    <xsl:when test="$in-artwork2">
3059                                      <tt><xsl:value-of select="@subitem"/></tt>
3060                                    </xsl:when>
3061                                    <xsl:otherwise>
3062                                      <xsl:value-of select="@subitem"/>
3063                                    </xsl:otherwise>
3064                                  </xsl:choose>
3065                                  <xsl:text>  </xsl:text>
3066                                   
3067                                  <xsl:variable name="irefs4" select="key('index-item-subitem',concat(@item,'..',@subitem))"/>
3068                                  <xsl:variable name="xrefs4" select="//xref[@target=$irefs4[@x:for-anchor='']/../@anchor or @target=$irefs4/@x:for-anchor]"/>
3069                                  <xsl:variable name="extrefs4" select="//x:ref[.=$irefs4[@x:for-anchor='']/../@anchor or .=$irefs4/@x:for-anchor]"/>
3070
3071                                  <xsl:for-each select="$irefs4|$xrefs4|$extrefs4">
3072                                    <!--<xsl:sort select="translate(@item,$lcase,$ucase)" />-->                   
3073                                    <xsl:call-template name="insertSingleIref"/>
3074                                  </xsl:for-each>
3075               
3076                                </li>
3077                              </xsl:if>
3078                            </xsl:for-each>
3079                          </ul>
3080                        </xsl:if>
3081                      </li>
3082                    </xsl:if>
3083                  </xsl:otherwise>
3084                </xsl:choose>
3085             
3086                     
3087            </xsl:for-each>           
3088          </ul>
3089        </li>
3090      </xsl:if>
3091     
3092    </xsl:for-each>
3093  </ul>
3094  </div>
3095 
3096</xsl:template>
3097
3098
3099
3100
3101<xsl:template name="insertPreamble" myns:namespaceless-elements="xml2rfc">
3102
3103  <section title="Status of this Memo" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.status">
3104
3105  <xsl:choose>
3106    <xsl:when test="/rfc/@ipr and not(/rfc/@number)">
3107      <t>
3108        <xsl:choose>
3109         
3110          <!-- RFC2026 -->
3111          <xsl:when test="/rfc/@ipr = 'full2026'">
3112            This document is an Internet-Draft and is
3113            in full conformance with all provisions of Section 10 of RFC2026.   
3114          </xsl:when>
3115          <xsl:when test="/rfc/@ipr = 'noDerivativeWorks2026'">
3116            This document is an Internet-Draft and is
3117            in full conformance with all provisions of Section 10 of RFC2026
3118            except that the right to produce derivative works is not granted.   
3119          </xsl:when>
3120          <xsl:when test="/rfc/@ipr = 'noDerivativeWorksNow'">
3121            This document is an Internet-Draft and is
3122            in full conformance with all provisions of Section 10 of RFC2026
3123            except that the right to produce derivative works is not granted.
3124            (If this document becomes part of an IETF working group activity,
3125            then it will be brought into full compliance with Section 10 of RFC2026.) 
3126          </xsl:when>
3127          <xsl:when test="/rfc/@ipr = 'none'">
3128            This document is an Internet-Draft and is
3129            NOT offered in accordance with Section 10 of RFC2026,
3130            and the author does not provide the IETF with any rights other
3131            than to publish as an Internet-Draft.
3132          </xsl:when>
3133         
3134          <!-- RFC3667 -->
3135          <xsl:when test="/rfc/@ipr = 'full3667'">
3136            This document is an Internet-Draft and is subject to all provisions
3137            of section 3 of RFC 3667.  By submitting this Internet-Draft, each
3138            author represents that any applicable patent or other IPR claims of
3139            which he or she is aware have been or will be disclosed, and any of
3140            which he or she become aware will be disclosed, in accordance with
3141            RFC 3668.
3142          </xsl:when>
3143          <xsl:when test="/rfc/@ipr = 'noModification3667'">
3144            This document is an Internet-Draft and is subject to all provisions
3145            of section 3 of RFC 3667.  By submitting this Internet-Draft, each
3146            author represents that any applicable patent or other IPR claims of
3147            which he or she is aware have been or will be disclosed, and any of
3148            which he or she become aware will be disclosed, in accordance with
3149            RFC 3668.  This document may not be modified, and derivative works of
3150            it may not be created, except to publish it as an RFC and to
3151            translate it into languages other than English<xsl:if test="/rfc/@iprExtract">,
3152            other than to extract <xref target="{/rfc/@iprExtract}"/> as-is
3153            for separate use.</xsl:if>.
3154          </xsl:when>
3155          <xsl:when test="/rfc/@ipr = 'noDerivatives3667'">
3156            This document is an Internet-Draft and is subject to all provisions
3157            of section 3 of RFC 3667 except for the right to produce derivative
3158            works.  By submitting this Internet-Draft, each author represents
3159            that any applicable patent or other IPR claims of which he or she
3160            is aware have been or will be disclosed, and any of which he or she
3161            become aware will be disclosed, in accordance with RFC 3668.  This
3162            document may not be modified, and derivative works of it may
3163            not be created<xsl:if test="/rfc/@iprExtract">, other than to extract
3164            <xref target="{/rfc/@iprExtract}"/> as-is for separate use.</xsl:if>.
3165          </xsl:when>
3166         
3167          <!-- RFC3978 -->
3168          <xsl:when test="/rfc/@ipr = 'full3978'">
3169            By submitting this Internet-Draft, each
3170            author represents that any applicable patent or other IPR claims of
3171            which he or she is aware have been or will be disclosed, and any of
3172            which he or she becomes aware will be disclosed, in accordance with
3173            Section 6 of BCP 79.
3174          </xsl:when>
3175          <xsl:when test="/rfc/@ipr = 'noModification3978'">
3176            By submitting this Internet-Draft, each
3177            author represents that any applicable patent or other IPR claims of
3178            which he or she is aware have been or will be disclosed, and any of
3179            which he or she becomes aware will be disclosed, in accordance with
3180            Section 6 of BCP 79.  This document may not be modified, and derivative works of
3181            it may not be created, except to publish it as an RFC and to
3182            translate it into languages other than English<xsl:if test="/rfc/@iprExtract">,
3183            other than to extract <xref target="{/rfc/@iprExtract}"/> as-is
3184            for separate use.</xsl:if>.
3185          </xsl:when>
3186          <xsl:when test="/rfc/@ipr = 'noDerivatives3978'">
3187            By submitting this Internet-Draft, each author represents
3188            that any applicable patent or other IPR claims of which he or she
3189            is aware have been or will be disclosed, and any of which he or she
3190            becomes aware will be disclosed, in accordance with Section 6 of BCP 79.  This
3191            document may not be modified, and derivative works of it may
3192            not be created<xsl:if test="/rfc/@iprExtract">, other than to extract
3193            <xref target="{/rfc/@iprExtract}"/> as-is for separate use.</xsl:if>.
3194          </xsl:when>
3195
3196          <xsl:otherwise>CONFORMANCE UNDEFINED.</xsl:otherwise>
3197        </xsl:choose>
3198      </t>
3199      <t>
3200        Internet-Drafts are working documents of the Internet Engineering
3201        Task Force (IETF), its areas, and its working groups.
3202        Note that other groups may also distribute working documents as
3203        Internet-Drafts.
3204      </t>
3205      <t>
3206        Internet-Drafts are draft documents valid for a maximum of six months
3207        and may be updated, replaced, or obsoleted by other documents at any time.
3208        It is inappropriate to use Internet-Drafts as reference material or to cite
3209        them other than as &#8220;work in progress&#8221;.
3210      </t>
3211      <t>
3212        The list of current Internet-Drafts can be accessed at
3213        <eref target="http://www.ietf.org/ietf/1id-abstracts.txt"/>.
3214      </t>
3215      <t>
3216        The list of Internet-Draft Shadow Directories can be accessed at
3217        <eref target="http://www.ietf.org/shadow.html"/>.
3218      </t>
3219      <t>
3220        This Internet-Draft will expire in <xsl:call-template name="expirydate"/>.
3221      </t>
3222    </xsl:when>
3223
3224    <xsl:when test="/rfc/@category='bcp'">
3225      <t>
3226        This document specifies an Internet Best Current Practices for the Internet
3227        Community, and requests discussion and suggestions for improvements.
3228        Distribution of this memo is unlimited.
3229      </t>
3230    </xsl:when>
3231    <xsl:when test="/rfc/@category='exp'">
3232      <t>
3233        This memo defines an Experimental Protocol for the Internet community.
3234        It does not specify an Internet standard of any kind.
3235        Discussion and suggestions for improvement are requested.
3236        Distribution of this memo is unlimited.
3237      </t>
3238    </xsl:when>
3239    <xsl:when test="/rfc/@category='historic'">
3240      <t>
3241        This memo describes a historic protocol for the Internet community.
3242        It does not specify an Internet standard of any kind.
3243        Distribution of this memo is unlimited.
3244      </t>
3245    </xsl:when>
3246    <xsl:when test="/rfc/@category='info' or not(/rfc/@category)">
3247      <t>
3248        This memo provides information for the Internet community.
3249        It does not specify an Internet standard of any kind.
3250        Distribution of this memo is unlimited.
3251      </t>
3252    </xsl:when>
3253    <xsl:when test="/rfc/@category='std'">
3254      <t>
3255        This document specifies an Internet standards track protocol for the Internet
3256        community, and requests discussion and suggestions for improvements.
3257        Please refer to the current edition of the &#8220;Internet Official Protocol
3258        Standards&#8221; (STD 1) for the standardization state and status of this
3259        protocol. Distribution of this memo is unlimited.
3260      </t>
3261    </xsl:when>
3262    <xsl:otherwise>
3263      <t>UNSUPPORTED CATEGORY.</t>
3264    </xsl:otherwise>
3265  </xsl:choose>
3266 
3267  </section>
3268
3269  <xsl:choose>
3270    <xsl:when test="$ipr-2007-08"/>
3271    <xsl:when test="$ipr-rfc4748">
3272      <section title="Copyright Notice" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.copyrightnotice">
3273        <t>
3274          Copyright © The IETF Trust (<xsl:value-of select="$xml2rfc-ext-pub-year"/>).  All Rights Reserved.
3275        </t>
3276      </section>
3277    </xsl:when>
3278    <xsl:otherwise>
3279      <section title="Copyright Notice" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.copyrightnotice">
3280        <t>
3281          Copyright © The Internet Society (<xsl:value-of select="$xml2rfc-ext-pub-year"/>).  All Rights Reserved.
3282      </t>
3283      </section>
3284    </xsl:otherwise>
3285  </xsl:choose>
3286 
3287</xsl:template>
3288
3289<!-- TOC generation -->
3290
3291<xsl:template match="/" mode="toc">
3292  <hr xmlns="http://www.w3.org/1999/xhtml" class="noprint"/>
3293
3294  <h1 xmlns="http://www.w3.org/1999/xhtml" class="np" id="{$anchor-prefix}.toc"> <!-- this pagebreak occurs always -->
3295    <a href="#{$anchor-prefix}.toc">Table of Contents</a>
3296  </h1>
3297
3298  <ul xmlns="http://www.w3.org/1999/xhtml" class="toc">
3299    <xsl:apply-templates mode="toc"/>
3300  </ul>
3301</xsl:template>
3302
3303<xsl:template name="insert-toc-line">
3304  <xsl:param name="number"/>
3305  <xsl:param name="target"/>
3306  <xsl:param name="title"/>
3307  <xsl:param name="tocparam"/>
3308  <xsl:param name="oldtitle"/>
3309  <xsl:param name="waschanged"/>
3310
3311  <!-- handle tocdepth parameter -->
3312  <xsl:choose>
3313    <xsl:when test="($tocparam='' or $tocparam='default') and string-length(translate($number,'.ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890§','.')) &gt;= $parsedTocDepth">
3314      <!-- dropped entry because excluded -->
3315      <xsl:attribute name="class">tocline2</xsl:attribute>
3316    </xsl:when>
3317    <xsl:when test="$tocparam='exclude'">
3318      <!-- dropped entry because excluded -->
3319      <xsl:attribute name="class">tocline2</xsl:attribute>
3320    </xsl:when>
3321    <xsl:otherwise>
3322      <xsl:choose>
3323        <xsl:when test="starts-with($number,'del-')">
3324          <del xmlns="http://www.w3.org/1999/xhtml">
3325            <xsl:value-of select="$number"/>
3326            <a href="#{$target}"><xsl:value-of select="$title"/></a>
3327          </del>
3328        </xsl:when>
3329        <xsl:otherwise>
3330          <xsl:choose>
3331            <xsl:when test="not(contains($number,'.'))">
3332              <xsl:attribute name="class">tocline0</xsl:attribute>
3333            </xsl:when>
3334            <xsl:otherwise>
3335              <xsl:attribute name="class">tocline1</xsl:attribute>
3336            </xsl:otherwise>
3337          </xsl:choose>
3338          <xsl:if test="$number != ''">
3339            <xsl:call-template name="emit-section-number">
3340              <xsl:with-param name="no" select="$number"/>
3341            </xsl:call-template>
3342            <xsl:text>   </xsl:text>
3343          </xsl:if>
3344          <a xmlns="http://www.w3.org/1999/xhtml" href="#{$target}">
3345            <xsl:choose>
3346              <xsl:when test="$waschanged!=''">
3347                <ins><xsl:value-of select="$title"/></ins>
3348                <del><xsl:value-of select="$oldtitle"/></del>
3349              </xsl:when>
3350              <xsl:otherwise>
3351                <xsl:value-of select="$title"/>
3352              </xsl:otherwise>
3353            </xsl:choose>
3354          </a>
3355        </xsl:otherwise>
3356      </xsl:choose>
3357    </xsl:otherwise>
3358  </xsl:choose>
3359</xsl:template>
3360
3361<xsl:template match="back" mode="toc">
3362
3363  <!-- <xsl:apply-templates select="references" mode="toc" /> -->
3364
3365  <xsl:if test="//cref and $xml2rfc-comments='yes' and $xml2rfc-inline!='yes'">
3366    <li xmlns="http://www.w3.org/1999/xhtml">
3367      <xsl:call-template name="insert-toc-line">
3368        <xsl:with-param name="target" select="concat($anchor-prefix,'.comments')"/>
3369        <xsl:with-param name="title" select="'Editorial Comments'"/>
3370      </xsl:call-template>
3371    </li>
3372  </xsl:if>
3373
3374  <xsl:if test="$xml2rfc-ext-authors-section!='end'">
3375    <xsl:apply-templates select="/rfc/front" mode="toc"/>
3376  </xsl:if>
3377  <xsl:apply-templates select="*[not(self::references)]" mode="toc"/>
3378
3379  <xsl:if test="$xml2rfc-ext-authors-section='end'">
3380    <xsl:apply-templates select="/rfc/front" mode="toc"/>
3381  </xsl:if>
3382
3383  <!-- copyright statements -->
3384  <xsl:if test="not($xml2rfc-private)">
3385    <li xmlns="http://www.w3.org/1999/xhtml">
3386      <xsl:call-template name="insert-toc-line">
3387        <xsl:with-param name="target" select="concat($anchor-prefix,'.ipr')"/>
3388        <xsl:with-param name="title" select="'Intellectual Property and Copyright Statements'"/>
3389      </xsl:call-template>
3390    </li>
3391  </xsl:if>
3392 
3393  <!-- insert the index if index entries exist -->
3394  <xsl:if test="//iref">
3395    <li xmlns="http://www.w3.org/1999/xhtml">
3396      <xsl:call-template name="insert-toc-line">
3397        <xsl:with-param name="target" select="concat($anchor-prefix,'.index')"/>
3398        <xsl:with-param name="title" select="'Index'"/>
3399      </xsl:call-template>
3400    </li>
3401  </xsl:if>
3402
3403</xsl:template>
3404
3405<xsl:template match="front" mode="toc">
3406 
3407  <li xmlns="http://www.w3.org/1999/xhtml">
3408    <xsl:variable name="authors-title">
3409      <xsl:call-template name="get-authors-section-title"/>
3410    </xsl:variable>
3411    <xsl:variable name="authors-number">
3412      <xsl:call-template name="get-authors-section-number"/>
3413    </xsl:variable>
3414    <xsl:call-template name="insert-toc-line">
3415      <xsl:with-param name="target" select="concat($anchor-prefix,'.authors')"/>
3416      <xsl:with-param name="title" select="$authors-title"/>
3417      <xsl:with-param name="number" select="$authors-number"/>
3418    </xsl:call-template>
3419  </li>
3420
3421</xsl:template>
3422
3423<xsl:template name="references-toc">
3424
3425  <!-- distinguish two cases: (a) single references element (process
3426  as toplevel section; (b) multiple references sections (add one toplevel
3427  container with subsection) -->
3428
3429  <xsl:variable name="refsecs" select="/rfc/back/references|/rfc/back/ed:replace/ed:ins/references"/>
3430   
3431  <xsl:choose>
3432    <xsl:when test="count($refsecs) = 0">
3433      <!-- nop -->
3434    </xsl:when>
3435    <xsl:when test="count($refsecs) = 1">
3436      <xsl:for-each select="$refsecs">
3437        <xsl:variable name="title">
3438          <xsl:choose>
3439            <xsl:when test="@title!=''"><xsl:value-of select="@title"/></xsl:when>
3440            <xsl:otherwise>References</xsl:otherwise>
3441          </xsl:choose>
3442        </xsl:variable>
3443     
3444        <li xmlns="http://www.w3.org/1999/xhtml">
3445          <xsl:call-template name="insert-toc-line">
3446            <xsl:with-param name="number">
3447              <xsl:call-template name="get-references-section-number"/>
3448            </xsl:with-param>
3449            <xsl:with-param name="target" select="concat($anchor-prefix,'.references')"/>
3450            <xsl:with-param name="title" select="$title"/>
3451          </xsl:call-template>
3452        </li>
3453      </xsl:for-each>
3454    </xsl:when>
3455    <xsl:otherwise>
3456      <li xmlns="http://www.w3.org/1999/xhtml">
3457        <!-- insert pseudo container -->   
3458        <xsl:call-template name="insert-toc-line">
3459          <xsl:with-param name="number">
3460            <xsl:call-template name="get-references-section-number"/>
3461          </xsl:with-param>
3462          <xsl:with-param name="target" select="concat($anchor-prefix,'.references')"/>
3463          <xsl:with-param name="title" select="'References'"/>
3464        </xsl:call-template>
3465 
3466        <ul class="toc">
3467          <!-- ...with subsections... -->   
3468          <xsl:for-each select="$refsecs">
3469            <xsl:variable name="title">
3470              <xsl:choose>
3471                <xsl:when test="@title!=''"><xsl:value-of select="@title"/></xsl:when>
3472                <xsl:otherwise>References</xsl:otherwise>
3473              </xsl:choose>
3474            </xsl:variable>
3475         
3476            <xsl:variable name="sectionNumber">
3477              <xsl:call-template name="get-section-number"/>
3478            </xsl:variable>
3479   
3480            <xsl:variable name="num">
3481              <xsl:number level="any"/>
3482            </xsl:variable>
3483   
3484            <li>
3485              <xsl:call-template name="insert-toc-line">
3486                <xsl:with-param name="number" select="$sectionNumber"/>
3487                <xsl:with-param name="target" select="concat($anchor-prefix,'.references','.',$num)"/>
3488                <xsl:with-param name="title" select="$title"/>
3489              </xsl:call-template>
3490            </li>
3491          </xsl:for-each>
3492        </ul>
3493      </li>
3494    </xsl:otherwise>
3495  </xsl:choose>
3496</xsl:template>
3497
3498<xsl:template match="section|appendix" mode="toc">
3499  <xsl:variable name="sectionNumber">
3500    <xsl:call-template name="get-section-number"/>
3501  </xsl:variable>
3502
3503  <xsl:variable name="target">
3504    <xsl:choose>
3505      <xsl:when test="@anchor"><xsl:value-of select="@anchor"/></xsl:when>
3506       <xsl:otherwise><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$sectionNumber"/></xsl:otherwise>
3507    </xsl:choose>
3508  </xsl:variable>
3509
3510  <!-- obtain content, just to check whether we need to recurse at all -->
3511  <xsl:variable name="content">
3512    <li xmlns="http://www.w3.org/1999/xhtml">
3513      <xsl:call-template name="insert-toc-line">
3514        <xsl:with-param name="number" select="$sectionNumber"/>
3515        <xsl:with-param name="target" select="$target"/>
3516        <xsl:with-param name="title" select="@title"/>
3517        <xsl:with-param name="tocparam" select="@toc"/>
3518        <xsl:with-param name="oldtitle" select="@ed:old-title"/>
3519        <xsl:with-param name="waschanged" select="@ed:resolves"/>
3520      </xsl:call-template>
3521   
3522      <ul class="toc">
3523        <xsl:apply-templates mode="toc"/>
3524      </ul>
3525    </li>
3526  </xsl:variable>
3527 
3528  <xsl:if test="$content!=''">
3529    <li xmlns="http://www.w3.org/1999/xhtml">
3530      <xsl:call-template name="insert-toc-line">
3531        <xsl:with-param name="number" select="$sectionNumber"/>
3532        <xsl:with-param name="target" select="$target"/>
3533        <xsl:with-param name="title" select="@title"/>
3534        <xsl:with-param name="tocparam" select="@toc"/>
3535        <xsl:with-param name="oldtitle" select="@ed:old-title"/>
3536        <xsl:with-param name="waschanged" select="@ed:resolves"/>
3537      </xsl:call-template>
3538   
3539      <!-- obtain nested content, just to check whether we need to recurse at all -->
3540      <xsl:variable name="nested-content">
3541        <ul class="toc">
3542          <xsl:apply-templates mode="toc"/>
3543        </ul>
3544      </xsl:variable>
3545     
3546      <!-- only recurse if we need to (do not produce useless list container) -->     
3547      <xsl:if test="$nested-content!=''">
3548        <ul class="toc">
3549          <xsl:apply-templates mode="toc"/>
3550        </ul>
3551      </xsl:if>
3552    </li>
3553  </xsl:if>
3554</xsl:template>
3555
3556<xsl:template match="middle" mode="toc">
3557  <xsl:apply-templates mode="toc"/>
3558  <xsl:call-template name="references-toc"/>
3559</xsl:template>
3560
3561<xsl:template match="rfc" mode="toc">
3562  <xsl:apply-templates select="middle|back" mode="toc"/>
3563</xsl:template>
3564
3565<xsl:template match="ed:del|ed:ins|ed:replace" mode="toc">
3566  <xsl:apply-templates mode="toc"/>
3567</xsl:template>
3568
3569<xsl:template match="*|text()" mode="toc"/>
3570
3571
3572<xsl:template name="insertTocAppendix">
3573 
3574  <xsl:if test="//figure[@title!='' or @anchor!='']">
3575    <ul xmlns="http://www.w3.org/1999/xhtml" class="toc">
3576      <xsl:for-each select="//figure[@title!='' or @anchor!='']">
3577        <xsl:variable name="title">Figure <xsl:value-of select="position()"/><xsl:if test="@title">: <xsl:value-of select="@title"/></xsl:if>
3578        </xsl:variable>
3579        <li>
3580          <xsl:call-template name="insert-toc-line">
3581            <xsl:with-param name="target" select="concat($anchor-prefix,'.figure.',position())"/>
3582            <xsl:with-param name="title" select="$title"/>
3583          </xsl:call-template>
3584        </li>
3585      </xsl:for-each>
3586    </ul>
3587  </xsl:if>
3588 
3589  <!-- experimental -->
3590  <xsl:if test="//ed:issue">
3591    <xsl:call-template name="insertIssuesList"/>
3592  </xsl:if>
3593
3594</xsl:template>
3595
3596<xsl:template name="referencename">
3597  <xsl:param name="node"/>
3598 
3599  <xsl:for-each select="$node">
3600    <xsl:choose>
3601      <xsl:when test="$xml2rfc-symrefs!='no' and ancestor::ed:del">
3602        <xsl:variable name="unprefixed" select="substring-after(@anchor,'deleted-')"/>
3603        <xsl:choose>
3604          <xsl:when test="$unprefixed!=''">
3605            <xsl:value-of select="concat('[',$unprefixed,']')"/>
3606          </xsl:when>
3607          <xsl:otherwise>
3608            <xsl:if test="count(//reference[@anchor=current()/@anchor])!=1">
3609              <xsl:message>Deleted duplicate anchors should have the prefix "deleted-": <xsl:value-of select="@anchor"/></xsl:message>
3610            </xsl:if>
3611            <xsl:value-of select="concat('[',@anchor,']')"/>
3612          </xsl:otherwise>
3613        </xsl:choose>
3614      </xsl:when>
3615      <xsl:when test="$xml2rfc-symrefs!='no'">[<xsl:value-of select="@anchor"/>]</xsl:when>
3616      <xsl:when test="ancestor::ed:del">
3617        <xsl:text>[del]</xsl:text>
3618      </xsl:when>
3619      <xsl:otherwise>[<xsl:number level="any" count="reference[not(ancestor::ed:del)]"/>]</xsl:otherwise>
3620    </xsl:choose>
3621  </xsl:for-each> 
3622</xsl:template>
3623
3624
3625
3626<xsl:template name="replace-substring">
3627
3628  <xsl:param name="string"/>
3629  <xsl:param name="replace"/>
3630  <xsl:param name="by"/>
3631
3632  <xsl:choose>
3633    <xsl:when test="contains($string,$replace)">
3634      <xsl:value-of select="concat(substring-before($string, $replace),$by)"/>
3635      <xsl:call-template name="replace-substring">
3636        <xsl:with-param name="string" select="substring-after($string,$replace)"/>
3637        <xsl:with-param name="replace" select="$replace"/>
3638        <xsl:with-param name="by" select="$by"/>
3639      </xsl:call-template>
3640    </xsl:when>
3641    <xsl:otherwise><xsl:value-of select="$string"/></xsl:otherwise>
3642  </xsl:choose>
3643
3644</xsl:template>
3645
3646
3647<xsl:template name="rfclist">
3648  <xsl:param name="list"/>
3649  <xsl:choose>
3650    <xsl:when test="contains($list,',')">
3651      <xsl:variable name="rfcNo" select="substring-before($list,',')"/>
3652      <xsl:if test="count(//references//reference/seriesInfo[@name='RFC' and @value=$rfcNo])=0">
3653        <xsl:call-template name="warning">
3654          <xsl:with-param name="inline" select="'no'"/>
3655          <xsl:with-param name="msg" select="concat('front matter mentions RFC ',$rfcNo,' for which there is no reference element')"/>
3656        </xsl:call-template>
3657      </xsl:if>
3658      <a xmlns="http://www.w3.org/1999/xhtml" href="{concat($rfcUrlPrefix,$rfcNo,$rfcUrlPostfix)}"><xsl:value-of select="$rfcNo"/></a>,
3659      <xsl:call-template name="rfclist">
3660        <xsl:with-param name="list" select="normalize-space(substring-after($list,','))"/>
3661      </xsl:call-template>
3662    </xsl:when>
3663    <xsl:otherwise>
3664      <xsl:variable name="rfcNo" select="$list"/>
3665      <xsl:if test="count(//references//reference/seriesInfo[@name='RFC' and @value=$rfcNo])=0">
3666        <xsl:call-template name="warning">
3667          <xsl:with-param name="inline" select="'no'"/>
3668          <xsl:with-param name="msg" select="concat('front matter mentions RFC',$rfcNo,' for which there is no reference element')"/>
3669        </xsl:call-template>
3670      </xsl:if>
3671      <a xmlns="http://www.w3.org/1999/xhtml" href="{concat($rfcUrlPrefix,$rfcNo,$rfcUrlPostfix)}"><xsl:value-of select="$rfcNo"/></a>
3672    </xsl:otherwise>
3673  </xsl:choose>
3674</xsl:template>
3675
3676<xsl:template name="rfclist-for-dcmeta">
3677  <xsl:param name="list"/>
3678  <xsl:choose>
3679    <xsl:when test="contains($list,',')">
3680      <xsl:variable name="rfcNo" select="substring-before($list,',')"/>
3681      <meta xmlns="http://www.w3.org/1999/xhtml" name="DC.Relation.Replaces" content="urn:ietf:rfc:{$rfcNo}"/>
3682      <xsl:call-template name="rfclist-for-dcmeta">
3683        <xsl:with-param name="list" select="normalize-space(substring-after($list,','))"/>
3684      </xsl:call-template>
3685    </xsl:when>
3686    <xsl:otherwise>
3687      <xsl:variable name="rfcNo" select="$list"/>
3688      <meta xmlns="http://www.w3.org/1999/xhtml" name="DC.Relation.Replaces" content="urn:ietf:rfc:{$rfcNo}"/>
3689    </xsl:otherwise>
3690  </xsl:choose>
3691</xsl:template>
3692
3693<xsl:template name="get-paragraph-number">
3694  <!-- get section number of ancestor section element, then add t or figure number -->
3695  <xsl:if test="ancestor::section and not(ancestor::section[@myns:unnumbered='unnumbered']) and not(ancestor::x:blockquote)">
3696    <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"/>
3697  </xsl:if>
3698</xsl:template>
3699
3700<xsl:template name="editingMark">
3701  <xsl:if test="$xml2rfc-editing='yes' and ancestor::rfc">
3702    <sup xmlns="http://www.w3.org/1999/xhtml" class="editingmark"><span><xsl:number level="any" count="postamble|preamble|t"/></span> </sup>
3703  </xsl:if>
3704</xsl:template>
3705
3706<!-- internal ref support -->
3707<xsl:template match="x:ref">
3708  <xsl:variable name="val" select="."/>
3709  <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)]"/>
3710  <xsl:variable name="irefs" select="//iref[@x:for-anchor=$val]"/>
3711  <xsl:choose>
3712    <xsl:when test="$target">
3713      <a xmlns="http://www.w3.org/1999/xhtml" href="#{$target/@anchor}" class="smpl">
3714        <!-- to be indexed? -->
3715        <xsl:if test="$irefs">
3716          <xsl:attribute name="id"><xsl:call-template name="compute-extref-anchor"/></xsl:attribute>
3717        </xsl:if>
3718        <xsl:value-of select="."/>
3719      </a>
3720    </xsl:when>
3721    <xsl:otherwise>
3722      <xsl:message>WARNING: internal link target for '<xsl:value-of select="."/>' does not exist.<xsl:call-template name="lineno"/></xsl:message>
3723      <xsl:value-of select="."/>
3724    </xsl:otherwise>
3725  </xsl:choose>
3726</xsl:template>
3727
3728<!-- Nothing to do here -->
3729<xsl:template match="x:anchor-alias"/>
3730
3731<!-- Quotes -->
3732<xsl:template match="x:q">
3733  <q xmlns="http://www.w3.org/1999/xhtml">
3734    <xsl:copy-of select="@cite"/>
3735    <xsl:apply-templates/>
3736  </q>
3737</xsl:template>
3738
3739<xsl:template match="x:bcp14">
3740  <!-- check valid BCP14 keywords, then emphasize them -->
3741  <xsl:variable name="c" select="normalize-space(.)"/>
3742  <xsl:choose>
3743    <xsl:when test="$c='MUST' or $c='REQUIRED' or $c='SHALL'">
3744      <em xmlns="http://www.w3.org/1999/xhtml" class="bcp14"><xsl:value-of select="."/></em>
3745    </xsl:when>
3746    <xsl:when test="$c='MUST NOT' or $c='SHALL NOT'">
3747      <em xmlns="http://www.w3.org/1999/xhtml" class="bcp14"><xsl:value-of select="."/></em>
3748    </xsl:when>
3749    <xsl:when test="$c='SHOULD' or $c='RECOMMENDED'">
3750      <em xmlns="http://www.w3.org/1999/xhtml" class="bcp14"><xsl:value-of select="."/></em>
3751    </xsl:when>
3752    <xsl:when test="$c='SHOULD NOT' or $c='NOT RECOMMENDED'">
3753      <em xmlns="http://www.w3.org/1999/xhtml" class="bcp14"><xsl:value-of select="."/></em>
3754    </xsl:when>
3755    <xsl:when test="$c='MAY' or $c='OPTIONAL'">
3756      <em xmlns="http://www.w3.org/1999/xhtml" class="bcp14"><xsl:value-of select="."/></em>
3757    </xsl:when>
3758    <xsl:otherwise>
3759      <xsl:value-of select="."/>
3760      <xsl:message>ERROR: unknown BCP14 keyword: <xsl:value-of select="."/></xsl:message>
3761    </xsl:otherwise>
3762  </xsl:choose>
3763</xsl:template>
3764
3765<xsl:template match="x:blockquote">
3766  <xsl:variable name="p">
3767    <xsl:call-template name="get-paragraph-number"/>
3768  </xsl:variable>
3769
3770  <blockquote xmlns="http://www.w3.org/1999/xhtml">
3771    <xsl:if test="string-length($p) &gt; 0 and not(ancestor::ed:del) and not(ancestor::ed:ins)">
3772      <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$p"/></xsl:attribute>
3773    </xsl:if>
3774    <xsl:call-template name="insertInsDelClass"/>
3775    <xsl:call-template name="editingMark"/>
3776    <xsl:copy-of select="@cite"/>
3777    <xsl:apply-templates/>
3778  </blockquote>
3779</xsl:template>
3780
3781<!-- Definitions -->
3782<xsl:template match="x:dfn">
3783  <dfn xmlns="http://www.w3.org/1999/xhtml">
3784    <xsl:apply-templates/>
3785  </dfn>
3786</xsl:template>
3787
3788<!-- headings -->
3789<xsl:template match="x:h">
3790  <b xmlns="http://www.w3.org/1999/xhtml">
3791    <xsl:apply-templates/>
3792  </b>
3793</xsl:template>
3794
3795<!-- superscripts -->
3796<xsl:template match="x:sup">
3797  <sup xmlns="http://www.w3.org/1999/xhtml">
3798    <xsl:apply-templates/>
3799  </sup>
3800</xsl:template>
3801
3802<!-- measuring lengths -->
3803<xsl:template match="x:length-of">
3804  <xsl:variable name="target" select="//*[@anchor=current()/@target]"/>
3805  <xsl:if test="count($target)!=1">
3806    <xsl:call-template name="error">
3807      <xsl:with-param name="msg" select="concat('@target ',@target,' defined ',count($target),' times.')"/>
3808    </xsl:call-template>
3809  </xsl:if>
3810  <xsl:variable name="content">
3811    <xsl:apply-templates select="$target"/>
3812  </xsl:variable>
3813  <xsl:variable name="lineends" select="string-length($content) - string-length(translate($content,'&#xA;',''))"/>
3814  <xsl:variable name="indents">
3815    <xsl:choose>
3816      <xsl:when test="@indented">
3817        <xsl:value-of select="number(@indented) * $lineends"/>
3818      </xsl:when>
3819      <xsl:otherwise>0</xsl:otherwise>
3820    </xsl:choose>
3821  </xsl:variable>
3822  <xsl:value-of select="string-length($content) + $lineends - $indents"/>
3823</xsl:template>
3824
3825<!-- Nop -->
3826<xsl:template match="x:span">
3827  <xsl:apply-templates/>
3828</xsl:template>
3829
3830<!-- box drawing -->
3831
3832<!-- nop for alignment -->
3833<xsl:template match="x:x"/>
3834
3835<!-- box (top) -->
3836<xsl:template match="x:bt">
3837  <xsl:text>&#9484;</xsl:text>
3838  <xsl:value-of select="translate(substring(.,2,string-length(.)-2),'-','&#9472;')"/>
3839  <xsl:text>&#9488;</xsl:text>
3840</xsl:template>
3841
3842<!-- box (center) -->
3843<xsl:template match="x:bc">
3844  <xsl:variable name="first" select="substring(.,1)"/>
3845  <xsl:variable name="last" select="substring(.,string-length(.)-1)"/>
3846  <xsl:variable name="content" select="substring(.,2,string-length(.)-2)"/>
3847  <xsl:variable name="is-delimiter" select="translate($content,'-','')=''"/>
3848 
3849  <xsl:choose>
3850    <xsl:when test="$is-delimiter">
3851      <xsl:text>&#9500;</xsl:text>
3852      <xsl:value-of select="translate($content,'-','&#9472;')"/>
3853      <xsl:text>&#9508;</xsl:text>
3854    </xsl:when>
3855    <xsl:when test="*">
3856      <xsl:for-each select="node()">
3857        <xsl:choose>
3858          <xsl:when test="position()=1">
3859            <xsl:text>&#9474;</xsl:text>
3860            <xsl:value-of select="substring(.,2)"/>
3861          </xsl:when>
3862          <xsl:when test="position()=last()">
3863            <xsl:value-of select="substring(.,1,string-length(.)-1)"/>
3864            <xsl:text>&#9474;</xsl:text>
3865          </xsl:when>
3866          <xsl:otherwise>
3867            <xsl:apply-templates select="."/>
3868          </xsl:otherwise>
3869        </xsl:choose>
3870      </xsl:for-each>
3871    </xsl:when>
3872    <xsl:otherwise>
3873      <xsl:text>&#9474;</xsl:text>
3874      <xsl:value-of select="$content"/>
3875      <xsl:text>&#9474;</xsl:text>
3876    </xsl:otherwise>
3877  </xsl:choose>
3878 
3879</xsl:template>
3880
3881<!-- box (bottom) -->
3882<xsl:template match="x:bb">
3883  <xsl:text>&#9492;</xsl:text>
3884  <xsl:value-of select="translate(substring(.,2,string-length(.)-2),'-','&#9472;')"/>
3885  <xsl:text>&#9496;</xsl:text>
3886</xsl:template>
3887
3888<!-- experimental annotation support -->
3889
3890<xsl:template match="ed:issueref">
3891  <xsl:choose>
3892    <xsl:when test=".=//ed:issue/@name">
3893      <a xmlns="http://www.w3.org/1999/xhtml" href="#{$anchor-prefix}.issue.{.}">
3894        <xsl:apply-templates/>
3895      </a>
3896    </xsl:when>
3897    <xsl:otherwise>
3898      <xsl:call-template name="warning">
3899        <xsl:with-param name="msg">Dangling ed:issueref: <xsl:value-of select="."/></xsl:with-param>
3900      </xsl:call-template>
3901      <xsl:apply-templates/>
3902    </xsl:otherwise>
3903  </xsl:choose>
3904</xsl:template>
3905
3906<xsl:template match="ed:issue">
3907  <xsl:variable name="class">
3908    <xsl:choose>
3909      <xsl:when test="@status='closed'">closedissue</xsl:when>
3910      <xsl:otherwise>openissue</xsl:otherwise>
3911    </xsl:choose>
3912  </xsl:variable>
3913 
3914  <table xmlns="http://www.w3.org/1999/xhtml" summary="issue {@name}" class="{$class}">
3915    <tr>
3916      <td colspan="3">
3917        <a id="{$anchor-prefix}.issue.{@name}">
3918          <xsl:choose>
3919            <xsl:when test="@status='closed'">
3920              <xsl:attribute name="class">closed-issue</xsl:attribute>
3921            </xsl:when>
3922            <xsl:when test="@status='editor'">
3923              <xsl:attribute name="class">editor-issue</xsl:attribute>
3924            </xsl:when>
3925            <xsl:otherwise>
3926              <xsl:attribute name="class">open-issue</xsl:attribute>
3927            </xsl:otherwise>
3928          </xsl:choose>
3929          <xsl:text> I </xsl:text>
3930        </a>
3931        <xsl:text> </xsl:text>
3932        <xsl:choose>
3933          <xsl:when test="@href">
3934            <em><a href="{@href}"><xsl:value-of select="@name"/></a></em>
3935          </xsl:when>
3936          <xsl:when test="@alternate-href">
3937            <em>[<a href="{@alternate-href}">alternate link</a>]</em>
3938          </xsl:when>
3939          <xsl:otherwise>
3940            <em><xsl:value-of select="@name"/></em>
3941          </xsl:otherwise>
3942        </xsl:choose>
3943         
3944        (type: <xsl:value-of select="@type"/>, status: <xsl:value-of select="@status"/>)
3945      </td>
3946    </tr>
3947
3948    <xsl:apply-templates select="ed:item"/>
3949    <xsl:apply-templates select="ed:resolution"/>
3950
3951    <xsl:variable name="changes" select="//*[@ed:resolves=current()/@name or ed:resolves=current()/@name]"/>
3952    <xsl:if test="$changes">
3953      <tr>
3954        <td class="top" colspan="3">
3955          Associated changes in this document:
3956          <xsl:variable name="issue" select="@name"/>
3957          <xsl:for-each select="$changes">
3958            <a href="#{$anchor-prefix}.change.{$issue}.{position()}">
3959              <xsl:variable name="label">
3960                <xsl:call-template name="get-section-number"/>
3961              </xsl:variable>
3962              <xsl:choose>
3963                <xsl:when test="$label!=''"><xsl:value-of select="$label"/></xsl:when>
3964                <xsl:otherwise>&lt;<xsl:value-of select="concat('#',$anchor-prefix,'.change.',$issue,'.',position())"/>&gt;</xsl:otherwise>
3965              </xsl:choose>
3966            </a>
3967            <xsl:if test="position()!=last()">, </xsl:if>
3968          </xsl:for-each>
3969          <xsl:text>.</xsl:text>
3970        </td>
3971      </tr>
3972    </xsl:if>
3973  </table>
3974   
3975</xsl:template>
3976
3977<xsl:template match="ed:item">
3978  <tr xmlns="http://www.w3.org/1999/xhtml">
3979    <td class="top">
3980      <xsl:if test="@entered-by">
3981        <a href="mailto:{@entered-by}?subject={/rfc/@docName},%20{../@name}">
3982          <i><xsl:value-of select="@entered-by"/></i>
3983        </a>
3984      </xsl:if>
3985    </td>
3986    <td class="topnowrap">
3987      <xsl:value-of select="@date"/>
3988    </td>
3989    <td class="top">
3990      <xsl:apply-templates select="node()" mode="issuehtml"/>
3991    </td>
3992  </tr>
3993</xsl:template>
3994
3995<xsl:template match="ed:resolution">
3996  <tr xmlns="http://www.w3.org/1999/xhtml">
3997    <td class="top">
3998      <xsl:if test="@entered-by">
3999        <a href="mailto:{@entered-by}?subject={/rfc/@docName},%20{../@name}"><i><xsl:value-of select="@entered-by"/></i></a>
4000      </xsl:if>
4001    </td>
4002    <td class="topnowrap">
4003      <xsl:value-of select="@datetime"/>
4004    </td>
4005    <td class="top">
4006      <em>Resolution:</em>
4007      <xsl:apply-templates select="node()" mode="issuehtml"/>
4008    </td>
4009  </tr>
4010</xsl:template>
4011
4012<xsl:template match="ed:annotation">
4013  <em xmlns="http://www.w3.org/1999/xhtml">
4014    <xsl:apply-templates/>
4015  </em>
4016</xsl:template>
4017
4018<!-- special templates for handling XHTML in issues -->
4019<xsl:template match="text()" mode="issuehtml">
4020  <xsl:value-of select="."/>
4021</xsl:template>
4022
4023<xsl:template match="*|@*" mode="issuehtml">
4024  <xsl:message terminate="yes">Unexpected node in issue HTML: <xsl:value-of select="local-name(.)"/></xsl:message>
4025</xsl:template>
4026
4027<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">
4028  <xsl:element namespace="http://www.w3.org/1999/xhtml" name="{local-name()}">
4029    <xsl:apply-templates select="@*|node()" mode="issuehtml"/>
4030  </xsl:element>
4031</xsl:template>
4032
4033<xsl:template match="xhtml:p" mode="issuehtml">
4034  <xsl:apply-templates select="node()" mode="issuehtml"/>
4035  <br xmlns="http://www.w3.org/1999/xhtml" class="p"/>
4036</xsl:template>
4037
4038<xsl:template match="xhtml:a/@href|xhtml:q/@cite" mode="issuehtml">
4039  <xsl:attribute name="{local-name(.)}">
4040    <xsl:value-of select="."/>
4041  </xsl:attribute>
4042</xsl:template>
4043
4044<xsl:template match="ed:issueref" mode="issuehtml">
4045  <xsl:apply-templates select="."/>
4046</xsl:template>
4047
4048<xsl:template match="ed:eref" mode="issuehtml">
4049  <xsl:text>&lt;</xsl:text>
4050  <a xmlns="http://www.w3.org/1999/xhtml" href="{.}"><xsl:value-of select="."/></a>
4051  <xsl:text>&gt;</xsl:text>
4052</xsl:template>
4053
4054<xsl:template name="insertIssuesList">
4055
4056  <h2 xmlns="http://www.w3.org/1999/xhtml" id="{$anchor-prefix}.issues-list"><a href="#{$anchor-prefix}.issues-list">Issues list</a></h2>
4057  <table xmlns="http://www.w3.org/1999/xhtml" summary="Issues list">
4058    <thead>
4059      <tr>
4060        <th>Id</th>
4061        <th>Type</th>
4062        <th>Status</th>
4063        <th>Date</th>
4064        <th>Raised By</th>
4065      </tr>
4066    </thead>
4067    <tbody>
4068      <xsl:for-each select="//ed:issue">
4069        <xsl:sort select="@status"/>
4070        <xsl:sort select="@name"/>
4071        <tr>
4072          <td><a href="#{$anchor-prefix}.issue.{@name}"><xsl:value-of select="@name"/></a></td>
4073          <td><xsl:value-of select="@type"/></td>
4074          <td><xsl:value-of select="@status"/></td>
4075          <td><xsl:value-of select="ed:item[1]/@date"/></td>
4076          <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>
4077        </tr>
4078      </xsl:for-each>
4079    </tbody>
4080  </table>
4081 
4082</xsl:template>
4083
4084<xsl:template name="formatTitle">
4085  <xsl:if test="@who">
4086    <xsl:value-of select="@who"/>
4087  </xsl:if>
4088  <xsl:if test="@datetime">
4089    <xsl:value-of select="concat(' (',@datetime,')')"/>
4090  </xsl:if>
4091  <xsl:if test="@reason">
4092    <xsl:value-of select="concat(': ',@reason)"/>
4093  </xsl:if>
4094  <xsl:if test="@cite">
4095    <xsl:value-of select="concat(' &lt;',@cite,'&gt;')"/>
4096  </xsl:if>
4097</xsl:template>
4098
4099<xsl:template name="insert-diagnostics">
4100 
4101  <!-- check anchor names -->
4102  <xsl:variable name="badAnchors" select="//*[starts-with(@anchor,concat($anchor-prefix,'.'))]"/>
4103  <xsl:if test="$badAnchors">
4104    <p xmlns="http://www.w3.org/1999/xhtml" class="warning">
4105      The following anchor names may collide with internally generated anchors because of their prefix "<xsl:value-of select="$anchor-prefix"/>":
4106      <xsl:for-each select="$badAnchors">
4107        <xsl:value-of select="@anchor"/><xsl:if test="position()!=last()">, </xsl:if>
4108      </xsl:for-each>
4109    </p>
4110    <xsl:message>
4111      The following anchor names may collide with internally generated anchors because of their prefix "<xsl:value-of select="$anchor-prefix"/>":
4112      <xsl:for-each select="$badAnchors">
4113        <xsl:value-of select="@anchor"/><xsl:if test="position()!=last()">, </xsl:if>
4114      </xsl:for-each>
4115    </xsl:message>
4116  </xsl:if>
4117 
4118  <!-- check IDs -->
4119  <xsl:variable name="badTargets" select="//xref[not(@target=//@anchor) and not(ancestor::ed:del)]"/>
4120  <xsl:if test="$badTargets">
4121    <p xmlns="http://www.w3.org/1999/xhtml" class="error">
4122      The following target names do not exist:
4123      <xsl:for-each select="$badTargets">
4124        <xsl:value-of select="@target"/><xsl:if test="position()!=last()">, </xsl:if>
4125      </xsl:for-each>
4126    </p>
4127    <xsl:message>
4128      The following target names do not exist:
4129      <xsl:for-each select="$badTargets">
4130        <xsl:value-of select="@target"/><xsl:if test="position()!=last()">, </xsl:if>
4131      </xsl:for-each>
4132    </xsl:message>
4133  </xsl:if>
4134 
4135 
4136</xsl:template>
4137
4138<!-- special change mark support, not supported by RFC2629 yet -->
4139
4140<xsl:template match="@ed:*"/>
4141
4142<xsl:template match="ed:del">
4143  <xsl:call-template name="insert-issue-pointer"/>
4144  <del 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  </del>
4151</xsl:template>
4152
4153<xsl:template match="ed:ins">
4154  <xsl:call-template name="insert-issue-pointer"/>
4155  <ins xmlns="http://www.w3.org/1999/xhtml">
4156    <xsl:copy-of select="@*[namespace-uri()='']"/>
4157    <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
4158      <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4159    </xsl:if>
4160    <xsl:apply-templates/>
4161  </ins>
4162</xsl:template>
4163
4164<xsl:template name="insert-issue-pointer">
4165  <xsl:param name="deleted-anchor"/>
4166  <xsl:variable name="change" select="."/>
4167  <xsl:for-each select="@ed:resolves|ed:resolves">
4168    <xsl:variable name="resolves" select="."/>
4169    <!-- need the right context node for proper numbering -->
4170    <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>
4171    <xsl:variable name="total" select="count(//*[@ed:resolves=$resolves or ed:resolves=$resolves])"/>
4172    <xsl:variable name="id">
4173      <xsl:value-of select="$anchor-prefix"/>.change.<xsl:value-of select="$resolves"/>.<xsl:value-of select="$count"/>
4174    </xsl:variable>
4175    <xsl:choose>
4176      <!-- block level? -->
4177      <xsl:when test="not(ancestor::t) and not(ancestor::title) and not(ancestor::figure) and not($change/@ed:old-title)">
4178        <div xmlns="http://www.w3.org/1999/xhtml" class="issuepointer noprint">
4179          <xsl:if test="not($deleted-anchor)">
4180            <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
4181          </xsl:if>
4182          <xsl:if test="$count &gt; 1">
4183            <a class="bg-issue" title="previous change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count - 1}">&#8593;</a>
4184          </xsl:if>
4185          <a class="open-issue" href="#{$anchor-prefix}.issue.{$resolves}" title="resolves: {$resolves}">
4186            <xsl:choose>
4187              <xsl:when test="//ed:issue[@name=$resolves and @status='closed']">
4188                <xsl:attribute name="class">closed-issue</xsl:attribute>
4189              </xsl:when>
4190              <xsl:when test="//ed:issue[@name=$resolves and @status='editor']">
4191                <xsl:attribute name="class">editor-issue</xsl:attribute>
4192              </xsl:when>
4193              <xsl:otherwise>
4194                <xsl:attribute name="class">open-issue</xsl:attribute>
4195              </xsl:otherwise>
4196            </xsl:choose>
4197            <xsl:text> I </xsl:text>
4198          </a>
4199          <xsl:if test="$count &lt; $total">
4200            <a class="bg-issue" title="next change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count + 1}">&#8595;</a>
4201          </xsl:if>
4202          <xsl:text> </xsl:text>
4203        </div>
4204      </xsl:when>
4205      <xsl:otherwise>
4206        <xsl:if test="$count &gt; 1">
4207          <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>
4208        </xsl:if>
4209        <a xmlns="http://www.w3.org/1999/xhtml" title="resolves: {$resolves}" href="#{$anchor-prefix}.issue.{$resolves}">
4210          <xsl:if test="not($deleted-anchor)">
4211            <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
4212          </xsl:if>
4213          <xsl:choose>
4214            <xsl:when test="//ed:issue[@name=$resolves and @status='closed']">
4215              <xsl:attribute name="class">closed-issue noprint</xsl:attribute>
4216            </xsl:when>
4217            <xsl:when test="//ed:issue[@name=$resolves and @status='editor']">
4218              <xsl:attribute name="class">editor-issue noprint</xsl:attribute>
4219            </xsl:when>
4220            <xsl:otherwise>
4221              <xsl:attribute name="class">open-issue noprint</xsl:attribute>
4222            </xsl:otherwise>
4223          </xsl:choose>
4224          <xsl:text> I </xsl:text>
4225        </a>
4226        <xsl:if test="$count &lt; $total">
4227          <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>
4228        </xsl:if>
4229      </xsl:otherwise>
4230    </xsl:choose>
4231  </xsl:for-each>
4232</xsl:template>
4233
4234<xsl:template match="ed:replace">
4235  <!-- we need to special-case things like lists and tables -->
4236  <xsl:choose>
4237    <xsl:when test="parent::list">
4238      <xsl:apply-templates select="ed:del/node()"/>
4239      <xsl:apply-templates select="ed:ins/node()"/>
4240    </xsl:when>
4241    <xsl:when test="ancestor::references">
4242      <xsl:apply-templates select="ed:del/node()"/>
4243      <xsl:apply-templates select="ed:ins/node()"/>
4244    </xsl:when>
4245    <xsl:otherwise>
4246      <xsl:if test="@cite">
4247        <a xmlns="http://www.w3.org/1999/xhtml" class="editor-issue" href="{@cite}" target="_blank" title="see {@cite}">
4248          <xsl:text> i </xsl:text>
4249        </a>
4250      </xsl:if>
4251      <xsl:call-template name="insert-issue-pointer"/>
4252      <xsl:if test="ed:del">
4253        <del xmlns="http://www.w3.org/1999/xhtml">
4254          <xsl:copy-of select="@*[namespace-uri()='']"/>
4255          <xsl:if test="not(@title) and ancestor-or-self::xsl:template[@ed:entered-by] and @datetime">
4256            <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4257          </xsl:if>
4258          <xsl:apply-templates select="ed:del/node()"/>
4259        </del>
4260      </xsl:if>
4261      <xsl:if test="ed:ins">
4262        <ins xmlns="http://www.w3.org/1999/xhtml">
4263          <xsl:copy-of select="@*[namespace-uri()='']"/>
4264          <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
4265            <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4266          </xsl:if>
4267          <xsl:apply-templates select="ed:ins/node()"/>
4268        </ins>
4269      </xsl:if>
4270    </xsl:otherwise>
4271  </xsl:choose>
4272</xsl:template>
4273
4274<!-- convenience template for helping Mozilla (pre/ins inheritance problem) -->
4275<xsl:template name="insertInsDelClass">
4276  <xsl:if test="ancestor::ed:del">
4277    <xsl:attribute name="class">del</xsl:attribute>
4278  </xsl:if>
4279  <xsl:if test="ancestor::ed:ins">
4280    <xsl:attribute name="class">ins</xsl:attribute>
4281  </xsl:if>
4282</xsl:template>
4283
4284
4285<xsl:template name="sectionnumberAndEdits">
4286  <xsl:choose>
4287    <xsl:when test="ancestor::ed:del">del-<xsl:number count="ed:del//section" level="any"/></xsl:when>
4288    <xsl:when test="@x:fixed-section-number">
4289      <xsl:value-of select="@x:fixed-section-number"/>
4290    </xsl:when>
4291    <xsl:when test="self::section and parent::ed:ins and local-name(../..)='replace'">
4292      <xsl:for-each select="../.."><xsl:call-template name="sectionnumberAndEdits"/></xsl:for-each>
4293      <xsl:for-each select="..">
4294        <xsl:if test="parent::ed:replace">
4295          <xsl:for-each select="..">
4296            <xsl:if test="parent::section">.</xsl:if>
4297            <xsl:variable name="cnt" select="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)"/>
4298            <xsl:choose>
4299              <xsl:when test="ancestor::back and not(ancestor::section)"><xsl:number format="A" value="$cnt"/></xsl:when>
4300              <xsl:otherwise><xsl:value-of select="$cnt"/></xsl:otherwise>
4301            </xsl:choose>
4302          </xsl:for-each>
4303        </xsl:if>
4304      </xsl:for-each>
4305    </xsl:when>
4306    <xsl:when test="self::section[parent::ed:ins]">
4307      <xsl:for-each select="../.."><xsl:call-template name="sectionnumberAndEdits"/></xsl:for-each>
4308      <xsl:for-each select="..">
4309        <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)"/>
4310      </xsl:for-each>
4311    </xsl:when>
4312    <xsl:when test="self::section">
4313      <xsl:for-each select=".."><xsl:call-template name="sectionnumberAndEdits"/></xsl:for-each>
4314      <xsl:if test="parent::section">.</xsl:if>
4315      <xsl:choose>
4316        <xsl:when test="parent::back">
4317          <xsl:number format="A" value="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)"/>
4318        </xsl:when>
4319        <xsl:otherwise>
4320          <xsl:number value="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)"/>
4321        </xsl:otherwise>
4322      </xsl:choose>
4323    </xsl:when>
4324    <xsl:when test="self::references">
4325      <xsl:choose>
4326        <xsl:when test="count(/*/back/references)+count(/*/back/ed:replace/ed:ins/references)=1"><xsl:call-template name="get-references-section-number"/></xsl:when>
4327        <xsl:otherwise><xsl:call-template name="get-references-section-number"/>.<xsl:number level="any"/></xsl:otherwise>
4328      </xsl:choose>
4329    </xsl:when>
4330    <xsl:when test="self::middle or self::back"><!-- done --></xsl:when>
4331    <xsl:otherwise>
4332      <!-- go up one level -->
4333      <xsl:for-each select=".."><xsl:call-template name="sectionnumberAndEdits"/></xsl:for-each>
4334    </xsl:otherwise>
4335  </xsl:choose>
4336</xsl:template>
4337
4338<!-- utilities for warnings -->
4339
4340<xsl:template name="warning">
4341  <xsl:param name="msg"/>
4342  <xsl:param name="msg2"/>
4343  <xsl:param name="inline"/>
4344  <xsl:if test="$inline!='no'">
4345    <div xmlns="http://www.w3.org/1999/xhtml" class="error">WARNING: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/></div>
4346  </xsl:if>
4347  <xsl:message>WARNING: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/><xsl:call-template name="lineno"/></xsl:message>
4348</xsl:template>
4349
4350<xsl:template name="error">
4351  <xsl:param name="msg"/>
4352  <xsl:param name="msg2"/>
4353  <xsl:param name="inline"/>
4354  <xsl:if test="$inline='no'">
4355    <div xmlns="http://www.w3.org/1999/xhtml" class="error">ERROR: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/></div>
4356  </xsl:if>
4357  <xsl:message>ERROR: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/><xsl:call-template name="lineno"/></xsl:message>
4358</xsl:template>
4359
4360<!-- table formatting -->
4361
4362<xsl:template match="texttable">
4363
4364  <xsl:variable name="anch">
4365    <xsl:call-template name="get-table-anchor"/>
4366  </xsl:variable>
4367
4368  <div xmlns="http://www.w3.org/1999/xhtml" id="{$anch}">
4369    <xsl:if test="@anchor!=''">
4370      <div id="{@anchor}"/>
4371    </xsl:if>
4372    <xsl:apply-templates select="preamble"/>
4373    <xsl:variable name="style">
4374      <xsl:text>tt </xsl:text>
4375      <xsl:choose>
4376        <xsl:when test="@style!=''">
4377          <xsl:value-of select="@style"/>
4378        </xsl:when>
4379        <xsl:otherwise>full</xsl:otherwise>
4380      </xsl:choose>
4381    </xsl:variable>
4382    <table summary="{preamble}" class="{$style}" cellpadding="3" cellspacing="0">
4383      <thead>
4384        <tr>
4385          <xsl:apply-templates select="ttcol"/>
4386        </tr>
4387      </thead>
4388      <tbody>
4389        <xsl:variable name="columns" select="count(ttcol)"/>
4390        <xsl:variable name="fields" select="c | ed:replace/ed:ins/c | ed:replace/ed:del/c"/>
4391        <xsl:for-each select="$fields[(position() mod $columns) = 1]">
4392          <tr>
4393            <xsl:for-each select=". | following-sibling::c[position() &lt; $columns]">
4394              <td>
4395                <xsl:call-template name="insertInsDelClass"/>
4396                <xsl:variable name="pos" select="position()"/>
4397                <xsl:variable name="col" select="../ttcol[position() = $pos]"/>
4398                <xsl:choose>
4399                  <xsl:when test="$col/@align='right' or $col/@align='center'">
4400                    <xsl:attribute name="class"><xsl:value-of select="$col/@align"/></xsl:attribute>
4401                  </xsl:when>
4402                  <xsl:when test="$col/@align='left' or not($col/@align)">
4403                    <!-- that's the default, nothing to do here -->
4404                  </xsl:when>
4405                  <xsl:otherwise>
4406                    <xsl:message>Unknown align attribute on ttcol: <xsl:value-of select="$col/@align"/></xsl:message>
4407                  </xsl:otherwise>
4408                </xsl:choose>
4409                <xsl:apply-templates select="node()"/>
4410              </td>
4411            </xsl:for-each>
4412          </tr>
4413        </xsl:for-each>
4414      </tbody>
4415    </table>
4416    <xsl:apply-templates select="postamble"/>
4417
4418    <xsl:if test="(@title!='' or @anchor!='') and not(@suppress-title='true')">
4419      <xsl:variable name="n"><xsl:number level="any" count="texttable[(@title!='' or @anchor!='') and not(@suppress-title='true')]"/></xsl:variable>
4420      <p class="figure">Table <xsl:value-of select="$n"/><xsl:if test="@title!=''">: <xsl:value-of select="@title"/></xsl:if></p>
4421    </xsl:if>
4422  </div>
4423 
4424</xsl:template>
4425
4426<xsl:template match="ttcol">
4427  <th xmlns="http://www.w3.org/1999/xhtml">
4428   
4429    <xsl:choose>
4430      <xsl:when test="@align='right' or @align='center' or @align='left'">
4431        <xsl:attribute name="class"><xsl:value-of select="@align"/></xsl:attribute>
4432      </xsl:when>
4433      <xsl:when test="not(@align)">
4434        <!-- that's the default, nothing to do here -->
4435      </xsl:when>
4436      <xsl:otherwise>
4437        <xsl:message>Unknown align attribute on ttcol: <xsl:value-of select="@align"/></xsl:message>
4438      </xsl:otherwise>
4439    </xsl:choose>
4440   
4441    <xsl:if test="@width">
4442      <xsl:attribute name="style">width: <xsl:value-of select="@width"/>;</xsl:attribute>
4443    </xsl:if>
4444
4445    <xsl:apply-templates/>
4446  </th>
4447</xsl:template>
4448
4449<!-- cref support -->
4450
4451<xsl:template match="cref">
4452  <xsl:if test="$xml2rfc-comments!='no'">
4453    <xsl:variable name="cid">
4454      <xsl:choose>
4455        <xsl:when test="@anchor">
4456          <xsl:value-of select="@anchor"/>
4457        </xsl:when>
4458        <xsl:otherwise>
4459          <xsl:value-of select="$anchor-prefix"/>
4460          <xsl:text>.comment.</xsl:text>
4461          <xsl:number count="cref[not(@anchor)]" level="any"/>
4462        </xsl:otherwise>
4463      </xsl:choose>
4464    </xsl:variable>
4465   
4466    <span xmlns="http://www.w3.org/1999/xhtml" class="comment">
4467      <xsl:if test="$xml2rfc-inline!='yes'">
4468        <xsl:attribute name="title">
4469          <xsl:if test="@source"><xsl:value-of select="@source"/>: </xsl:if>
4470          <xsl:apply-templates select="text()|eref"/>
4471        </xsl:attribute>
4472      </xsl:if>
4473      <xsl:text>[</xsl:text>
4474      <xsl:choose>
4475        <xsl:when test="$xml2rfc-inline='yes'">
4476          <xsl:value-of select="$cid"/>
4477          <xsl:text>: </xsl:text>
4478          <xsl:apply-templates select="text()|eref"/>
4479          <xsl:if test="@source"> --<xsl:value-of select="@source"/></xsl:if>
4480        </xsl:when>
4481        <xsl:otherwise>
4482          <a href="#{$cid}">
4483            <xsl:value-of select="$cid"/>
4484          </a>
4485        </xsl:otherwise>
4486      </xsl:choose>
4487      <xsl:text>]</xsl:text>
4488    </span>
4489  </xsl:if>
4490</xsl:template>
4491
4492<xsl:template name="insertComments">
4493
4494  <xsl:call-template name="insert-conditional-hrule"/>
4495   
4496  <h1 xmlns="http://www.w3.org/1999/xhtml">
4497    <xsl:call-template name="insert-conditional-pagebreak"/>
4498    <a id="{$anchor-prefix}.comments" href="#{$anchor-prefix}.comments">Editorial Comments</a>
4499  </h1>
4500
4501  <dl xmlns="http://www.w3.org/1999/xhtml">
4502    <xsl:for-each select="//cref">
4503      <xsl:variable name="cid">
4504        <xsl:choose>
4505          <xsl:when test="@anchor">
4506            <xsl:value-of select="@anchor"/>
4507          </xsl:when>
4508          <xsl:otherwise>
4509            <xsl:value-of select="$anchor-prefix"/>
4510            <xsl:text>.comment.</xsl:text>
4511            <xsl:number count="cref[not(@anchor)]" level="any"/>
4512          </xsl:otherwise>
4513        </xsl:choose>
4514      </xsl:variable>
4515      <dt id="{$cid}">
4516        [<xsl:value-of select="$cid"/>]
4517      </dt>
4518      <dd>
4519        <xsl:value-of select="."/>
4520        <xsl:if test="@source"> --<xsl:value-of select="@source"/></xsl:if>
4521      </dd>
4522    </xsl:for-each>
4523  </dl>
4524</xsl:template>
4525
4526
4527<!-- Chapter Link Generation -->
4528
4529<xsl:template match="*" mode="links"><xsl:apply-templates mode="links"/></xsl:template>
4530<xsl:template match="text()" mode="links"/>
4531
4532<xsl:template match="/*/middle//section[not(myns:unnumbered) and not(ancestor::section)]" mode="links">
4533  <xsl:variable name="sectionNumber"><xsl:call-template name="get-section-number"/></xsl:variable>
4534  <link xmlns="http://www.w3.org/1999/xhtml" rel="Chapter" title="{$sectionNumber} {@title}" href="#{$anchor-prefix}.section.{$sectionNumber}"/>
4535  <xsl:apply-templates mode="links"/>
4536</xsl:template>
4537
4538<xsl:template match="/*/back//section[not(myns:unnumbered) and not(ancestor::section)]" mode="links">
4539  <xsl:variable name="sectionNumber"><xsl:call-template name="get-section-number"/></xsl:variable>
4540  <link xmlns="http://www.w3.org/1999/xhtml" rel="Appendix" title="{$sectionNumber} {@title}" href="#{$anchor-prefix}.section.{$sectionNumber}"/>
4541  <xsl:apply-templates mode="links"/>
4542</xsl:template>
4543
4544<xsl:template match="/*/back/references[position()=1]" mode="links">
4545  <xsl:variable name="sectionNumber"><xsl:call-template name="get-references-section-number"/></xsl:variable>
4546  <link xmlns="http://www.w3.org/1999/xhtml" rel="Chapter" href="#{$anchor-prefix}.section.{$sectionNumber}">
4547    <xsl:choose>
4548      <xsl:when test="@title and count(/*/back/references)=1">
4549        <xsl:attribute name="title">
4550          <xsl:call-template name="get-references-section-number"/>
4551          <xsl:text> </xsl:text>
4552          <xsl:value-of select="@title"/>
4553        </xsl:attribute>
4554      </xsl:when>
4555      <xsl:otherwise>
4556        <xsl:attribute name="title">
4557          <xsl:call-template name="get-references-section-number"/>
4558          <xsl:text> References</xsl:text>
4559        </xsl:attribute>
4560      </xsl:otherwise>
4561    </xsl:choose>
4562  </link>
4563</xsl:template>
4564
4565<!-- convenience templates -->
4566
4567<xsl:template name="get-author-summary">
4568  <xsl:choose>
4569    <xsl:when test="count(/rfc/front/author)=1">
4570      <xsl:value-of select="/rfc/front/author[1]/@surname"/>
4571    </xsl:when>
4572    <xsl:when test="count(/rfc/front/author)=2">
4573      <xsl:value-of select="concat(/rfc/front/author[1]/@surname,' &amp; ',/rfc/front/author[2]/@surname)"/>
4574    </xsl:when>
4575    <xsl:otherwise>
4576      <xsl:value-of select="concat(/rfc/front/author[1]/@surname,', et al.')"/>
4577    </xsl:otherwise>
4578  </xsl:choose>
4579</xsl:template>
4580
4581<xsl:template name="get-authors">
4582  <xsl:for-each select="/rfc/front/author">
4583    <xsl:value-of select="@fullname"/>
4584    <xsl:if test="position()!=last()">, </xsl:if>
4585  </xsl:for-each>
4586</xsl:template>
4587
4588<xsl:template name="get-category-long">
4589  <xsl:choose>
4590    <xsl:when test="$xml2rfc-footer"><xsl:value-of select="$xml2rfc-footer"/></xsl:when>
4591    <xsl:when test="$xml2rfc-private"/> <!-- private draft, footer not set -->
4592    <xsl:when test="/rfc/@category='bcp'">Best Current Practice</xsl:when>
4593    <xsl:when test="/rfc/@category='historic'">Historic</xsl:when>
4594    <xsl:when test="/rfc/@category='info' or not(/rfc/@category)">Informational</xsl:when>
4595    <xsl:when test="/rfc/@category='std'">Standards Track</xsl:when>
4596    <xsl:when test="/rfc/@category='exp'">Experimental</xsl:when>
4597    <xsl:otherwise>(category unknown)</xsl:otherwise>
4598  </xsl:choose>
4599</xsl:template>
4600
4601<xsl:template name="get-header-center">
4602  <xsl:choose>
4603    <xsl:when test="string-length(/rfc/front/title/@abbrev) &gt; 0">
4604      <xsl:value-of select="/rfc/front/title/@abbrev"/>
4605    </xsl:when>
4606    <xsl:otherwise>
4607      <xsl:apply-templates select="/rfc/front/title" mode="get-text-content"/>
4608    </xsl:otherwise>
4609  </xsl:choose>
4610</xsl:template>
4611
4612<xsl:template name="get-header-left">
4613  <xsl:choose>
4614    <xsl:when test="$xml2rfc-header"><xsl:value-of select="$xml2rfc-header"/></xsl:when>
4615    <xsl:when test="$xml2rfc-private"/> <!-- private draft, header not set -->
4616    <xsl:when test="/rfc/@ipr and not(/rfc/@number)">INTERNET DRAFT</xsl:when>
4617    <xsl:otherwise>RFC <xsl:value-of select="/rfc/@number"/></xsl:otherwise>
4618  </xsl:choose>
4619</xsl:template>
4620
4621<xsl:template name="get-generator">
4622  <xsl:variable name="gen">
4623    <xsl:text>http://greenbytes.de/tech/webdav/rfc2629.xslt, </xsl:text>
4624    <!-- when RCS keyword substitution in place, add version info -->
4625    <xsl:if test="contains('$Revision: 1.367 $',':')">
4626      <xsl:value-of select="concat('Revision ',normalize-space(translate(substring-after('$Revision: 1.367 $', 'Revision: '),'$','')),', ')"/>
4627    </xsl:if>
4628    <xsl:if test="contains('$Date: 2008-05-19 13:00:19 $',':')">
4629      <xsl:value-of select="concat(normalize-space(translate(substring-after('$Date: 2008-05-19 13:00:19 $', 'Date: '),'$','')),', ')"/>
4630    </xsl:if>
4631    <xsl:value-of select="concat('XSLT vendor: ',system-property('xsl:vendor'),' ',system-property('xsl:vendor-url'))"/>
4632  </xsl:variable>
4633  <xsl:value-of select="$gen"/>
4634</xsl:template>
4635
4636<xsl:template name="get-header-right">
4637  <xsl:value-of select="concat($xml2rfc-ext-pub-month, ' ', $xml2rfc-ext-pub-year)"/>
4638</xsl:template>
4639
4640<xsl:template name="get-keywords">
4641  <xsl:variable name="keyw">
4642    <xsl:for-each select="/rfc/front/keyword">
4643      <xsl:value-of select="translate(.,',',' ')"/>
4644      <xsl:if test="position()!=last()">, </xsl:if>
4645    </xsl:for-each>
4646  </xsl:variable>
4647  <xsl:value-of select="normalize-space($keyw)"/>
4648</xsl:template>
4649
4650<!-- get language from context node. nearest ancestor or return the default of "en" -->
4651<xsl:template name="get-lang">
4652  <xsl:choose>
4653    <xsl:when test="ancestor-or-self::*[@xml:lang]"><xsl:value-of select="ancestor-or-self::*/@xml:lang"/></xsl:when>
4654    <xsl:otherwise>en</xsl:otherwise>
4655  </xsl:choose>
4656</xsl:template>
4657
4658<xsl:template name="get-section-number">
4659  <xsl:variable name="hasEdits" select="count(//ed:del|//ed:ins)!=0"/>
4660  <xsl:variable name="anchor" select="@anchor"/>
4661  <xsl:choose>
4662    <xsl:when test="@x:fixed-section-number">
4663      <xsl:value-of select="@x:fixed-section-number"/>
4664    </xsl:when>
4665    <xsl:when test="$hasEdits or ancestor::*/@x:fixed-section-number">
4666      <xsl:call-template name="sectionnumberAndEdits"/>
4667    </xsl:when>
4668    <xsl:otherwise>
4669      <xsl:choose>
4670        <xsl:when test="self::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:when>
4680        <xsl:when test="self::reference">
4681          <xsl:for-each select="parent::references">
4682            <xsl:choose>
4683              <xsl:when test="count(/*/back/references)=1">
4684                <xsl:call-template name="get-references-section-number"/>
4685              </xsl:when>
4686              <xsl:otherwise>
4687                <xsl:call-template name="get-references-section-number"/>.<xsl:number count="references"/>
4688              </xsl:otherwise>
4689            </xsl:choose>
4690          </xsl:for-each>
4691        </xsl:when>
4692        <xsl:when test="ancestor::back"><xsl:number count="section|appendix" level="multiple" format="A.1.1.1.1.1.1.1"/></xsl:when>
4693        <xsl:when test="self::appendix"><xsl:number count="appendix" level="multiple" format="A.1.1.1.1.1.1.1"/></xsl:when>
4694        <xsl:otherwise><xsl:number count="section" level="multiple"/></xsl:otherwise>
4695      </xsl:choose>
4696    </xsl:otherwise>
4697  </xsl:choose>
4698</xsl:template>
4699
4700<!-- get the section number for the references section -->
4701<xsl:template name="get-references-section-number">
4702  <xsl:value-of select="count(/rfc/middle/section) + count(/rfc/middle/ed:replace/ed:ins/section) + 1"/>
4703</xsl:template>
4704
4705<xsl:template name="emit-section-number">
4706  <xsl:param name="no"/>
4707  <xsl:value-of select="$no"/><xsl:if test="not(contains($no,'.')) or $xml2rfc-ext-sec-no-trailing-dots='yes'">.</xsl:if>
4708</xsl:template>
4709
4710<xsl:template name="get-section-type">
4711  <xsl:param name="prec"/>
4712  <xsl:choose>
4713    <xsl:when test="ancestor::back">Appendix</xsl:when>
4714    <xsl:otherwise>Section</xsl:otherwise>
4715  </xsl:choose>
4716</xsl:template>
4717
4718<xsl:template name="get-table-anchor">
4719  <xsl:value-of select="$anchor-prefix"/>
4720  <xsl:text>.table.</xsl:text>
4721  <xsl:choose>
4722    <xsl:when test="@title!='' or @anchor!=''">
4723      <xsl:number level="any" count="texttable[@title!='' or @anchor!='']"/>
4724    </xsl:when>
4725    <xsl:otherwise>
4726      <xsl:text>u.</xsl:text>
4727      <xsl:number level="any" count="texttable[not(@title!='' or @anchor!='')]"/>
4728    </xsl:otherwise>
4729  </xsl:choose>
4730</xsl:template>
4731
4732<xsl:template name="get-figure-anchor">
4733  <xsl:value-of select="$anchor-prefix"/>
4734  <xsl:text>.figure.</xsl:text>
4735  <xsl:choose>
4736    <xsl:when test="@title!='' or @anchor!=''">
4737      <xsl:number level="any" count="figure[@title!='' or @anchor!='']"/>
4738    </xsl:when>
4739    <xsl:otherwise>
4740      <xsl:text>u.</xsl:text>
4741      <xsl:number level="any" count="figure[not(@title!='' or @anchor!='')]"/>
4742    </xsl:otherwise>
4743  </xsl:choose>
4744</xsl:template>
4745
4746<!-- reformat contents of author/@initials -->
4747<xsl:template name="format-initials">
4748  <xsl:choose>
4749    <xsl:when test="string-length(@initials)=1">
4750      <xsl:value-of select="concat(@initials,'.')"/>
4751    </xsl:when>
4752    <xsl:otherwise>
4753      <xsl:value-of select="@initials"/>
4754    </xsl:otherwise>
4755  </xsl:choose>
4756</xsl:template>
4757
4758<xsl:template name="insert-conditional-pagebreak">
4759  <xsl:if test="$xml2rfc-compact!='yes'">
4760    <xsl:attribute name="class">np</xsl:attribute>
4761  </xsl:if>
4762</xsl:template>
4763
4764<xsl:template name="insert-conditional-hrule">
4765  <xsl:if test="$xml2rfc-compact!='yes'">
4766    <hr xmlns="http://www.w3.org/1999/xhtml" class="noprint"/>
4767  </xsl:if>
4768</xsl:template>
4769
4770<!-- get text content from marked-up text -->
4771
4772<xsl:template match="text()" mode="get-text-content">
4773  <xsl:value-of select="."/>
4774</xsl:template>
4775
4776<xsl:template match="*" mode="get-text-content">
4777  <xsl:apply-templates mode="get-text-content"/>
4778</xsl:template>
4779
4780<xsl:template match="ed:del" mode="get-text-content">
4781</xsl:template>
4782
4783<!-- diag support -->
4784<xsl:template name="lineno">
4785  <xsl:if test="function-available('saxon-old:line-number')">
4786    <xsl:if test="saxon-old:line-number() &gt; 0">
4787      <xsl:text> (at line </xsl:text>
4788      <xsl:value-of select="saxon-old:line-number()"/>
4789      <xsl:text>)</xsl:text>
4790    </xsl:if>
4791  </xsl:if>
4792  <xsl:if test="function-available('saxon:line-number')">
4793    <xsl:if test="saxon:line-number() &gt; 0">
4794      <xsl:text> (at line </xsl:text>
4795      <xsl:value-of select="saxon:line-number()"/>
4796      <xsl:text>)</xsl:text>
4797    </xsl:if>
4798  </xsl:if>
4799</xsl:template>
4800
4801<!-- date handling -->
4802
4803<msxsl:script language="JScript" implements-prefix="date">
4804  this['year'] = function (x) {
4805    if (x) {throw "not supported"};
4806    return (new Date()).getFullYear();
4807  }
4808
4809  this['month-in-year'] = function (x) {
4810    if (x) {throw "not supported"};
4811    return 1 + (new Date()).getMonth();
4812  }
4813
4814  this['day-in-month'] = function (x) {
4815    if (x) {throw "not supported"};
4816    return (new Date()).getDate();
4817  }
4818</msxsl:script>
4819
4820<xsl:variable name="may-default-dates">
4821  <xsl:choose>
4822    <xsl:when test="function-available('date:year') and function-available('date:month-in-year') and date:day-in-month()">
4823      <xsl:variable name="year-specified" select="/rfc/front/date/@year and /rfc/front/date/@year!=''"/>
4824      <xsl:variable name="month-specified" select="/rfc/front/date/@month and /rfc/front/date/@month!=''"/>
4825      <xsl:variable name="day-specified" select="/rfc/front/date/@day and /rfc/front/date/@day!=''"/>
4826      <xsl:variable name="system-month">
4827        <xsl:call-template name="get-month-as-name">
4828          <xsl:with-param name="month" select="date:month-in-year()"/>
4829        </xsl:call-template>
4830      </xsl:variable>
4831      <xsl:choose>
4832        <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>
4833        <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>
4834        <xsl:when test="$day-specified and /rfc/front/date/@day!=date:day-in-month()">Specified day does not match system date</xsl:when>
4835        <xsl:when test="not($year-specified) and ($month-specified or $day-specified)">Can't default year when month or day is specified</xsl:when>
4836        <xsl:when test="not($month-specified) and $day-specified">Can't default month when day is specified</xsl:when>
4837        <xsl:otherwise>yes</xsl:otherwise>
4838      </xsl:choose>
4839    </xsl:when>
4840    <!-- may, but won't -->
4841    <xsl:otherwise>yes</xsl:otherwise> 
4842  </xsl:choose>
4843</xsl:variable>
4844
4845<xsl:param name="xml2rfc-ext-pub-year">
4846  <xsl:choose>
4847    <xsl:when test="/rfc/front/date/@year and /rfc/front/date/@year!=''">
4848      <xsl:value-of select="/rfc/front/date/@year"/>
4849    </xsl:when>
4850    <xsl:when test="function-available('date:year')">
4851      <xsl:if test="/rfc/front/date/@month and /rfc/front/date/@month!=''">
4852        <xsl:call-template name="error">
4853          <xsl:with-param name="msg" select="'defaulting publication year although month was specified'"/>
4854        </xsl:call-template>
4855      </xsl:if>
4856      <xsl:if test="/rfc/front/date/@day and /rfc/front/date/@day!=''">
4857        <xsl:call-template name="error">
4858          <xsl:with-param name="msg" select="'defaulting publication year although day was specified'"/>
4859        </xsl:call-template>
4860      </xsl:if>
4861      <xsl:value-of select="date:year()"/>
4862    </xsl:when>
4863    <xsl:otherwise>
4864      <xsl:call-template name="error">
4865        <xsl:with-param name="msg" select="'/rfc/front/date/@year missing (and XSLT processor cannot compute the system date)'"/>
4866      </xsl:call-template>
4867    </xsl:otherwise>
4868  </xsl:choose>
4869</xsl:param>
4870
4871<xsl:param name="xml2rfc-ext-pub-month">
4872  <xsl:choose>
4873    <xsl:when test="/rfc/front/date/@month and /rfc/front/date/@month!=''">
4874      <xsl:value-of select="/rfc/front/date/@month"/>
4875    </xsl:when>
4876    <xsl:when test="function-available('date:month-in-year') and $may-default-dates='yes'">
4877      <xsl:call-template name="get-month-as-name">
4878        <xsl:with-param name="month" select="date:month-in-year()"/>
4879      </xsl:call-template>
4880    </xsl:when>
4881    <xsl:when test="function-available('date:month-in-year') and $may-default-dates!='yes'">
4882      <xsl:call-template name="warning">
4883        <xsl:with-param name="inline" select="'no'"/>
4884        <xsl:with-param name="msg" select="$may-default-dates"/>
4885      </xsl:call-template>
4886    </xsl:when>
4887    <xsl:otherwise>
4888      <xsl:call-template name="error">
4889        <xsl:with-param name="msg" select="'/rfc/front/date/@month missing (and XSLT processor cannot compute the system date)'"/>
4890      </xsl:call-template>
4891    </xsl:otherwise>
4892  </xsl:choose>
4893</xsl:param>
4894
4895<xsl:param name="xml2rfc-ext-pub-month-numeric">
4896  <xsl:call-template name="get-month-as-num">
4897    <xsl:with-param name="month" select="$xml2rfc-ext-pub-month"/>
4898  </xsl:call-template>
4899</xsl:param>
4900
4901<xsl:param name="xml2rfc-ext-pub-day">
4902  <xsl:choose>
4903    <xsl:when test="/rfc/front/date/@day and /rfc/front/date/@day!=''">
4904      <xsl:value-of select="/rfc/front/date/@day"/>
4905    </xsl:when>
4906    <xsl:when test="function-available('date:day-in-month') and $may-default-dates='yes'">
4907      <xsl:value-of select="date:day-in-month()"/>
4908    </xsl:when>
4909    <xsl:otherwise/> <!-- harmless, we just don't have it -->
4910  </xsl:choose>
4911</xsl:param>
4912
4913</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.