source: rfc2629xslt/rfc2629toXHTML.xslt @ 272

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

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

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