source: rfc2629xslt/rfc2629toXHTML.xslt @ 227

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

Update to latest version of rfc2629.xslt (matching xml2rfc 1.33).

  • Property svn:eol-style set to native
File size: 186.4 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="http://icl.com/saxon" 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 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:variable name="sectionNumber">
1361    <xsl:choose>
1362      <xsl:when test="@myns:unnumbered"/>
1363      <xsl:otherwise><xsl:call-template name="get-section-number"/></xsl:otherwise>
1364    </xsl:choose>
1365  </xsl:variable>
1366   
1367  <xsl:if test="not(ancestor::section) and not(@myns:notoclink)">
1368    <xsl:call-template name="insert-conditional-hrule"/>
1369  </xsl:if>
1370 
1371  <xsl:variable name="elemtype">
1372    <xsl:choose>
1373      <xsl:when test="count(ancestor::section) = 0">h1</xsl:when>
1374      <xsl:when test="count(ancestor::section) = 1">h2</xsl:when>
1375      <xsl:when test="count(ancestor::section) = 2">h3</xsl:when>
1376      <xsl:when test="count(ancestor::section) = 3">h4</xsl:when>
1377      <xsl:otherwise>h5</xsl:otherwise>
1378    </xsl:choose>
1379  </xsl:variable>
1380 
1381  <!-- process irefs immediadetely following the section so that their anchor
1382  actually is the section heading -->
1383  <xsl:apply-templates select="iref[count(preceding-sibling::*[not(self::iref)])=0]"/>
1384
1385  <xsl:element namespace="http://www.w3.org/1999/xhtml" name="{$elemtype}">
1386    <xsl:if test="$sectionNumber!=''">
1387      <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$sectionNumber"/></xsl:attribute>
1388    </xsl:if>
1389    <xsl:choose>
1390      <xsl:when test="$sectionNumber='1'">
1391        <!-- pagebreak, this the first section -->
1392        <xsl:attribute name="class">np</xsl:attribute>
1393      </xsl:when>
1394      <xsl:when test="not(ancestor::section) and not(@myns:notoclink)">
1395        <xsl:call-template name="insert-conditional-pagebreak"/>
1396      </xsl:when>
1397      <xsl:otherwise/>
1398    </xsl:choose>
1399   
1400    <xsl:call-template name="insertInsDelClass"/>
1401       
1402    <xsl:if test="$sectionNumber!=''">
1403      <a xmlns="http://www.w3.org/1999/xhtml" href="#{$anchor-prefix}.section.{$sectionNumber}">
1404        <xsl:call-template name="emit-section-number">
1405          <xsl:with-param name="no" select="$sectionNumber"/>
1406        </xsl:call-template>
1407      </a>
1408      <xsl:text> </xsl:text>
1409    </xsl:if>
1410   
1411    <!-- issue tracking? -->
1412    <xsl:if test="@ed:resolves">
1413      <xsl:call-template name="insert-issue-pointer"/>
1414    </xsl:if>
1415   
1416    <xsl:choose>
1417      <xsl:when test="@anchor">
1418        <a xmlns="http://www.w3.org/1999/xhtml" id="{@anchor}" href="#{@anchor}"><xsl:call-template name="insertTitle"/></a>
1419      </xsl:when>
1420      <xsl:otherwise>
1421        <xsl:call-template name="insertTitle"/>
1422      </xsl:otherwise>
1423    </xsl:choose>
1424  </xsl:element>
1425  <!-- continue with all child elements but the irefs processed above -->
1426  <xsl:apply-templates select="*[not(self::iref)]|iref[count(preceding-sibling::*[not(self::iref)])!=0]"/>
1427</xsl:template>
1428
1429<xsl:template match="spanx[@style='emph' or not(@style)]">
1430  <em xmlns="http://www.w3.org/1999/xhtml">
1431    <xsl:if test="@anchor">
1432      <xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute>
1433    </xsl:if>
1434    <xsl:apply-templates/>
1435  </em>
1436</xsl:template>
1437
1438<xsl:template match="spanx[@style='verb']">
1439  <samp xmlns="http://www.w3.org/1999/xhtml">
1440    <xsl:if test="@anchor">
1441      <xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute>
1442    </xsl:if>
1443    <xsl:apply-templates/>
1444  </samp>
1445</xsl:template>
1446
1447<xsl:template match="spanx[@style='strong']">
1448  <strong xmlns="http://www.w3.org/1999/xhtml">
1449    <xsl:if test="@anchor">
1450      <xsl:attribute name="id"><xsl:value-of select="@anchor"/></xsl:attribute>
1451    </xsl:if>
1452    <xsl:apply-templates/>
1453  </strong>
1454</xsl:template>
1455
1456<xsl:template name="insert-blank-lines">
1457  <xsl:param name="no"/>
1458  <xsl:choose>
1459    <xsl:when test="$no &lt;= 0">
1460      <br xmlns="http://www.w3.org/1999/xhtml"/>
1461      <!-- done -->
1462    </xsl:when>
1463    <xsl:otherwise>
1464      <br xmlns="http://www.w3.org/1999/xhtml"/>
1465      <xsl:call-template name="insert-blank-lines">
1466        <xsl:with-param name="no" select="$no - 1"/>
1467      </xsl:call-template>
1468    </xsl:otherwise>
1469  </xsl:choose>
1470</xsl:template>
1471
1472<xsl:template match="vspace[not(@blankLines)]">
1473  <br xmlns="http://www.w3.org/1999/xhtml"/>
1474</xsl:template>
1475
1476<xsl:template match="vspace">
1477  <xsl:call-template name="insert-blank-lines">
1478    <xsl:with-param name="no" select="@blankLines"/>
1479  </xsl:call-template>
1480</xsl:template>
1481
1482<!-- keep the root for the case when we process XSLT-inline markup -->
1483<xsl:variable name="src" select="/"/>
1484
1485<xsl:template name="render-section-ref">
1486  <xsl:param name="from"/>
1487  <xsl:param name="to"/>
1488
1489  <xsl:variable name="refname">
1490    <xsl:for-each select="$to">
1491      <xsl:call-template name="get-section-type">
1492        <xsl:with-param name="prec" select="$from/preceding-sibling::node()[1]"/>
1493      </xsl:call-template>
1494    </xsl:for-each>
1495  </xsl:variable>
1496  <xsl:variable name="refnum">
1497    <xsl:for-each select="$to">
1498      <xsl:call-template name="get-section-number"/>
1499    </xsl:for-each>
1500  </xsl:variable>
1501  <xsl:attribute name="title">
1502    <xsl:value-of select="$to/@title"/>
1503  </xsl:attribute>
1504  <xsl:choose>
1505    <xsl:when test="@format='counter'">
1506      <xsl:value-of select="$refnum"/>
1507    </xsl:when>
1508    <xsl:when test="@format='title'">
1509      <xsl:value-of select="$to/@title"/>
1510    </xsl:when>
1511    <xsl:otherwise>
1512      <xsl:value-of select="normalize-space(concat($refname,' ',$refnum))"/>
1513    </xsl:otherwise>
1514  </xsl:choose>
1515</xsl:template>
1516
1517<xsl:template match="xref[node()]">
1518
1519  <xsl:variable name="target" select="@target"/>
1520  <xsl:variable name="node" select="$src//*[@anchor=$target]"/>
1521  <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>
1522
1523  <xsl:choose>
1524
1525    <!-- x:fmt='none': do not generate any links -->
1526    <xsl:when test="@x:fmt='none'">
1527      <xsl:choose>
1528        <xsl:when test="name($node)='reference'">
1529          <cite xmlns="http://www.w3.org/1999/xhtml" title="{normalize-space($node/front/title)}">
1530            <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
1531              <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1532            </xsl:if>
1533            <!-- insert id when a backlink to this xref is needed in the index -->
1534            <xsl:if test="//iref[@x:for-anchor=$target] | //iref[@x:for-anchor='' and ../@anchor=$target]">
1535              <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1536            </xsl:if>
1537            <xsl:apply-templates/>
1538          </cite>
1539        </xsl:when>
1540        <xsl:otherwise>
1541          <xsl:apply-templates/>
1542        </xsl:otherwise>
1543      </xsl:choose>
1544    </xsl:when>
1545 
1546    <!-- Other x:fmt values than "none": unsupported -->
1547    <xsl:when test="@x:fmt and @x:fmt!='none'">
1548      <xsl:call-template name="error">
1549        <xsl:with-param name="msg" select="concat('unknown xref/@x:fmt extension: ',@x:fmt)"/>
1550      </xsl:call-template>
1551    </xsl:when>
1552
1553    <!-- Section links -->
1554    <xsl:when test="name($node)='section' or name($node)='appendix'">
1555      <xsl:apply-templates/>
1556      <xsl:variable name="context" select="."/>
1557      <xsl:text> (</xsl:text>
1558      <a xmlns="http://www.w3.org/1999/xhtml" href="#{@target}">
1559        <!-- insert id when a backlink to this xref is needed in the index -->
1560        <xsl:if test="//iref[@x:for-anchor=$target] | //iref[@x:for-anchor='' and ../@anchor=$target]">
1561          <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1562        </xsl:if>
1563        <xsl:call-template name="render-section-ref">
1564          <xsl:with-param name="from" select="."/>
1565          <xsl:with-param name="to" select="$node"/>
1566        </xsl:call-template>
1567      </a>
1568      <xsl:text>)</xsl:text>
1569    </xsl:when>
1570
1571    <xsl:otherwise>
1572      <a xmlns="http://www.w3.org/1999/xhtml" href="#{$target}"><xsl:apply-templates/></a>
1573      <xsl:for-each select="$src/rfc/back/references//reference[@anchor=$target]">
1574        <xsl:text> </xsl:text>
1575        <cite xmlns="http://www.w3.org/1999/xhtml" title="{normalize-space(front/title)}">
1576          <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
1577            <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1578          </xsl:if>
1579          <xsl:call-template name="referencename">
1580             <xsl:with-param name="node" select="."/>
1581          </xsl:call-template>
1582        </cite>
1583      </xsl:for-each>
1584    </xsl:otherwise>
1585  </xsl:choose>
1586
1587</xsl:template>
1588               
1589<xsl:template match="xref[not(node())]">
1590
1591  <xsl:variable name="context" select="."/>
1592  <xsl:variable name="target" select="@target"/>
1593  <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>
1594  <xsl:variable name="node" select="$src//*[@anchor=$target]"/>
1595  <xsl:if test="count($node)=0 and not(ancestor::ed:del)">
1596    <xsl:call-template name="error">
1597      <xsl:with-param name="msg" select="concat('Undefined target: ',@target)"/>
1598    </xsl:call-template>
1599  </xsl:if>
1600
1601  <xsl:choose>
1602 
1603    <!-- Section links -->
1604    <xsl:when test="name($node)='section' or name($node)='appendix'">
1605      <a xmlns="http://www.w3.org/1999/xhtml" href="#{@target}">
1606        <!-- insert id when a backlink to this xref is needed in the index -->
1607        <xsl:if test="//iref[@x:for-anchor=$target] | //iref[@x:for-anchor='' and ../@anchor=$target]">
1608          <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1609        </xsl:if>
1610        <xsl:call-template name="render-section-ref">
1611          <xsl:with-param name="from" select="."/>
1612          <xsl:with-param name="to" select="$node"/>
1613        </xsl:call-template>
1614      </a>
1615    </xsl:when>
1616
1617    <!-- Figure links -->
1618    <xsl:when test="name($node)='figure'">
1619      <a xmlns="http://www.w3.org/1999/xhtml" href="#{$target}">
1620        <xsl:variable name="figcnt">
1621          <xsl:for-each select="$node">
1622            <xsl:number level="any" count="figure[(@title!='' or @anchor!='') and not(@suppress-title='true')]"/>
1623          </xsl:for-each>
1624        </xsl:variable>
1625        <xsl:choose>
1626          <xsl:when test="@format='counter'">
1627            <xsl:value-of select="$figcnt"/>
1628          </xsl:when>
1629          <xsl:when test="@format='title'">
1630            <xsl:value-of select="$node/@title"/>
1631          </xsl:when>
1632          <xsl:otherwise>
1633            <xsl:value-of select="normalize-space(concat('Figure ',$figcnt))"/>
1634          </xsl:otherwise>
1635        </xsl:choose>
1636      </a>
1637    </xsl:when>
1638   
1639    <!-- Table links -->
1640    <xsl:when test="name($node)='texttable'">
1641      <a xmlns="http://www.w3.org/1999/xhtml" href="#{$target}">
1642        <xsl:variable name="tabcnt">
1643          <xsl:for-each select="$node">
1644            <xsl:number level="any" count="texttable[(@title!='' or @anchor!='') and not(@suppress-title='true')]"/>
1645          </xsl:for-each>
1646        </xsl:variable>
1647        <xsl:choose>
1648          <xsl:when test="@format='counter'">
1649            <xsl:value-of select="$tabcnt"/>
1650          </xsl:when>
1651          <xsl:when test="@format='title'">
1652            <xsl:value-of select="$node/@title"/>
1653          </xsl:when>
1654          <xsl:otherwise>
1655            <xsl:value-of select="normalize-space(concat('Table ',$tabcnt))"/>
1656          </xsl:otherwise>
1657        </xsl:choose>
1658      </a>
1659    </xsl:when>
1660   
1661    <!-- Reference links -->
1662    <xsl:when test="name($node)='reference'">
1663
1664      <xsl:variable name="href">
1665        <xsl:call-template name="computed-target">
1666          <xsl:with-param name="bib" select="$node"/>
1667          <xsl:with-param name="ref" select="."/>
1668        </xsl:call-template>
1669      </xsl:variable>
1670     
1671      <xsl:variable name="sec">
1672        <xsl:choose>
1673          <xsl:when test="starts-with(@x:rel,'#') and not(@x:sec) and $node/x:source/@href">
1674            <xsl:variable name="extdoc" select="document($node/x:source/@href)"/>
1675            <xsl:variable name="nodes" select="$extdoc//*[@anchor=substring-after(current()/@x:rel,'#')]"/>
1676            <xsl:if test="not($nodes)">
1677              <xsl:call-template name="error">
1678                <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>
1679              </xsl:call-template>
1680            </xsl:if>
1681            <xsl:for-each select="$nodes">
1682              <xsl:call-template name="get-section-number"/>
1683            </xsl:for-each>
1684          </xsl:when>
1685          <xsl:otherwise>
1686            <xsl:value-of select="@x:sec"/>
1687          </xsl:otherwise>
1688        </xsl:choose>
1689      </xsl:variable>
1690     
1691      <xsl:variable name="secterm">
1692        <xsl:choose>
1693          <!-- starts with letter? -->
1694          <xsl:when test="translate(substring($sec,1,1),$ucase,'')=''">Appendix</xsl:when>
1695          <xsl:otherwise>Section</xsl:otherwise>
1696        </xsl:choose>
1697      </xsl:variable>
1698
1699      <xsl:variable name="fmt">
1700        <xsl:choose>
1701          <xsl:when test="@x:fmt!=''"><xsl:value-of select="@x:fmt"/></xsl:when>
1702          <xsl:when test="ancestor::artwork">,</xsl:when>
1703          <xsl:otherwise>of</xsl:otherwise>
1704        </xsl:choose>
1705      </xsl:variable>
1706
1707      <xsl:variable name="title">
1708        <xsl:choose>
1709          <xsl:when test="starts-with(@x:rel,'#') and not(@x:sec) and $node/x:source/@href">
1710            <xsl:variable name="extdoc" select="document($node/x:source/@href)"/>
1711            <xsl:variable name="nodes" select="$extdoc//*[@anchor=substring-after(current()/@x:rel,'#')]"/>
1712            <xsl:if test="not($nodes)">
1713              <xsl:call-template name="error">
1714                <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>
1715              </xsl:call-template>
1716            </xsl:if>
1717            <xsl:for-each select="$nodes">
1718              <xsl:value-of select="@title"/>
1719            </xsl:for-each>
1720          </xsl:when>
1721          <xsl:otherwise/>
1722        </xsl:choose>
1723      </xsl:variable>
1724
1725      <!--
1726      Formats:
1727     
1728        ()      [XXXX] (Section SS)
1729        ,       [XXXX], Section SS
1730        of      Section SS of [XXXX]
1731        sec     Section SS
1732        number  SS
1733      -->
1734     
1735      <xsl:if test="$fmt and not($fmt='()' or $fmt=',' or $fmt='of' or $fmt='sec' or $fmt='anchor' or $fmt='number')">
1736        <xsl:call-template name="error">
1737          <xsl:with-param name="msg" select="concat('unknown xref/@x:fmt extension: ',$fmt)"/>
1738        </xsl:call-template>
1739      </xsl:if>
1740
1741      <xsl:if test="$sec!=''">
1742             
1743        <xsl:choose>
1744          <xsl:when test="$fmt='of' or $fmt='sec'">
1745            <xsl:choose>
1746              <xsl:when test="$href!=''">
1747                <a xmlns="http://www.w3.org/1999/xhtml" href="{$href}">
1748                  <xsl:if test="$title!=''">
1749                    <xsl:attribute name="title"><xsl:value-of select="$title"/></xsl:attribute>
1750                  </xsl:if>
1751                  <xsl:if test="$fmt='sec' and $xml2rfc-ext-include-references-in-index='yes'">
1752                    <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1753                  </xsl:if>
1754                  <xsl:value-of select="$secterm"/>
1755                  <xsl:text> </xsl:text>
1756                  <xsl:value-of select="$sec"/>
1757                </a>
1758              </xsl:when>
1759              <xsl:otherwise><xsl:value-of select="$secterm"/><xsl:text> </xsl:text><xsl:value-of select="$sec"/></xsl:otherwise>
1760            </xsl:choose>
1761            <xsl:if test="$fmt='of'">
1762              <xsl:text> of </xsl:text>
1763            </xsl:if>
1764          </xsl:when>
1765          <xsl:when test="$fmt='number'">
1766            <xsl:choose>
1767              <xsl:when test="$href!=''">
1768                <a xmlns="http://www.w3.org/1999/xhtml" href="{$href}">
1769                  <xsl:if test="$title!=''">
1770                    <xsl:attribute name="title"><xsl:value-of select="$title"/></xsl:attribute>
1771                  </xsl:if>
1772                  <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
1773                    <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1774                  </xsl:if>
1775                  <xsl:value-of select="$sec"/>
1776                </a>
1777              </xsl:when>
1778              <xsl:otherwise><xsl:value-of select="$sec"/></xsl:otherwise>
1779            </xsl:choose>
1780          </xsl:when>
1781          <xsl:otherwise/>
1782        </xsl:choose>
1783      </xsl:if>
1784
1785      <xsl:if test="$sec='' or ($fmt!='sec' and $fmt!='number')">
1786        <a xmlns="http://www.w3.org/1999/xhtml" href="#{$target}">
1787          <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
1788            <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1789          </xsl:if>
1790          <cite title="{normalize-space($node/front/title)}">
1791            <xsl:variable name="val">
1792              <xsl:call-template name="referencename">
1793                <xsl:with-param name="node" select="$node"/>
1794              </xsl:call-template>
1795            </xsl:variable>
1796            <xsl:choose>
1797              <xsl:when test="$fmt='anchor'">
1798                <!-- remove brackets -->
1799                <xsl:value-of select="substring($val,2,string-length($val)-2)"/>
1800              </xsl:when>
1801              <xsl:otherwise>
1802                <xsl:value-of select="$val"/>
1803              </xsl:otherwise>
1804            </xsl:choose>
1805          </cite>
1806        </a>
1807      </xsl:if>
1808     
1809      <xsl:if test="$sec!=''">
1810        <xsl:choose>
1811          <xsl:when test="$fmt='()'">
1812            <xsl:text> (</xsl:text>
1813            <xsl:choose>
1814              <xsl:when test="$href!=''">
1815                <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>
1816              </xsl:when>
1817              <xsl:otherwise><xsl:value-of select="$secterm"/><xsl:text> </xsl:text><xsl:value-of select="$sec"/></xsl:otherwise>
1818            </xsl:choose>
1819            <xsl:text>)</xsl:text>
1820          </xsl:when>
1821          <xsl:when test="$fmt=','">
1822            <xsl:text>, </xsl:text>
1823            <xsl:choose>
1824              <xsl:when test="$href!=''">
1825                <a xmlns="http://www.w3.org/1999/xhtml" href="{$href}">
1826                  <xsl:if test="$title!=''">
1827                    <xsl:attribute name="title"><xsl:value-of select="$title"/></xsl:attribute>
1828                  </xsl:if>
1829                  <xsl:value-of select="$secterm"/>
1830                  <xsl:text> </xsl:text>
1831                  <xsl:value-of select="$sec"/>
1832                </a>
1833              </xsl:when>
1834              <xsl:otherwise><xsl:value-of select="$secterm"/><xsl:text> </xsl:text><xsl:value-of select="$sec"/></xsl:otherwise>
1835            </xsl:choose>
1836          </xsl:when>
1837          <xsl:otherwise/>
1838        </xsl:choose>
1839      </xsl:if>
1840    </xsl:when>
1841   
1842    <xsl:otherwise>
1843      <xsl:call-template name="error">
1844        <xsl:with-param name="msg" select="concat('xref to unknown element: ',name($node))"/>
1845      </xsl:call-template>
1846    </xsl:otherwise>
1847  </xsl:choose>
1848</xsl:template>
1849
1850
1851<!-- mark unmatched elements red -->
1852
1853<xsl:template match="*">
1854  <xsl:message>ERROR: no XSLT template for element: &lt;<xsl:value-of select="name()"/>&gt;</xsl:message>   
1855  <tt xmlns="http://www.w3.org/1999/xhtml" class="error">&lt;<xsl:value-of select="name()"/>&gt;</tt>
1856  <xsl:copy><xsl:apply-templates select="node()|@*"/></xsl:copy>
1857  <tt xmlns="http://www.w3.org/1999/xhtml" class="error">&lt;/<xsl:value-of select="name()"/>&gt;</tt>
1858</xsl:template>
1859
1860<xsl:template match="/">
1861  <xsl:apply-templates select="*"/>
1862</xsl:template>
1863
1864<!-- utility templates -->
1865
1866<xsl:template name="collectLeftHeaderColumn">
1867  <xsl:param name="mode"/>
1868  <!-- default case -->
1869  <xsl:if test="not($xml2rfc-private)">
1870    <myns:item>Network Working Group</myns:item>
1871    <myns:item>
1872       <xsl:choose>
1873        <xsl:when test="/rfc/@ipr and not(/rfc/@number)">Internet Draft</xsl:when>
1874        <xsl:otherwise>Request for Comments: <xsl:value-of select="/rfc/@number"/></xsl:otherwise>
1875      </xsl:choose>
1876    </myns:item>
1877    <xsl:if test="/rfc/@docName and $mode!='nroff'">
1878      <myns:item>
1879        &lt;<xsl:value-of select="/rfc/@docName"/>&gt;
1880      </myns:item>
1881    </xsl:if>
1882    <xsl:if test="/rfc/@obsoletes and /rfc/@obsoletes!=''">
1883      <myns:item>
1884        <xsl:text>Obsoletes: </xsl:text>
1885        <xsl:call-template name="rfclist">
1886          <xsl:with-param name="list" select="normalize-space(/rfc/@obsoletes)"/>
1887        </xsl:call-template>
1888        <xsl:if test="not(/rfc/@number)"> (if approved)</xsl:if>
1889      </myns:item>
1890    </xsl:if>
1891    <xsl:if test="/rfc/@seriesNo">
1892       <myns:item>
1893        <xsl:choose>
1894          <xsl:when test="/rfc/@category='bcp'">BCP: <xsl:value-of select="/rfc/@seriesNo"/></xsl:when>
1895          <xsl:when test="/rfc/@category='info'">FYI: <xsl:value-of select="/rfc/@seriesNo"/></xsl:when>
1896          <xsl:when test="/rfc/@category='std'">STD: <xsl:value-of select="/rfc/@seriesNo"/></xsl:when>
1897          <xsl:otherwise><xsl:value-of select="concat(/rfc/@category,': ',/rfc/@seriesNo)"/></xsl:otherwise>
1898        </xsl:choose>
1899      </myns:item>
1900    </xsl:if>
1901    <xsl:if test="/rfc/@updates and /rfc/@updates!=''">
1902      <myns:item>
1903        <xsl:text>Updates: </xsl:text>
1904          <xsl:call-template name="rfclist">
1905             <xsl:with-param name="list" select="normalize-space(/rfc/@updates)"/>
1906          </xsl:call-template>
1907          <xsl:if test="not(/rfc/@number)"> (if approved)</xsl:if>
1908      </myns:item>
1909    </xsl:if>
1910    <xsl:if test="$mode!='nroff'">
1911      <myns:item>
1912        <xsl:choose>
1913          <xsl:when test="/rfc/@number">
1914            <xsl:text>Category: </xsl:text>
1915          </xsl:when>
1916          <xsl:otherwise>
1917            <xsl:text>Intended status: </xsl:text>
1918          </xsl:otherwise>
1919        </xsl:choose>
1920        <xsl:call-template name="get-category-long"/>
1921      </myns:item>
1922    </xsl:if>
1923    <xsl:if test="/rfc/@ipr and not(/rfc/@number)">
1924       <myns:item>Expires: <xsl:call-template name="expirydate"/></myns:item>
1925    </xsl:if>
1926  </xsl:if>
1927   
1928  <!-- private case -->
1929  <xsl:if test="$xml2rfc-private">
1930    <myns:item><xsl:value-of select="$xml2rfc-private"/></myns:item>
1931  </xsl:if>
1932</xsl:template>
1933
1934<xsl:template name="collectRightHeaderColumn">
1935  <xsl:for-each select="author">
1936    <xsl:variable name="initials">
1937      <xsl:call-template name="format-initials"/>
1938    </xsl:variable>
1939    <xsl:if test="@surname">
1940      <myns:item>
1941        <xsl:value-of select="concat($initials,' ',@surname)"/>
1942        <xsl:if test="@role">
1943          <xsl:choose>
1944            <xsl:when test="@role='editor'">
1945              <xsl:text>, Editor</xsl:text>
1946            </xsl:when>
1947            <xsl:otherwise>
1948              <xsl:text>, </xsl:text><xsl:value-of select="@role"/>
1949            </xsl:otherwise>
1950          </xsl:choose>
1951        </xsl:if>
1952      </myns:item>
1953    </xsl:if>
1954    <xsl:variable name="org">
1955      <xsl:choose>
1956        <xsl:when test="organization/@abbrev"><xsl:value-of select="organization/@abbrev"/></xsl:when>
1957        <xsl:otherwise><xsl:value-of select="organization"/></xsl:otherwise>
1958      </xsl:choose>
1959    </xsl:variable>
1960    <xsl:variable name="orgOfFollowing">
1961      <xsl:choose>
1962        <xsl:when test="following-sibling::*[1]/organization/@abbrev"><xsl:value-of select="following-sibling::*[1]/organization/@abbrev"/></xsl:when>
1963        <xsl:otherwise><xsl:value-of select="following-sibling::*/organization"/></xsl:otherwise>
1964      </xsl:choose>
1965    </xsl:variable>
1966    <xsl:if test="$org != $orgOfFollowing and $org != ''">
1967      <myns:item><xsl:value-of select="$org"/></myns:item>
1968    </xsl:if>
1969  </xsl:for-each>
1970  <myns:item>
1971    <xsl:if test="$xml2rfc-ext-pub-month!=''">
1972      <xsl:value-of select="$xml2rfc-ext-pub-month"/>
1973      <xsl:if test="$xml2rfc-ext-pub-day!='' and /rfc/@ipr and not(/rfc/@number)">
1974        <xsl:text> </xsl:text>
1975        <xsl:value-of select="$xml2rfc-ext-pub-day"/>
1976        <xsl:text>,</xsl:text>
1977      </xsl:if>
1978    </xsl:if>
1979    <xsl:value-of select="concat(' ',$xml2rfc-ext-pub-year)"/>
1980  </myns:item>
1981</xsl:template>
1982
1983
1984<xsl:template name="emitheader">
1985  <xsl:param name="lc"/>
1986  <xsl:param name="rc"/>
1987
1988  <xsl:for-each select="$lc/myns:item | $rc/myns:item">
1989    <xsl:variable name="pos" select="position()"/>
1990    <xsl:if test="$pos &lt; count($lc/myns:item) + 1 or $pos &lt; count($rc/myns:item) + 1"> 
1991      <tr xmlns="http://www.w3.org/1999/xhtml">
1992        <td class="header left"><xsl:call-template name="copynodes"><xsl:with-param name="nodes" select="$lc/myns:item[$pos]/node()"/></xsl:call-template></td>
1993        <td class="header right"><xsl:call-template name="copynodes"><xsl:with-param name="nodes" select="$rc/myns:item[$pos]/node()"/></xsl:call-template></td>
1994      </tr>
1995    </xsl:if>
1996  </xsl:for-each>
1997</xsl:template>
1998
1999<!-- convenience template that avoids copying namespace nodes we don't want -->
2000<xsl:template name="copynodes">
2001  <xsl:param name="nodes"/>
2002  <xsl:for-each select="$nodes">
2003    <xsl:choose>
2004      <xsl:when test="namespace-uri()='http://www.w3.org/1999/xhtml'">
2005        <xsl:element namespace="{namespace-uri()}" name="{name()}">
2006          <xsl:copy-of select="@*|node()"/>
2007        </xsl:element>
2008      </xsl:when>
2009      <xsl:when test="self::*">
2010        <xsl:element namespace="http://www.w3.org/1999/xhtml" name="{name()}">
2011          <xsl:copy-of select="@*|node()"/>
2012        </xsl:element>
2013      </xsl:when>
2014      <!-- workaround for opera, remove when Opera > 9.0.x comes out -->
2015      <xsl:when test="self::text()">
2016        <xsl:value-of select="."/>
2017      </xsl:when>
2018      <xsl:otherwise>
2019        <xsl:copy-of select="."/>
2020      </xsl:otherwise>
2021    </xsl:choose>
2022  </xsl:for-each>
2023</xsl:template>
2024
2025
2026<xsl:template name="expirydate">
2027  <xsl:choose>
2028    <xsl:when test="$xml2rfc-ext-pub-month='January'">July <xsl:value-of select="$xml2rfc-ext-pub-year"/></xsl:when>
2029    <xsl:when test="$xml2rfc-ext-pub-month='February'">August <xsl:value-of select="$xml2rfc-ext-pub-year"/></xsl:when>
2030    <xsl:when test="$xml2rfc-ext-pub-month='March'">September <xsl:value-of select="$xml2rfc-ext-pub-year"/></xsl:when>
2031    <xsl:when test="$xml2rfc-ext-pub-month='April'">October <xsl:value-of select="$xml2rfc-ext-pub-year"/></xsl:when>
2032    <xsl:when test="$xml2rfc-ext-pub-month='May'">November <xsl:value-of select="$xml2rfc-ext-pub-year"/></xsl:when>
2033    <xsl:when test="$xml2rfc-ext-pub-month='June'">December <xsl:value-of select="$xml2rfc-ext-pub-year"/></xsl:when>
2034    <xsl:when test="$xml2rfc-ext-pub-month='July'">January <xsl:value-of select="$xml2rfc-ext-pub-year + 1"/></xsl:when>
2035    <xsl:when test="$xml2rfc-ext-pub-month='August'">February <xsl:value-of select="$xml2rfc-ext-pub-year + 1"/></xsl:when>
2036    <xsl:when test="$xml2rfc-ext-pub-month='September'">March <xsl:value-of select="$xml2rfc-ext-pub-year + 1"/></xsl:when>
2037    <xsl:when test="$xml2rfc-ext-pub-month='October'">April <xsl:value-of select="$xml2rfc-ext-pub-year + 1"/></xsl:when>
2038    <xsl:when test="$xml2rfc-ext-pub-month='November'">May <xsl:value-of select="$xml2rfc-ext-pub-year + 1"/></xsl:when>
2039    <xsl:when test="$xml2rfc-ext-pub-month='December'">June <xsl:value-of select="$xml2rfc-ext-pub-year + 1"/></xsl:when>
2040      <xsl:otherwise>WRONG SYNTAX FOR MONTH</xsl:otherwise>
2041   </xsl:choose>
2042</xsl:template>
2043
2044<xsl:template name="get-month-as-num">
2045  <xsl:param name="month"/>
2046  <xsl:choose>
2047    <xsl:when test="$month='January'">01</xsl:when>
2048    <xsl:when test="$month='February'">02</xsl:when>
2049    <xsl:when test="$month='March'">03</xsl:when>
2050    <xsl:when test="$month='April'">04</xsl:when>
2051    <xsl:when test="$month='May'">05</xsl:when>
2052    <xsl:when test="$month='June'">06</xsl:when>
2053    <xsl:when test="$month='July'">07</xsl:when>
2054    <xsl:when test="$month='August'">08</xsl:when>
2055    <xsl:when test="$month='September'">09</xsl:when>
2056    <xsl:when test="$month='October'">10</xsl:when>
2057    <xsl:when test="$month='November'">11</xsl:when>
2058    <xsl:when test="$month='December'">12</xsl:when>
2059    <xsl:otherwise>WRONG SYNTAX FOR MONTH</xsl:otherwise>
2060  </xsl:choose>
2061</xsl:template>
2062
2063<xsl:template name="get-month-as-name">
2064  <xsl:param name="month"/>
2065  <xsl:choose>
2066    <xsl:when test="$month=1">January</xsl:when>
2067    <xsl:when test="$month=2">February</xsl:when>
2068    <xsl:when test="$month=3">March</xsl:when>
2069    <xsl:when test="$month=4">April</xsl:when>
2070    <xsl:when test="$month=5">May</xsl:when>
2071    <xsl:when test="$month=6">June</xsl:when>
2072    <xsl:when test="$month=7">July</xsl:when>
2073    <xsl:when test="$month=8">August</xsl:when>
2074    <xsl:when test="$month=9">September</xsl:when>
2075    <xsl:when test="$month=10">October</xsl:when>
2076    <xsl:when test="$month=11">November</xsl:when>
2077    <xsl:when test="$month=12">December</xsl:when>
2078    <xsl:otherwise>WRONG SYNTAX FOR MONTH</xsl:otherwise>
2079   </xsl:choose>
2080</xsl:template>
2081
2082<!-- produce back section with author information -->
2083<xsl:template name="get-authors-section-title">
2084  <xsl:choose>
2085    <xsl:when test="count(/rfc/front/author)=1">Author's Address</xsl:when>
2086    <xsl:otherwise>Authors' Addresses</xsl:otherwise>
2087  </xsl:choose>
2088</xsl:template>
2089
2090<xsl:template name="get-authors-section-number">
2091  <xsl:if test="/*/x:assign-section-number[@builtin-target='authors']">
2092    <xsl:value-of select="/*/x:assign-section-number[@builtin-target='authors']/@number"/>
2093  </xsl:if>
2094</xsl:template>
2095
2096<xsl:template name="insertAuthors">
2097
2098  <xsl:call-template name="insert-conditional-hrule"/>
2099 
2100  <xsl:variable name="number">
2101    <xsl:call-template name="get-authors-section-number"/>
2102  </xsl:variable>
2103   
2104  <h1 xmlns="http://www.w3.org/1999/xhtml" id="{$anchor-prefix}.authors">
2105    <xsl:call-template name="insert-conditional-pagebreak"/>
2106    <xsl:if test="$number != ''">
2107      <a href="#{$anchor-prefix}.section.{$number}" id="{$anchor-prefix}.section.{$number}"><xsl:value-of select="$number"/>.</a>
2108      <xsl:text> </xsl:text>
2109    </xsl:if>
2110    <a href="#{$anchor-prefix}.authors"><xsl:call-template name="get-authors-section-title"/></a>
2111  </h1>
2112
2113  <xsl:apply-templates select="/rfc/front/author"/>
2114</xsl:template>
2115
2116
2117
2118<!-- insert copyright statement -->
2119
2120<xsl:template name="insertCopyright" myns:namespaceless-elements="xml2rfc">
2121
2122  <xsl:choose>
2123    <xsl:when test="$ipr-rfc3667">
2124      <section title="Full Copyright Statement" anchor="{$anchor-prefix}.copyright" myns:unnumbered="unnumbered" myns:notoclink="notoclink">
2125        <t>
2126          <xsl:choose>
2127            <xsl:when test="$ipr-2007-08"/>
2128            <xsl:when test="$ipr-rfc4748">
2129              Copyright © The IETF Trust (<xsl:value-of select="$xml2rfc-ext-pub-year"/>).
2130            </xsl:when>
2131            <xsl:otherwise>
2132              Copyright © The Internet Society (<xsl:value-of select="$xml2rfc-ext-pub-year"/>).
2133            </xsl:otherwise>
2134          </xsl:choose>
2135        </t>
2136        <t>
2137          This document is subject to the rights, licenses and restrictions
2138          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
2139          retain all their rights.
2140        </t>
2141        <t>
2142          <xsl:choose>
2143            <xsl:when test="$ipr-rfc4748">
2144              This document and the information contained herein are provided
2145              on an &#8220;AS IS&#8221; basis and THE CONTRIBUTOR,
2146              THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY),
2147              THE INTERNET SOCIETY, THE IETF TRUST AND THE INTERNET ENGINEERING
2148              TASK FORCE DISCLAIM ALL WARRANTIES,
2149              EXPRESS OR IMPLIED,
2150              INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
2151              INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
2152              WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
2153            </xsl:when>
2154            <xsl:otherwise>
2155              This document and the information contained herein are provided
2156              on an &#8220;AS IS&#8221; basis and THE CONTRIBUTOR,
2157              THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY),
2158              THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIM
2159              ALL WARRANTIES,
2160              EXPRESS OR IMPLIED,
2161              INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
2162              INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
2163              WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
2164            </xsl:otherwise>
2165          </xsl:choose>
2166        </t>
2167      </section>   
2168    </xsl:when>
2169    <xsl:otherwise>
2170      <!-- <http://tools.ietf.org/html/rfc2026#section-10.4> -->
2171      <section title="Full Copyright Statement" anchor="{$anchor-prefix}.copyright" myns:unnumbered="unnumbered" myns:notoclink="notoclink">
2172        <t>
2173          Copyright © The Internet Society (<xsl:value-of select="$xml2rfc-ext-pub-year"/>). All Rights Reserved.
2174        </t>
2175        <t>
2176          This document and translations of it may be copied and furnished to
2177          others, and derivative works that comment on or otherwise explain it
2178          or assist in its implementation may be prepared, copied, published and
2179          distributed, in whole or in part, without restriction of any kind,
2180          provided that the above copyright notice and this paragraph are
2181          included on all such copies and derivative works. However, this
2182          document itself may not be modified in any way, such as by removing
2183          the copyright notice or references to the Internet Society or other
2184          Internet organizations, except as needed for the purpose of
2185          developing Internet standards in which case the procedures for
2186          copyrights defined in the Internet Standards process must be
2187          followed, or as required to translate it into languages other than
2188          English.
2189        </t>
2190        <t>
2191          The limited permissions granted above are perpetual and will not be
2192          revoked by the Internet Society or its successors or assignees.
2193        </t>
2194        <t>
2195          This document and the information contained herein is provided on an
2196          &#8220;;AS IS&#8221; basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
2197          TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
2198          BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
2199          HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
2200          MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
2201        </t>
2202      </section>
2203    </xsl:otherwise>
2204  </xsl:choose>
2205
2206  <section title="Intellectual Property" anchor="{$anchor-prefix}.ipr" myns:unnumbered="unnumbered">
2207    <xsl:choose>
2208      <xsl:when test="$ipr-rfc3667">
2209        <t>
2210          The IETF takes no position regarding the validity or scope of any
2211          Intellectual Property Rights or other rights that might be claimed to
2212          pertain to the implementation or use of the technology described in
2213          this document or the extent to which any license under such rights
2214          might or might not be available; nor does it represent that it has
2215          made any independent effort to identify any such rights.  Information
2216          on the procedures with respect to rights in RFC documents
2217          can be found in BCP 78 and BCP 79.
2218        </t>       
2219        <t>
2220          Copies of IPR disclosures made to the IETF Secretariat and any
2221          assurances of licenses to be made available, or the result of an
2222          attempt made to obtain a general license or permission for the use
2223          of such proprietary rights by implementers or users of this
2224          specification can be obtained from the IETF on-line IPR repository
2225          at <eref target="http://www.ietf.org/ipr"/>.
2226        </t>       
2227        <t>
2228          The IETF invites any interested party to bring to its attention any
2229          copyrights, patents or patent applications, or other proprietary
2230          rights that may cover technology that may be required to implement
2231          this standard. Please address the information to the IETF at
2232          <eref target="mailto:ietf-ipr@ietf.org">ietf-ipr@ietf.org</eref>.
2233        </t>       
2234      </xsl:when>
2235      <xsl:otherwise>
2236        <t>
2237          The IETF takes no position regarding the validity or scope of
2238          any intellectual property or other rights that might be claimed
2239          to  pertain to the implementation or use of the technology
2240          described in this document or the extent to which any license
2241          under such rights might or might not be available; neither does
2242          it represent that it has made any effort to identify any such
2243          rights. Information on the IETF's procedures with respect to
2244          rights in standards-track and standards-related documentation
2245          can be found in BCP-11. Copies of claims of rights made
2246          available for publication and any assurances of licenses to
2247          be made available, or the result of an attempt made
2248          to obtain a general license or permission for the use of such
2249          proprietary rights by implementors or users of this
2250          specification can be obtained from the IETF Secretariat.
2251        </t>
2252        <t>
2253          The IETF invites any interested party to bring to its
2254          attention any copyrights, patents or patent applications, or
2255          other proprietary rights which may cover technology that may be
2256          required to practice this standard. Please address the
2257          information to the IETF Executive Director.
2258        </t>
2259        <xsl:if test="$xml2rfc-iprnotified='yes'">
2260          <t>
2261            The IETF has been notified of intellectual property rights
2262            claimed in regard to some or all of the specification contained
2263            in this document. For more information consult the online list
2264            of claimed rights.
2265          </t>
2266        </xsl:if>
2267      </xsl:otherwise>
2268    </xsl:choose>
2269  </section>
2270 
2271  <xsl:choose>
2272    <xsl:when test="$funding2"/>
2273    <xsl:when test="$funding1 and /rfc/@number">
2274      <section title="Acknowledgement" myns:unnumbered="unnumbered" myns:notoclink="notoclink">
2275        <t>
2276          Funding for the RFC Editor function is provided by the IETF
2277          Administrative Support Activity (IASA).
2278        </t>
2279      </section>
2280    </xsl:when>
2281    <xsl:when test="$funding0 and /rfc/@number">
2282      <section title="Acknowledgement" myns:unnumbered="unnumbered" myns:notoclink="notoclink">
2283        <t>
2284          Funding for the RFC Editor function is currently provided by
2285          the Internet Society.
2286        </t>
2287      </section>
2288    </xsl:when>
2289    <xsl:otherwise/>
2290  </xsl:choose>
2291
2292</xsl:template>
2293
2294
2295<!-- insert CSS style info -->
2296
2297<xsl:template name="insertCss">
2298a {
2299  text-decoration: none;
2300}
2301a.smpl {
2302  color: black;
2303}
2304a:hover {
2305  text-decoration: underline;
2306}
2307a:active {
2308  text-decoration: underline;
2309}
2310address {
2311  margin-top: 1em;
2312  margin-left: 2em;
2313  font-style: normal;
2314}<xsl:if test="//x:blockquote">
2315blockquote {
2316  border-style: solid;
2317  border-color: gray;
2318  border-width: 0 0 0 .25em;
2319  font-style: italic;
2320  padding-left: 0.5em;
2321}</xsl:if>
2322body {<xsl:if test="$xml2rfc-background!=''">
2323  background: url(<xsl:value-of select="$xml2rfc-background"/>) #ffffff left top;</xsl:if>
2324  color: black;
2325  font-family: verdana, helvetica, arial, sans-serif;
2326  font-size: 10pt;
2327}<xsl:if test="//xhtml:p">
2328br.p {
2329  line-height: 150%;
2330}</xsl:if>
2331cite {
2332  font-style: normal;
2333}
2334dd {
2335  margin-right: 2em;<xsl:if test="$xml2rfc-ext-justification='always'">
2336  text-align: justify;</xsl:if>
2337}
2338dl {
2339  margin-left: 2em;
2340}
2341<!-- spacing between two entries in definition lists -->
2342dl.empty dd {
2343  margin-top: .5em;
2344}
2345dl p {
2346  margin-left: 0em;
2347}
2348dt {
2349  margin-top: .5em;
2350}
2351h1 {
2352  font-size: 14pt;
2353  line-height: 21pt;
2354  page-break-after: avoid;
2355}
2356h1.np {
2357  page-break-before: always;
2358}
2359h1 a {
2360  color: #333333;
2361}
2362h2 {
2363  font-size: 12pt;
2364  line-height: 15pt;
2365  page-break-after: avoid;
2366}
2367h2 a {
2368  color: black;
2369}
2370h3 {
2371  font-size: 10pt;
2372  page-break-after: avoid;
2373}
2374h3 a {
2375  color: black;
2376}
2377h4 {
2378  font-size: 10pt;
2379  page-break-after: avoid;
2380}
2381h4 a {
2382  color: black;
2383}
2384h5 {
2385  font-size: 10pt;
2386  page-break-after: avoid;
2387}
2388h5 a {
2389  color: black;
2390}
2391img {
2392  margin-left: 3em;
2393}
2394li {
2395  margin-left: 2em;
2396  margin-right: 2em;<xsl:if test="$xml2rfc-ext-justification='always'">
2397  text-align: justify;</xsl:if>
2398}
2399ol {
2400  margin-left: 2em;
2401  margin-right: 2em;
2402}
2403ol p {
2404  margin-left: 0em;
2405}<xsl:if test="//xhtml:q">
2406q {
2407  font-style: italic;
2408}</xsl:if>
2409p {
2410  margin-left: 2em;
2411  margin-right: 2em;<xsl:if test="$xml2rfc-ext-justification='always'">
2412  text-align: justify;</xsl:if>
2413}
2414pre {
2415  margin-left: 3em;
2416  background-color: lightyellow;
2417  padding: .25em;
2418}
2419pre.text2 {
2420  border-style: dotted;
2421  border-width: 1px;
2422  background-color: #f0f0f0;
2423  width: 69em;
2424}
2425pre.inline {
2426  background-color: white;
2427  padding: 0em;
2428}
2429pre.text {
2430  border-style: dotted;
2431  border-width: 1px;
2432  background-color: #f8f8f8;
2433  width: 69em;
2434}
2435pre.drawing {
2436  border-style: solid;
2437  border-width: 1px;
2438  background-color: #f8f8f8;
2439  padding: 2em;
2440}<xsl:if test="//x:q">
2441q {
2442  font-style: italic;
2443}</xsl:if>
2444table {
2445  margin-left: 2em;
2446}<xsl:if test="//texttable">
2447table.tt {
2448  vertical-align: top;
2449}
2450table.full {
2451  border-style: outset;
2452  border-width: 1px;
2453}
2454table.headers {
2455  border-style: outset;
2456  border-width: 1px;
2457}
2458table.tt td {
2459  vertical-align: top;
2460}
2461table.full td {
2462  border-style: inset;
2463  border-width: 1px;
2464}
2465table.tt th {
2466  vertical-align: top;
2467}
2468table.full th {
2469  border-style: inset;
2470  border-width: 1px;
2471}
2472table.headers th {
2473  border-style: none none inset none;
2474  border-width: 1px;
2475}</xsl:if>
2476table.header {
2477  width: 95%;
2478  font-size: 10pt;
2479  color: white;
2480}
2481td.top {
2482  vertical-align: top;
2483}
2484td.topnowrap {
2485  vertical-align: top;
2486  white-space: nowrap;
2487}
2488td.header {
2489  background-color: gray;
2490  width: 50%;
2491}<xsl:if test="/rfc/@obsoletes | /rfc/@updates">
2492td.header a {
2493  color: white;
2494}</xsl:if>
2495td.reference {
2496  vertical-align: top;
2497  white-space: nowrap;
2498  padding-right: 1em;
2499}
2500thead {
2501  display:table-header-group;
2502}
2503ul.toc {
2504  list-style: none;
2505  margin-left: 1.5em;
2506  margin-right: 0em;
2507  padding-left: 0em;
2508}
2509li.tocline0 {
2510  line-height: 150%;
2511  font-weight: bold;
2512  font-size: 10pt;
2513  margin-left: 0em;
2514  margin-right: 0em;
2515}
2516li.tocline1 {
2517  line-height: normal;
2518  font-weight: normal;
2519  font-size: 9pt;
2520  margin-left: 0em;
2521  margin-right: 0em;
2522}
2523li.tocline2 {
2524  font-size: 0pt;
2525}
2526ul p {
2527  margin-left: 0em;
2528}
2529ul.ind {
2530  list-style: none;
2531  margin-left: 1.5em;
2532  margin-right: 0em;
2533  padding-left: 0em;
2534}
2535li.indline0 {
2536  font-weight: bold;
2537  line-height: 200%;
2538  margin-left: 0em;
2539  margin-right: 0em;
2540}
2541li.indline1 {
2542  font-weight: normal;
2543  line-height: 150%;
2544  margin-left: 0em;
2545  margin-right: 0em;
2546}
2547<xsl:if test="//x:bcp14">.bcp14 {
2548  font-style: normal;
2549  text-transform: lowercase;
2550  font-variant: small-caps;
2551}</xsl:if><xsl:if test="//x:blockquote">
2552blockquote &gt; * .bcp14 {
2553  font-style: italic;
2554}</xsl:if>
2555.comment {
2556  background-color: yellow;
2557}<xsl:if test="$xml2rfc-editing='yes'">
2558.editingmark {
2559  background-color: khaki;
2560}</xsl:if>
2561.center {
2562  text-align: center;
2563}
2564.error {
2565  color: red;
2566  font-style: italic;
2567  font-weight: bold;
2568}
2569.figure {
2570  font-weight: bold;
2571  text-align: center;
2572  font-size: 9pt;
2573}
2574.filename {
2575  color: #333333;
2576  font-weight: bold;
2577  font-size: 12pt;
2578  line-height: 21pt;
2579  text-align: center;
2580}
2581.fn {
2582  font-weight: bold;
2583}
2584.hidden {
2585  display: none;
2586}
2587.left {
2588  text-align: left;
2589}
2590.right {
2591  text-align: right;
2592}
2593.title {
2594  color: #990000;
2595  font-size: 18pt;
2596  line-height: 18pt;
2597  font-weight: bold;
2598  text-align: center;
2599  margin-top: 36pt;
2600}
2601.vcardline {
2602  display: block;
2603}
2604.warning {
2605  font-size: 14pt;
2606  background-color: yellow;
2607}
2608<xsl:if test="//ed:del|//ed:replace|//ed:ins">del {
2609  color: red;
2610  text-decoration: line-through;
2611}
2612.del {
2613  color: red;
2614  text-decoration: line-through;
2615}
2616ins {
2617  color: green;
2618  text-decoration: underline;
2619}
2620.ins {
2621  color: green;
2622  text-decoration: underline;
2623}
2624div.issuepointer {
2625  float: left;
2626}</xsl:if><xsl:if test="//ed:issue">
2627table.openissue {
2628  background-color: khaki;
2629  border-width: thin;
2630  border-style: solid;
2631  border-color: black;
2632}
2633table.closedissue {
2634  background-color: white;
2635  border-width: thin;
2636  border-style: solid;
2637  border-color: gray;
2638  color: gray;
2639}
2640thead th {
2641  text-align: left;
2642}
2643.bg-issue {
2644  border: solid;
2645  border-width: 1px;
2646  font-size: 7pt;
2647}
2648.closed-issue {
2649  border: solid;
2650  border-width: thin;
2651  background-color: lime;
2652  font-size: smaller;
2653  font-weight: bold;
2654}
2655.open-issue {
2656  border: solid;
2657  border-width: thin;
2658  background-color: red;
2659  font-size: smaller;
2660  font-weight: bold;
2661}
2662.editor-issue {
2663  border: solid;
2664  border-width: thin;
2665  background-color: yellow;
2666  font-size: smaller;
2667  font-weight: bold;
2668}</xsl:if>
2669
2670@media print {
2671  .noprint {
2672    display: none;
2673  }
2674 
2675  a {
2676    color: black;
2677    text-decoration: none;
2678  }
2679
2680  table.header {
2681    width: 90%;
2682  }
2683
2684  td.header {
2685    width: 50%;
2686    color: black;
2687    background-color: white;
2688    vertical-align: top;
2689    font-size: 12pt;
2690  }
2691
2692  ul.toc a::after {
2693    content: leader('.') target-counter(attr(href), page);
2694  }
2695 
2696  a.iref {
2697    content: target-counter(attr(href), page);
2698  }
2699 
2700  .print2col {
2701    column-count: 2;
2702    -moz-column-count: 2;<!-- for Firefox -->
2703    column-fill: auto;<!-- for PrinceXML -->
2704  }
2705<xsl:if test="$xml2rfc-ext-justification='print'">
2706  dd {
2707    text-align: justify;
2708  }
2709  li {
2710    text-align: justify;
2711  }
2712  p {
2713    text-align: justify;
2714  }
2715</xsl:if>}
2716
2717@page {
2718  @top-left {
2719       content: "<xsl:call-template name="get-header-left"/>";
2720  }
2721  @top-right {
2722       content: "<xsl:call-template name="get-header-right"/>";
2723  }
2724  @top-center {
2725       content: "<xsl:call-template name="get-header-center"/>";
2726  }
2727  @bottom-left {
2728       content: "<xsl:call-template name="get-author-summary"/>";
2729  }
2730  @bottom-center {
2731       content: "<xsl:call-template name="get-category-long"/>";
2732  }
2733  @bottom-right {
2734       content: "[Page " counter(page) "]";
2735  }
2736}
2737
2738@page:first {
2739    @top-left {
2740      content: normal;
2741    }
2742    @top-right {
2743      content: normal;
2744    }
2745    @top-center {
2746      content: normal;
2747    }
2748}
2749</xsl:template>
2750
2751
2752<!-- generate the index section -->
2753
2754<xsl:template name="insertSingleIref">
2755  <xsl:choose>
2756    <xsl:when test="@ed:xref">
2757      <!-- special index generator mode -->
2758      <xsl:text>[</xsl:text>
2759      <a xmlns="http://www.w3.org/1999/xhtml" href="#{@ed:xref}"><xsl:value-of select="@ed:xref"/></a>
2760      <xsl:text>, </xsl:text>
2761      <a xmlns="http://www.w3.org/1999/xhtml">
2762        <xsl:variable name="htmluri" select="//reference[@anchor=current()/@ed:xref]/format[@type='HTML']/@target"/>
2763        <xsl:if test="$htmluri">
2764          <xsl:attribute name="href"><xsl:value-of select="concat($htmluri,'#',@ed:frag)"/></xsl:attribute>
2765        </xsl:if>       
2766        <xsl:choose>
2767          <xsl:when test="@primary='true'"><b><xsl:value-of select="@ed:label"/></b></xsl:when>
2768          <xsl:otherwise><xsl:value-of select="@ed:label"/></xsl:otherwise>
2769        </xsl:choose>
2770      </a>
2771      <xsl:text>]</xsl:text>
2772      <xsl:if test="position()!=last()">, </xsl:if>
2773    </xsl:when>
2774    <xsl:otherwise>
2775      <xsl:variable name="_n">
2776        <xsl:call-template name="get-section-number"/>
2777      </xsl:variable>
2778      <xsl:variable name="n">
2779        <xsl:choose>
2780          <xsl:when test="$_n!=''">
2781            <xsl:value-of select="$_n"/>
2782          </xsl:when>
2783          <xsl:otherwise>§</xsl:otherwise>
2784        </xsl:choose>
2785      </xsl:variable>
2786      <xsl:variable name="backlink">
2787        <xsl:choose>
2788          <xsl:when test="self::xref">
2789            <xsl:variable name="target" select="@target"/>
2790            <xsl:text>#</xsl:text>
2791            <xsl:value-of select="$anchor-prefix"/>
2792            <xsl:text>.xref.</xsl:text>
2793            <xsl:value-of select="@target"/>.<xsl:number level="any" count="xref[@target=$target]"/>
2794          </xsl:when>
2795          <xsl:when test="self::iref">
2796            <xsl:text>#</xsl:text>
2797            <xsl:call-template name="compute-iref-anchor"/>
2798          </xsl:when>
2799          <xsl:when test="self::x:ref">
2800            <xsl:text>#</xsl:text>
2801            <xsl:call-template name="compute-extref-anchor"/>
2802          </xsl:when>
2803          <xsl:otherwise>
2804            <xsl:message>Unsupported element type for insertSingleIref</xsl:message>
2805          </xsl:otherwise>
2806        </xsl:choose>
2807      </xsl:variable>
2808      <a xmlns="http://www.w3.org/1999/xhtml" class="iref" href="{$backlink}">
2809        <xsl:call-template name="insertInsDelClass"/>
2810        <xsl:choose>
2811          <xsl:when test="@primary='true'"><b><xsl:value-of select="$n"/></b></xsl:when>
2812          <xsl:otherwise><xsl:value-of select="$n"/></xsl:otherwise>
2813        </xsl:choose>
2814      </a>
2815      <xsl:if test="position()!=last()">, </xsl:if>
2816    </xsl:otherwise>
2817  </xsl:choose>
2818</xsl:template>
2819
2820<xsl:template name="insertSingleXref">
2821  <xsl:variable name="_n">
2822    <xsl:call-template name="get-section-number"/>
2823  </xsl:variable>
2824  <xsl:variable name="n">
2825    <xsl:choose>
2826      <xsl:when test="$_n!=''">
2827        <xsl:value-of select="$_n"/>
2828      </xsl:when>
2829      <xsl:otherwise>§</xsl:otherwise>
2830    </xsl:choose>
2831  </xsl:variable>
2832  <xsl:choose>
2833    <xsl:when test="self::reference">
2834      <a xmlns="http://www.w3.org/1999/xhtml" class="iref" href="#{@anchor}">
2835        <xsl:call-template name="insertInsDelClass"/>
2836        <b><xsl:value-of select="$n"/></b>
2837      </a>
2838    </xsl:when>
2839    <xsl:otherwise>
2840      <xsl:variable name="target" select="@target"/>
2841      <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>
2842      <a xmlns="http://www.w3.org/1999/xhtml" class="iref" href="{$backlink}">
2843        <xsl:call-template name="insertInsDelClass"/>
2844        <xsl:value-of select="$n"/>
2845      </a>
2846    </xsl:otherwise>
2847  </xsl:choose>
2848  <xsl:if test="position()!=last()">, </xsl:if>
2849</xsl:template>
2850
2851<xsl:template name="insertIndex">
2852
2853  <xsl:call-template name="insert-conditional-hrule"/>
2854
2855  <h1 xmlns="http://www.w3.org/1999/xhtml" id="{$anchor-prefix}.index">
2856    <xsl:call-template name="insert-conditional-pagebreak"/>
2857    <a href="#{$anchor-prefix}.index">Index</a>
2858  </h1>
2859 
2860  <!-- generate navigation links to index subsections -->
2861  <p xmlns="http://www.w3.org/1999/xhtml" class="noprint">
2862    <xsl:variable name="irefs" select="//iref[generate-id(.) = generate-id(key('index-first-letter',translate(substring(@item,1,1),$lcase,$ucase)))]"/>
2863    <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)))]"/>
2864 
2865    <xsl:for-each select="$irefs | $xrefs">
2866   
2867      <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)"/>
2868         
2869      <xsl:variable name="letter" select="translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase)"/>
2870
2871      <!-- character? -->
2872      <xsl:if test="translate($letter,concat($lcase,$ucase,'0123456789'),'')=''">
2873     
2874        <xsl:variable name="showit">
2875          <xsl:choose>
2876            <xsl:when test="$xml2rfc-ext-include-references-in-index!='yes'">
2877              <xsl:if test="$irefs[starts-with(translate(@item,$lcase,$ucase),$letter)]">
2878                <xsl:text>yes</xsl:text>
2879              </xsl:if>
2880            </xsl:when>
2881            <xsl:otherwise>
2882              <xsl:text>yes</xsl:text>
2883            </xsl:otherwise>
2884          </xsl:choose>
2885        </xsl:variable>
2886       
2887        <xsl:if test="$showit='yes'">
2888          <a href="#{$anchor-prefix}.index.{$letter}">
2889            <xsl:value-of select="$letter"/>
2890          </a>
2891          <xsl:text> </xsl:text>
2892        </xsl:if>
2893     
2894      </xsl:if>
2895
2896    </xsl:for-each>
2897  </p>
2898
2899  <!-- for each index subsection -->
2900  <div xmlns="http://www.w3.org/1999/xhtml" class="print2col">
2901  <ul class="ind">
2902    <xsl:variable name="irefs2" select="//iref[generate-id(.) = generate-id(key('index-first-letter',translate(substring(@item,1,1),$lcase,$ucase)))]"/>
2903    <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)))]"/>
2904 
2905    <xsl:for-each select="$irefs2 | $xrefs2">
2906      <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)"/>
2907      <xsl:variable name="letter" select="translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase)"/>
2908           
2909      <xsl:variable name="showit">
2910        <xsl:choose>
2911          <xsl:when test="$xml2rfc-ext-include-references-in-index!='yes'">
2912            <xsl:if test="$irefs2[starts-with(translate(@item,$lcase,$ucase),$letter)]">
2913              <xsl:text>yes</xsl:text>
2914            </xsl:if>
2915          </xsl:when>
2916          <xsl:otherwise>
2917            <xsl:text>yes</xsl:text>
2918          </xsl:otherwise>
2919        </xsl:choose>
2920      </xsl:variable>
2921
2922      <xsl:if test="$showit='yes'">
2923        <li class="indline0">
2924         
2925          <!-- make letters and digits stand out -->
2926          <xsl:choose>
2927            <xsl:when test="translate($letter,concat($lcase,$ucase,'0123456789'),'')=''">
2928              <a id="{$anchor-prefix}.index.{$letter}" href="#{$anchor-prefix}.index.{$letter}">
2929                <b><xsl:value-of select="$letter"/></b>
2930              </a>
2931            </xsl:when>
2932            <xsl:otherwise>
2933              <b><xsl:value-of select="$letter"/></b>
2934            </xsl:otherwise>
2935          </xsl:choose>
2936       
2937          <ul class="ind"> 
2938            <xsl:for-each select="key('index-first-letter',translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase))">
2939       
2940              <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)"/>
2941             
2942                <xsl:choose>
2943                  <xsl:when test="self::reference">
2944                    <xsl:if test="$xml2rfc-ext-include-references-in-index='yes' and not(starts-with(@anchor,'deleted-'))">
2945                      <li class="indline1">
2946                        <em>
2947                          <xsl:value-of select="@anchor"/>
2948                        </em>
2949                        <xsl:text>  </xsl:text>
2950                       
2951                        <xsl:variable name="rs" select="//xref[@target=current()/@anchor] | . | //reference[@anchor=concat('deleted-',current()/@anchor)]"/>
2952                        <xsl:for-each select="$rs">
2953                          <xsl:call-template name="insertSingleXref"/>
2954                        </xsl:for-each>
2955
2956                        <xsl:variable name="rs2" select="$rs[@x:sec]"/>
2957
2958                        <xsl:if test="$rs2">
2959                          <ul class="ind"> 
2960                            <xsl:for-each select="$rs2">
2961                              <xsl:sort select="substring-before(concat(@x:sec,'.'),'.')" data-type="number"/>
2962                              <xsl:sort select="substring(@x:sec,1+string-length(substring-before(@x:sec,'.')))" data-type="number"/>
2963                              <xsl:if test="generate-id(.) = generate-id(key('index-xref-by-sec',concat(@target,'..',@x:sec)))">
2964                                <li class="indline1">
2965                                  <em>
2966                                    <xsl:text>Section </xsl:text>
2967                                    <xsl:value-of select="@x:sec"/>
2968                                  </em>
2969                                  <xsl:text>  </xsl:text>
2970                                  <xsl:for-each select="key('index-xref-by-sec',concat(@target,'..',@x:sec))">
2971                                    <xsl:call-template name="insertSingleXref"/>
2972                                  </xsl:for-each>
2973                                </li>
2974                              </xsl:if>
2975                            </xsl:for-each>
2976                          </ul>
2977                        </xsl:if>
2978
2979                        <xsl:if test="current()/x:source/@href">
2980                          <xsl:variable name="rs3" select="$rs[not(@x:sec) and @x:rel]"/>
2981                          <xsl:variable name="doc" select="document(current()/x:source/@href)"/>
2982                          <xsl:if test="$rs3">
2983                            <ul class="ind"> 
2984                              <xsl:for-each select="$rs3">
2985                                <xsl:sort select="count($doc//*[@anchor and following::*/@anchor=substring-after(current()/@x:rel,'#')])" order="ascending" data-type="number"/>
2986                                <xsl:if test="generate-id(.) = generate-id(key('index-xref-by-anchor',concat(@target,'..',@x:rel)))">
2987                                  <li class="indline1">
2988                                    <em>
2989                                      <xsl:text>Section </xsl:text>
2990                                      <xsl:for-each select="$doc//*[@anchor=substring-after(current()/@x:rel,'#')]">
2991                                        <xsl:call-template name="get-section-number"/>
2992                                      </xsl:for-each>
2993                                    </em>
2994                                    <xsl:text>  </xsl:text>
2995                                    <xsl:for-each select="key('index-xref-by-anchor',concat(@target,'..',@x:rel))">
2996                                      <xsl:call-template name="insertSingleXref"/>
2997                                    </xsl:for-each>
2998                                  </li>
2999                                </xsl:if>
3000                              </xsl:for-each>
3001                            </ul>
3002                          </xsl:if>
3003                        </xsl:if>
3004                      </li>
3005                    </xsl:if>
3006                  </xsl:when>
3007                  <xsl:otherwise>
3008                    <!-- regular iref -->
3009                    <xsl:if test="generate-id(.) = generate-id(key('index-item',concat(@item,@anchor)))">
3010                      <xsl:variable name="item" select="@item"/>
3011                      <xsl:variable name="in-artwork" select="count(//iref[@item=$item and @primary='true' and ancestor::artwork])!=0"/>
3012                         
3013                      <li class="indline1">
3014                        <xsl:choose>
3015                          <xsl:when test="$in-artwork">
3016                            <tt><xsl:value-of select="@item"/></tt>
3017                          </xsl:when>
3018                          <xsl:otherwise>
3019                            <xsl:value-of select="@item"/>
3020                          </xsl:otherwise>
3021                        </xsl:choose>
3022                        <xsl:text>  </xsl:text>
3023                       
3024                        <xsl:variable name="irefs3" select="key('index-item',@item)[not(@subitem) or @subitem='']"/>
3025                        <xsl:variable name="xrefs3" select="//xref[@target=$irefs3[@x:for-anchor='']/../@anchor or @target=$irefs3/@x:for-anchor]"/>
3026                        <xsl:variable name="extrefs3" select="//x:ref[.=$irefs3[@x:for-anchor='']/../@anchor or .=$irefs3/@x:for-anchor]"/>
3027
3028                        <xsl:for-each select="$irefs3|$xrefs3|$extrefs3">
3029                          <!-- <xsl:sort select="translate(@item,$lcase,$ucase)" />  -->
3030                          <xsl:call-template name="insertSingleIref"/>
3031                        </xsl:for-each>
3032         
3033                        <xsl:variable name="s2" select="key('index-item',@item)[@subitem and @subitem!='']"/>
3034                        <xsl:if test="$s2">
3035                          <ul class="ind"> 
3036                            <xsl:for-each select="$s2">
3037                              <xsl:sort select="translate(@subitem,$lcase,$ucase)"/>
3038                             
3039                              <xsl:if test="generate-id(.) = generate-id(key('index-item-subitem',concat(@item,'..',@subitem)))">
3040                 
3041                                <xsl:variable name="itemsubitem" select="concat(@item,'..',@subitem)"/>
3042                                <xsl:variable name="in-artwork2" select="count(//iref[concat(@item,'..',@subitem)=$itemsubitem and @primary='true' and ancestor::artwork])!=0"/>
3043                 
3044                                <li class="indline1">
3045             
3046                                  <xsl:choose>
3047                                    <xsl:when test="$in-artwork2">
3048                                      <tt><xsl:value-of select="@subitem"/></tt>
3049                                    </xsl:when>
3050                                    <xsl:otherwise>
3051                                      <xsl:value-of select="@subitem"/>
3052                                    </xsl:otherwise>
3053                                  </xsl:choose>
3054                                  <xsl:text>  </xsl:text>
3055                                   
3056                                  <xsl:variable name="irefs4" select="key('index-item-subitem',concat(@item,'..',@subitem))"/>
3057                                  <xsl:variable name="xrefs4" select="//xref[@target=$irefs4[@x:for-anchor='']/../@anchor or @target=$irefs4/@x:for-anchor]"/>
3058                                  <xsl:variable name="extrefs4" select="//x:ref[.=$irefs4[@x:for-anchor='']/../@anchor or .=$irefs4/@x:for-anchor]"/>
3059
3060                                  <xsl:for-each select="$irefs4|$xrefs4|$extrefs4">
3061                                    <!--<xsl:sort select="translate(@item,$lcase,$ucase)" />-->                   
3062                                    <xsl:call-template name="insertSingleIref"/>
3063                                  </xsl:for-each>
3064               
3065                                </li>
3066                              </xsl:if>
3067                            </xsl:for-each>
3068                          </ul>
3069                        </xsl:if>
3070                      </li>
3071                    </xsl:if>
3072                  </xsl:otherwise>
3073                </xsl:choose>
3074             
3075                     
3076            </xsl:for-each>           
3077          </ul>
3078        </li>
3079      </xsl:if>
3080     
3081    </xsl:for-each>
3082  </ul>
3083  </div>
3084 
3085</xsl:template>
3086
3087
3088
3089
3090<xsl:template name="insertPreamble" myns:namespaceless-elements="xml2rfc">
3091
3092  <section title="Status of this Memo" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.status">
3093
3094  <xsl:choose>
3095    <xsl:when test="/rfc/@ipr and not(/rfc/@number)">
3096      <t>
3097        <xsl:choose>
3098         
3099          <!-- RFC2026 -->
3100          <xsl:when test="/rfc/@ipr = 'full2026'">
3101            This document is an Internet-Draft and is
3102            in full conformance with all provisions of Section 10 of RFC2026.   
3103          </xsl:when>
3104          <xsl:when test="/rfc/@ipr = 'noDerivativeWorks2026'">
3105            This document is an Internet-Draft and is
3106            in full conformance with all provisions of Section 10 of RFC2026
3107            except that the right to produce derivative works is not granted.   
3108          </xsl:when>
3109          <xsl:when test="/rfc/@ipr = 'noDerivativeWorksNow'">
3110            This document is an Internet-Draft and is
3111            in full conformance with all provisions of Section 10 of RFC2026
3112            except that the right to produce derivative works is not granted.
3113            (If this document becomes part of an IETF working group activity,
3114            then it will be brought into full compliance with Section 10 of RFC2026.) 
3115          </xsl:when>
3116          <xsl:when test="/rfc/@ipr = 'none'">
3117            This document is an Internet-Draft and is
3118            NOT offered in accordance with Section 10 of RFC2026,
3119            and the author does not provide the IETF with any rights other
3120            than to publish as an Internet-Draft.
3121          </xsl:when>
3122         
3123          <!-- RFC3667 -->
3124          <xsl:when test="/rfc/@ipr = 'full3667'">
3125            This document is an Internet-Draft and is subject to all provisions
3126            of section 3 of RFC 3667.  By submitting this Internet-Draft, each
3127            author represents that any applicable patent or other IPR claims of
3128            which he or she is aware have been or will be disclosed, and any of
3129            which he or she become aware will be disclosed, in accordance with
3130            RFC 3668.
3131          </xsl:when>
3132          <xsl:when test="/rfc/@ipr = 'noModification3667'">
3133            This document is an Internet-Draft and is subject to all provisions
3134            of section 3 of RFC 3667.  By submitting this Internet-Draft, each
3135            author represents that any applicable patent or other IPR claims of
3136            which he or she is aware have been or will be disclosed, and any of
3137            which he or she become aware will be disclosed, in accordance with
3138            RFC 3668.  This document may not be modified, and derivative works of
3139            it may not be created, except to publish it as an RFC and to
3140            translate it into languages other than English<xsl:if test="/rfc/@iprExtract">,
3141            other than to extract <xref target="{/rfc/@iprExtract}"/> as-is
3142            for separate use.</xsl:if>.
3143          </xsl:when>
3144          <xsl:when test="/rfc/@ipr = 'noDerivatives3667'">
3145            This document is an Internet-Draft and is subject to all provisions
3146            of section 3 of RFC 3667 except for the right to produce derivative
3147            works.  By submitting this Internet-Draft, each author represents
3148            that any applicable patent or other IPR claims of which he or she
3149            is aware have been or will be disclosed, and any of which he or she
3150            become aware will be disclosed, in accordance with RFC 3668.  This
3151            document may not be modified, and derivative works of it may
3152            not be created<xsl:if test="/rfc/@iprExtract">, other than to extract
3153            <xref target="{/rfc/@iprExtract}"/> as-is for separate use.</xsl:if>.
3154          </xsl:when>
3155         
3156          <!-- RFC3978 -->
3157          <xsl:when test="/rfc/@ipr = 'full3978'">
3158            By submitting this Internet-Draft, each
3159            author represents that any applicable patent or other IPR claims of
3160            which he or she is aware have been or will be disclosed, and any of
3161            which he or she becomes aware will be disclosed, in accordance with
3162            Section 6 of BCP 79.
3163          </xsl:when>
3164          <xsl:when test="/rfc/@ipr = 'noModification3978'">
3165            By submitting this Internet-Draft, each
3166            author represents that any applicable patent or other IPR claims of
3167            which he or she is aware have been or will be disclosed, and any of
3168            which he or she becomes aware will be disclosed, in accordance with
3169            Section 6 of BCP 79.  This document may not be modified, and derivative works of
3170            it may not be created, except to publish it as an RFC and to
3171            translate it into languages other than English<xsl:if test="/rfc/@iprExtract">,
3172            other than to extract <xref target="{/rfc/@iprExtract}"/> as-is
3173            for separate use.</xsl:if>.
3174          </xsl:when>
3175          <xsl:when test="/rfc/@ipr = 'noDerivatives3978'">
3176            By submitting this Internet-Draft, each author represents
3177            that any applicable patent or other IPR claims of which he or she
3178            is aware have been or will be disclosed, and any of which he or she
3179            becomes aware will be disclosed, in accordance with Section 6 of BCP 79.  This
3180            document may not be modified, and derivative works of it may
3181            not be created<xsl:if test="/rfc/@iprExtract">, other than to extract
3182            <xref target="{/rfc/@iprExtract}"/> as-is for separate use.</xsl:if>.
3183          </xsl:when>
3184
3185          <xsl:otherwise>CONFORMANCE UNDEFINED.</xsl:otherwise>
3186        </xsl:choose>
3187      </t>
3188      <t>
3189        Internet-Drafts are working documents of the Internet Engineering
3190        Task Force (IETF), its areas, and its working groups.
3191        Note that other groups may also distribute working documents as
3192        Internet-Drafts.
3193      </t>
3194      <t>
3195        Internet-Drafts are draft documents valid for a maximum of six months
3196        and may be updated, replaced, or obsoleted by other documents at any time.
3197        It is inappropriate to use Internet-Drafts as reference material or to cite
3198        them other than as &#8220;work in progress&#8221;.
3199      </t>
3200      <t>
3201        The list of current Internet-Drafts can be accessed at
3202        <eref target="http://www.ietf.org/ietf/1id-abstracts.txt"/>.
3203      </t>
3204      <t>
3205        The list of Internet-Draft Shadow Directories can be accessed at
3206        <eref target="http://www.ietf.org/shadow.html"/>.
3207      </t>
3208      <t>
3209        This Internet-Draft will expire in <xsl:call-template name="expirydate"/>.
3210      </t>
3211    </xsl:when>
3212
3213    <xsl:when test="/rfc/@category='bcp'">
3214      <t>
3215        This document specifies an Internet Best Current Practices for the Internet
3216        Community, and requests discussion and suggestions for improvements.
3217        Distribution of this memo is unlimited.
3218      </t>
3219    </xsl:when>
3220    <xsl:when test="/rfc/@category='exp'">
3221      <t>
3222        This memo defines an Experimental Protocol for the Internet community.
3223        It does not specify an Internet standard of any kind.
3224        Discussion and suggestions for improvement are requested.
3225        Distribution of this memo is unlimited.
3226      </t>
3227    </xsl:when>
3228    <xsl:when test="/rfc/@category='historic'">
3229      <t>
3230        This memo describes a historic protocol for the Internet community.
3231        It does not specify an Internet standard of any kind.
3232        Distribution of this memo is unlimited.
3233      </t>
3234    </xsl:when>
3235    <xsl:when test="/rfc/@category='info' or not(/rfc/@category)">
3236      <t>
3237        This memo provides information for the Internet community.
3238        It does not specify an Internet standard of any kind.
3239        Distribution of this memo is unlimited.
3240      </t>
3241    </xsl:when>
3242    <xsl:when test="/rfc/@category='std'">
3243      <t>
3244        This document specifies an Internet standards track protocol for the Internet
3245        community, and requests discussion and suggestions for improvements.
3246        Please refer to the current edition of the &#8220;Internet Official Protocol
3247        Standards&#8221; (STD 1) for the standardization state and status of this
3248        protocol. Distribution of this memo is unlimited.
3249      </t>
3250    </xsl:when>
3251    <xsl:otherwise>
3252      <t>UNSUPPORTED CATEGORY.</t>
3253    </xsl:otherwise>
3254  </xsl:choose>
3255 
3256  </section>
3257
3258  <xsl:choose>
3259    <xsl:when test="$ipr-2007-08"/>
3260    <xsl:when test="$ipr-rfc4748">
3261      <section title="Copyright Notice" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.copyrightnotice">
3262        <t>
3263          Copyright © The IETF Trust (<xsl:value-of select="$xml2rfc-ext-pub-year"/>).  All Rights Reserved.
3264        </t>
3265      </section>
3266    </xsl:when>
3267    <xsl:otherwise>
3268      <section title="Copyright Notice" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.copyrightnotice">
3269        <t>
3270          Copyright © The Internet Society (<xsl:value-of select="$xml2rfc-ext-pub-year"/>).  All Rights Reserved.
3271      </t>
3272      </section>
3273    </xsl:otherwise>
3274  </xsl:choose>
3275 
3276</xsl:template>
3277
3278<!-- TOC generation -->
3279
3280<xsl:template match="/" mode="toc">
3281  <hr xmlns="http://www.w3.org/1999/xhtml" class="noprint"/>
3282
3283  <h1 xmlns="http://www.w3.org/1999/xhtml" class="np" id="{$anchor-prefix}.toc"> <!-- this pagebreak occurs always -->
3284    <a href="#{$anchor-prefix}.toc">Table of Contents</a>
3285  </h1>
3286
3287  <ul xmlns="http://www.w3.org/1999/xhtml" class="toc">
3288    <xsl:apply-templates mode="toc"/>
3289  </ul>
3290</xsl:template>
3291
3292<xsl:template name="insert-toc-line">
3293  <xsl:param name="number"/>
3294  <xsl:param name="target"/>
3295  <xsl:param name="title"/>
3296  <xsl:param name="tocparam"/>
3297  <xsl:param name="oldtitle"/>
3298  <xsl:param name="waschanged"/>
3299
3300  <!-- handle tocdepth parameter -->
3301  <xsl:choose>
3302    <xsl:when test="($tocparam='' or $tocparam='default') and string-length(translate($number,'.ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890§','.')) &gt;= $parsedTocDepth">
3303      <!-- dropped entry because excluded -->
3304      <xsl:attribute name="class">tocline2</xsl:attribute>
3305    </xsl:when>
3306    <xsl:when test="$tocparam='exclude'">
3307      <!-- dropped entry because excluded -->
3308      <xsl:attribute name="class">tocline2</xsl:attribute>
3309    </xsl:when>
3310    <xsl:otherwise>
3311      <xsl:choose>
3312        <xsl:when test="starts-with($number,'del-')">
3313          <del xmlns="http://www.w3.org/1999/xhtml">
3314            <xsl:value-of select="$number"/>
3315            <a href="#{$target}"><xsl:value-of select="$title"/></a>
3316          </del>
3317        </xsl:when>
3318        <xsl:otherwise>
3319          <xsl:choose>
3320            <xsl:when test="not(contains($number,'.'))">
3321              <xsl:attribute name="class">tocline0</xsl:attribute>
3322            </xsl:when>
3323            <xsl:otherwise>
3324              <xsl:attribute name="class">tocline1</xsl:attribute>
3325            </xsl:otherwise>
3326          </xsl:choose>
3327          <xsl:if test="$number != ''">
3328            <xsl:call-template name="emit-section-number">
3329              <xsl:with-param name="no" select="$number"/>
3330            </xsl:call-template>
3331            <xsl:text>   </xsl:text>
3332          </xsl:if>
3333          <a xmlns="http://www.w3.org/1999/xhtml" href="#{$target}">
3334            <xsl:choose>
3335              <xsl:when test="$waschanged!=''">
3336                <ins><xsl:value-of select="$title"/></ins>
3337                <del><xsl:value-of select="$oldtitle"/></del>
3338              </xsl:when>
3339              <xsl:otherwise>
3340                <xsl:value-of select="$title"/>
3341              </xsl:otherwise>
3342            </xsl:choose>
3343          </a>
3344        </xsl:otherwise>
3345      </xsl:choose>
3346    </xsl:otherwise>
3347  </xsl:choose>
3348</xsl:template>
3349
3350<xsl:template match="back" mode="toc">
3351
3352  <!-- <xsl:apply-templates select="references" mode="toc" /> -->
3353
3354  <xsl:if test="//cref and $xml2rfc-comments='yes' and $xml2rfc-inline!='yes'">
3355    <li xmlns="http://www.w3.org/1999/xhtml">
3356      <xsl:call-template name="insert-toc-line">
3357        <xsl:with-param name="target" select="concat($anchor-prefix,'.comments')"/>
3358        <xsl:with-param name="title" select="'Editorial Comments'"/>
3359      </xsl:call-template>
3360    </li>
3361  </xsl:if>
3362
3363  <xsl:if test="$xml2rfc-ext-authors-section!='end'">
3364    <xsl:apply-templates select="/rfc/front" mode="toc"/>
3365  </xsl:if>
3366  <xsl:apply-templates select="*[not(self::references)]" mode="toc"/>
3367
3368  <xsl:if test="$xml2rfc-ext-authors-section='end'">
3369    <xsl:apply-templates select="/rfc/front" mode="toc"/>
3370  </xsl:if>
3371
3372  <!-- copyright statements -->
3373  <xsl:if test="not($xml2rfc-private)">
3374    <li xmlns="http://www.w3.org/1999/xhtml">
3375      <xsl:call-template name="insert-toc-line">
3376        <xsl:with-param name="target" select="concat($anchor-prefix,'.ipr')"/>
3377        <xsl:with-param name="title" select="'Intellectual Property and Copyright Statements'"/>
3378      </xsl:call-template>
3379    </li>
3380  </xsl:if>
3381 
3382  <!-- insert the index if index entries exist -->
3383  <xsl:if test="//iref">
3384    <li xmlns="http://www.w3.org/1999/xhtml">
3385      <xsl:call-template name="insert-toc-line">
3386        <xsl:with-param name="target" select="concat($anchor-prefix,'.index')"/>
3387        <xsl:with-param name="title" select="'Index'"/>
3388      </xsl:call-template>
3389    </li>
3390  </xsl:if>
3391
3392</xsl:template>
3393
3394<xsl:template match="front" mode="toc">
3395 
3396  <li xmlns="http://www.w3.org/1999/xhtml">
3397    <xsl:variable name="authors-title">
3398      <xsl:call-template name="get-authors-section-title"/>
3399    </xsl:variable>
3400    <xsl:variable name="authors-number">
3401      <xsl:call-template name="get-authors-section-number"/>
3402    </xsl:variable>
3403    <xsl:call-template name="insert-toc-line">
3404      <xsl:with-param name="target" select="concat($anchor-prefix,'.authors')"/>
3405      <xsl:with-param name="title" select="$authors-title"/>
3406      <xsl:with-param name="number" select="$authors-number"/>
3407    </xsl:call-template>
3408  </li>
3409
3410</xsl:template>
3411
3412<xsl:template name="references-toc">
3413
3414  <!-- distinguish two cases: (a) single references element (process
3415  as toplevel section; (b) multiple references sections (add one toplevel
3416  container with subsection) -->
3417
3418  <xsl:variable name="refsecs" select="/rfc/back/references|/rfc/back/ed:replace/ed:ins/references"/>
3419   
3420  <xsl:choose>
3421    <xsl:when test="count($refsecs) = 0">
3422      <!-- nop -->
3423    </xsl:when>
3424    <xsl:when test="count($refsecs) = 1">
3425      <xsl:for-each select="$refsecs">
3426        <xsl:variable name="title">
3427          <xsl:choose>
3428            <xsl:when test="@title!=''"><xsl:value-of select="@title"/></xsl:when>
3429            <xsl:otherwise>References</xsl:otherwise>
3430          </xsl:choose>
3431        </xsl:variable>
3432     
3433        <li xmlns="http://www.w3.org/1999/xhtml">
3434          <xsl:call-template name="insert-toc-line">
3435            <xsl:with-param name="number">
3436              <xsl:call-template name="get-references-section-number"/>
3437            </xsl:with-param>
3438            <xsl:with-param name="target" select="concat($anchor-prefix,'.references')"/>
3439            <xsl:with-param name="title" select="$title"/>
3440          </xsl:call-template>
3441        </li>
3442      </xsl:for-each>
3443    </xsl:when>
3444    <xsl:otherwise>
3445      <li xmlns="http://www.w3.org/1999/xhtml">
3446        <!-- insert pseudo container -->   
3447        <xsl:call-template name="insert-toc-line">
3448          <xsl:with-param name="number">
3449            <xsl:call-template name="get-references-section-number"/>
3450          </xsl:with-param>
3451          <xsl:with-param name="target" select="concat($anchor-prefix,'.references')"/>
3452          <xsl:with-param name="title" select="'References'"/>
3453        </xsl:call-template>
3454 
3455        <ul class="toc">
3456          <!-- ...with subsections... -->   
3457          <xsl:for-each select="$refsecs">
3458            <xsl:variable name="title">
3459              <xsl:choose>
3460                <xsl:when test="@title!=''"><xsl:value-of select="@title"/></xsl:when>
3461                <xsl:otherwise>References</xsl:otherwise>
3462              </xsl:choose>
3463            </xsl:variable>
3464         
3465            <xsl:variable name="sectionNumber">
3466              <xsl:call-template name="get-section-number"/>
3467            </xsl:variable>
3468   
3469            <xsl:variable name="num">
3470              <xsl:number level="any"/>
3471            </xsl:variable>
3472   
3473            <li>
3474              <xsl:call-template name="insert-toc-line">
3475                <xsl:with-param name="number" select="$sectionNumber"/>
3476                <xsl:with-param name="target" select="concat($anchor-prefix,'.references','.',$num)"/>
3477                <xsl:with-param name="title" select="$title"/>
3478              </xsl:call-template>
3479            </li>
3480          </xsl:for-each>
3481        </ul>
3482      </li>
3483    </xsl:otherwise>
3484  </xsl:choose>
3485</xsl:template>
3486
3487<xsl:template match="section|appendix" mode="toc">
3488  <xsl:variable name="sectionNumber">
3489    <xsl:call-template name="get-section-number"/>
3490  </xsl:variable>
3491
3492  <xsl:variable name="target">
3493    <xsl:choose>
3494      <xsl:when test="@anchor"><xsl:value-of select="@anchor"/></xsl:when>
3495       <xsl:otherwise><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$sectionNumber"/></xsl:otherwise>
3496    </xsl:choose>
3497  </xsl:variable>
3498
3499  <!-- obtain content, just to check whether we need to recurse at all -->
3500  <xsl:variable name="content">
3501    <li xmlns="http://www.w3.org/1999/xhtml">
3502      <xsl:call-template name="insert-toc-line">
3503        <xsl:with-param name="number" select="$sectionNumber"/>
3504        <xsl:with-param name="target" select="$target"/>
3505        <xsl:with-param name="title" select="@title"/>
3506        <xsl:with-param name="tocparam" select="@toc"/>
3507        <xsl:with-param name="oldtitle" select="@ed:old-title"/>
3508        <xsl:with-param name="waschanged" select="@ed:resolves"/>
3509      </xsl:call-template>
3510   
3511      <ul class="toc">
3512        <xsl:apply-templates mode="toc"/>
3513      </ul>
3514    </li>
3515  </xsl:variable>
3516 
3517  <xsl:if test="$content!=''">
3518    <li xmlns="http://www.w3.org/1999/xhtml">
3519      <xsl:call-template name="insert-toc-line">
3520        <xsl:with-param name="number" select="$sectionNumber"/>
3521        <xsl:with-param name="target" select="$target"/>
3522        <xsl:with-param name="title" select="@title"/>
3523        <xsl:with-param name="tocparam" select="@toc"/>
3524        <xsl:with-param name="oldtitle" select="@ed:old-title"/>
3525        <xsl:with-param name="waschanged" select="@ed:resolves"/>
3526      </xsl:call-template>
3527   
3528      <!-- obtain nested content, just to check whether we need to recurse at all -->
3529      <xsl:variable name="nested-content">
3530        <ul class="toc">
3531          <xsl:apply-templates mode="toc"/>
3532        </ul>
3533      </xsl:variable>
3534     
3535      <!-- only recurse if we need to (do not produce useless list container) -->     
3536      <xsl:if test="$nested-content!=''">
3537        <ul class="toc">
3538          <xsl:apply-templates mode="toc"/>
3539        </ul>
3540      </xsl:if>
3541    </li>
3542  </xsl:if>
3543</xsl:template>
3544
3545<xsl:template match="middle" mode="toc">
3546  <xsl:apply-templates mode="toc"/>
3547  <xsl:call-template name="references-toc"/>
3548</xsl:template>
3549
3550<xsl:template match="rfc" mode="toc">
3551  <xsl:apply-templates select="middle|back" mode="toc"/>
3552</xsl:template>
3553
3554<xsl:template match="ed:del|ed:ins|ed:replace" mode="toc">
3555  <xsl:apply-templates mode="toc"/>
3556</xsl:template>
3557
3558<xsl:template match="*|text()" mode="toc"/>
3559
3560
3561<xsl:template name="insertTocAppendix">
3562 
3563  <xsl:if test="//figure[@title!='' or @anchor!='']">
3564    <ul xmlns="http://www.w3.org/1999/xhtml" class="toc">
3565      <xsl:for-each select="//figure[@title!='' or @anchor!='']">
3566        <xsl:variable name="title">Figure <xsl:value-of select="position()"/><xsl:if test="@title">: <xsl:value-of select="@title"/></xsl:if>
3567        </xsl:variable>
3568        <li>
3569          <xsl:call-template name="insert-toc-line">
3570            <xsl:with-param name="target" select="concat($anchor-prefix,'.figure.',position())"/>
3571            <xsl:with-param name="title" select="$title"/>
3572          </xsl:call-template>
3573        </li>
3574      </xsl:for-each>
3575    </ul>
3576  </xsl:if>
3577 
3578  <!-- experimental -->
3579  <xsl:if test="//ed:issue">
3580    <xsl:call-template name="insertIssuesList"/>
3581  </xsl:if>
3582
3583</xsl:template>
3584
3585<xsl:template name="referencename">
3586  <xsl:param name="node"/>
3587 
3588  <xsl:for-each select="$node">
3589    <xsl:choose>
3590      <xsl:when test="$xml2rfc-symrefs!='no' and ancestor::ed:del">
3591        <xsl:variable name="unprefixed" select="substring-after(@anchor,'deleted-')"/>
3592        <xsl:choose>
3593          <xsl:when test="$unprefixed!=''">
3594            <xsl:value-of select="concat('[',$unprefixed,']')"/>
3595          </xsl:when>
3596          <xsl:otherwise>
3597            <xsl:if test="count(//reference[@anchor=current()/@anchor])!=1">
3598              <xsl:message>Deleted duplicate anchors should have the prefix "deleted-": <xsl:value-of select="@anchor"/></xsl:message>
3599            </xsl:if>
3600            <xsl:value-of select="concat('[',@anchor,']')"/>
3601          </xsl:otherwise>
3602        </xsl:choose>
3603      </xsl:when>
3604      <xsl:when test="$xml2rfc-symrefs!='no'">[<xsl:value-of select="@anchor"/>]</xsl:when>
3605      <xsl:when test="ancestor::ed:del">
3606        <xsl:text>[del]</xsl:text>
3607      </xsl:when>
3608      <xsl:otherwise>[<xsl:number level="any" count="reference[not(ancestor::ed:del)]"/>]</xsl:otherwise>
3609    </xsl:choose>
3610  </xsl:for-each> 
3611</xsl:template>
3612
3613
3614
3615<xsl:template name="replace-substring">
3616
3617  <xsl:param name="string"/>
3618  <xsl:param name="replace"/>
3619  <xsl:param name="by"/>
3620
3621  <xsl:choose>
3622    <xsl:when test="contains($string,$replace)">
3623      <xsl:value-of select="concat(substring-before($string, $replace),$by)"/>
3624      <xsl:call-template name="replace-substring">
3625        <xsl:with-param name="string" select="substring-after($string,$replace)"/>
3626        <xsl:with-param name="replace" select="$replace"/>
3627        <xsl:with-param name="by" select="$by"/>
3628      </xsl:call-template>
3629    </xsl:when>
3630    <xsl:otherwise><xsl:value-of select="$string"/></xsl:otherwise>
3631  </xsl:choose>
3632
3633</xsl:template>
3634
3635
3636<xsl:template name="rfclist">
3637  <xsl:param name="list"/>
3638  <xsl:choose>
3639    <xsl:when test="contains($list,',')">
3640      <xsl:variable name="rfcNo" select="substring-before($list,',')"/>
3641      <xsl:if test="count(//references//reference/seriesInfo[@name='RFC' and @value=$rfcNo])=0">
3642        <xsl:call-template name="warning">
3643          <xsl:with-param name="inline" select="'no'"/>
3644          <xsl:with-param name="msg" select="concat('front matter mentions RFC',$rfcNo,' for which there is no reference element')"/>
3645        </xsl:call-template>
3646      </xsl:if>
3647      <a xmlns="http://www.w3.org/1999/xhtml" href="{concat($rfcUrlPrefix,$rfcNo,$rfcUrlPostfix)}"><xsl:value-of select="$rfcNo"/></a>,
3648      <xsl:call-template name="rfclist">
3649        <xsl:with-param name="list" select="normalize-space(substring-after($list,','))"/>
3650      </xsl:call-template>
3651    </xsl:when>
3652    <xsl:otherwise>
3653      <xsl:variable name="rfcNo" select="$list"/>
3654      <xsl:if test="count(//references//reference/seriesInfo[@name='RFC' and @value=$rfcNo])=0">
3655        <xsl:call-template name="warning">
3656          <xsl:with-param name="inline" select="'no'"/>
3657          <xsl:with-param name="msg" select="concat('front matter mentions RFC',$rfcNo,' for which there is no reference element')"/>
3658        </xsl:call-template>
3659      </xsl:if>
3660      <a xmlns="http://www.w3.org/1999/xhtml" href="{concat($rfcUrlPrefix,$rfcNo,$rfcUrlPostfix)}"><xsl:value-of select="$rfcNo"/></a>
3661    </xsl:otherwise>
3662  </xsl:choose>
3663</xsl:template>
3664
3665<xsl:template name="rfclist-for-dcmeta">
3666  <xsl:param name="list"/>
3667  <xsl:choose>
3668    <xsl:when test="contains($list,',')">
3669      <xsl:variable name="rfcNo" select="substring-before($list,',')"/>
3670      <meta xmlns="http://www.w3.org/1999/xhtml" name="DC.Relation.Replaces" content="urn:ietf:rfc:{$rfcNo}"/>
3671      <xsl:call-template name="rfclist-for-dcmeta">
3672        <xsl:with-param name="list" select="normalize-space(substring-after($list,','))"/>
3673      </xsl:call-template>
3674    </xsl:when>
3675    <xsl:otherwise>
3676      <xsl:variable name="rfcNo" select="$list"/>
3677      <meta xmlns="http://www.w3.org/1999/xhtml" name="DC.Relation.Replaces" content="urn:ietf:rfc:{$rfcNo}"/>
3678    </xsl:otherwise>
3679  </xsl:choose>
3680</xsl:template>
3681
3682<xsl:template name="get-paragraph-number">
3683  <!-- get section number of ancestor section element, then add t or figure number -->
3684  <xsl:if test="ancestor::section and not(ancestor::section[@myns:unnumbered='unnumbered']) and not(ancestor::x:blockquote)">
3685    <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"/>
3686  </xsl:if>
3687</xsl:template>
3688
3689<xsl:template name="editingMark">
3690  <xsl:if test="$xml2rfc-editing='yes' and ancestor::rfc">
3691    <sup xmlns="http://www.w3.org/1999/xhtml" class="editingmark"><span><xsl:number level="any" count="postamble|preamble|t"/></span> </sup>
3692  </xsl:if>
3693</xsl:template>
3694
3695<!-- internal ref support -->
3696<xsl:template match="x:ref">
3697  <xsl:variable name="val" select="."/>
3698  <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)]"/>
3699  <xsl:variable name="irefs" select="//iref[@x:for-anchor=$val]"/>
3700  <xsl:choose>
3701    <xsl:when test="$target">
3702      <a xmlns="http://www.w3.org/1999/xhtml" href="#{$target/@anchor}" class="smpl">
3703        <!-- to be indexed? -->
3704        <xsl:if test="$irefs">
3705          <xsl:attribute name="id"><xsl:call-template name="compute-extref-anchor"/></xsl:attribute>
3706        </xsl:if>
3707        <xsl:value-of select="."/>
3708      </a>
3709    </xsl:when>
3710    <xsl:otherwise>
3711      <xsl:message>WARNING: internal link target for '<xsl:value-of select="."/>' does not exist.<xsl:call-template name="lineno"/></xsl:message>
3712      <xsl:value-of select="."/>
3713    </xsl:otherwise>
3714  </xsl:choose>
3715</xsl:template>
3716
3717<!-- Nothing to do here -->
3718<xsl:template match="x:anchor-alias"/>
3719
3720<!-- Quotes -->
3721<xsl:template match="x:q">
3722  <q xmlns="http://www.w3.org/1999/xhtml">
3723    <xsl:copy-of select="@cite"/>
3724    <xsl:apply-templates/>
3725  </q>
3726</xsl:template>
3727
3728<xsl:template match="x:bcp14">
3729  <!-- check valid BCP14 keywords, then emphasize them -->
3730  <xsl:variable name="c" select="normalize-space(.)"/>
3731  <xsl:choose>
3732    <xsl:when test="$c='MUST' or $c='REQUIRED' or $c='SHALL'">
3733      <em xmlns="http://www.w3.org/1999/xhtml" class="bcp14"><xsl:value-of select="."/></em>
3734    </xsl:when>
3735    <xsl:when test="$c='MUST NOT' or $c='SHALL NOT'">
3736      <em xmlns="http://www.w3.org/1999/xhtml" class="bcp14"><xsl:value-of select="."/></em>
3737    </xsl:when>
3738    <xsl:when test="$c='SHOULD' or $c='RECOMMENDED'">
3739      <em xmlns="http://www.w3.org/1999/xhtml" class="bcp14"><xsl:value-of select="."/></em>
3740    </xsl:when>
3741    <xsl:when test="$c='SHOULD NOT' or $c='NOT RECOMMENDED'">
3742      <em xmlns="http://www.w3.org/1999/xhtml" class="bcp14"><xsl:value-of select="."/></em>
3743    </xsl:when>
3744    <xsl:when test="$c='MAY' or $c='OPTIONAL'">
3745      <em xmlns="http://www.w3.org/1999/xhtml" class="bcp14"><xsl:value-of select="."/></em>
3746    </xsl:when>
3747    <xsl:otherwise>
3748      <xsl:value-of select="."/>
3749      <xsl:message>ERROR: unknown BCP14 keyword: <xsl:value-of select="."/></xsl:message>
3750    </xsl:otherwise>
3751  </xsl:choose>
3752</xsl:template>
3753
3754<xsl:template match="x:blockquote">
3755  <xsl:variable name="p">
3756    <xsl:call-template name="get-paragraph-number"/>
3757  </xsl:variable>
3758
3759  <blockquote xmlns="http://www.w3.org/1999/xhtml">
3760    <xsl:if test="string-length($p) &gt; 0 and not(ancestor::ed:del) and not(ancestor::ed:ins)">
3761      <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$p"/></xsl:attribute>
3762    </xsl:if>
3763    <xsl:call-template name="insertInsDelClass"/>
3764    <xsl:call-template name="editingMark"/>
3765    <xsl:copy-of select="@cite"/>
3766    <xsl:apply-templates/>
3767  </blockquote>
3768</xsl:template>
3769
3770<!-- Definitions -->
3771<xsl:template match="x:dfn">
3772  <dfn xmlns="http://www.w3.org/1999/xhtml">
3773    <xsl:apply-templates/>
3774  </dfn>
3775</xsl:template>
3776
3777<!-- headings -->
3778<xsl:template match="x:h">
3779  <b xmlns="http://www.w3.org/1999/xhtml">
3780    <xsl:apply-templates/>
3781  </b>
3782</xsl:template>
3783
3784<!-- measuring lengths -->
3785<xsl:template match="x:length-of">
3786  <xsl:variable name="target" select="//*[@anchor=current()/@target]"/>
3787  <xsl:if test="count($target)!=1">
3788    <xsl:call-template name="error">
3789      <xsl:with-param name="msg" select="concat('@target ',@target,' defined ',count($target),' times.')"/>
3790    </xsl:call-template>
3791  </xsl:if>
3792  <xsl:variable name="content">
3793    <xsl:apply-templates select="$target"/>
3794  </xsl:variable>
3795  <xsl:variable name="lineends" select="string-length($content) - string-length(translate($content,'&#xA;',''))"/>
3796  <xsl:variable name="indents">
3797    <xsl:choose>
3798      <xsl:when test="@indented">
3799        <xsl:value-of select="number(@indented) * $lineends"/>
3800      </xsl:when>
3801      <xsl:otherwise>0</xsl:otherwise>
3802    </xsl:choose>
3803  </xsl:variable>
3804  <xsl:value-of select="string-length($content) + $lineends - $indents"/>
3805</xsl:template>
3806
3807<!-- Nop -->
3808<xsl:template match="x:span">
3809  <xsl:apply-templates/>
3810</xsl:template>
3811
3812<!-- box drawing -->
3813
3814<!-- nop for alignment -->
3815<xsl:template match="x:x"/>
3816
3817<!-- box (top) -->
3818<xsl:template match="x:bt">
3819  <xsl:text>&#9484;</xsl:text>
3820  <xsl:value-of select="translate(substring(.,2,string-length(.)-2),'-','&#9472;')"/>
3821  <xsl:text>&#9488;</xsl:text>
3822</xsl:template>
3823
3824<!-- box (center) -->
3825<xsl:template match="x:bc">
3826  <xsl:variable name="first" select="substring(.,1)"/>
3827  <xsl:variable name="last" select="substring(.,string-length(.)-1)"/>
3828  <xsl:variable name="content" select="substring(.,2,string-length(.)-2)"/>
3829  <xsl:variable name="is-delimiter" select="translate($content,'-','')=''"/>
3830 
3831  <xsl:choose>
3832    <xsl:when test="$is-delimiter">
3833      <xsl:text>&#9500;</xsl:text>
3834      <xsl:value-of select="translate($content,'-','&#9472;')"/>
3835      <xsl:text>&#9508;</xsl:text>
3836    </xsl:when>
3837    <xsl:when test="*">
3838      <xsl:for-each select="node()">
3839        <xsl:choose>
3840          <xsl:when test="position()=1">
3841            <xsl:text>&#9474;</xsl:text>
3842            <xsl:value-of select="substring(.,2)"/>
3843          </xsl:when>
3844          <xsl:when test="position()=last()">
3845            <xsl:value-of select="substring(.,1,string-length(.)-1)"/>
3846            <xsl:text>&#9474;</xsl:text>
3847          </xsl:when>
3848          <xsl:otherwise>
3849            <xsl:apply-templates select="."/>
3850          </xsl:otherwise>
3851        </xsl:choose>
3852      </xsl:for-each>
3853    </xsl:when>
3854    <xsl:otherwise>
3855      <xsl:text>&#9474;</xsl:text>
3856      <xsl:value-of select="$content"/>
3857      <xsl:text>&#9474;</xsl:text>
3858    </xsl:otherwise>
3859  </xsl:choose>
3860 
3861</xsl:template>
3862
3863<!-- box (bottom) -->
3864<xsl:template match="x:bb">
3865  <xsl:text>&#9492;</xsl:text>
3866  <xsl:value-of select="translate(substring(.,2,string-length(.)-2),'-','&#9472;')"/>
3867  <xsl:text>&#9496;</xsl:text>
3868</xsl:template>
3869
3870<!-- experimental annotation support -->
3871
3872<xsl:template match="ed:issueref">
3873  <xsl:choose>
3874    <xsl:when test=".=//ed:issue/@name">
3875      <a xmlns="http://www.w3.org/1999/xhtml" href="#{$anchor-prefix}.issue.{.}">
3876        <xsl:apply-templates/>
3877      </a>
3878    </xsl:when>
3879    <xsl:otherwise>
3880      <xsl:call-template name="warning">
3881        <xsl:with-param name="msg">Dangling ed:issueref: <xsl:value-of select="."/></xsl:with-param>
3882      </xsl:call-template>
3883      <xsl:apply-templates/>
3884    </xsl:otherwise>
3885  </xsl:choose>
3886</xsl:template>
3887
3888<xsl:template match="ed:issue">
3889  <xsl:variable name="class">
3890    <xsl:choose>
3891      <xsl:when test="@status='closed'">closedissue</xsl:when>
3892      <xsl:otherwise>openissue</xsl:otherwise>
3893    </xsl:choose>
3894  </xsl:variable>
3895 
3896  <table xmlns="http://www.w3.org/1999/xhtml" summary="issue {@name}" class="{$class}">
3897    <tr>
3898      <td colspan="3">
3899        <a id="{$anchor-prefix}.issue.{@name}">
3900          <xsl:choose>
3901            <xsl:when test="@status='closed'">
3902              <xsl:attribute name="class">closed-issue</xsl:attribute>
3903            </xsl:when>
3904            <xsl:when test="@status='editor'">
3905              <xsl:attribute name="class">editor-issue</xsl:attribute>
3906            </xsl:when>
3907            <xsl:otherwise>
3908              <xsl:attribute name="class">open-issue</xsl:attribute>
3909            </xsl:otherwise>
3910          </xsl:choose>
3911          <xsl:text> I </xsl:text>
3912        </a>
3913        <xsl:text> </xsl:text>
3914        <xsl:choose>
3915          <xsl:when test="@href">
3916            <em><a href="{@href}"><xsl:value-of select="@name"/></a></em>
3917          </xsl:when>
3918          <xsl:when test="@alternate-href">
3919            <em>[<a href="{@alternate-href}">alternate link</a>]</em>
3920          </xsl:when>
3921          <xsl:otherwise>
3922            <em><xsl:value-of select="@name"/></em>
3923          </xsl:otherwise>
3924        </xsl:choose>
3925         
3926        (type: <xsl:value-of select="@type"/>, status: <xsl:value-of select="@status"/>)
3927      </td>
3928    </tr>
3929
3930    <xsl:apply-templates select="ed:item"/>
3931    <xsl:apply-templates select="ed:resolution"/>
3932
3933    <xsl:variable name="changes" select="//*[@ed:resolves=current()/@name or ed:resolves=current()/@name]"/>
3934    <xsl:if test="$changes">
3935      <tr>
3936        <td class="top" colspan="3">
3937          Associated changes in this document:
3938          <xsl:variable name="issue" select="@name"/>
3939          <xsl:for-each select="$changes">
3940            <a href="#{$anchor-prefix}.change.{$issue}.{position()}">
3941              <xsl:variable name="label">
3942                <xsl:call-template name="get-section-number"/>
3943              </xsl:variable>
3944              <xsl:choose>
3945                <xsl:when test="$label!=''"><xsl:value-of select="$label"/></xsl:when>
3946                <xsl:otherwise>&lt;<xsl:value-of select="concat('#',$anchor-prefix,'.change.',$issue,'.',position())"/>&gt;</xsl:otherwise>
3947              </xsl:choose>
3948            </a>
3949            <xsl:if test="position()!=last()">, </xsl:if>
3950          </xsl:for-each>
3951          <xsl:text>.</xsl:text>
3952        </td>
3953      </tr>
3954    </xsl:if>
3955  </table>
3956   
3957</xsl:template>
3958
3959<xsl:template match="ed:item">
3960  <tr xmlns="http://www.w3.org/1999/xhtml">
3961    <td class="top">
3962      <xsl:if test="@entered-by">
3963        <a href="mailto:{@entered-by}?subject={/rfc/@docName},%20{../@name}">
3964          <i><xsl:value-of select="@entered-by"/></i>
3965        </a>
3966      </xsl:if>
3967    </td>
3968    <td class="topnowrap">
3969      <xsl:value-of select="@date"/>
3970    </td>
3971    <td class="top">
3972      <xsl:apply-templates select="node()" mode="issuehtml"/>
3973    </td>
3974  </tr>
3975</xsl:template>
3976
3977<xsl:template match="ed:resolution">
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}"><i><xsl:value-of select="@entered-by"/></i></a>
3982      </xsl:if>
3983    </td>
3984    <td class="topnowrap">
3985      <xsl:value-of select="@datetime"/>
3986    </td>
3987    <td class="top">
3988      <em>Resolution:</em>
3989      <xsl:apply-templates select="node()" mode="issuehtml"/>
3990    </td>
3991  </tr>
3992</xsl:template>
3993
3994<xsl:template match="ed:annotation">
3995  <em xmlns="http://www.w3.org/1999/xhtml">
3996    <xsl:apply-templates/>
3997  </em>
3998</xsl:template>
3999
4000<!-- special templates for handling XHTML in issues -->
4001<xsl:template match="text()" mode="issuehtml">
4002  <xsl:value-of select="."/>
4003</xsl:template>
4004
4005<xsl:template match="*|@*" mode="issuehtml">
4006  <xsl:message terminate="yes">Unexpected node in issue HTML: <xsl:value-of select="local-name(.)"/></xsl:message>
4007</xsl:template>
4008
4009<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">
4010  <xsl:element namespace="http://www.w3.org/1999/xhtml" name="{local-name()}">
4011    <xsl:apply-templates select="@*|node()" mode="issuehtml"/>
4012  </xsl:element>
4013</xsl:template>
4014
4015<xsl:template match="xhtml:p" mode="issuehtml">
4016  <xsl:apply-templates select="node()" mode="issuehtml"/>
4017  <br xmlns="http://www.w3.org/1999/xhtml" class="p"/>
4018</xsl:template>
4019
4020<xsl:template match="xhtml:a/@href|xhtml:q/@cite" mode="issuehtml">
4021  <xsl:attribute name="{local-name(.)}">
4022    <xsl:value-of select="."/>
4023  </xsl:attribute>
4024</xsl:template>
4025
4026<xsl:template match="ed:issueref" mode="issuehtml">
4027  <xsl:apply-templates select="."/>
4028</xsl:template>
4029
4030<xsl:template match="ed:eref" mode="issuehtml">
4031  <xsl:text>&lt;</xsl:text>
4032  <a xmlns="http://www.w3.org/1999/xhtml" href="{.}"><xsl:value-of select="."/></a>
4033  <xsl:text>&gt;</xsl:text>
4034</xsl:template>
4035
4036<xsl:template name="insertIssuesList">
4037
4038  <h2 xmlns="http://www.w3.org/1999/xhtml" id="{$anchor-prefix}.issues-list"><a href="#{$anchor-prefix}.issues-list">Issues list</a></h2>
4039  <table xmlns="http://www.w3.org/1999/xhtml" summary="Issues list">
4040    <thead>
4041      <tr>
4042        <th>Id</th>
4043        <th>Type</th>
4044        <th>Status</th>
4045        <th>Date</th>
4046        <th>Raised By</th>
4047      </tr>
4048    </thead>
4049    <tbody>
4050      <xsl:for-each select="//ed:issue">
4051        <xsl:sort select="@status"/>
4052        <xsl:sort select="@name"/>
4053        <tr>
4054          <td><a href="#{$anchor-prefix}.issue.{@name}"><xsl:value-of select="@name"/></a></td>
4055          <td><xsl:value-of select="@type"/></td>
4056          <td><xsl:value-of select="@status"/></td>
4057          <td><xsl:value-of select="ed:item[1]/@date"/></td>
4058          <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>
4059        </tr>
4060      </xsl:for-each>
4061    </tbody>
4062  </table>
4063 
4064</xsl:template>
4065
4066<xsl:template name="formatTitle">
4067  <xsl:if test="@who">
4068    <xsl:value-of select="@who"/>
4069  </xsl:if>
4070  <xsl:if test="@datetime">
4071    <xsl:value-of select="concat(' (',@datetime,')')"/>
4072  </xsl:if>
4073  <xsl:if test="@reason">
4074    <xsl:value-of select="concat(': ',@reason)"/>
4075  </xsl:if>
4076  <xsl:if test="@cite">
4077    <xsl:value-of select="concat(' &lt;',@cite,'&gt;')"/>
4078  </xsl:if>
4079</xsl:template>
4080
4081<xsl:template name="insert-diagnostics">
4082 
4083  <!-- check anchor names -->
4084  <xsl:variable name="badAnchors" select="//*[starts-with(@anchor,concat($anchor-prefix,'.'))]"/>
4085  <xsl:if test="$badAnchors">
4086    <p xmlns="http://www.w3.org/1999/xhtml" class="warning">
4087      The following anchor names may collide with internally generated anchors because of their prefix "<xsl:value-of select="$anchor-prefix"/>":
4088      <xsl:for-each select="$badAnchors">
4089        <xsl:value-of select="@anchor"/><xsl:if test="position()!=last()">, </xsl:if>
4090      </xsl:for-each>
4091    </p>
4092    <xsl:message>
4093      The following anchor names may collide with internally generated anchors because of their prefix "<xsl:value-of select="$anchor-prefix"/>":
4094      <xsl:for-each select="$badAnchors">
4095        <xsl:value-of select="@anchor"/><xsl:if test="position()!=last()">, </xsl:if>
4096      </xsl:for-each>
4097    </xsl:message>
4098  </xsl:if>
4099 
4100  <!-- check IDs -->
4101  <xsl:variable name="badTargets" select="//xref[not(@target=//@anchor) and not(ancestor::ed:del)]"/>
4102  <xsl:if test="$badTargets">
4103    <p xmlns="http://www.w3.org/1999/xhtml" class="error">
4104      The following target names do not exist:
4105      <xsl:for-each select="$badTargets">
4106        <xsl:value-of select="@target"/><xsl:if test="position()!=last()">, </xsl:if>
4107      </xsl:for-each>
4108    </p>
4109    <xsl:message>
4110      The following target names do not exist:
4111      <xsl:for-each select="$badTargets">
4112        <xsl:value-of select="@target"/><xsl:if test="position()!=last()">, </xsl:if>
4113      </xsl:for-each>
4114    </xsl:message>
4115  </xsl:if>
4116 
4117 
4118</xsl:template>
4119
4120<!-- special change mark support, not supported by RFC2629 yet -->
4121
4122<xsl:template match="@ed:*"/>
4123
4124<xsl:template match="ed:del">
4125  <xsl:call-template name="insert-issue-pointer"/>
4126  <del xmlns="http://www.w3.org/1999/xhtml">
4127    <xsl:copy-of select="@*[namespace-uri()='']"/>
4128    <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
4129      <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4130    </xsl:if>
4131    <xsl:apply-templates/>
4132  </del>
4133</xsl:template>
4134
4135<xsl:template match="ed:ins">
4136  <xsl:call-template name="insert-issue-pointer"/>
4137  <ins xmlns="http://www.w3.org/1999/xhtml">
4138    <xsl:copy-of select="@*[namespace-uri()='']"/>
4139    <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
4140      <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4141    </xsl:if>
4142    <xsl:apply-templates/>
4143  </ins>
4144</xsl:template>
4145
4146<xsl:template name="insert-issue-pointer">
4147  <xsl:param name="deleted-anchor"/>
4148  <xsl:variable name="change" select="."/>
4149  <xsl:for-each select="@ed:resolves|ed:resolves">
4150    <xsl:variable name="resolves" select="."/>
4151    <!-- need the right context node for proper numbering -->
4152    <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>
4153    <xsl:variable name="total" select="count(//*[@ed:resolves=$resolves or ed:resolves=$resolves])"/>
4154    <xsl:variable name="id">
4155      <xsl:value-of select="$anchor-prefix"/>.change.<xsl:value-of select="$resolves"/>.<xsl:value-of select="$count"/>
4156    </xsl:variable>
4157    <xsl:choose>
4158      <!-- block level? -->
4159      <xsl:when test="not(ancestor::t) and not(ancestor::title) and not(ancestor::figure) and not($change/@ed:old-title)">
4160        <div xmlns="http://www.w3.org/1999/xhtml" class="issuepointer noprint">
4161          <xsl:if test="not($deleted-anchor)">
4162            <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
4163          </xsl:if>
4164          <xsl:if test="$count &gt; 1">
4165            <a class="bg-issue" title="previous change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count - 1}">&#8593;</a>
4166          </xsl:if>
4167          <a class="open-issue" href="#{$anchor-prefix}.issue.{$resolves}" title="resolves: {$resolves}">
4168            <xsl:choose>
4169              <xsl:when test="//ed:issue[@name=$resolves and @status='closed']">
4170                <xsl:attribute name="class">closed-issue</xsl:attribute>
4171              </xsl:when>
4172              <xsl:when test="//ed:issue[@name=$resolves and @status='editor']">
4173                <xsl:attribute name="class">editor-issue</xsl:attribute>
4174              </xsl:when>
4175              <xsl:otherwise>
4176                <xsl:attribute name="class">open-issue</xsl:attribute>
4177              </xsl:otherwise>
4178            </xsl:choose>
4179            <xsl:text> I </xsl:text>
4180          </a>
4181          <xsl:if test="$count &lt; $total">
4182            <a class="bg-issue" title="next change for {$resolves}" href="#{$anchor-prefix}.change.{$resolves}.{$count + 1}">&#8595;</a>
4183          </xsl:if>
4184          <xsl:text> </xsl:text>
4185        </div>
4186      </xsl:when>
4187      <xsl:otherwise>
4188        <xsl:if test="$count &gt; 1">
4189          <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>
4190        </xsl:if>
4191        <a xmlns="http://www.w3.org/1999/xhtml" title="resolves: {$resolves}" href="#{$anchor-prefix}.issue.{$resolves}">
4192          <xsl:if test="not($deleted-anchor)">
4193            <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
4194          </xsl:if>
4195          <xsl:choose>
4196            <xsl:when test="//ed:issue[@name=$resolves and @status='closed']">
4197              <xsl:attribute name="class">closed-issue noprint</xsl:attribute>
4198            </xsl:when>
4199            <xsl:when test="//ed:issue[@name=$resolves and @status='editor']">
4200              <xsl:attribute name="class">editor-issue noprint</xsl:attribute>
4201            </xsl:when>
4202            <xsl:otherwise>
4203              <xsl:attribute name="class">open-issue noprint</xsl:attribute>
4204            </xsl:otherwise>
4205          </xsl:choose>
4206          <xsl:text> I </xsl:text>
4207        </a>
4208        <xsl:if test="$count &lt; $total">
4209          <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>
4210        </xsl:if>
4211      </xsl:otherwise>
4212    </xsl:choose>
4213  </xsl:for-each>
4214</xsl:template>
4215
4216<xsl:template match="ed:replace">
4217  <!-- we need to special-case things like lists and tables -->
4218  <xsl:choose>
4219    <xsl:when test="parent::list">
4220      <xsl:apply-templates select="ed:del/node()"/>
4221      <xsl:apply-templates select="ed:ins/node()"/>
4222    </xsl:when>
4223    <xsl:when test="ancestor::references">
4224      <xsl:apply-templates select="ed:del/node()"/>
4225      <xsl:apply-templates select="ed:ins/node()"/>
4226    </xsl:when>
4227    <xsl:otherwise>
4228      <xsl:if test="@cite">
4229        <a xmlns="http://www.w3.org/1999/xhtml" class="editor-issue" href="{@cite}" target="_blank" title="see {@cite}">
4230          <xsl:text> i </xsl:text>
4231        </a>
4232      </xsl:if>
4233      <xsl:call-template name="insert-issue-pointer"/>
4234      <xsl:if test="ed:del">
4235        <del xmlns="http://www.w3.org/1999/xhtml">
4236          <xsl:copy-of select="@*[namespace-uri()='']"/>
4237          <xsl:if test="not(@title) and ancestor-or-self::xsl:template[@ed:entered-by] and @datetime">
4238            <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4239          </xsl:if>
4240          <xsl:apply-templates select="ed:del/node()"/>
4241        </del>
4242      </xsl:if>
4243      <xsl:if test="ed:ins">
4244        <ins xmlns="http://www.w3.org/1999/xhtml">
4245          <xsl:copy-of select="@*[namespace-uri()='']"/>
4246          <xsl:if test="not(@title) and ancestor-or-self::*[@ed:entered-by] and @datetime">
4247            <xsl:attribute name="title"><xsl:value-of select="concat(@datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
4248          </xsl:if>
4249          <xsl:apply-templates select="ed:ins/node()"/>
4250        </ins>
4251      </xsl:if>
4252    </xsl:otherwise>
4253  </xsl:choose>
4254</xsl:template>
4255
4256<!-- convenience template for helping Mozilla (pre/ins inheritance problem) -->
4257<xsl:template name="insertInsDelClass">
4258  <xsl:if test="ancestor::ed:del">
4259    <xsl:attribute name="class">del</xsl:attribute>
4260  </xsl:if>
4261  <xsl:if test="ancestor::ed:ins">
4262    <xsl:attribute name="class">ins</xsl:attribute>
4263  </xsl:if>
4264</xsl:template>
4265
4266
4267<xsl:template name="sectionnumberAndEdits">
4268  <xsl:choose>
4269    <xsl:when test="ancestor::ed:del">del-<xsl:number count="ed:del//section" level="any"/></xsl:when>
4270    <xsl:when test="@x:fixed-section-number">
4271      <xsl:value-of select="@x:fixed-section-number"/>
4272    </xsl:when>
4273    <xsl:when test="self::section and parent::ed:ins and local-name(../..)='replace'">
4274      <xsl:for-each select="../.."><xsl:call-template name="sectionnumberAndEdits"/></xsl:for-each>
4275      <xsl:for-each select="..">
4276        <xsl:if test="parent::ed:replace">
4277          <xsl:for-each select="..">
4278            <xsl:if test="parent::section">.</xsl:if>
4279            <xsl:variable name="cnt" select="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)"/>
4280            <xsl:choose>
4281              <xsl:when test="ancestor::back and not(ancestor::section)"><xsl:number format="A" value="$cnt"/></xsl:when>
4282              <xsl:otherwise><xsl:value-of select="$cnt"/></xsl:otherwise>
4283            </xsl:choose>
4284          </xsl:for-each>
4285        </xsl:if>
4286      </xsl:for-each>
4287    </xsl:when>
4288    <xsl:when test="self::section[parent::ed:ins]">
4289      <xsl:for-each select="../.."><xsl:call-template name="sectionnumberAndEdits"/></xsl:for-each>
4290      <xsl:for-each select="..">
4291        <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)"/>
4292      </xsl:for-each>
4293    </xsl:when>
4294    <xsl:when test="self::section">
4295      <xsl:for-each select=".."><xsl:call-template name="sectionnumberAndEdits"/></xsl:for-each>
4296      <xsl:if test="parent::section">.</xsl:if>
4297      <xsl:choose>
4298        <xsl:when test="parent::back">
4299          <xsl:number format="A" value="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)"/>
4300        </xsl:when>
4301        <xsl:otherwise>
4302          <xsl:number value="1+count(preceding-sibling::section|preceding-sibling::ed:ins/section|preceding-sibling::ed:replace/ed:ins/section)"/>
4303        </xsl:otherwise>
4304      </xsl:choose>
4305    </xsl:when>
4306    <xsl:when test="self::references">
4307      <xsl:choose>
4308        <xsl:when test="count(/*/back/references)+count(/*/back/ed:replace/ed:ins/references)=1"><xsl:call-template name="get-references-section-number"/></xsl:when>
4309        <xsl:otherwise><xsl:call-template name="get-references-section-number"/>.<xsl:number level="any"/></xsl:otherwise>
4310      </xsl:choose>
4311    </xsl:when>
4312    <xsl:when test="self::middle or self::back"><!-- done --></xsl:when>
4313    <xsl:otherwise>
4314      <!-- go up one level -->
4315      <xsl:for-each select=".."><xsl:call-template name="sectionnumberAndEdits"/></xsl:for-each>
4316    </xsl:otherwise>
4317  </xsl:choose>
4318</xsl:template>
4319
4320<!-- utilities for warnings -->
4321
4322<xsl:template name="warning">
4323  <xsl:param name="msg"/>
4324  <xsl:param name="msg2"/>
4325  <xsl:param name="inline"/>
4326  <xsl:if test="$inline!='no'">
4327    <div xmlns="http://www.w3.org/1999/xhtml" class="error">WARNING: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/></div>
4328  </xsl:if>
4329  <xsl:message>WARNING: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/><xsl:call-template name="lineno"/></xsl:message>
4330</xsl:template>
4331
4332<xsl:template name="error">
4333  <xsl:param name="msg"/>
4334  <xsl:param name="msg2"/>
4335  <xsl:param name="inline"/>
4336  <xsl:if test="$inline='no'">
4337    <div xmlns="http://www.w3.org/1999/xhtml" class="error">ERROR: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/></div>
4338  </xsl:if>
4339  <xsl:message>ERROR: <xsl:value-of select="$msg"/><xsl:value-of select="$msg2"/><xsl:call-template name="lineno"/></xsl:message>
4340</xsl:template>
4341
4342<!-- table formatting -->
4343
4344<xsl:template match="texttable">
4345
4346  <xsl:variable name="anch">
4347    <xsl:call-template name="get-table-anchor"/>
4348  </xsl:variable>
4349
4350  <div xmlns="http://www.w3.org/1999/xhtml" id="{$anch}">
4351    <xsl:if test="@anchor!=''">
4352      <div id="{@anchor}"/>
4353    </xsl:if>
4354    <xsl:apply-templates select="preamble"/>
4355    <xsl:variable name="style">
4356      <xsl:text>tt </xsl:text>
4357      <xsl:choose>
4358        <xsl:when test="@style!=''">
4359          <xsl:value-of select="@style"/>
4360        </xsl:when>
4361        <xsl:otherwise>full</xsl:otherwise>
4362      </xsl:choose>
4363    </xsl:variable>
4364    <table summary="{preamble}" class="{$style}" cellpadding="3" cellspacing="0">
4365      <thead>
4366        <tr>
4367          <xsl:apply-templates select="ttcol"/>
4368        </tr>
4369      </thead>
4370      <tbody>
4371        <xsl:variable name="columns" select="count(ttcol)"/>
4372        <xsl:variable name="fields" select="c | ed:replace/ed:ins/c | ed:replace/ed:del/c"/>
4373        <xsl:for-each select="$fields[(position() mod $columns) = 1]">
4374          <tr>
4375            <xsl:for-each select=". | following-sibling::c[position() &lt; $columns]">
4376              <td>
4377                <xsl:call-template name="insertInsDelClass"/>
4378                <xsl:variable name="pos" select="position()"/>
4379                <xsl:variable name="col" select="../ttcol[position() = $pos]"/>
4380                <xsl:choose>
4381                  <xsl:when test="$col/@align='right' or $col/@align='center'">
4382                    <xsl:attribute name="class"><xsl:value-of select="$col/@align"/></xsl:attribute>
4383                  </xsl:when>
4384                  <xsl:when test="$col/@align='left' or not($col/@align)">
4385                    <!-- that's the default, nothing to do here -->
4386                  </xsl:when>
4387                  <xsl:otherwise>
4388                    <xsl:message>Unknown align attribute on ttcol: <xsl:value-of select="$col/@align"/></xsl:message>
4389                  </xsl:otherwise>
4390                </xsl:choose>
4391                <xsl:apply-templates select="node()"/>
4392              </td>
4393            </xsl:for-each>
4394          </tr>
4395        </xsl:for-each>
4396      </tbody>
4397    </table>
4398    <xsl:apply-templates select="postamble"/>
4399
4400    <xsl:if test="(@title!='' or @anchor!='') and not(@suppress-title='true')">
4401      <xsl:variable name="n"><xsl:number level="any" count="texttable[(@title!='' or @anchor!='') and not(@suppress-title='true')]"/></xsl:variable>
4402      <p class="figure">Table <xsl:value-of select="$n"/><xsl:if test="@title!=''">: <xsl:value-of select="@title"/></xsl:if></p>
4403    </xsl:if>
4404  </div>
4405 
4406</xsl:template>
4407
4408<xsl:template match="ttcol">
4409  <th xmlns="http://www.w3.org/1999/xhtml">
4410   
4411    <xsl:choose>
4412      <xsl:when test="@align='right' or @align='center' or @align='left'">
4413        <xsl:attribute name="class"><xsl:value-of select="@align"/></xsl:attribute>
4414      </xsl:when>
4415      <xsl:when test="not(@align)">
4416        <!-- that's the default, nothing to do here -->
4417      </xsl:when>
4418      <xsl:otherwise>
4419        <xsl:message>Unknown align attribute on ttcol: <xsl:value-of select="@align"/></xsl:message>
4420      </xsl:otherwise>
4421    </xsl:choose>
4422   
4423    <xsl:if test="@width">
4424      <xsl:attribute name="style">width: <xsl:value-of select="@width"/>;</xsl:attribute>
4425    </xsl:if>
4426
4427    <xsl:apply-templates/>
4428  </th>
4429</xsl:template>
4430
4431<!-- cref support -->
4432
4433<xsl:template match="cref">
4434  <xsl:if test="$xml2rfc-comments!='no'">
4435    <xsl:variable name="cid">
4436      <xsl:choose>
4437        <xsl:when test="@anchor">
4438          <xsl:value-of select="@anchor"/>
4439        </xsl:when>
4440        <xsl:otherwise>
4441          <xsl:value-of select="$anchor-prefix"/>
4442          <xsl:text>.comment.</xsl:text>
4443          <xsl:number count="cref[not(@anchor)]" level="any"/>
4444        </xsl:otherwise>
4445      </xsl:choose>
4446    </xsl:variable>
4447   
4448    <span xmlns="http://www.w3.org/1999/xhtml" class="comment">
4449      <xsl:if test="$xml2rfc-inline!='yes'">
4450        <xsl:attribute name="title">
4451          <xsl:if test="@source"><xsl:value-of select="@source"/>: </xsl:if>
4452          <xsl:apply-templates select="text()|eref"/>
4453        </xsl:attribute>
4454      </xsl:if>
4455      <xsl:text>[</xsl:text>
4456      <xsl:choose>
4457        <xsl:when test="$xml2rfc-inline='yes'">
4458          <xsl:value-of select="$cid"/>
4459          <xsl:text>: </xsl:text>
4460          <xsl:apply-templates select="text()|eref"/>
4461          <xsl:if test="@source"> --<xsl:value-of select="@source"/></xsl:if>
4462        </xsl:when>
4463        <xsl:otherwise>
4464          <a href="#{$cid}">
4465            <xsl:value-of select="$cid"/>
4466          </a>
4467        </xsl:otherwise>
4468      </xsl:choose>
4469      <xsl:text>]</xsl:text>
4470    </span>
4471  </xsl:if>
4472</xsl:template>
4473
4474<xsl:template name="insertComments">
4475
4476  <xsl:call-template name="insert-conditional-hrule"/>
4477   
4478  <h1 xmlns="http://www.w3.org/1999/xhtml">
4479    <xsl:call-template name="insert-conditional-pagebreak"/>
4480    <a id="{$anchor-prefix}.comments" href="#{$anchor-prefix}.comments">Editorial Comments</a>
4481  </h1>
4482
4483  <dl xmlns="http://www.w3.org/1999/xhtml">
4484    <xsl:for-each select="//cref">
4485      <xsl:variable name="cid">
4486        <xsl:choose>
4487          <xsl:when test="@anchor">
4488            <xsl:value-of select="@anchor"/>
4489          </xsl:when>
4490          <xsl:otherwise>
4491            <xsl:value-of select="$anchor-prefix"/>
4492            <xsl:text>.comment.</xsl:text>
4493            <xsl:number count="cref[not(@anchor)]" level="any"/>
4494          </xsl:otherwise>
4495        </xsl:choose>
4496      </xsl:variable>
4497      <dt id="{$cid}">
4498        [<xsl:value-of select="$cid"/>]
4499      </dt>
4500      <dd>
4501        <xsl:value-of select="."/>
4502        <xsl:if test="@source"> --<xsl:value-of select="@source"/></xsl:if>
4503      </dd>
4504    </xsl:for-each>
4505  </dl>
4506</xsl:template>
4507
4508
4509<!-- Chapter Link Generation -->
4510
4511<xsl:template match="*" mode="links"><xsl:apply-templates mode="links"/></xsl:template>
4512<xsl:template match="text()" mode="links"/>
4513
4514<xsl:template match="/*/middle//section[not(myns:unnumbered) and not(ancestor::section)]" mode="links">
4515  <xsl:variable name="sectionNumber"><xsl:call-template name="get-section-number"/></xsl:variable>
4516  <link xmlns="http://www.w3.org/1999/xhtml" rel="Chapter" title="{$sectionNumber} {@title}" href="#{$anchor-prefix}.section.{$sectionNumber}"/>
4517  <xsl:apply-templates mode="links"/>
4518</xsl:template>
4519
4520<xsl:template match="/*/back//section[not(myns:unnumbered) and not(ancestor::section)]" mode="links">
4521  <xsl:variable name="sectionNumber"><xsl:call-template name="get-section-number"/></xsl:variable>
4522  <link xmlns="http://www.w3.org/1999/xhtml" rel="Appendix" title="{$sectionNumber} {@title}" href="#{$anchor-prefix}.section.{$sectionNumber}"/>
4523  <xsl:apply-templates mode="links"/>
4524</xsl:template>
4525
4526<xsl:template match="/*/back/references[position()=1]" mode="links">
4527  <xsl:variable name="sectionNumber"><xsl:call-template name="get-references-section-number"/></xsl:variable>
4528  <link xmlns="http://www.w3.org/1999/xhtml" rel="Chapter" href="#{$anchor-prefix}.section.{$sectionNumber}">
4529    <xsl:choose>
4530      <xsl:when test="@title and count(/*/back/references)=1">
4531        <xsl:attribute name="title">
4532          <xsl:call-template name="get-references-section-number"/>
4533          <xsl:text> </xsl:text>
4534          <xsl:value-of select="@title"/>
4535        </xsl:attribute>
4536      </xsl:when>
4537      <xsl:otherwise>
4538        <xsl:attribute name="title">
4539          <xsl:call-template name="get-references-section-number"/>
4540          <xsl:text> References</xsl:text>
4541        </xsl:attribute>
4542      </xsl:otherwise>
4543    </xsl:choose>
4544  </link>
4545</xsl:template>
4546
4547<!-- convenience templates -->
4548
4549<xsl:template name="get-author-summary">
4550  <xsl:choose>
4551    <xsl:when test="count(/rfc/front/author)=1">
4552      <xsl:value-of select="/rfc/front/author[1]/@surname"/>
4553    </xsl:when>
4554    <xsl:when test="count(/rfc/front/author)=2">
4555      <xsl:value-of select="concat(/rfc/front/author[1]/@surname,' &amp; ',/rfc/front/author[2]/@surname)"/>
4556    </xsl:when>
4557    <xsl:otherwise>
4558      <xsl:value-of select="concat(/rfc/front/author[1]/@surname,', et al.')"/>
4559    </xsl:otherwise>
4560  </xsl:choose>
4561</xsl:template>
4562
4563<xsl:template name="get-authors">
4564  <xsl:for-each select="/rfc/front/author">
4565    <xsl:value-of select="@fullname"/>
4566    <xsl:if test="position()!=last()">, </xsl:if>
4567  </xsl:for-each>
4568</xsl:template>
4569
4570<xsl:template name="get-category-long">
4571  <xsl:choose>
4572    <xsl:when test="$xml2rfc-footer"><xsl:value-of select="$xml2rfc-footer"/></xsl:when>
4573    <xsl:when test="$xml2rfc-private"/> <!-- private draft, footer not set -->
4574    <xsl:when test="/rfc/@category='bcp'">Best Current Practice</xsl:when>
4575    <xsl:when test="/rfc/@category='historic'">Historic</xsl:when>
4576    <xsl:when test="/rfc/@category='info' or not(/rfc/@category)">Informational</xsl:when>
4577    <xsl:when test="/rfc/@category='std'">Standards Track</xsl:when>
4578    <xsl:when test="/rfc/@category='exp'">Experimental</xsl:when>
4579    <xsl:otherwise>(category unknown)</xsl:otherwise>
4580  </xsl:choose>
4581</xsl:template>
4582
4583<xsl:template name="get-header-center">
4584  <xsl:choose>
4585    <xsl:when test="string-length(/rfc/front/title/@abbrev) &gt; 0">
4586      <xsl:value-of select="/rfc/front/title/@abbrev"/>
4587    </xsl:when>
4588    <xsl:otherwise>
4589      <xsl:apply-templates select="/rfc/front/title" mode="get-text-content"/>
4590    </xsl:otherwise>
4591  </xsl:choose>
4592</xsl:template>
4593
4594<xsl:template name="get-header-left">
4595  <xsl:choose>
4596    <xsl:when test="$xml2rfc-header"><xsl:value-of select="$xml2rfc-header"/></xsl:when>
4597    <xsl:when test="$xml2rfc-private"/> <!-- private draft, header not set -->
4598    <xsl:when test="/rfc/@ipr and not(/rfc/@number)">INTERNET DRAFT</xsl:when>
4599    <xsl:otherwise>RFC <xsl:value-of select="/rfc/@number"/></xsl:otherwise>
4600  </xsl:choose>
4601</xsl:template>
4602
4603<xsl:template name="get-generator">
4604  <xsl:variable name="gen">
4605    <xsl:text>http://greenbytes.de/tech/webdav/rfc2629.xslt, </xsl:text>
4606    <!-- when RCS keyword substitution in place, add version info -->
4607    <xsl:if test="contains('$Revision: 1.362 $',':')">
4608      <xsl:value-of select="concat('Revision ',normalize-space(translate(substring-after('$Revision: 1.362 $', 'Revision: '),'$','')),', ')"/>
4609    </xsl:if>
4610    <xsl:if test="contains('$Date: 2008-02-29 17:10:19 $',':')">
4611      <xsl:value-of select="concat(normalize-space(translate(substring-after('$Date: 2008-02-29 17:10:19 $', 'Date: '),'$','')),', ')"/>
4612    </xsl:if>
4613    <xsl:value-of select="concat('XSLT vendor: ',system-property('xsl:vendor'),' ',system-property('xsl:vendor-url'))"/>
4614  </xsl:variable>
4615  <xsl:value-of select="$gen"/>
4616</xsl:template>
4617
4618<xsl:template name="get-header-right">
4619  <xsl:value-of select="concat($xml2rfc-ext-pub-month, ' ', $xml2rfc-ext-pub-year)"/>
4620</xsl:template>
4621
4622<xsl:template name="get-keywords">
4623  <xsl:variable name="keyw">
4624    <xsl:for-each select="/rfc/front/keyword">
4625      <xsl:value-of select="translate(.,',',' ')"/>
4626      <xsl:if test="position()!=last()">, </xsl:if>
4627    </xsl:for-each>
4628  </xsl:variable>
4629  <xsl:value-of select="normalize-space($keyw)"/>
4630</xsl:template>
4631
4632<!-- get language from context node. nearest ancestor or return the default of "en" -->
4633<xsl:template name="get-lang">
4634  <xsl:choose>
4635    <xsl:when test="ancestor-or-self::*[@xml:lang]"><xsl:value-of select="ancestor-or-self::*/@xml:lang"/></xsl:when>
4636    <xsl:otherwise>en</xsl:otherwise>
4637  </xsl:choose>
4638</xsl:template>
4639
4640<xsl:template name="get-section-number">
4641  <xsl:variable name="hasEdits" select="count(//ed:del|//ed:ins)!=0"/>
4642  <xsl:variable name="anchor" select="@anchor"/>
4643  <xsl:choose>
4644    <xsl:when test="@x:fixed-section-number">
4645      <xsl:value-of select="@x:fixed-section-number"/>
4646    </xsl:when>
4647    <xsl:when test="$hasEdits or ancestor::*/@x:fixed-section-number">
4648      <xsl:call-template name="sectionnumberAndEdits"/>
4649    </xsl:when>
4650    <xsl:otherwise>
4651      <xsl:choose>
4652        <xsl:when test="self::references">
4653          <xsl:choose>
4654            <xsl:when test="count(/*/back/references)=1">
4655              <xsl:call-template name="get-references-section-number"/>
4656            </xsl:when>
4657            <xsl:otherwise>
4658              <xsl:call-template name="get-references-section-number"/>.<xsl:number count="references"/>
4659            </xsl:otherwise>
4660          </xsl:choose>
4661        </xsl:when>
4662        <xsl:when test="self::reference">
4663          <xsl:for-each select="parent::references">
4664            <xsl:choose>
4665              <xsl:when test="count(/*/back/references)=1">
4666                <xsl:call-template name="get-references-section-number"/>
4667              </xsl:when>
4668              <xsl:otherwise>
4669                <xsl:call-template name="get-references-section-number"/>.<xsl:number count="references"/>
4670              </xsl:otherwise>
4671            </xsl:choose>
4672          </xsl:for-each>
4673        </xsl:when>
4674        <xsl:when test="ancestor::back"><xsl:number count="section|appendix" level="multiple" format="A.1.1.1.1.1.1.1"/></xsl:when>
4675        <xsl:when test="self::appendix"><xsl:number count="appendix" level="multiple" format="A.1.1.1.1.1.1.1"/></xsl:when>
4676        <xsl:otherwise><xsl:number count="section" level="multiple"/></xsl:otherwise>
4677      </xsl:choose>
4678    </xsl:otherwise>
4679  </xsl:choose>
4680</xsl:template>
4681
4682<!-- get the section number for the references section -->
4683<xsl:template name="get-references-section-number">
4684  <xsl:value-of select="count(/rfc/middle/section) + count(/rfc/middle/ed:replace/ed:ins/section) + 1"/>
4685</xsl:template>
4686
4687<xsl:template name="emit-section-number">
4688  <xsl:param name="no"/>
4689  <xsl:value-of select="$no"/><xsl:if test="not(contains($no,'.')) or $xml2rfc-ext-sec-no-trailing-dots='yes'">.</xsl:if>
4690</xsl:template>
4691
4692<xsl:template name="get-section-type">
4693  <xsl:param name="prec"/>
4694  <xsl:choose>
4695    <xsl:when test="ancestor::back">Appendix</xsl:when>
4696    <xsl:otherwise>Section</xsl:otherwise>
4697  </xsl:choose>
4698</xsl:template>
4699
4700<xsl:template name="get-table-anchor">
4701  <xsl:value-of select="$anchor-prefix"/>
4702  <xsl:text>.table.</xsl:text>
4703  <xsl:choose>
4704    <xsl:when test="@title!='' or @anchor!=''">
4705      <xsl:number level="any" count="texttable[@title!='' or @anchor!='']"/>
4706    </xsl:when>
4707    <xsl:otherwise>
4708      <xsl:text>u.</xsl:text>
4709      <xsl:number level="any" count="texttable[not(@title!='' or @anchor!='')]"/>
4710    </xsl:otherwise>
4711  </xsl:choose>
4712</xsl:template>
4713
4714<xsl:template name="get-figure-anchor">
4715  <xsl:value-of select="$anchor-prefix"/>
4716  <xsl:text>.figure.</xsl:text>
4717  <xsl:choose>
4718    <xsl:when test="@title!='' or @anchor!=''">
4719      <xsl:number level="any" count="figure[@title!='' or @anchor!='']"/>
4720    </xsl:when>
4721    <xsl:otherwise>
4722      <xsl:text>u.</xsl:text>
4723      <xsl:number level="any" count="figure[not(@title!='' or @anchor!='')]"/>
4724    </xsl:otherwise>
4725  </xsl:choose>
4726</xsl:template>
4727
4728<!-- reformat contents of author/@initials -->
4729<xsl:template name="format-initials">
4730  <xsl:choose>
4731    <xsl:when test="string-length(@initials)=1">
4732      <xsl:value-of select="concat(@initials,'.')"/>
4733    </xsl:when>
4734    <xsl:otherwise>
4735      <xsl:value-of select="@initials"/>
4736    </xsl:otherwise>
4737  </xsl:choose>
4738</xsl:template>
4739
4740<xsl:template name="insert-conditional-pagebreak">
4741  <xsl:if test="$xml2rfc-compact!='yes'">
4742    <xsl:attribute name="class">np</xsl:attribute>
4743  </xsl:if>
4744</xsl:template>
4745
4746<xsl:template name="insert-conditional-hrule">
4747  <xsl:if test="$xml2rfc-compact!='yes'">
4748    <hr xmlns="http://www.w3.org/1999/xhtml" class="noprint"/>
4749  </xsl:if>
4750</xsl:template>
4751
4752<!-- get text content from marked-up text -->
4753
4754<xsl:template match="text()" mode="get-text-content">
4755  <xsl:value-of select="."/>
4756</xsl:template>
4757
4758<xsl:template match="*" mode="get-text-content">
4759  <xsl:apply-templates mode="get-text-content"/>
4760</xsl:template>
4761
4762<xsl:template match="ed:del" mode="get-text-content">
4763</xsl:template>
4764
4765<!-- diag support -->
4766<xsl:template name="lineno">
4767  <xsl:if test="function-available('saxon:line-number')">
4768    <xsl:if test="saxon:line-number() &gt; 0">
4769      <xsl:text> (at line </xsl:text>
4770      <xsl:value-of select="saxon:line-number()"/>
4771      <xsl:text>)</xsl:text>
4772    </xsl:if>
4773  </xsl:if>
4774</xsl:template>
4775
4776<!-- date handling -->
4777
4778<msxsl:script language="JScript" implements-prefix="date">
4779  this['year'] = function (x) {
4780    if (x) {throw "not supported"};
4781    return (new Date()).getFullYear();
4782  }
4783
4784  this['month-in-year'] = function (x) {
4785    if (x) {throw "not supported"};
4786    return 1 + (new Date()).getMonth();
4787  }
4788
4789  this['day-in-month'] = function (x) {
4790    if (x) {throw "not supported"};
4791    return (new Date()).getDate();
4792  }
4793</msxsl:script>
4794
4795<xsl:variable name="may-default-dates">
4796  <xsl:choose>
4797    <xsl:when test="function-available('date:year') and function-available('date:month-in-year') and date:day-in-month()">
4798      <xsl:variable name="year-specified" select="/rfc/front/date/@year and /rfc/front/date/@year!=''"/>
4799      <xsl:variable name="month-specified" select="/rfc/front/date/@month and /rfc/front/date/@month!=''"/>
4800      <xsl:variable name="day-specified" select="/rfc/front/date/@day and /rfc/front/date/@day!=''"/>
4801      <xsl:variable name="system-month">
4802        <xsl:call-template name="get-month-as-name">
4803          <xsl:with-param name="month" select="date:month-in-year()"/>
4804        </xsl:call-template>
4805      </xsl:variable>
4806      <xsl:choose>
4807        <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>
4808        <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>
4809        <xsl:when test="$day-specified and /rfc/front/date/@day!=date:day-in-month()">Specified day does not match system date</xsl:when>
4810        <xsl:when test="not($year-specified) and ($month-specified or $day-specified)">Can't default year when month or day is specified</xsl:when>
4811        <xsl:when test="not($month-specified) and $day-specified">Can't default month when day is specified</xsl:when>
4812        <xsl:otherwise>yes</xsl:otherwise>
4813      </xsl:choose>
4814    </xsl:when>
4815    <!-- may, but won't -->
4816    <xsl:otherwise>yes</xsl:otherwise> 
4817  </xsl:choose>
4818</xsl:variable>
4819
4820<xsl:param name="xml2rfc-ext-pub-year">
4821  <xsl:choose>
4822    <xsl:when test="/rfc/front/date/@year and /rfc/front/date/@year!=''">
4823      <xsl:value-of select="/rfc/front/date/@year"/>
4824    </xsl:when>
4825    <xsl:when test="function-available('date:year')">
4826      <xsl:if test="/rfc/front/date/@month and /rfc/front/date/@month!=''">
4827        <xsl:call-template name="error">
4828          <xsl:with-param name="msg" select="'defaulting publication year although month was specified'"/>
4829        </xsl:call-template>
4830      </xsl:if>
4831      <xsl:if test="/rfc/front/date/@day and /rfc/front/date/@day!=''">
4832        <xsl:call-template name="error">
4833          <xsl:with-param name="msg" select="'defaulting publication year although day was specified'"/>
4834        </xsl:call-template>
4835      </xsl:if>
4836      <xsl:value-of select="date:year()"/>
4837    </xsl:when>
4838    <xsl:otherwise>
4839      <xsl:call-template name="error">
4840        <xsl:with-param name="msg" select="'/rfc/front/date/@year missing (and XSLT processor cannot compute the system date)'"/>
4841      </xsl:call-template>
4842    </xsl:otherwise>
4843  </xsl:choose>
4844</xsl:param>
4845
4846<xsl:param name="xml2rfc-ext-pub-month">
4847  <xsl:choose>
4848    <xsl:when test="/rfc/front/date/@month and /rfc/front/date/@month!=''">
4849      <xsl:value-of select="/rfc/front/date/@month"/>
4850    </xsl:when>
4851    <xsl:when test="function-available('date:month-in-year') and $may-default-dates='yes'">
4852      <xsl:call-template name="get-month-as-name">
4853        <xsl:with-param name="month" select="date:month-in-year()"/>
4854      </xsl:call-template>
4855    </xsl:when>
4856    <xsl:when test="function-available('date:month-in-year') and $may-default-dates!='yes'">
4857      <xsl:call-template name="warning">
4858        <xsl:with-param name="inline" select="'no'"/>
4859        <xsl:with-param name="msg" select="$may-default-dates"/>
4860      </xsl:call-template>
4861    </xsl:when>
4862    <xsl:otherwise>
4863      <xsl:call-template name="error">
4864        <xsl:with-param name="msg" select="'/rfc/front/date/@month missing (and XSLT processor cannot compute the system date)'"/>
4865      </xsl:call-template>
4866    </xsl:otherwise>
4867  </xsl:choose>
4868</xsl:param>
4869
4870<xsl:param name="xml2rfc-ext-pub-month-numeric">
4871  <xsl:call-template name="get-month-as-num">
4872    <xsl:with-param name="month" select="$xml2rfc-ext-pub-month"/>
4873  </xsl:call-template>
4874</xsl:param>
4875
4876<xsl:param name="xml2rfc-ext-pub-day">
4877  <xsl:choose>
4878    <xsl:when test="/rfc/front/date/@day and /rfc/front/date/@day!=''">
4879      <xsl:value-of select="/rfc/front/date/@day"/>
4880    </xsl:when>
4881    <xsl:when test="function-available('date:day-in-month') and $may-default-dates='yes'">
4882      <xsl:value-of select="date:day-in-month()"/>
4883    </xsl:when>
4884    <xsl:otherwise/> <!-- harmless, we just don't have it -->
4885  </xsl:choose>
4886</xsl:param>
4887
4888</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.