source: rfc2629xslt/rfc2629toXHTML.xslt @ 599

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

Update to latest version of rfc2629.xslt, bump up document dates.

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