source: rfc2629xslt/rfc2629toXHTML.xslt @ 573

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

update to latest version of rfc2629.xslt; bump up document dates

  • Property svn:eol-style set to native
File size: 211.1 KB
RevLine 
[6]1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!--Auto-generated from rfc2629.xslt through HTMLtoXHTML.xslt-->
[440]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">
[6]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
[440]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
[6]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 
[227]121<xsl:param name="xml2rfc-linkmailto" select="substring-after(        translate(/processing-instruction('rfc')[contains(.,'linkmailto=')], concat($quote-chars,' '), ''),          'linkmailto=')"/> 
[6]122
123
124<!-- iprnotified switch --> 
125 
[227]126<xsl:param name="xml2rfc-iprnotified" select="substring-after(        translate(/processing-instruction('rfc')[contains(.,'iprnotified=')], concat($quote-chars,' '), ''),          'iprnotified=')"/> 
[6]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="''"/>
[440]137<xsl:param name="rfcUrlFragSection" select="'section-'"/>
138<xsl:param name="rfcUrlFragAppendix" select="'appendix-'"/>
[6]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
[272]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
[6]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
[227]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)     )   )"/>
[6]178
[230]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)     )   )"/>
[227]180
[446]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'   )"/>
[440]182
[446]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
[227]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
[440]190<xsl:variable name="no-funding" select="$ipr-2007-08"/>
[227]191
[440]192<xsl:variable name="no-copylong" select="$ipr-2008-11"/>
193
[6]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         
[272]197<!-- does the document contain edits? -->
198<xsl:variable name="has-edits" select="//ed:ins | //ed:del | //ed:replace"/>
199
[6]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>
[440]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'">
[6]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]329    <xsl:with-param name="indent"><xsl:value-of select="string-length(@x:indent-with)"/></xsl:with-param>
[6]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"/>
[329]349  <xsl:param name="indent"/>
[6]350  <xsl:choose>
351    <xsl:when test="not(contains($content,'&#xA;'))">
[329]352      <xsl:if test="string-length($content) &gt; 69 + $indent">
[227]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>
[6]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;')"/> 
[329]362      <xsl:if test="string-length($start) &gt; 69 + $indent">
[227]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>
[6]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">
[329]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>
[6]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>
[272]468      <xsl:for-each select="address/email">
469        <xsl:variable name="email">
470          <xsl:call-template name="extract-email"/>
471        </xsl:variable>
472       
[6]473        <span class="vcardline">
[440]474          <xsl:choose>
475            <xsl:when test="$xml2rfc-rfcedstyle='yes'">Email: </xsl:when>
476            <xsl:otherwise>EMail: </xsl:otherwise>
477          </xsl:choose>
[272]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>
[6]484        </span>
[272]485      </xsl:for-each>
[285]486      <xsl:for-each select="address/uri">
487        <xsl:variable name="uri">
488          <xsl:call-template name="extract-uri"/>
489        </xsl:variable>
490
[6]491        <span class="vcardline">
492          <xsl:text>URI: </xsl:text>
[285]493          <a href="{$uri}" class="url"><xsl:value-of select="$uri"/></a>
[6]494        </span>
[285]495      </xsl:for-each>
[6]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>
[118]535        <xsl:call-template name="error">
536          <xsl:with-param name="msg" select="$node-set-warning"/>
537        </xsl:call-template>
[6]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!=''">
[329]561    <xsl:call-template name="check-anchor"/>
[6]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/>
[189]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>
[6]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>
[118]600          <xsl:call-template name="error">
601            <xsl:with-param name="msg" select="$node-set-warning"/>
602          </xsl:call-template>
[6]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 -->
[329]610
[6]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   
[440]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'"/>
[446]637    <xsl:when test="/rfc/@ipr = 'noDerivativeWorksNow'"/>
[440]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'"/>
[446]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'"/>
[440]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
[6]659  <xsl:if test="not($xml2rfc-private)">
[440]660 
[6]661    <!-- Get status info formatted as per RFC2629-->
[440]662    <xsl:variable name="preamble">
663      <xsl:call-template name="insertPreamble"/>
664    </xsl:variable>
[6]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>
[118]672        <xsl:call-template name="error">
673          <xsl:with-param name="msg" select="$node-set-warning"/>
674        </xsl:call-template>
[6]675      </xsl:otherwise>
676    </xsl:choose>
677  </xsl:if>
[446]678 
679  <xsl:apply-templates select="x:boilerplate"/>
[6]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>
[566]696    <xsl:when test="parent::figure">
697      <div xmlns="http://www.w3.org/1999/xhtml" id="{$anchor}"/>
698    </xsl:when>
[571]699    <xsl:when test="ancestor::t or ancestor::artwork or ancestor::preamble or ancestor::postamble">
[6]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
[189]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
[6]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">
[329]800    <xsl:call-template name="copy-anchor"/>
[6]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">
[329]808    <xsl:call-template name="copy-anchor"/>
[6]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">
[329]815    <xsl:call-template name="copy-anchor"/>
[6]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">
[329]827      <xsl:call-template name="copy-anchor"/>
[6]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">
[329]853      <xsl:call-template name="copy-anchor"/>
[6]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">
[329]899    <xsl:call-template name="copy-anchor"/>
[6]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">
[329]943      <xsl:call-template name="copy-anchor"/>
[6]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)"/>
[440]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>
[6]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"/>
[272]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>
[6]1026  </xsl:if>
1027
[329]1028  <xsl:call-template name="check-anchor"/>
1029
[6]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">
[446]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>
[6]1138        </xsl:when>
1139        <xsl:otherwise>
[446]1140          <xsl:text>&#8220;</xsl:text>
1141          <xsl:value-of select="normalize-space(front/title)"/>
1142          <xsl:text>&#8221;</xsl:text>
[6]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 != '' and front/date/@year != '???'">
1159        <xsl:text>, </xsl:text>
[227]1160        <xsl:if test="front/date/@month!=''"><xsl:value-of select="front/date/@month"/> </xsl:if>
[6]1161        <xsl:value-of select="front/date/@year"/>
1162      </xsl:if>
1163     
1164      <xsl:if test="@target">
1165        <xsl:text>, &lt;</xsl:text>
1166        <a href="{@target}"><xsl:value-of select="@target"/></a>
1167        <xsl:text>&gt;</xsl:text>
1168      </xsl:if>
1169     
1170      <xsl:text>.</xsl:text>
1171
1172      <xsl:for-each select="annotation">
1173        <br/>
1174        <xsl:apply-templates/>
1175      </xsl:for-each>
1176
1177    </td>
1178  </tr>
1179 
1180 
1181</xsl:template>
1182
1183
1184<xsl:template match="references">
1185
1186  <xsl:variable name="name">
1187    <xsl:if test="ancestor::ed:del">
1188      <xsl:text>del-</xsl:text>
1189    </xsl:if>
1190    <xsl:number level="any"/>     
1191  </xsl:variable>
1192 
1193  <xsl:variable name="refseccount" select="count(/rfc/back/references)+count(/rfc/back/ed:replace/ed:ins/references)"/>
1194
1195  <!-- insert pseudo section when needed -->
1196  <xsl:if test="not(preceding::references) and $refseccount!=1">
1197    <xsl:call-template name="insert-conditional-hrule"/>
1198    <h1 xmlns="http://www.w3.org/1999/xhtml" id="{$anchor-prefix}.references">
1199      <xsl:call-template name="insert-conditional-pagebreak"/>
1200      <xsl:variable name="sectionNumber">
1201        <xsl:call-template name="get-references-section-number"/>
1202      </xsl:variable>
1203      <a id="{$anchor-prefix}.section.{$sectionNumber}" href="#{$anchor-prefix}.section.{$sectionNumber}">
1204        <xsl:call-template name="emit-section-number">
1205          <xsl:with-param name="no" select="$sectionNumber"/>
1206        </xsl:call-template>
1207      </a>
1208      <xsl:text> References</xsl:text>
1209    </h1>
1210  </xsl:if>
1211 
1212  <xsl:variable name="elemtype">
1213    <xsl:choose>
1214      <xsl:when test="$refseccount!=1">h2</xsl:when>
1215      <xsl:otherwise>h1</xsl:otherwise>
1216    </xsl:choose>
1217  </xsl:variable>
1218 
1219  <xsl:variable name="title">
1220    <xsl:choose>
1221      <xsl:when test="not(@title) or @title=''">References</xsl:when>
1222      <xsl:otherwise><xsl:value-of select="@title"/></xsl:otherwise>
1223    </xsl:choose>
1224  </xsl:variable>
1225 
1226  <xsl:element namespace="http://www.w3.org/1999/xhtml" name="{$elemtype}"> 
1227    <xsl:if test="$name='1'">
1228      <xsl:call-template name="insert-conditional-pagebreak"/>
1229    </xsl:if>
1230    <xsl:variable name="sectionNumber">
1231      <xsl:call-template name="get-section-number"/>
1232    </xsl:variable>
1233    <xsl:variable name="anchorpref">
1234      <xsl:choose>
1235        <xsl:when test="$elemtype='h1'"/>
1236        <xsl:otherwise>.<xsl:value-of select="$name"/></xsl:otherwise>
1237      </xsl:choose>
1238    </xsl:variable>
1239    <xsl:attribute name="id"><xsl:value-of select="concat($anchor-prefix,'.references',$anchorpref)"/></xsl:attribute>
1240    <a xmlns="http://www.w3.org/1999/xhtml" href="#{$anchor-prefix}.section.{$sectionNumber}" id="{$anchor-prefix}.section.{$sectionNumber}">
1241      <xsl:call-template name="emit-section-number">
1242        <xsl:with-param name="no" select="$sectionNumber"/>
1243      </xsl:call-template>
1244    </a>
1245    <xsl:text> </xsl:text>
1246    <xsl:value-of select="$title"/>
1247  </xsl:element>
1248 
1249  <table xmlns="http://www.w3.org/1999/xhtml" summary="{$title}">
1250    <xsl:choose>
1251      <xsl:when test="$xml2rfc-sortrefs='yes' and $xml2rfc-symrefs!='no'">
1252        <xsl:apply-templates>
1253          <xsl:sort select="@anchor|.//ed:ins//reference/@anchor"/>
1254        </xsl:apply-templates>
1255      </xsl:when>
1256      <xsl:otherwise>
1257        <xsl:apply-templates/>
1258      </xsl:otherwise>
1259    </xsl:choose>
1260  </table>
1261
1262</xsl:template>
1263
1264<xsl:template match="rfc">
1265 
1266  <!-- conformance checks -->
1267  <xsl:if test="$xml2rfc-symrefs!='no' and $xml2rfc-symrefs!='yes' and //reference">
[272]1268    <xsl:call-template name="warning">
1269      <xsl:with-param name="inline" select="'no'"/>
1270      <xsl:with-param name="msg">symrefs PI not specified; default has changed from 'no' to 'yes'.</xsl:with-param>
1271    </xsl:call-template>
[6]1272  </xsl:if>
1273 
1274  <xsl:variable name="lang">
1275    <xsl:call-template name="get-lang"/>
1276  </xsl:variable>
1277
[329]1278  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{$lang}">
[573]1279    <head>
1280      <xsl:attribute name="profile">
1281        <xsl:text>http://www.w3.org/2006/03/hcard</xsl:text>
1282        <xsl:if test="$xml2rfc-ext-support-rfc2731!='no'">
1283          <xsl:text> </xsl:text>
1284          <xsl:text>http://dublincore.org/documents/2008/08/04/dc-html/</xsl:text>
1285        </xsl:if>
1286      </xsl:attribute>
[6]1287      <title>
1288        <xsl:apply-templates select="front/title" mode="get-text-content"/>
1289      </title>
1290      <style type="text/css" title="Xml2Rfc (sans serif)">
1291        <xsl:call-template name="insertCss"/>
1292      </style>
1293      <!-- <link rel="alternate stylesheet" type="text/css" media="screen" title="Plain (typewriter)" href="rfc2629tty.css" /> -->
1294           
1295      <!-- link elements -->
1296      <xsl:if test="$xml2rfc-toc='yes'">
1297        <link rel="Contents" href="#{$anchor-prefix}.toc"/>
1298      </xsl:if>
1299      <link rel="Author" href="#{$anchor-prefix}.authors"/>
1300      <xsl:if test="not($xml2rfc-private)">
1301        <link rel="Copyright" href="#{$anchor-prefix}.copyright"/>
1302      </xsl:if>
1303      <xsl:if test="$has-index">
1304        <link rel="Index" href="#{$anchor-prefix}.index"/>
1305      </xsl:if>
1306      <xsl:apply-templates select="/" mode="links"/>
1307      <xsl:for-each select="/rfc/x:link">
1308        <link><xsl:copy-of select="@*"/></link>
1309      </xsl:for-each>
1310      <xsl:if test="/rfc/@number">
[329]1311        <xsl:variable name="number">
1312          <xsl:choose>
1313            <xsl:when test="string-length(/rfc/@number) &lt; 2">000<xsl:value-of select="/rfc/@number"/></xsl:when>
1314            <xsl:when test="string-length(/rfc/@number) &lt; 3">00<xsl:value-of select="/rfc/@number"/></xsl:when>
1315            <xsl:when test="string-length(/rfc/@number) &lt; 4">0<xsl:value-of select="/rfc/@number"/></xsl:when>
1316            <xsl:otherwise><xsl:value-of select="/rfc/@number"/></xsl:otherwise>
1317          </xsl:choose>
1318        </xsl:variable>
1319        <link rel="Alternate" title="Authorative ASCII Version" href="http://www.ietf.org/rfc/rfc{/rfc/@number}.txt"/>
1320        <link rel="Help" title="Additional Information on tools.ietf.org" href="http://tools.ietf.org/html/rfc{$number}"/>
[6]1321      </xsl:if>
1322
1323      <!-- generator -->
1324      <xsl:variable name="gen">
1325        <xsl:call-template name="get-generator"/>
1326      </xsl:variable>
1327      <meta name="generator" content="{$gen}"/>
1328     
1329      <!-- keywords -->
1330      <xsl:if test="front/keyword">
1331        <xsl:variable name="keyw">
1332          <xsl:call-template name="get-keywords"/>
1333        </xsl:variable>
1334        <meta name="keywords" content="{$keyw}"/>
1335      </xsl:if>
1336
1337      <xsl:if test="$xml2rfc-ext-support-rfc2731!='no'">
1338        <!-- Dublin Core Metadata -->
1339        <link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"/>
1340             
1341        <!-- DC creator, see RFC2731 -->
1342        <xsl:for-each select="/rfc/front/author">
1343          <xsl:variable name="initials">
1344            <xsl:call-template name="format-initials"/>
1345          </xsl:variable>
1346          <meta name="DC.Creator" content="{concat(@surname,', ',$initials)}"/>
1347        </xsl:for-each>
1348       
1349        <xsl:if test="not($xml2rfc-private)">
1350          <xsl:choose>
1351            <xsl:when test="/rfc/@number">
1352              <meta name="DC.Identifier" content="urn:ietf:rfc:{/rfc/@number}"/>
1353            </xsl:when>
1354            <xsl:when test="/rfc/@docName">
1355              <meta name="DC.Identifier" content="urn:ietf:id:{/rfc/@docName}"/>
1356            </xsl:when>
1357            <xsl:otherwise/>
1358          </xsl:choose>
[227]1359          <meta name="DC.Date.Issued" scheme="ISO8601" content="{$xml2rfc-ext-pub-year}-{$xml2rfc-ext-pub-month-numeric}"/>
[6]1360 
1361          <xsl:if test="/rfc/@obsoletes!=''">
1362            <xsl:call-template name="rfclist-for-dcmeta">
1363              <xsl:with-param name="list" select="/rfc/@obsoletes"/>
1364            </xsl:call-template>
1365          </xsl:if>
1366        </xsl:if>
1367 
1368        <xsl:if test="/rfc/front/abstract">
1369          <meta name="DC.Description.Abstract" content="{normalize-space(/rfc/front/abstract)}"/>
1370        </xsl:if>     
1371      </xsl:if>     
1372    </head>
1373    <body>
1374      <!-- insert diagnostics -->
1375      <xsl:call-template name="insert-diagnostics"/>
1376
1377      <xsl:apply-templates select="front"/>
1378      <xsl:apply-templates select="middle"/>
1379      <xsl:apply-templates select="back"/>
1380    </body>
1381  </html>
1382</xsl:template>               
1383
1384
1385<xsl:template match="t">
1386  <xsl:if test="preceding-sibling::section or preceding-sibling::appendix">
1387    <xsl:call-template name="warning">
1388      <xsl:with-param name="msg">The paragraph below is misplaced; maybe a section is closed in the wrong place: </xsl:with-param>
1389      <xsl:with-param name="msg2"><xsl:value-of select="."/></xsl:with-param>
1390    </xsl:call-template>
1391  </xsl:if>
1392  <xsl:choose>
1393    <xsl:when test="@anchor">
1394      <div xmlns="http://www.w3.org/1999/xhtml" id="{@anchor}"><xsl:apply-templates mode="t-content" select="node()[1]"/></div>
1395    </xsl:when>
1396    <xsl:otherwise>
1397      <xsl:apply-templates mode="t-content" select="node()[1]"/>
1398    </xsl:otherwise>
1399  </xsl:choose>
1400</xsl:template>
1401
1402<!-- for t-content, dispatch to default templates if it's block-level content -->
1403<xsl:template mode="t-content" match="list|figure|texttable">
1404  <!-- <xsl:comment>t-content block-level</xsl:comment>  -->
1405  <xsl:apply-templates select="."/>
1406  <xsl:apply-templates select="following-sibling::node()[1]" mode="t-content"/>
1407</xsl:template>               
1408               
1409<!-- ... otherwise group into p elements -->
1410<xsl:template mode="t-content" match="*|node()">
1411  <xsl:variable name="p">
1412    <xsl:call-template name="get-paragraph-number"/>
1413  </xsl:variable>
1414
1415  <!-- do not open a new p element if this is a whitespace-only text node and no siblings follow --> 
1416  <xsl:if test="not(self::text() and normalize-space(.)='' and not(following-sibling::node()))">
1417    <p xmlns="http://www.w3.org/1999/xhtml">
1418      <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">
1419        <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$p"/></xsl:attribute>
1420      </xsl:if>
1421      <xsl:call-template name="insertInsDelClass"/>
1422      <xsl:call-template name="editingMark"/>
1423      <xsl:apply-templates mode="t-content2" select="."/>
1424    </p>
1425  </xsl:if>
1426  <xsl:apply-templates mode="t-content" select="following-sibling::*[self::list or self::figure or self::texttable][1]"/>
1427</xsl:template>               
1428               
1429<xsl:template mode="t-content2" match="*">
1430  <xsl:apply-templates select="."/>
1431  <xsl:if test="not(following-sibling::node()[1] [self::list or self::figure or self::texttable])">
1432    <xsl:apply-templates select="following-sibling::node()[1]" mode="t-content2"/>
1433  </xsl:if>
1434</xsl:template>       
1435
1436<xsl:template mode="t-content2" match="text()">
1437  <xsl:apply-templates select="."/>
1438  <xsl:if test="not(following-sibling::node()[1] [self::list or self::figure or self::texttable])">
1439    <xsl:apply-templates select="following-sibling::node()[1]" mode="t-content2"/>
1440  </xsl:if>
1441</xsl:template>               
1442
[545]1443<xsl:template mode="t-content2" match="comment()|processing-instruction()">
[329]1444  <xsl:apply-templates select="."/>
1445  <xsl:if test="not(following-sibling::node()[1] [self::list or self::figure or self::texttable])">
1446    <xsl:apply-templates select="following-sibling::node()[1]" mode="t-content2"/>
1447  </xsl:if>
1448</xsl:template>               
1449
[6]1450<xsl:template match="title">
[329]1451  <xsl:if test="@abbrev and string-length(@abbrev) &gt; 40">
1452    <xsl:call-template name="warning">
1453      <xsl:with-param name="inline" select="'no'"/>
1454      <xsl:with-param name="msg">title/@abbrev too long (max 40 characters)</xsl:with-param>
1455    </xsl:call-template>
1456  </xsl:if>
1457
1458  <xsl:if test="string-length(.) &gt; 40 and (not(@abbrev) or @abbrev='')">
1459    <xsl:call-template name="warning">
1460      <xsl:with-param name="inline" select="'no'"/>
1461      <xsl:with-param name="msg">title too long, should supply title/@abbrev attribute with less than 40 characters</xsl:with-param>
1462    </xsl:call-template>
1463  </xsl:if>
1464
[6]1465  <xsl:apply-templates/>
1466</xsl:template>
1467
1468<xsl:template name="insertTitle">
1469  <xsl:choose>
1470    <xsl:when test="@ed:old-title">
1471      <del xmlns="http://www.w3.org/1999/xhtml">
1472        <xsl:if test="ancestor-or-self::*[@ed:entered-by] and @ed:datetime">
1473          <xsl:attribute name="title"><xsl:value-of select="concat(@ed:datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
1474        </xsl:if>
1475        <xsl:value-of select="@ed:old-title"/>
1476      </del>
1477      <ins xmlns="http://www.w3.org/1999/xhtml">
1478        <xsl:if test="ancestor-or-self::*[@ed:entered-by] and @ed:datetime">
1479          <xsl:attribute name="title"><xsl:value-of select="concat(@ed:datetime,', ',ancestor-or-self::*[@ed:entered-by][1]/@ed:entered-by)"/></xsl:attribute>
1480        </xsl:if>
1481        <xsl:value-of select="@title"/>
1482      </ins>
1483    </xsl:when>
1484    <xsl:otherwise>
1485      <xsl:value-of select="@title"/>
1486    </xsl:otherwise>
1487  </xsl:choose>
1488</xsl:template>
1489
1490<xsl:template match="section|appendix">
1491
[230]1492  <xsl:if test="self::appendix">
1493    <xsl:call-template name="warning">
1494      <xsl:with-param name="inline" select="'no'"/>
1495      <xsl:with-param name="msg">The "appendix" element is deprecated, use "section" inside "back" instead.</xsl:with-param>
1496    </xsl:call-template>
1497  </xsl:if>
1498
[6]1499  <xsl:variable name="sectionNumber">
1500    <xsl:choose>
1501      <xsl:when test="@myns:unnumbered"/>
[446]1502      <xsl:when test="ancestor::x:boilerplate"/>
[6]1503      <xsl:otherwise><xsl:call-template name="get-section-number"/></xsl:otherwise>
1504    </xsl:choose>
1505  </xsl:variable>
1506   
[446]1507  <xsl:if test="not(ancestor::section) and not(ancestor::x:boilerplate) and not(@myns:notoclink)">
[6]1508    <xsl:call-template name="insert-conditional-hrule"/>
1509  </xsl:if>
1510 
1511  <xsl:variable name="elemtype">
1512    <xsl:choose>
[446]1513      <xsl:when test="count(ancestor::section) &lt;= 4">h<xsl:value-of select="1 + count(ancestor::section)"/></xsl:when>
1514      <xsl:otherwise>h6</xsl:otherwise>
[6]1515    </xsl:choose>
1516  </xsl:variable>
1517 
1518  <!-- process irefs immediadetely following the section so that their anchor
1519  actually is the section heading -->
1520  <xsl:apply-templates select="iref[count(preceding-sibling::*[not(self::iref)])=0]"/>
1521
1522  <xsl:element namespace="http://www.w3.org/1999/xhtml" name="{$elemtype}">
1523    <xsl:if test="$sectionNumber!=''">
1524      <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$sectionNumber"/></xsl:attribute>
1525    </xsl:if>
1526    <xsl:choose>
1527      <xsl:when test="$sectionNumber='1'">
1528        <!-- pagebreak, this the first section -->
1529        <xsl:attribute name="class">np</xsl:attribute>
1530      </xsl:when>
1531      <xsl:when test="not(ancestor::section) and not(@myns:notoclink)">
1532        <xsl:call-template name="insert-conditional-pagebreak"/>
1533      </xsl:when>
1534      <xsl:otherwise/>
1535    </xsl:choose>
1536   
1537    <xsl:call-template name="insertInsDelClass"/>
1538       
1539    <xsl:if test="$sectionNumber!=''">
1540      <a xmlns="http://www.w3.org/1999/xhtml" href="#{$anchor-prefix}.section.{$sectionNumber}">
1541        <xsl:call-template name="emit-section-number">
1542          <xsl:with-param name="no" select="$sectionNumber"/>
1543        </xsl:call-template>
1544      </a>
1545      <xsl:text> </xsl:text>
1546    </xsl:if>
1547   
1548    <!-- issue tracking? -->
1549    <xsl:if test="@ed:resolves">
1550      <xsl:call-template name="insert-issue-pointer"/>
1551    </xsl:if>
1552   
1553    <xsl:choose>
1554      <xsl:when test="@anchor">
[329]1555        <xsl:call-template name="check-anchor"/>
[6]1556        <a xmlns="http://www.w3.org/1999/xhtml" id="{@anchor}" href="#{@anchor}"><xsl:call-template name="insertTitle"/></a>
1557      </xsl:when>
1558      <xsl:otherwise>
1559        <xsl:call-template name="insertTitle"/>
1560      </xsl:otherwise>
1561    </xsl:choose>
1562  </xsl:element>
1563  <!-- continue with all child elements but the irefs processed above -->
1564  <xsl:apply-templates select="*[not(self::iref)]|iref[count(preceding-sibling::*[not(self::iref)])!=0]"/>
1565</xsl:template>
1566
1567<xsl:template match="spanx[@style='emph' or not(@style)]">
1568  <em xmlns="http://www.w3.org/1999/xhtml">
[329]1569    <xsl:call-template name="copy-anchor"/>
[6]1570    <xsl:apply-templates/>
1571  </em>
1572</xsl:template>
1573
1574<xsl:template match="spanx[@style='verb']">
1575  <samp xmlns="http://www.w3.org/1999/xhtml">
[329]1576    <xsl:call-template name="copy-anchor"/>
[6]1577    <xsl:apply-templates/>
1578  </samp>
1579</xsl:template>
1580
1581<xsl:template match="spanx[@style='strong']">
1582  <strong xmlns="http://www.w3.org/1999/xhtml">
[329]1583    <xsl:call-template name="copy-anchor"/>
[6]1584    <xsl:apply-templates/>
1585  </strong>
1586</xsl:template>
1587
1588<xsl:template name="insert-blank-lines">
1589  <xsl:param name="no"/>
1590  <xsl:choose>
1591    <xsl:when test="$no &lt;= 0">
1592      <br xmlns="http://www.w3.org/1999/xhtml"/>
1593      <!-- done -->
1594    </xsl:when>
1595    <xsl:otherwise>
1596      <br xmlns="http://www.w3.org/1999/xhtml"/>
1597      <xsl:call-template name="insert-blank-lines">
1598        <xsl:with-param name="no" select="$no - 1"/>
1599      </xsl:call-template>
1600    </xsl:otherwise>
1601  </xsl:choose>
1602</xsl:template>
1603
1604<xsl:template match="vspace[not(@blankLines)]">
1605  <br xmlns="http://www.w3.org/1999/xhtml"/>
1606</xsl:template>
1607
1608<xsl:template match="vspace">
1609  <xsl:call-template name="insert-blank-lines">
1610    <xsl:with-param name="no" select="@blankLines"/>
1611  </xsl:call-template>
1612</xsl:template>
1613
1614<!-- keep the root for the case when we process XSLT-inline markup -->
1615<xsl:variable name="src" select="/"/>
1616
1617<xsl:template name="render-section-ref">
1618  <xsl:param name="from"/>
1619  <xsl:param name="to"/>
1620
1621  <xsl:variable name="refname">
1622    <xsl:for-each select="$to">
1623      <xsl:call-template name="get-section-type">
1624        <xsl:with-param name="prec" select="$from/preceding-sibling::node()[1]"/>
1625      </xsl:call-template>
1626    </xsl:for-each>
1627  </xsl:variable>
1628  <xsl:variable name="refnum">
1629    <xsl:for-each select="$to">
1630      <xsl:call-template name="get-section-number"/>
1631    </xsl:for-each>
1632  </xsl:variable>
1633  <xsl:attribute name="title">
1634    <xsl:value-of select="$to/@title"/>
1635  </xsl:attribute>
1636  <xsl:choose>
1637    <xsl:when test="@format='counter'">
1638      <xsl:value-of select="$refnum"/>
1639    </xsl:when>
1640    <xsl:when test="@format='title'">
1641      <xsl:value-of select="$to/@title"/>
1642    </xsl:when>
1643    <xsl:otherwise>
1644      <xsl:value-of select="normalize-space(concat($refname,' ',$refnum))"/>
1645    </xsl:otherwise>
1646  </xsl:choose>
1647</xsl:template>
1648
1649<xsl:template match="xref[node()]">
1650
1651  <xsl:variable name="target" select="@target"/>
[272]1652  <xsl:variable name="node" select="key('anchor-item',$target)"/>
[6]1653  <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>
1654
1655  <xsl:choose>
1656
1657    <!-- x:fmt='none': do not generate any links -->
1658    <xsl:when test="@x:fmt='none'">
1659      <xsl:choose>
[440]1660        <xsl:when test="$node/self::reference">
[6]1661          <cite xmlns="http://www.w3.org/1999/xhtml" title="{normalize-space($node/front/title)}">
1662            <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
1663              <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1664            </xsl:if>
1665            <!-- insert id when a backlink to this xref is needed in the index -->
1666            <xsl:if test="//iref[@x:for-anchor=$target] | //iref[@x:for-anchor='' and ../@anchor=$target]">
1667              <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1668            </xsl:if>
1669            <xsl:apply-templates/>
1670          </cite>
1671        </xsl:when>
1672        <xsl:otherwise>
1673          <xsl:apply-templates/>
1674        </xsl:otherwise>
1675      </xsl:choose>
1676    </xsl:when>
1677 
1678    <!-- Other x:fmt values than "none": unsupported -->
1679    <xsl:when test="@x:fmt and @x:fmt!='none'">
[118]1680      <xsl:call-template name="error">
1681        <xsl:with-param name="msg" select="concat('unknown xref/@x:fmt extension: ',@x:fmt)"/>
1682      </xsl:call-template>
[6]1683    </xsl:when>
1684
1685    <!-- Section links -->
[440]1686    <xsl:when test="$node/self::section or $node/self::appendix">
[6]1687      <xsl:apply-templates/>
1688      <xsl:text> (</xsl:text>
1689      <a xmlns="http://www.w3.org/1999/xhtml" href="#{@target}">
1690        <!-- insert id when a backlink to this xref is needed in the index -->
1691        <xsl:if test="//iref[@x:for-anchor=$target] | //iref[@x:for-anchor='' and ../@anchor=$target]">
1692          <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1693        </xsl:if>
1694        <xsl:call-template name="render-section-ref">
1695          <xsl:with-param name="from" select="."/>
1696          <xsl:with-param name="to" select="$node"/>
1697        </xsl:call-template>
1698      </a>
1699      <xsl:text>)</xsl:text>
1700    </xsl:when>
1701
1702    <xsl:otherwise>
1703      <a xmlns="http://www.w3.org/1999/xhtml" href="#{$target}"><xsl:apply-templates/></a>
[329]1704      <xsl:if test="not(@format='none')">
1705        <xsl:for-each select="$src/rfc/back/references//reference[@anchor=$target]">
1706          <xsl:text> </xsl:text>
1707          <cite xmlns="http://www.w3.org/1999/xhtml" title="{normalize-space(front/title)}">
1708            <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
1709              <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1710            </xsl:if>
1711            <xsl:call-template name="referencename">
1712               <xsl:with-param name="node" select="."/>
1713            </xsl:call-template>
1714          </cite>
1715        </xsl:for-each>
1716      </xsl:if>
[6]1717    </xsl:otherwise>
1718  </xsl:choose>
1719
1720</xsl:template>
1721               
[272]1722<xsl:key name="iref-xanch" match="iref[@x:for-anchor]" use="@x:for-anchor"/>           
1723               
[6]1724<xsl:template match="xref[not(node())]">
1725
1726  <xsl:variable name="target" select="@target"/>
1727  <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>
[272]1728  <xsl:variable name="node" select="key('anchor-item',$target)"/>
[6]1729  <xsl:if test="count($node)=0 and not(ancestor::ed:del)">
[118]1730    <xsl:call-template name="error">
1731      <xsl:with-param name="msg" select="concat('Undefined target: ',@target)"/>
1732    </xsl:call-template>
[6]1733  </xsl:if>
1734
1735  <xsl:choose>
1736 
1737    <!-- Section links -->
[440]1738    <xsl:when test="$node/self::section or $node/self::appendix">
[6]1739      <a xmlns="http://www.w3.org/1999/xhtml" href="#{@target}">
1740        <!-- insert id when a backlink to this xref is needed in the index -->
[272]1741        <xsl:if test="key('iref-xanch',$target) | key('iref-xanch','')[../@anchor=$target]">
[6]1742          <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1743        </xsl:if>
1744        <xsl:call-template name="render-section-ref">
1745          <xsl:with-param name="from" select="."/>
1746          <xsl:with-param name="to" select="$node"/>
1747        </xsl:call-template>
1748      </a>
1749    </xsl:when>
1750
1751    <!-- Figure links -->
[440]1752    <xsl:when test="$node/self::figure">
[6]1753      <a xmlns="http://www.w3.org/1999/xhtml" href="#{$target}">
1754        <xsl:variable name="figcnt">
1755          <xsl:for-each select="$node">
[189]1756            <xsl:number level="any" count="figure[(@title!='' or @anchor!='') and not(@suppress-title='true')]"/>
[6]1757          </xsl:for-each>
1758        </xsl:variable>
1759        <xsl:choose>
1760          <xsl:when test="@format='counter'">
1761            <xsl:value-of select="$figcnt"/>
1762          </xsl:when>
1763          <xsl:when test="@format='title'">
1764            <xsl:value-of select="$node/@title"/>
1765          </xsl:when>
1766          <xsl:otherwise>
1767            <xsl:value-of select="normalize-space(concat('Figure ',$figcnt))"/>
1768          </xsl:otherwise>
1769        </xsl:choose>
1770      </a>
1771    </xsl:when>
1772   
1773    <!-- Table links -->
[440]1774    <xsl:when test="$node/self::texttable">
[6]1775      <a xmlns="http://www.w3.org/1999/xhtml" href="#{$target}">
1776        <xsl:variable name="tabcnt">
1777          <xsl:for-each select="$node">
[189]1778            <xsl:number level="any" count="texttable[(@title!='' or @anchor!='') and not(@suppress-title='true')]"/>
[6]1779          </xsl:for-each>
1780        </xsl:variable>
1781        <xsl:choose>
1782          <xsl:when test="@format='counter'">
1783            <xsl:value-of select="$tabcnt"/>
1784          </xsl:when>
1785          <xsl:when test="@format='title'">
1786            <xsl:value-of select="$node/@title"/>
1787          </xsl:when>
1788          <xsl:otherwise>
1789            <xsl:value-of select="normalize-space(concat('Table ',$tabcnt))"/>
1790          </xsl:otherwise>
1791        </xsl:choose>
1792      </a>
1793    </xsl:when>
1794   
1795    <!-- Reference links -->
[440]1796    <xsl:when test="$node/self::reference">
[6]1797
1798      <xsl:variable name="href">
1799        <xsl:call-template name="computed-target">
1800          <xsl:with-param name="bib" select="$node"/>
1801          <xsl:with-param name="ref" select="."/>
1802        </xsl:call-template>
1803      </xsl:variable>
1804     
1805      <xsl:variable name="sec">
1806        <xsl:choose>
1807          <xsl:when test="starts-with(@x:rel,'#') and not(@x:sec) and $node/x:source/@href">
1808            <xsl:variable name="extdoc" select="document($node/x:source/@href)"/>
1809            <xsl:variable name="nodes" select="$extdoc//*[@anchor=substring-after(current()/@x:rel,'#')]"/>
1810            <xsl:if test="not($nodes)">
1811              <xsl:call-template name="error">
1812                <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>
1813              </xsl:call-template>
1814            </xsl:if>
1815            <xsl:for-each select="$nodes">
1816              <xsl:call-template name="get-section-number"/>
1817            </xsl:for-each>
1818          </xsl:when>
1819          <xsl:otherwise>
1820            <xsl:value-of select="@x:sec"/>
1821          </xsl:otherwise>
1822        </xsl:choose>
1823      </xsl:variable>
[32]1824     
1825      <xsl:variable name="secterm">
1826        <xsl:choose>
1827          <!-- starts with letter? -->
1828          <xsl:when test="translate(substring($sec,1,1),$ucase,'')=''">Appendix</xsl:when>
1829          <xsl:otherwise>Section</xsl:otherwise>
1830        </xsl:choose>
1831      </xsl:variable>
[6]1832
1833      <xsl:variable name="fmt">
1834        <xsl:choose>
1835          <xsl:when test="@x:fmt!=''"><xsl:value-of select="@x:fmt"/></xsl:when>
1836          <xsl:when test="ancestor::artwork">,</xsl:when>
1837          <xsl:otherwise>of</xsl:otherwise>
1838        </xsl:choose>
1839      </xsl:variable>
1840
1841      <xsl:variable name="title">
1842        <xsl:choose>
1843          <xsl:when test="starts-with(@x:rel,'#') and not(@x:sec) and $node/x:source/@href">
1844            <xsl:variable name="extdoc" select="document($node/x:source/@href)"/>
1845            <xsl:variable name="nodes" select="$extdoc//*[@anchor=substring-after(current()/@x:rel,'#')]"/>
1846            <xsl:if test="not($nodes)">
1847              <xsl:call-template name="error">
1848                <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>
1849              </xsl:call-template>
1850            </xsl:if>
1851            <xsl:for-each select="$nodes">
1852              <xsl:value-of select="@title"/>
1853            </xsl:for-each>
1854          </xsl:when>
1855          <xsl:otherwise/>
1856        </xsl:choose>
1857      </xsl:variable>
1858
1859      <!--
1860      Formats:
1861     
1862        ()      [XXXX] (Section SS)
1863        ,       [XXXX], Section SS
1864        of      Section SS of [XXXX]
1865        sec     Section SS
1866        number  SS
1867      -->
1868     
1869      <xsl:if test="$fmt and not($fmt='()' or $fmt=',' or $fmt='of' or $fmt='sec' or $fmt='anchor' or $fmt='number')">
[118]1870        <xsl:call-template name="error">
1871          <xsl:with-param name="msg" select="concat('unknown xref/@x:fmt extension: ',$fmt)"/>
1872        </xsl:call-template>
[6]1873      </xsl:if>
1874
1875      <xsl:if test="$sec!=''">
1876             
1877        <xsl:choose>
1878          <xsl:when test="$fmt='of' or $fmt='sec'">
1879            <xsl:choose>
1880              <xsl:when test="$href!=''">
1881                <a xmlns="http://www.w3.org/1999/xhtml" href="{$href}">
1882                  <xsl:if test="$title!=''">
1883                    <xsl:attribute name="title"><xsl:value-of select="$title"/></xsl:attribute>
1884                  </xsl:if>
1885                  <xsl:if test="$fmt='sec' and $xml2rfc-ext-include-references-in-index='yes'">
1886                    <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1887                  </xsl:if>
[32]1888                  <xsl:value-of select="$secterm"/>
1889                  <xsl:text> </xsl:text>
[6]1890                  <xsl:value-of select="$sec"/>
1891                </a>
1892              </xsl:when>
[32]1893              <xsl:otherwise><xsl:value-of select="$secterm"/><xsl:text> </xsl:text><xsl:value-of select="$sec"/></xsl:otherwise>
[6]1894            </xsl:choose>
1895            <xsl:if test="$fmt='of'">
1896              <xsl:text> of </xsl:text>
1897            </xsl:if>
1898          </xsl:when>
1899          <xsl:when test="$fmt='number'">
1900            <xsl:choose>
1901              <xsl:when test="$href!=''">
1902                <a xmlns="http://www.w3.org/1999/xhtml" href="{$href}">
1903                  <xsl:if test="$title!=''">
1904                    <xsl:attribute name="title"><xsl:value-of select="$title"/></xsl:attribute>
1905                  </xsl:if>
1906                  <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
1907                    <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1908                  </xsl:if>
1909                  <xsl:value-of select="$sec"/>
1910                </a>
1911              </xsl:when>
1912              <xsl:otherwise><xsl:value-of select="$sec"/></xsl:otherwise>
1913            </xsl:choose>
1914          </xsl:when>
1915          <xsl:otherwise/>
1916        </xsl:choose>
1917      </xsl:if>
1918
1919      <xsl:if test="$sec='' or ($fmt!='sec' and $fmt!='number')">
1920        <a xmlns="http://www.w3.org/1999/xhtml" href="#{$target}">
1921          <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
1922            <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1923          </xsl:if>
1924          <cite title="{normalize-space($node/front/title)}">
1925            <xsl:variable name="val">
1926              <xsl:call-template name="referencename">
1927                <xsl:with-param name="node" select="$node"/>
1928              </xsl:call-template>
1929            </xsl:variable>
1930            <xsl:choose>
1931              <xsl:when test="$fmt='anchor'">
1932                <!-- remove brackets -->
1933                <xsl:value-of select="substring($val,2,string-length($val)-2)"/>
1934              </xsl:when>
1935              <xsl:otherwise>
1936                <xsl:value-of select="$val"/>
1937              </xsl:otherwise>
1938            </xsl:choose>
1939          </cite>
1940        </a>
1941      </xsl:if>
1942     
1943      <xsl:if test="$sec!=''">
1944        <xsl:choose>
1945          <xsl:when test="$fmt='()'">
1946            <xsl:text> (</xsl:text>
1947            <xsl:choose>
1948              <xsl:when test="$href!=''">
[32]1949                <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>
[6]1950              </xsl:when>
[32]1951              <xsl:otherwise><xsl:value-of select="$secterm"/><xsl:text> </xsl:text><xsl:value-of select="$sec"/></xsl:otherwise>
[6]1952            </xsl:choose>
1953            <xsl:text>)</xsl:text>
1954          </xsl:when>
1955          <xsl:when test="$fmt=','">
1956            <xsl:text>, </xsl:text>
1957            <xsl:choose>
1958              <xsl:when test="$href!=''">
1959                <a xmlns="http://www.w3.org/1999/xhtml" href="{$href}">
1960                  <xsl:if test="$title!=''">
1961                    <xsl:attribute name="title"><xsl:value-of select="$title"/></xsl:attribute>
1962                  </xsl:if>
[32]1963                  <xsl:value-of select="$secterm"/>
1964                  <xsl:text> </xsl:text>
[6]1965                  <xsl:value-of select="$sec"/>
1966                </a>
1967              </xsl:when>
[32]1968              <xsl:otherwise><xsl:value-of select="$secterm"/><xsl:text> </xsl:text><xsl:value-of select="$sec"/></xsl:otherwise>
[6]1969            </xsl:choose>
1970          </xsl:when>
1971          <xsl:otherwise/>
1972        </xsl:choose>
1973      </xsl:if>
1974    </xsl:when>
1975   
1976    <xsl:otherwise>
[118]1977      <xsl:call-template name="error">
1978        <xsl:with-param name="msg" select="concat('xref to unknown element: ',name($node))"/>
1979      </xsl:call-template>
[6]1980    </xsl:otherwise>
1981  </xsl:choose>
1982</xsl:template>
1983
1984
1985<!-- mark unmatched elements red -->
1986
1987<xsl:template match="*">
1988  <xsl:message>ERROR: no XSLT template for element: &lt;<xsl:value-of select="name()"/>&gt;</xsl:message>   
1989  <tt xmlns="http://www.w3.org/1999/xhtml" class="error">&lt;<xsl:value-of select="name()"/>&gt;</tt>
1990  <xsl:copy><xsl:apply-templates select="node()|@*"/></xsl:copy>
1991  <tt xmlns="http://www.w3.org/1999/xhtml" class="error">&lt;/<xsl:value-of select="name()"/>&gt;</tt>
1992</xsl:template>
1993
1994<xsl:template match="/">
1995  <xsl:apply-templates select="*"/>
1996</xsl:template>
1997
1998<!-- utility templates -->
1999
2000<xsl:template name="collectLeftHeaderColumn">
2001  <xsl:param name="mode"/>
2002  <!-- default case -->
2003  <xsl:if test="not($xml2rfc-private)">
[440]2004    <xsl:choose>
2005      <xsl:when test="/rfc/front/workgroup">
2006        <xsl:for-each select="/rfc/front/workgroup">
2007          <myns:item><xsl:value-of select="."/></myns:item>
2008        </xsl:for-each>
2009      </xsl:when>
2010      <xsl:otherwise>
2011        <myns:item>Network Working Group</myns:item>
2012      </xsl:otherwise>
2013    </xsl:choose>
[6]2014    <myns:item>
2015       <xsl:choose>
2016        <xsl:when test="/rfc/@ipr and not(/rfc/@number)">Internet Draft</xsl:when>
2017        <xsl:otherwise>Request for Comments: <xsl:value-of select="/rfc/@number"/></xsl:otherwise>
2018      </xsl:choose>
2019    </myns:item>
2020    <xsl:if test="/rfc/@docName and $mode!='nroff'">
2021      <myns:item>
2022        &lt;<xsl:value-of select="/rfc/@docName"/>&gt;
2023      </myns:item>
2024    </xsl:if>
2025    <xsl:if test="/rfc/@obsoletes and /rfc/@obsoletes!=''">
2026      <myns:item>
2027        <xsl:text>Obsoletes: </xsl:text>
2028        <xsl:call-template name="rfclist">
2029          <xsl:with-param name="list" select="normalize-space(/rfc/@obsoletes)"/>
2030        </xsl:call-template>
2031        <xsl:if test="not(/rfc/@number)"> (if approved)</xsl:if>
2032      </myns:item>
2033    </xsl:if>
2034    <xsl:if test="/rfc/@seriesNo">
2035       <myns:item>
2036        <xsl:choose>
2037          <xsl:when test="/rfc/@category='bcp'">BCP: <xsl:value-of select="/rfc/@seriesNo"/></xsl:when>
2038          <xsl:when test="/rfc/@category='info'">FYI: <xsl:value-of select="/rfc/@seriesNo"/></xsl:when>
2039          <xsl:when test="/rfc/@category='std'">STD: <xsl:value-of select="/rfc/@seriesNo"/></xsl:when>
2040          <xsl:otherwise><xsl:value-of select="concat(/rfc/@category,': ',/rfc/@seriesNo)"/></xsl:otherwise>
2041        </xsl:choose>
2042      </myns:item>
2043    </xsl:if>
2044    <xsl:if test="/rfc/@updates and /rfc/@updates!=''">
2045      <myns:item>
2046        <xsl:text>Updates: </xsl:text>
2047          <xsl:call-template name="rfclist">
2048             <xsl:with-param name="list" select="normalize-space(/rfc/@updates)"/>
2049          </xsl:call-template>
2050          <xsl:if test="not(/rfc/@number)"> (if approved)</xsl:if>
2051      </myns:item>
2052    </xsl:if>
2053    <xsl:if test="$mode!='nroff'">
2054      <myns:item>
2055        <xsl:choose>
2056          <xsl:when test="/rfc/@number">
2057            <xsl:text>Category: </xsl:text>
2058          </xsl:when>
2059          <xsl:otherwise>
2060            <xsl:text>Intended status: </xsl:text>
2061          </xsl:otherwise>
2062        </xsl:choose>
2063        <xsl:call-template name="get-category-long"/>
2064      </myns:item>
2065    </xsl:if>
2066    <xsl:if test="/rfc/@ipr and not(/rfc/@number)">
2067       <myns:item>Expires: <xsl:call-template name="expirydate"/></myns:item>
2068    </xsl:if>
2069  </xsl:if>
2070   
2071  <!-- private case -->
2072  <xsl:if test="$xml2rfc-private">
2073    <myns:item><xsl:value-of select="$xml2rfc-private"/></myns:item>
2074  </xsl:if>
2075</xsl:template>
2076
2077<xsl:template name="collectRightHeaderColumn">
2078  <xsl:for-each select="author">
2079    <xsl:variable name="initials">
2080      <xsl:call-template name="format-initials"/>
2081    </xsl:variable>
2082    <xsl:if test="@surname">
2083      <myns:item>
2084        <xsl:value-of select="concat($initials,' ',@surname)"/>
2085        <xsl:if test="@role">
2086          <xsl:choose>
2087            <xsl:when test="@role='editor'">
2088              <xsl:text>, Editor</xsl:text>
2089            </xsl:when>
2090            <xsl:otherwise>
2091              <xsl:text>, </xsl:text><xsl:value-of select="@role"/>
2092            </xsl:otherwise>
2093          </xsl:choose>
2094        </xsl:if>
2095      </myns:item>
2096    </xsl:if>
2097    <xsl:variable name="org">
2098      <xsl:choose>
2099        <xsl:when test="organization/@abbrev"><xsl:value-of select="organization/@abbrev"/></xsl:when>
2100        <xsl:otherwise><xsl:value-of select="organization"/></xsl:otherwise>
2101      </xsl:choose>
2102    </xsl:variable>
2103    <xsl:variable name="orgOfFollowing">
2104      <xsl:choose>
2105        <xsl:when test="following-sibling::*[1]/organization/@abbrev"><xsl:value-of select="following-sibling::*[1]/organization/@abbrev"/></xsl:when>
2106        <xsl:otherwise><xsl:value-of select="following-sibling::*/organization"/></xsl:otherwise>
2107      </xsl:choose>
2108    </xsl:variable>
2109    <xsl:if test="$org != $orgOfFollowing and $org != ''">
2110      <myns:item><xsl:value-of select="$org"/></myns:item>
2111    </xsl:if>
2112  </xsl:for-each>
2113  <myns:item>
[227]2114    <xsl:if test="$xml2rfc-ext-pub-month!=''">
2115      <xsl:value-of select="$xml2rfc-ext-pub-month"/>
2116      <xsl:if test="$xml2rfc-ext-pub-day!='' and /rfc/@ipr and not(/rfc/@number)">
2117        <xsl:text> </xsl:text>
2118        <xsl:value-of select="$xml2rfc-ext-pub-day"/>
2119        <xsl:text>,</xsl:text>
2120      </xsl:if>
2121    </xsl:if>
2122    <xsl:value-of select="concat(' ',$xml2rfc-ext-pub-year)"/>
[6]2123  </myns:item>
2124</xsl:template>
2125
2126
2127<xsl:template name="emitheader">
2128  <xsl:param name="lc"/>
2129  <xsl:param name="rc"/>
2130
2131  <xsl:for-each select="$lc/myns:item | $rc/myns:item">
2132    <xsl:variable name="pos" select="position()"/>
2133    <xsl:if test="$pos &lt; count($lc/myns:item) + 1 or $pos &lt; count($rc/myns:item) + 1"> 
2134      <tr xmlns="http://www.w3.org/1999/xhtml">
2135        <td class="header left"><xsl:call-template name="copynodes"><xsl:with-param name="nodes" select="$lc/myns:item[$pos]/node()"/></xsl:call-template></td>
2136        <td class="header right"><xsl:call-template name="copynodes"><xsl:with-param name="nodes" select="$rc/myns:item[$pos]/node()"/></xsl:call-template></td>
2137      </tr>
2138    </xsl:if>
2139  </xsl:for-each>
2140</xsl:template>
2141
2142<!-- convenience template that avoids copying namespace nodes we don't want -->
2143<xsl:template name="copynodes">
2144  <xsl:param name="nodes"/>
2145  <xsl:for-each select="$nodes">
2146    <xsl:choose>
2147      <xsl:when test="namespace-uri()='http://www.w3.org/1999/xhtml'">
2148        <xsl:element namespace="{namespace-uri()}" name="{name()}">
2149          <xsl:copy-of select="@*|node()"/>
2150        </xsl:element>
2151      </xsl:when>
2152      <xsl:when test="self::*">
2153        <xsl:element namespace="http://www.w3.org/1999/xhtml" name="{name()}">
2154          <xsl:copy-of select="@*|node()"/>
2155        </xsl:element>
2156      </xsl:when>
2157      <!-- workaround for opera, remove when Opera > 9.0.x comes out -->
2158      <xsl:when test="self::text()">
2159        <xsl:value-of select="."/>
2160      </xsl:when>
2161      <xsl:otherwise>
2162        <xsl:copy-of select="."/>
2163      </xsl:otherwise>
2164    </xsl:choose>
2165  </xsl:for-each>
2166</xsl:template>
2167
2168
2169<xsl:template name="expirydate">
2170  <xsl:choose>
[227]2171    <xsl:when test="$xml2rfc-ext-pub-month='January'">July <xsl:value-of select="$xml2rfc-ext-pub-year"/></xsl:when>
2172    <xsl:when test="$xml2rfc-ext-pub-month='February'">August <xsl:value-of select="$xml2rfc-ext-pub-year"/></xsl:when>
2173    <xsl:when test="$xml2rfc-ext-pub-month='March'">September <xsl:value-of select="$xml2rfc-ext-pub-year"/></xsl:when>
2174    <xsl:when test="$xml2rfc-ext-pub-month='April'">October <xsl:value-of select="$xml2rfc-ext-pub-year"/></xsl:when>
2175    <xsl:when test="$xml2rfc-ext-pub-month='May'">November <xsl:value-of select="$xml2rfc-ext-pub-year"/></xsl:when>
2176    <xsl:when test="$xml2rfc-ext-pub-month='June'">December <xsl:value-of select="$xml2rfc-ext-pub-year"/></xsl:when>
2177    <xsl:when test="$xml2rfc-ext-pub-month='July'">January <xsl:value-of select="$xml2rfc-ext-pub-year + 1"/></xsl:when>
2178    <xsl:when test="$xml2rfc-ext-pub-month='August'">February <xsl:value-of select="$xml2rfc-ext-pub-year + 1"/></xsl:when>
2179    <xsl:when test="$xml2rfc-ext-pub-month='September'">March <xsl:value-of select="$xml2rfc-ext-pub-year + 1"/></xsl:when>
2180    <xsl:when test="$xml2rfc-ext-pub-month='October'">April <xsl:value-of select="$xml2rfc-ext-pub-year + 1"/></xsl:when>
2181    <xsl:when test="$xml2rfc-ext-pub-month='November'">May <xsl:value-of select="$xml2rfc-ext-pub-year + 1"/></xsl:when>
2182    <xsl:when test="$xml2rfc-ext-pub-month='December'">June <xsl:value-of select="$xml2rfc-ext-pub-year + 1"/></xsl:when>
2183      <xsl:otherwise>WRONG SYNTAX FOR MONTH</xsl:otherwise>
2184   </xsl:choose>
[6]2185</xsl:template>
2186
2187<xsl:template name="get-month-as-num">
[227]2188  <xsl:param name="month"/>
[6]2189  <xsl:choose>
[227]2190    <xsl:when test="$month='January'">01</xsl:when>
2191    <xsl:when test="$month='February'">02</xsl:when>
2192    <xsl:when test="$month='March'">03</xsl:when>
2193    <xsl:when test="$month='April'">04</xsl:when>
2194    <xsl:when test="$month='May'">05</xsl:when>
2195    <xsl:when test="$month='June'">06</xsl:when>
2196    <xsl:when test="$month='July'">07</xsl:when>
2197    <xsl:when test="$month='August'">08</xsl:when>
2198    <xsl:when test="$month='September'">09</xsl:when>
2199    <xsl:when test="$month='October'">10</xsl:when>
2200    <xsl:when test="$month='November'">11</xsl:when>
2201    <xsl:when test="$month='December'">12</xsl:when>
2202    <xsl:otherwise>WRONG SYNTAX FOR MONTH</xsl:otherwise>
2203  </xsl:choose>
[6]2204</xsl:template>
2205
[227]2206<xsl:template name="get-month-as-name">
2207  <xsl:param name="month"/>
2208  <xsl:choose>
2209    <xsl:when test="$month=1">January</xsl:when>
2210    <xsl:when test="$month=2">February</xsl:when>
2211    <xsl:when test="$month=3">March</xsl:when>
2212    <xsl:when test="$month=4">April</xsl:when>
2213    <xsl:when test="$month=5">May</xsl:when>
2214    <xsl:when test="$month=6">June</xsl:when>
2215    <xsl:when test="$month=7">July</xsl:when>
2216    <xsl:when test="$month=8">August</xsl:when>
2217    <xsl:when test="$month=9">September</xsl:when>
2218    <xsl:when test="$month=10">October</xsl:when>
2219    <xsl:when test="$month=11">November</xsl:when>
2220    <xsl:when test="$month=12">December</xsl:when>
2221    <xsl:otherwise>WRONG SYNTAX FOR MONTH</xsl:otherwise>
2222   </xsl:choose>
2223</xsl:template>
2224
[6]2225<!-- produce back section with author information -->
2226<xsl:template name="get-authors-section-title">
2227  <xsl:choose>
2228    <xsl:when test="count(/rfc/front/author)=1">Author's Address</xsl:when>
2229    <xsl:otherwise>Authors' Addresses</xsl:otherwise>
2230  </xsl:choose>
2231</xsl:template>
2232
2233<xsl:template name="get-authors-section-number">
2234  <xsl:if test="/*/x:assign-section-number[@builtin-target='authors']">
2235    <xsl:value-of select="/*/x:assign-section-number[@builtin-target='authors']/@number"/>
2236  </xsl:if>
2237</xsl:template>
2238
2239<xsl:template name="insertAuthors">
2240
2241  <xsl:variable name="number">
2242    <xsl:call-template name="get-authors-section-number"/>
2243  </xsl:variable>
2244   
[329]2245  <xsl:if test="$number!='suppress'">
2246    <xsl:call-template name="insert-conditional-hrule"/>
2247   
2248    <h1 xmlns="http://www.w3.org/1999/xhtml" id="{$anchor-prefix}.authors">
2249      <xsl:call-template name="insert-conditional-pagebreak"/>
2250      <xsl:if test="$number != ''">
2251        <a href="#{$anchor-prefix}.section.{$number}" id="{$anchor-prefix}.section.{$number}"><xsl:value-of select="$number"/>.</a>
2252        <xsl:text> </xsl:text>
2253      </xsl:if>
2254      <a href="#{$anchor-prefix}.authors"><xsl:call-template name="get-authors-section-title"/></a>
2255    </h1>
2256 
2257    <xsl:apply-templates select="/rfc/front/author"/>
2258  </xsl:if>
[6]2259</xsl:template>
2260
2261
2262
2263<!-- insert copyright statement -->
2264
2265<xsl:template name="insertCopyright" myns:namespaceless-elements="xml2rfc">
2266
[440]2267  <xsl:if test="not($no-copylong)">
2268    <section title="Full Copyright Statement" anchor="{$anchor-prefix}.copyright" myns:unnumbered="unnumbered" myns:notoclink="notoclink">
2269      <xsl:choose>
2270        <xsl:when test="$ipr-rfc3667">
2271          <t>
2272            <xsl:choose>
2273              <xsl:when test="$ipr-2007-08"/>
2274              <xsl:when test="$ipr-rfc4748">
2275                Copyright © The IETF Trust (<xsl:value-of select="$xml2rfc-ext-pub-year"/>).
2276              </xsl:when>
2277              <xsl:otherwise>
2278                Copyright © The Internet Society (<xsl:value-of select="$xml2rfc-ext-pub-year"/>).
2279              </xsl:otherwise>
2280            </xsl:choose>
2281          </t>
2282          <t>
2283            This document is subject to the rights, licenses and restrictions
2284            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
2285            retain all their rights.
2286          </t>
2287          <t>
2288            This document and the information contained herein are provided
2289            on an &#8220;AS IS&#8221; basis and THE CONTRIBUTOR,
2290            THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY),
2291            THE INTERNET SOCIETY<xsl:if test="$ipr-rfc4748">, THE IETF TRUST</xsl:if>
2292            AND THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES,
2293            EXPRESS OR IMPLIED,
2294            INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
2295            INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
2296            WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
2297          </t>
2298        </xsl:when>
2299        <xsl:otherwise>
2300          <!-- <http://tools.ietf.org/html/rfc2026#section-10.4> -->
2301          <t>
2302            Copyright © The Internet Society (<xsl:value-of select="$xml2rfc-ext-pub-year"/>). All Rights Reserved.
2303          </t>
2304          <t>
2305            This document and translations of it may be copied and furnished to
2306            others, and derivative works that comment on or otherwise explain it
2307            or assist in its implementation may be prepared, copied, published and
2308            distributed, in whole or in part, without restriction of any kind,
2309            provided that the above copyright notice and this paragraph are
2310            included on all such copies and derivative works. However, this
2311            document itself may not be modified in any way, such as by removing
2312            the copyright notice or references to the Internet Society or other
2313            Internet organizations, except as needed for the purpose of
2314            developing Internet standards in which case the procedures for
2315            copyrights defined in the Internet Standards process must be
2316            followed, or as required to translate it into languages other than
2317            English.
2318          </t>
2319          <t>
2320            The limited permissions granted above are perpetual and will not be
2321            revoked by the Internet Society or its successors or assignees.
2322          </t>
2323          <t>
2324            This document and the information contained herein is provided on an
2325            &#8220;AS IS&#8221; basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
2326            TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
2327            BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
2328            HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
2329            MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
2330          </t>
2331        </xsl:otherwise>
2332      </xsl:choose>
2333    </section>
2334   
2335    <section title="Intellectual Property" anchor="{$anchor-prefix}.ipr" myns:unnumbered="unnumbered">
2336      <xsl:choose>
2337        <xsl:when test="$ipr-rfc3667">
2338          <t>
2339            The IETF takes no position regarding the validity or scope of any
2340            Intellectual Property Rights or other rights that might be claimed to
2341            pertain to the implementation or use of the technology described in
2342            this document or the extent to which any license under such rights
2343            might or might not be available; nor does it represent that it has
2344            made any independent effort to identify any such rights.  Information
2345            on the procedures with respect to rights in RFC documents
2346            can be found in BCP 78 and BCP 79.
2347          </t>       
2348          <t>
2349            Copies of IPR disclosures made to the IETF Secretariat and any
2350            assurances of licenses to be made available, or the result of an
2351            attempt made to obtain a general license or permission for the use
2352            of such proprietary rights by implementers or users of this
2353            specification can be obtained from the IETF on-line IPR repository
2354            at <eref target="http://www.ietf.org/ipr"/>.
2355          </t>       
2356          <t>
2357            The IETF invites any interested party to bring to its attention any
2358            copyrights, patents or patent applications, or other proprietary
2359            rights that may cover technology that may be required to implement
2360            this standard. Please address the information to the IETF at
2361            <eref target="mailto:ietf-ipr@ietf.org">ietf-ipr@ietf.org</eref>.
2362          </t>       
2363        </xsl:when>
2364        <xsl:otherwise>
2365          <t>
2366            The IETF takes no position regarding the validity or scope of
2367            any intellectual property or other rights that might be claimed
2368            to  pertain to the implementation or use of the technology
2369            described in this document or the extent to which any license
2370            under such rights might or might not be available; neither does
2371            it represent that it has made any effort to identify any such
2372            rights. Information on the IETF's procedures with respect to
2373            rights in standards-track and standards-related documentation
2374            can be found in BCP-11. Copies of claims of rights made
2375            available for publication and any assurances of licenses to
2376            be made available, or the result of an attempt made
2377            to obtain a general license or permission for the use of such
2378            proprietary rights by implementors or users of this
2379            specification can be obtained from the IETF Secretariat.
2380          </t>
2381          <t>
2382            The IETF invites any interested party to bring to its
2383            attention any copyrights, patents or patent applications, or
2384            other proprietary rights which may cover technology that may be
2385            required to practice this standard. Please address the
2386            information to the IETF Executive Director.
2387          </t>
2388          <xsl:if test="$xml2rfc-iprnotified='yes'">
2389            <t>
2390              The IETF has been notified of intellectual property rights
2391              claimed in regard to some or all of the specification contained
2392              in this document. For more information consult the online list
2393              of claimed rights.
2394            </t>
2395          </xsl:if>
2396        </xsl:otherwise>
2397      </xsl:choose>
2398    </section>
2399   
[6]2400    <xsl:choose>
[440]2401      <xsl:when test="$no-funding"/>
2402      <xsl:when test="$funding1 and /rfc/@number">
2403        <section myns:unnumbered="unnumbered" myns:notoclink="notoclink">
2404          <xsl:attribute name="title">
2405            <xsl:choose>
2406              <xsl:when test="$xml2rfc-rfcedstyle='yes'">Acknowledgement</xsl:when>
2407              <xsl:otherwise>Acknowledgment</xsl:otherwise>
2408            </xsl:choose>
2409          </xsl:attribute>
2410          <t>
2411            Funding for the RFC Editor function is provided by the IETF
2412            Administrative Support Activity (IASA).
2413          </t>
2414        </section>
[6]2415      </xsl:when>
[440]2416      <xsl:when test="$funding0 and /rfc/@number">
2417        <section myns:unnumbered="unnumbered" myns:notoclink="notoclink">
2418          <xsl:attribute name="title">
2419            <xsl:choose>
2420              <xsl:when test="$xml2rfc-rfcedstyle='yes'">Acknowledgement</xsl:when>
2421              <xsl:otherwise>Acknowledgment</xsl:otherwise>
2422            </xsl:choose>
2423          </xsl:attribute>
[6]2424          <t>
[440]2425            Funding for the RFC Editor function is currently provided by
2426            the Internet Society.
[6]2427          </t>
[440]2428        </section>
2429      </xsl:when>
2430      <xsl:otherwise/>
[6]2431    </xsl:choose>
[440]2432  </xsl:if>
[6]2433
2434</xsl:template>
2435
2436
2437<!-- insert CSS style info -->
2438
2439<xsl:template name="insertCss">
2440a {
2441  text-decoration: none;
2442}
2443a.smpl {
2444  color: black;
2445}
2446a:hover {
2447  text-decoration: underline;
2448}
2449a:active {
2450  text-decoration: underline;
2451}
2452address {
2453  margin-top: 1em;
2454  margin-left: 2em;
2455  font-style: normal;
2456}<xsl:if test="//x:blockquote">
2457blockquote {
2458  border-style: solid;
2459  border-color: gray;
2460  border-width: 0 0 0 .25em;
2461  font-style: italic;
2462  padding-left: 0.5em;
2463}</xsl:if>
2464body {<xsl:if test="$xml2rfc-background!=''">
2465  background: url(<xsl:value-of select="$xml2rfc-background"/>) #ffffff left top;</xsl:if>
2466  color: black;
2467  font-family: verdana, helvetica, arial, sans-serif;
2468  font-size: 10pt;
2469}<xsl:if test="//xhtml:p">
2470br.p {
2471  line-height: 150%;
2472}</xsl:if>
2473cite {
2474  font-style: normal;
[329]2475}<xsl:if test="//x:note">
2476div.note {
2477  margin-left: 2em;
2478}</xsl:if>
[6]2479dd {
2480  margin-right: 2em;<xsl:if test="$xml2rfc-ext-justification='always'">
2481  text-align: justify;</xsl:if>
2482}
2483dl {
2484  margin-left: 2em;
2485}
2486<!-- spacing between two entries in definition lists -->
2487dl.empty dd {
2488  margin-top: .5em;
2489}
2490dl p {
2491  margin-left: 0em;
2492}
2493dt {
2494  margin-top: .5em;
2495}
2496h1 {
2497  font-size: 14pt;
2498  line-height: 21pt;
2499  page-break-after: avoid;
2500}
2501h1.np {
2502  page-break-before: always;
2503}
2504h1 a {
2505  color: #333333;
2506}
2507h2 {
2508  font-size: 12pt;
2509  line-height: 15pt;
2510  page-break-after: avoid;
2511}
[446]2512h3, h4, h5, h6 {
[6]2513  font-size: 10pt;
2514  page-break-after: avoid;
2515}
[446]2516h2 a, h3 a, h4 a, h5 a, h6 a {
[6]2517  color: black;
2518}
2519img {
2520  margin-left: 3em;
2521}
2522li {
2523  margin-left: 2em;
2524  margin-right: 2em;<xsl:if test="$xml2rfc-ext-justification='always'">
2525  text-align: justify;</xsl:if>
2526}
2527ol {
2528  margin-left: 2em;
2529  margin-right: 2em;
2530}
2531ol p {
2532  margin-left: 0em;
2533}<xsl:if test="//xhtml:q">
2534q {
2535  font-style: italic;
2536}</xsl:if>
2537p {
2538  margin-left: 2em;
2539  margin-right: 2em;<xsl:if test="$xml2rfc-ext-justification='always'">
2540  text-align: justify;</xsl:if>
2541}
2542pre {
2543  margin-left: 3em;
2544  background-color: lightyellow;
2545  padding: .25em;
2546}
2547pre.text2 {
2548  border-style: dotted;
2549  border-width: 1px;
2550  background-color: #f0f0f0;
2551  width: 69em;
2552}
2553pre.inline {
2554  background-color: white;
2555  padding: 0em;
2556}
2557pre.text {
2558  border-style: dotted;
2559  border-width: 1px;
2560  background-color: #f8f8f8;
2561  width: 69em;
2562}
2563pre.drawing {
2564  border-style: solid;
2565  border-width: 1px;
2566  background-color: #f8f8f8;
2567  padding: 2em;
2568}<xsl:if test="//x:q">
2569q {
2570  font-style: italic;
2571}</xsl:if>
[246]2572<xsl:if test="//x:sup">
2573sup {
2574  font-size: 60%;
2575}</xsl:if>
[6]2576table {
2577  margin-left: 2em;
2578}<xsl:if test="//texttable">
2579table.tt {
2580  vertical-align: top;
2581}
2582table.full {
2583  border-style: outset;
2584  border-width: 1px;
2585}
2586table.headers {
2587  border-style: outset;
2588  border-width: 1px;
2589}
2590table.tt td {
2591  vertical-align: top;
2592}
2593table.full td {
2594  border-style: inset;
2595  border-width: 1px;
2596}
2597table.tt th {
2598  vertical-align: top;
2599}
2600table.full th {
2601  border-style: inset;
2602  border-width: 1px;
2603}
2604table.headers th {
2605  border-style: none none inset none;
2606  border-width: 1px;
[448]2607}
2608caption {
2609  caption-side: bottom;
2610  font-weight: bold;
2611  font-size: 9pt;
2612  margin-top: .5em;
2613}
2614</xsl:if>
[6]2615table.header {
2616  width: 95%;
2617  font-size: 10pt;
2618  color: white;
2619}
2620td.top {
2621  vertical-align: top;
2622}
2623td.topnowrap {
2624  vertical-align: top;
2625  white-space: nowrap;
2626}
2627td.header {
2628  background-color: gray;
2629  width: 50%;
[227]2630}<xsl:if test="/rfc/@obsoletes | /rfc/@updates">
2631td.header a {
2632  color: white;
2633}</xsl:if>
[6]2634td.reference {
2635  vertical-align: top;
2636  white-space: nowrap;
2637  padding-right: 1em;
2638}
2639thead {
2640  display:table-header-group;
2641}
2642ul.toc {
2643  list-style: none;
2644  margin-left: 1.5em;
2645  margin-right: 0em;
2646  padding-left: 0em;
2647}
2648li.tocline0 {
2649  line-height: 150%;
2650  font-weight: bold;
2651  font-size: 10pt;
2652  margin-left: 0em;
2653  margin-right: 0em;
2654}
2655li.tocline1 {
2656  line-height: normal;
2657  font-weight: normal;
2658  font-size: 9pt;
2659  margin-left: 0em;
2660  margin-right: 0em;
2661}
2662li.tocline2 {
2663  font-size: 0pt;
2664}
2665ul p {
2666  margin-left: 0em;
2667}
[440]2668<xsl:if test="$has-index">ul.ind {
[6]2669  list-style: none;
2670  margin-left: 1.5em;
2671  margin-right: 0em;
2672  padding-left: 0em;
[440]2673  page-break-before: avoid;
[6]2674}
2675li.indline0 {
2676  font-weight: bold;
2677  line-height: 200%;
2678  margin-left: 0em;
2679  margin-right: 0em;
2680}
2681li.indline1 {
2682  font-weight: normal;
2683  line-height: 150%;
2684  margin-left: 0em;
2685  margin-right: 0em;
2686}
[440]2687</xsl:if><xsl:if test="//x:bcp14">.bcp14 {
[6]2688  font-style: normal;
2689  text-transform: lowercase;
2690  font-variant: small-caps;
2691}</xsl:if><xsl:if test="//x:blockquote">
2692blockquote &gt; * .bcp14 {
2693  font-style: italic;
2694}</xsl:if>
2695.comment {
2696  background-color: yellow;
2697}<xsl:if test="$xml2rfc-editing='yes'">
2698.editingmark {
2699  background-color: khaki;
2700}</xsl:if>
2701.center {
2702  text-align: center;
2703}
2704.error {
2705  color: red;
2706  font-style: italic;
2707  font-weight: bold;
2708}
2709.figure {
2710  font-weight: bold;
2711  text-align: center;
2712  font-size: 9pt;
2713}
2714.filename {
2715  color: #333333;
2716  font-weight: bold;
2717  font-size: 12pt;
2718  line-height: 21pt;
2719  text-align: center;
2720}
2721.fn {
2722  font-weight: bold;
2723}
2724.hidden {
2725  display: none;
2726}
2727.left {
2728  text-align: left;
2729}
2730.right {
2731  text-align: right;
2732}
2733.title {
2734  color: #990000;
2735  font-size: 18pt;
2736  line-height: 18pt;
2737  font-weight: bold;
2738  text-align: center;
2739  margin-top: 36pt;
2740}
2741.vcardline {
2742  display: block;
2743}
2744.warning {
2745  font-size: 14pt;
2746  background-color: yellow;
2747}
[272]2748<xsl:if test="$has-edits">del {
[6]2749  color: red;
2750  text-decoration: line-through;
2751}
2752.del {
2753  color: red;
2754  text-decoration: line-through;
2755}
2756ins {
2757  color: green;
2758  text-decoration: underline;
2759}
2760.ins {
2761  color: green;
2762  text-decoration: underline;
2763}
2764div.issuepointer {
2765  float: left;
2766}</xsl:if><xsl:if test="//ed:issue">
2767table.openissue {
2768  background-color: khaki;
2769  border-width: thin;
2770  border-style: solid;
2771  border-color: black;
2772}
2773table.closedissue {
2774  background-color: white;
2775  border-width: thin;
2776  border-style: solid;
2777  border-color: gray;
2778  color: gray;
2779}
2780thead th {
2781  text-align: left;
2782}
2783.bg-issue {
2784  border: solid;
2785  border-width: 1px;
2786  font-size: 7pt;
2787}
2788.closed-issue {
2789  border: solid;
2790  border-width: thin;
2791  background-color: lime;
2792  font-size: smaller;
2793  font-weight: bold;
2794}
2795.open-issue {
2796  border: solid;
2797  border-width: thin;
2798  background-color: red;
2799  font-size: smaller;
2800  font-weight: bold;
2801}
2802.editor-issue {
2803  border: solid;
2804  border-width: thin;
2805  background-color: yellow;
2806  font-size: smaller;
2807  font-weight: bold;
2808}</xsl:if>
2809
2810@media print {
2811  .noprint {
2812    display: none;
2813  }
2814 
2815  a {
2816    color: black;
2817    text-decoration: none;
2818  }
2819
2820  table.header {
2821    width: 90%;
2822  }
2823
2824  td.header {
2825    width: 50%;
2826    color: black;
2827    background-color: white;
2828    vertical-align: top;
2829    font-size: 12pt;
2830  }
2831
2832  ul.toc a::after {
2833    content: leader('.') target-counter(attr(href), page);
2834  }
2835 
2836  a.iref {
2837    content: target-counter(attr(href), page);
2838  }
2839 
2840  .print2col {
2841    column-count: 2;
2842    -moz-column-count: 2;<!-- for Firefox -->
2843    column-fill: auto;<!-- for PrinceXML -->
2844  }
2845<xsl:if test="$xml2rfc-ext-justification='print'">
2846  dd {
2847    text-align: justify;
2848  }
2849  li {
2850    text-align: justify;
2851  }
2852  p {
2853    text-align: justify;
2854  }
2855</xsl:if>}
2856
2857@page {
2858  @top-left {
2859       content: "<xsl:call-template name="get-header-left"/>";
2860  }
2861  @top-right {
2862       content: "<xsl:call-template name="get-header-right"/>";
2863  }
2864  @top-center {
2865       content: "<xsl:call-template name="get-header-center"/>";
2866  }
2867  @bottom-left {
2868       content: "<xsl:call-template name="get-author-summary"/>";
2869  }
2870  @bottom-center {
2871       content: "<xsl:call-template name="get-category-long"/>";
2872  }
2873  @bottom-right {
2874       content: "[Page " counter(page) "]";
2875  }
2876}
2877
2878@page:first {
2879    @top-left {
2880      content: normal;
2881    }
2882    @top-right {
2883      content: normal;
2884    }
2885    @top-center {
2886      content: normal;
2887    }
2888}
2889</xsl:template>
2890
2891
2892<!-- generate the index section -->
2893
2894<xsl:template name="insertSingleIref">
2895  <xsl:choose>
2896    <xsl:when test="@ed:xref">
2897      <!-- special index generator mode -->
2898      <xsl:text>[</xsl:text>
2899      <a xmlns="http://www.w3.org/1999/xhtml" href="#{@ed:xref}"><xsl:value-of select="@ed:xref"/></a>
2900      <xsl:text>, </xsl:text>
2901      <a xmlns="http://www.w3.org/1999/xhtml">
2902        <xsl:variable name="htmluri" select="//reference[@anchor=current()/@ed:xref]/format[@type='HTML']/@target"/>
2903        <xsl:if test="$htmluri">
2904          <xsl:attribute name="href"><xsl:value-of select="concat($htmluri,'#',@ed:frag)"/></xsl:attribute>
2905        </xsl:if>       
2906        <xsl:choose>
2907          <xsl:when test="@primary='true'"><b><xsl:value-of select="@ed:label"/></b></xsl:when>
2908          <xsl:otherwise><xsl:value-of select="@ed:label"/></xsl:otherwise>
2909        </xsl:choose>
2910      </a>
2911      <xsl:text>]</xsl:text>
2912      <xsl:if test="position()!=last()">, </xsl:if>
2913    </xsl:when>
2914    <xsl:otherwise>
2915      <xsl:variable name="_n">
2916        <xsl:call-template name="get-section-number"/>
2917      </xsl:variable>
2918      <xsl:variable name="n">
2919        <xsl:choose>
2920          <xsl:when test="$_n!=''">
2921            <xsl:value-of select="$_n"/>
2922          </xsl:when>
2923          <xsl:otherwise>§</xsl:otherwise>
2924        </xsl:choose>
2925      </xsl:variable>
2926      <xsl:variable name="backlink">
2927        <xsl:choose>
2928          <xsl:when test="self::xref">
2929            <xsl:variable name="target" select="@target"/>
2930            <xsl:text>#</xsl:text>
2931            <xsl:value-of select="$anchor-prefix"/>
2932            <xsl:text>.xref.</xsl:text>
2933            <xsl:value-of select="@target"/>.<xsl:number level="any" count="xref[@target=$target]"/>
2934          </xsl:when>
2935          <xsl:when test="self::iref">
2936            <xsl:text>#</xsl:text>
2937            <xsl:call-template name="compute-iref-anchor"/>
2938          </xsl:when>
[189]2939          <xsl:when test="self::x:ref">
2940            <xsl:text>#</xsl:text>
2941            <xsl:call-template name="compute-extref-anchor"/>
2942          </xsl:when>
[6]2943          <xsl:otherwise>
2944            <xsl:message>Unsupported element type for insertSingleIref</xsl:message>
2945          </xsl:otherwise>
2946        </xsl:choose>
2947      </xsl:variable>
2948      <a xmlns="http://www.w3.org/1999/xhtml" class="iref" href="{$backlink}">
2949        <xsl:call-template name="insertInsDelClass"/>
2950        <xsl:choose>
2951          <xsl:when test="@primary='true'"><b><xsl:value-of select="$n"/></b></xsl:when>
2952          <xsl:otherwise><xsl:value-of select="$n"/></xsl:otherwise>
2953        </xsl:choose>
2954      </a>
2955      <xsl:if test="position()!=last()">, </xsl:if>
2956    </xsl:otherwise>
2957  </xsl:choose>
2958</xsl:template>
2959
2960<xsl:template name="insertSingleXref">
2961  <xsl:variable name="_n">
2962    <xsl:call-template name="get-section-number"/>
2963  </xsl:variable>
2964  <xsl:variable name="n">
2965    <xsl:choose>
2966      <xsl:when test="$_n!=''">
2967        <xsl:value-of select="$_n"/>
2968      </xsl:when>
2969      <xsl:otherwise>§</xsl:otherwise>
2970    </xsl:choose>
2971  </xsl:variable>
2972  <xsl:choose>
2973    <xsl:when test="self::reference">
2974      <a xmlns="http://www.w3.org/1999/xhtml" class="iref" href="#{@anchor}">
2975        <xsl:call-template name="insertInsDelClass"/>
2976        <b><xsl:value-of select="$n"/></b>
2977      </a>
2978    </xsl:when>
2979    <xsl:otherwise>
2980      <xsl:variable name="target" select="@target"/>
2981      <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>
2982      <a xmlns="http://www.w3.org/1999/xhtml" class="iref" href="{$backlink}">
2983        <xsl:call-template name="insertInsDelClass"/>
2984        <xsl:value-of select="$n"/>
2985      </a>
2986    </xsl:otherwise>
2987  </xsl:choose>
2988  <xsl:if test="position()!=last()">, </xsl:if>
2989</xsl:template>
2990
2991<xsl:template name="insertIndex">
2992
2993  <xsl:call-template name="insert-conditional-hrule"/>
2994
2995  <h1 xmlns="http://www.w3.org/1999/xhtml" id="{$anchor-prefix}.index">
2996    <xsl:call-template name="insert-conditional-pagebreak"/>
2997    <a href="#{$anchor-prefix}.index">Index</a>
2998  </h1>
2999 
3000  <!-- generate navigation links to index subsections -->
3001  <p xmlns="http://www.w3.org/1999/xhtml" class="noprint">
3002    <xsl:variable name="irefs" select="//iref[generate-id(.) = generate-id(key('index-first-letter',translate(substring(@item,1,1),$lcase,$ucase)))]"/>
3003    <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)))]"/>
3004 
3005    <xsl:for-each select="$irefs | $xrefs">
3006   
3007      <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)"/>
3008         
3009      <xsl:variable name="letter" select="translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase)"/>
3010
3011      <!-- character? -->
3012      <xsl:if test="translate($letter,concat($lcase,$ucase,'0123456789'),'')=''">
3013     
3014        <xsl:variable name="showit">
3015          <xsl:choose>
3016            <xsl:when test="$xml2rfc-ext-include-references-in-index!='yes'">
3017              <xsl:if test="$irefs[starts-with(translate(@item,$lcase,$ucase),$letter)]">
3018                <xsl:text>yes</xsl:text>
3019              </xsl:if>
3020            </xsl:when>
3021            <xsl:otherwise>
3022              <xsl:text>yes</xsl:text>
3023            </xsl:otherwise>
3024          </xsl:choose>
3025        </xsl:variable>
3026       
3027        <xsl:if test="$showit='yes'">
3028          <a href="#{$anchor-prefix}.index.{$letter}">
3029            <xsl:value-of select="$letter"/>
3030          </a>
3031          <xsl:text> </xsl:text>
3032        </xsl:if>
3033     
3034      </xsl:if>
3035
3036    </xsl:for-each>
3037  </p>
3038
3039  <!-- for each index subsection -->
3040  <div xmlns="http://www.w3.org/1999/xhtml" class="print2col">
3041  <ul class="ind">
3042    <xsl:variable name="irefs2" select="//iref[generate-id(.) = generate-id(key('index-first-letter',translate(substring(@item,1,1),$lcase,$ucase)))]"/>
3043    <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)))]"/>
3044 
3045    <xsl:for-each select="$irefs2 | $xrefs2">
3046      <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)"/>
3047      <xsl:variable name="letter" select="translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase)"/>
3048           
3049      <xsl:variable name="showit">
3050        <xsl:choose>
3051          <xsl:when test="$xml2rfc-ext-include-references-in-index!='yes'">
3052            <xsl:if test="$irefs2[starts-with(translate(@item,$lcase,$ucase),$letter)]">
3053              <xsl:text>yes</xsl:text>
3054            </xsl:if>
3055          </xsl:when>
3056          <xsl:otherwise>
3057            <xsl:text>yes</xsl:text>
3058          </xsl:otherwise>
3059        </xsl:choose>
3060      </xsl:variable>
3061
3062      <xsl:if test="$showit='yes'">
3063        <li class="indline0">
3064         
3065          <!-- make letters and digits stand out -->
3066          <xsl:choose>
3067            <xsl:when test="translate($letter,concat($lcase,$ucase,'0123456789'),'')=''">
3068              <a id="{$anchor-prefix}.index.{$letter}" href="#{$anchor-prefix}.index.{$letter}">
3069                <b><xsl:value-of select="$letter"/></b>
3070              </a>
3071            </xsl:when>
3072            <xsl:otherwise>
3073              <b><xsl:value-of select="$letter"/></b>
3074            </xsl:otherwise>
3075          </xsl:choose>
3076       
3077          <ul class="ind"> 
3078            <xsl:for-each select="key('index-first-letter',translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase))">
3079       
3080              <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)"/>
3081             
3082                <xsl:choose>
3083                  <xsl:when test="self::reference">
3084                    <xsl:if test="$xml2rfc-ext-include-references-in-index='yes' and not(starts-with(@anchor,'deleted-'))">
3085                      <li class="indline1">
3086                        <em>
3087                          <xsl:value-of select="@anchor"/>
3088                        </em>
3089                        <xsl:text>  </xsl:text>
3090                       
[272]3091                        <xsl:variable name="rs" select="key('xref-item',current()/@anchor) | . | key('anchor-item',concat('deleted-',current()/@anchor))"/>
3092                       
[6]3093                        <xsl:for-each select="$rs">
3094                          <xsl:call-template name="insertSingleXref"/>
3095                        </xsl:for-each>
3096
3097                        <xsl:variable name="rs2" select="$rs[@x:sec]"/>
3098
3099                        <xsl:if test="$rs2">
3100                          <ul class="ind"> 
3101                            <xsl:for-each select="$rs2">
3102                              <xsl:sort select="substring-before(concat(@x:sec,'.'),'.')" data-type="number"/>
3103                              <xsl:sort select="substring(@x:sec,1+string-length(substring-before(@x:sec,'.')))" data-type="number"/>
3104                              <xsl:if test="generate-id(.) = generate-id(key('index-xref-by-sec',concat(@target,'..',@x:sec)))">
3105                                <li class="indline1">
3106                                  <em>
[272]3107                                    <xsl:choose>
3108                                      <xsl:when test="translate(substring(@x:sec,1,1),$ucase,'')=''">
3109                                        <xsl:text>Appendix </xsl:text>
3110                                      </xsl:when>
3111                                      <xsl:otherwise>
3112                                        <xsl:text>Section </xsl:text>
3113                                      </xsl:otherwise>
3114                                    </xsl:choose>
[6]3115                                    <xsl:value-of select="@x:sec"/>
3116                                  </em>
3117                                  <xsl:text>  </xsl:text>
3118                                  <xsl:for-each select="key('index-xref-by-sec',concat(@target,'..',@x:sec))">
3119                                    <xsl:call-template name="insertSingleXref"/>
3120                                  </xsl:for-each>
3121                                </li>
3122                              </xsl:if>
3123                            </xsl:for-each>
3124                          </ul>
3125                        </xsl:if>
3126
3127                        <xsl:if test="current()/x:source/@href">
3128                          <xsl:variable name="rs3" select="$rs[not(@x:sec) and @x:rel]"/>
3129                          <xsl:variable name="doc" select="document(current()/x:source/@href)"/>
3130                          <xsl:if test="$rs3">
3131                            <ul class="ind"> 
3132                              <xsl:for-each select="$rs3">
3133                                <xsl:sort select="count($doc//*[@anchor and following::*/@anchor=substring-after(current()/@x:rel,'#')])" order="ascending" data-type="number"/>
3134                                <xsl:if test="generate-id(.) = generate-id(key('index-xref-by-anchor',concat(@target,'..',@x:rel)))">
3135                                  <li class="indline1">
3136                                    <em>
[272]3137                                      <xsl:variable name="sec">
3138                                        <xsl:for-each select="$doc//*[@anchor=substring-after(current()/@x:rel,'#')]">
3139                                          <xsl:call-template name="get-section-number"/>
3140                                        </xsl:for-each>
3141                                      </xsl:variable>
3142                                      <xsl:choose>
3143                                        <xsl:when test="translate(substring($sec,1,1),$ucase,'')=''">
3144                                          <xsl:text>Appendix </xsl:text>
3145                                        </xsl:when>
3146                                        <xsl:otherwise>
3147                                          <xsl:text>Section </xsl:text>
3148                                        </xsl:otherwise>
3149                                      </xsl:choose>
3150                                      <xsl:value-of select="$sec"/>
[6]3151                                    </em>
3152                                    <xsl:text>  </xsl:text>
3153                                    <xsl:for-each select="key('index-xref-by-anchor',concat(@target,'..',@x:rel))">
3154                                      <xsl:call-template name="insertSingleXref"/>
3155                                    </xsl:for-each>
3156                                  </li>
3157                                </xsl:if>
3158                              </xsl:for-each>
3159                            </ul>
3160                          </xsl:if>
3161                        </xsl:if>
3162                      </li>
3163                    </xsl:if>
3164                  </xsl:when>
3165                  <xsl:otherwise>
3166                    <!-- regular iref -->
3167                    <xsl:if test="generate-id(.) = generate-id(key('index-item',concat(@item,@anchor)))">
3168                      <xsl:variable name="item" select="@item"/>
[272]3169                      <xsl:variable name="in-artwork" select="key('index-item',$item)[@primary='true' and ancestor::artwork]"/>
[6]3170                         
3171                      <li class="indline1">
3172                        <xsl:choose>
3173                          <xsl:when test="$in-artwork">
3174                            <tt><xsl:value-of select="@item"/></tt>
3175                          </xsl:when>
3176                          <xsl:otherwise>
3177                            <xsl:value-of select="@item"/>
3178                          </xsl:otherwise>
3179                        </xsl:choose>
3180                        <xsl:text>  </xsl:text>
3181                       
3182                        <xsl:variable name="irefs3" select="key('index-item',@item)[not(@subitem) or @subitem='']"/>
[272]3183                        <xsl:variable name="xrefs3" select="key('xref-item',$irefs3[@x:for-anchor='']/../@anchor) | key('xref-item',$irefs3/@x:for-anchor)"/>
3184                        <xsl:variable name="extrefs3" select="key('extref-item',$irefs3[@x:for-anchor='']/../@anchor) | key('extref-item',$irefs3/@x:for-anchor)"/>
[6]3185
[189]3186                        <xsl:for-each select="$irefs3|$xrefs3|$extrefs3">
[6]3187                          <!-- <xsl:sort select="translate(@item,$lcase,$ucase)" />  -->
3188                          <xsl:call-template name="insertSingleIref"/>
3189                        </xsl:for-each>
3190         
3191                        <xsl:variable name="s2" select="key('index-item',@item)[@subitem and @subitem!='']"/>
3192                        <xsl:if test="$s2">
3193                          <ul class="ind"> 
3194                            <xsl:for-each select="$s2">
3195                              <xsl:sort select="translate(@subitem,$lcase,$ucase)"/>
3196                             
3197                              <xsl:if test="generate-id(.) = generate-id(key('index-item-subitem',concat(@item,'..',@subitem)))">
3198                 
[272]3199                                <xsl:variable name="in-artwork2" select="key('index-item-subitem',concat(@item,'..',@subitem))[@primary='true' and ancestor::artwork]"/>
[6]3200                 
3201                                <li class="indline1">
3202             
3203                                  <xsl:choose>
3204                                    <xsl:when test="$in-artwork2">
3205                                      <tt><xsl:value-of select="@subitem"/></tt>
3206                                    </xsl:when>
3207                                    <xsl:otherwise>
3208                                      <xsl:value-of select="@subitem"/>
3209                                    </xsl:otherwise>
3210                                  </xsl:choose>
3211                                  <xsl:text>  </xsl:text>
3212                                   
3213                                  <xsl:variable name="irefs4" select="key('index-item-subitem',concat(@item,'..',@subitem))"/>
[272]3214                                  <xsl:variable name="xrefs4" select="key('xref-item',$irefs4[@x:for-anchor='']/../@anchor) | key('xref-item',$irefs4/@x:for-anchor)"/>
3215                                  <xsl:variable name="extrefs4" select="key('extref-item',$irefs4[@x:for-anchor='']/../@anchor) | key('extref-item',$irefs4/@x:for-anchor)"/>
[6]3216
[189]3217                                  <xsl:for-each select="$irefs4|$xrefs4|$extrefs4">
[6]3218                                    <!--<xsl:sort select="translate(@item,$lcase,$ucase)" />-->                   
3219                                    <xsl:call-template name="insertSingleIref"/>
3220                                  </xsl:for-each>
3221               
3222                                </li>
3223                              </xsl:if>
3224                            </xsl:for-each>
3225                          </ul>
3226                        </xsl:if>
3227                      </li>
3228                    </xsl:if>
3229                  </xsl:otherwise>
3230                </xsl:choose>
3231             
3232                     
3233            </xsl:for-each>           
3234          </ul>
3235        </li>
3236      </xsl:if>
3237     
3238    </xsl:for-each>
3239  </ul>
3240  </div>
3241 
3242</xsl:template>
3243
3244
3245
3246
3247<xsl:template name="insertPreamble" myns:namespaceless-elements="xml2rfc">
3248
[440]3249  <section myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.status">
3250  <xsl:attribute name="title">
3251    <xsl:choose>
3252      <xsl:when test="$xml2rfc-rfcedstyle='yes'">Status of This Memo</xsl:when>
3253      <xsl:otherwise>Status of this Memo</xsl:otherwise>
3254    </xsl:choose>
3255  </xsl:attribute>
[6]3256
3257  <xsl:choose>
3258    <xsl:when test="/rfc/@ipr and not(/rfc/@number)">
3259      <t>
3260        <xsl:choose>
3261         
3262          <!-- RFC2026 -->
3263          <xsl:when test="/rfc/@ipr = 'full2026'">
3264            This document is an Internet-Draft and is
3265            in full conformance with all provisions of Section 10 of RFC2026.   
3266          </xsl:when>
3267          <xsl:when test="/rfc/@ipr = 'noDerivativeWorks2026'">
3268            This document is an Internet-Draft and is
3269            in full conformance with all provisions of Section 10 of RFC2026
3270            except that the right to produce derivative works is not granted.   
3271          </xsl:when>
3272          <xsl:when test="/rfc/@ipr = 'noDerivativeWorksNow'">
3273            This document is an Internet-Draft and is
3274            in full conformance with all provisions of Section 10 of RFC2026
3275            except that the right to produce derivative works is not granted.
3276            (If this document becomes part of an IETF working group activity,
3277            then it will be brought into full compliance with Section 10 of RFC2026.) 
3278          </xsl:when>
3279          <xsl:when test="/rfc/@ipr = 'none'">
3280            This document is an Internet-Draft and is
3281            NOT offered in accordance with Section 10 of RFC2026,
3282            and the author does not provide the IETF with any rights other
3283            than to publish as an Internet-Draft.
3284          </xsl:when>
3285         
3286          <!-- RFC3667 -->
3287          <xsl:when test="/rfc/@ipr = 'full3667'">
3288            This document is an Internet-Draft and is subject to all provisions
3289            of section 3 of RFC 3667.  By submitting this Internet-Draft, each
3290            author represents that any applicable patent or other IPR claims of
3291            which he or she is aware have been or will be disclosed, and any of
3292            which he or she become aware will be disclosed, in accordance with
3293            RFC 3668.
3294          </xsl:when>
3295          <xsl:when test="/rfc/@ipr = 'noModification3667'">
3296            This document is an Internet-Draft and is subject to all provisions
3297            of section 3 of RFC 3667.  By submitting this Internet-Draft, each
3298            author represents that any applicable patent or other IPR claims of
3299            which he or she is aware have been or will be disclosed, and any of
3300            which he or she become aware will be disclosed, in accordance with
3301            RFC 3668.  This document may not be modified, and derivative works of
3302            it may not be created, except to publish it as an RFC and to
3303            translate it into languages other than English<xsl:if test="/rfc/@iprExtract">,
3304            other than to extract <xref target="{/rfc/@iprExtract}"/> as-is
3305            for separate use.</xsl:if>.
3306          </xsl:when>
3307          <xsl:when test="/rfc/@ipr = 'noDerivatives3667'">
3308            This document is an Internet-Draft and is subject to all provisions
3309            of section 3 of RFC 3667 except for the right to produce derivative
3310            works.  By submitting this Internet-Draft, each author represents
3311            that any applicable patent or other IPR claims of which he or she
3312            is aware have been or will be disclosed, and any of which he or she
3313            become aware will be disclosed, in accordance with RFC 3668.  This
3314            document may not be modified, and derivative works of it may
3315            not be created<xsl:if test="/rfc/@iprExtract">, other than to extract
3316            <xref target="{/rfc/@iprExtract}"/> as-is for separate use.</xsl:if>.
3317          </xsl:when>
3318         
3319          <!-- RFC3978 -->
3320          <xsl:when test="/rfc/@ipr = 'full3978'">
3321            By submitting this Internet-Draft, each
3322            author represents that any applicable patent or other IPR claims of
3323            which he or she is aware have been or will be disclosed, and any of
3324            which he or she becomes aware will be disclosed, in accordance with
3325            Section 6 of BCP 79.
3326          </xsl:when>
3327          <xsl:when test="/rfc/@ipr = 'noModification3978'">
3328            By submitting this Internet-Draft, each
3329            author represents that any applicable patent or other IPR claims of
3330            which he or she is aware have been or will be disclosed, and any of
3331            which he or she becomes aware will be disclosed, in accordance with
3332            Section 6 of BCP 79.  This document may not be modified, and derivative works of
3333            it may not be created, except to publish it as an RFC and to
3334            translate it into languages other than English<xsl:if test="/rfc/@iprExtract">,
3335            other than to extract <xref target="{/rfc/@iprExtract}"/> as-is
3336            for separate use.</xsl:if>.
3337          </xsl:when>
3338          <xsl:when test="/rfc/@ipr = 'noDerivatives3978'">
3339            By submitting this Internet-Draft, each author represents
3340            that any applicable patent or other IPR claims of which he or she
3341            is aware have been or will be disclosed, and any of which he or she
3342            becomes aware will be disclosed, in accordance with Section 6 of BCP 79.  This
3343            document may not be modified, and derivative works of it may
3344            not be created<xsl:if test="/rfc/@iprExtract">, other than to extract
3345            <xref target="{/rfc/@iprExtract}"/> as-is for separate use.</xsl:if>.
3346          </xsl:when>
[440]3347 
3348          <!-- as of Nov 2008 -->
[447]3349          <xsl:when test="/rfc/@ipr = 'trust200811'                           or /rfc/@ipr = 'noModificationTrust200811'                           or  /rfc/@ipr = 'noDerivativesTrust200811'">
[440]3350            This Internet-Draft is submitted to IETF pursuant to, and in full
3351            conformance with, the provisions of BCP 78 and BCP 79.
3352          </xsl:when>
[446]3353 
3354          <!-- as of Feb 2009 -->
[447]3355          <xsl:when test="/rfc/@ipr = 'trust200902'                           or /rfc/@ipr = 'noModificationTrust200902'                           or /rfc/@ipr = 'noDerivativesTrust200902'                           or /rfc/@ipr = 'pre5378Trust200902'">
[446]3356            This Internet-Draft is submitted to IETF pursuant to, and in full
3357            conformance with, the provisions of BCP 78 and BCP 79.
3358          </xsl:when>
3359          <xsl:when test="/rfc/@ipr = 'noModificationTrust200902'">
3360            This document may not be modified, and derivative works of it may
3361            not be created, except to format it for publication as an RFC or
3362            to translate it into languages other than English.
3363          </xsl:when>
3364          <xsl:when test="/rfc/@ipr = 'noDerivativesTrust200902'">
3365            This document may not be modified, and derivative works of it may
3366            not be created, and it may not be published except as an Internet-Draft.
3367          </xsl:when>
3368          <xsl:when test="/rfc/@ipr = 'pre5378Trust200902'">
3369            This document may contain material from IETF Documents or IETF Contributions published or
3370            made publicly available before November 10, 2008. The person(s) controlling the copyright in
3371            some of this material may not have granted the IETF Trust the right to allow modifications of such
3372            material outside the IETF Standards Process. Without obtaining an adequate license from the
3373            person(s) controlling the copyright in such materials, this document may not be modified outside
3374            the IETF Standards Process, and derivative works of it may not be created outside the IETF
3375            Standards Process, except to format it for publication as an RFC or to translate it into languages
3376            other than English.
3377          </xsl:when>
3378 
[440]3379          <xsl:otherwise>
3380            CONFORMANCE UNDEFINED.
3381          </xsl:otherwise>
[6]3382        </xsl:choose>
[447]3383       
3384        <!-- restrictions -->
3385        <xsl:choose>
3386          <xsl:when test="/rfc/@ipr = 'noModificationTrust200811'">
3387            This document may not be modified, and derivative works of it may
3388            not be created, except to format it for publication as an RFC and
3389            to translate it into languages other than English.
3390          </xsl:when>
3391          <xsl:when test="/rfc/@ipr = 'noDerivativesTrust200811'">
3392            This document may not be modified, and derivative works of it may
3393            not be created, and it may not be published except as an Internet-Draft.
3394          </xsl:when>
3395
3396          <xsl:when test="/rfc/@ipr = 'noModificationTrust200902'">
3397            This document may not be modified, and derivative works of it may
3398            not be created, except to format it for publication as an RFC or
3399            to translate it into languages other than English.
3400          </xsl:when>
3401          <xsl:when test="/rfc/@ipr = 'noDerivativesTrust200902'">
3402            This document may not be modified, and derivative works of it may
3403            not be created, and it may not be published except as an Internet-Draft.
3404          </xsl:when>
[448]3405          <xsl:when test="/rfc/@ipr = 'pre5378Trust200902'">
3406            This document may contain material from IETF Documents or IETF Contributions published or
3407            made publicly available before November 10, 2008. The person(s) controlling the copyright in
3408            some of this material may not have granted the IETF Trust the right to allow modifications of such
3409            material outside the IETF Standards Process. Without obtaining an adequate license from the
3410            person(s) controlling the copyright in such materials, this document may not be modified outside
3411            the IETF Standards Process, and derivative works of it may not be created outside the IETF
3412            Standards Process, except to format it for publication as an RFC or to translate it into languages
3413            other than English.
3414          </xsl:when>
[447]3415
3416          <xsl:otherwise/>
3417        </xsl:choose>
[6]3418      </t>
3419      <t>
3420        Internet-Drafts are working documents of the Internet Engineering
3421        Task Force (IETF), its areas, and its working groups.
3422        Note that other groups may also distribute working documents as
3423        Internet-Drafts.
3424      </t>
3425      <t>
3426        Internet-Drafts are draft documents valid for a maximum of six months
3427        and may be updated, replaced, or obsoleted by other documents at any time.
3428        It is inappropriate to use Internet-Drafts as reference material or to cite
3429        them other than as &#8220;work in progress&#8221;.
3430      </t>
3431      <t>
3432        The list of current Internet-Drafts can be accessed at
3433        <eref target="http://www.ietf.org/ietf/1id-abstracts.txt"/>.
3434      </t>
3435      <t>
3436        The list of Internet-Draft Shadow Directories can be accessed at
3437        <eref target="http://www.ietf.org/shadow.html"/>.
3438      </t>
3439      <t>
3440        This Internet-Draft will expire in <xsl:call-template name="expirydate"/>.
3441      </t>
3442    </xsl:when>
3443
3444    <xsl:when test="/rfc/@category='bcp'">
3445      <t>
3446        This document specifies an Internet Best Current Practices for the Internet
3447        Community, and requests discussion and suggestions for improvements.
3448        Distribution of this memo is unlimited.
3449      </t>
3450    </xsl:when>
3451    <xsl:when test="/rfc/@category='exp'">
3452      <t>
3453        This memo defines an Experimental Protocol for the Internet community.
3454        It does not specify an Internet standard of any kind.
3455        Discussion and suggestions for improvement are requested.
3456        Distribution of this memo is unlimited.
3457      </t>
3458    </xsl:when>
3459    <xsl:when test="/rfc/@category='historic'">
3460      <t>
3461        This memo describes a historic protocol for the Internet community.
3462        It does not specify an Internet standard of any kind.
3463        Distribution of this memo is unlimited.
3464      </t>
3465    </xsl:when>
3466    <xsl:when test="/rfc/@category='info' or not(/rfc/@category)">
3467      <t>
3468        This memo provides information for the Internet community.
3469        It does not specify an Internet standard of any kind.
3470        Distribution of this memo is unlimited.
3471      </t>
3472    </xsl:when>
3473    <xsl:when test="/rfc/@category='std'">
3474      <t>
3475        This document specifies an Internet standards track protocol for the Internet
3476        community, and requests discussion and suggestions for improvements.
3477        Please refer to the current edition of the &#8220;Internet Official Protocol
3478        Standards&#8221; (STD 1) for the standardization state and status of this
3479        protocol. Distribution of this memo is unlimited.
3480      </t>
3481    </xsl:when>
3482    <xsl:otherwise>
3483      <t>UNSUPPORTED CATEGORY.</t>
3484    </xsl:otherwise>
3485  </xsl:choose>
[446]3486  </section>
[6]3487 
[227]3488  <xsl:choose>
[440]3489    <xsl:when test="$ipr-2008-11">
3490      <section title="Copyright Notice" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.copyrightnotice">
3491        <t>
3492          Copyright © <xsl:value-of select="$xml2rfc-ext-pub-year"/> IETF Trust and the persons identified
3493          as the document authors.  All rights reserved.
3494        </t>
[446]3495        <xsl:choose>
3496          <xsl:when test="$ipr-2009-02">
3497            <t>
3498              This document is subject to BCP 78 and the IETF Trust's Legal
3499              Provisions Relating to IETF Documents in effect on the date of
3500              publication of this document
3501              (<eref target="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</eref>).
3502              Please review these documents carefully, as they describe your rights and restrictions with
3503              respect to this document.
3504            </t>
3505          </xsl:when>
3506          <xsl:otherwise>
3507            <t>
3508              This document is subject to BCP 78 and the IETF Trust's Legal
3509              Provisions Relating to IETF Documents
3510              (<eref target="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</eref>) in effect on the date of
3511              publication of this document.  Please review these documents
3512              carefully, as they describe your rights and restrictions with respect
3513              to this document.
3514            </t>
3515          </xsl:otherwise>
3516        </xsl:choose>
3517       
3518        <!-- special case: RFC5378 escape applies to RFCs as well -->
[448]3519        <!-- <xsl:if test="/rfc/@ipr = 'pre5378Trust200902'">
[446]3520          <t>
3521            This document may contain material from IETF Documents or IETF Contributions published or
3522            made publicly available before November 10, 2008. The person(s) controlling the copyright in
3523            some of this material may not have granted the IETF Trust the right to allow modifications of such
3524            material outside the IETF Standards Process. Without obtaining an adequate license from the
3525            person(s) controlling the copyright in such materials, this document may not be modified outside
3526            the IETF Standards Process, and derivative works of it may not be created outside the IETF
3527            Standards Process, except to format it for publication as an RFC or to translate it into languages
3528            other than English.
3529          </t>
[448]3530        </xsl:if> -->
[446]3531       
[440]3532      </section>
3533    </xsl:when>
3534    <xsl:when test="$ipr-2007-08">
3535      <!-- no copyright notice -->
3536    </xsl:when>
[227]3537    <xsl:when test="$ipr-rfc4748">
3538      <section title="Copyright Notice" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.copyrightnotice">
3539        <t>
3540          Copyright © The IETF Trust (<xsl:value-of select="$xml2rfc-ext-pub-year"/>).  All Rights Reserved.
3541        </t>
3542      </section>
3543    </xsl:when>
3544    <xsl:otherwise>
3545      <section title="Copyright Notice" myns:unnumbered="unnumbered" myns:notoclink="notoclink" anchor="{$anchor-prefix}.copyrightnotice">
3546        <t>
3547          Copyright © The Internet Society (<xsl:value-of select="$xml2rfc-ext-pub-year"/>).  All Rights Reserved.
[440]3548        </t>
[227]3549      </section>
3550    </xsl:otherwise>
3551  </xsl:choose>
[6]3552 
3553</xsl:template>
3554
3555<!-- TOC generation -->
3556
3557<xsl:template match="/" mode="toc">
3558  <hr xmlns="http://www.w3.org/1999/xhtml" class="noprint"/>
3559
3560  <h1 xmlns="http://www.w3.org/1999/xhtml" class="np" id="{$anchor-prefix}.toc"> <!-- this pagebreak occurs always -->
3561    <a href="#{$anchor-prefix}.toc">Table of Contents</a>
3562  </h1>
3563
3564  <ul xmlns="http://www.w3.org/1999/xhtml" class="toc">
3565    <xsl:apply-templates mode="toc"/>
3566  </ul>
3567</xsl:template>
3568
3569<xsl:template name="insert-toc-line">
3570  <xsl:param name="number"/>
3571  <xsl:param name="target"/>
3572  <xsl:param name="title"/>
3573  <xsl:param name="tocparam"/>
3574  <xsl:param name="oldtitle"/>
3575  <xsl:param name="waschanged"/>
3576
3577  <!-- handle tocdepth parameter -->
3578  <xsl:choose>
3579    <xsl:when test="($tocparam='' or $tocparam='default') and string-length(translate($number,'.ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890§','.')) &gt;= $parsedTocDepth">
3580      <!-- dropped entry because excluded -->
3581      <xsl:attribute name="class">tocline2</xsl:attribute>
3582    </xsl:when>
3583    <xsl:when test="$tocparam='exclude'">
3584      <!-- dropped entry because excluded -->
3585      <xsl:attribute name="class">tocline2</xsl:attribute>
3586    </xsl:when>
3587    <xsl:otherwise>
3588      <xsl:choose>
3589        <xsl:when test="starts-with($number,'del-')">
3590          <del xmlns="http://www.w3.org/1999/xhtml">
3591            <xsl:value-of select="$number"/>
3592            <a href="#{$target}"><xsl:value-of select="$title"/></a>
3593          </del>
3594        </xsl:when>
3595        <xsl:otherwise>
3596          <xsl:choose>
3597            <xsl:when test="not(contains($number,'.'))">
3598              <xsl:attribute name="class">tocline0</xsl:attribute>
3599            </xsl:when>
3600            <xsl:otherwise>
3601              <xsl:attribute name="class">tocline1</xsl:attribute>
3602            </xsl:otherwise>
3603          </xsl:choose>
3604          <xsl:if test="$number != ''">
3605            <xsl:call-template name="emit-section-number">
3606              <xsl:with-param name="no" select="$number"/>
3607            </xsl:call-template>
3608            <xsl:text>   </xsl:text>
3609          </xsl:if>
3610          <a xmlns="http://www.w3.org/1999/xhtml" href="#{$target}">
3611            <xsl:choose>
3612              <xsl:when test="$waschanged!=''">
3613                <ins><xsl:value-of select="$title"/></ins>
3614                <del><xsl:value-of select="$oldtitle"/></del>
3615              </xsl:when>
3616              <xsl:otherwise>
3617                <xsl:value-of select="$title"/>
3618              </xsl:otherwise>
3619            </xsl:choose>
3620          </a>
3621        </xsl:otherwise>
3622      </xsl:choose>
3623    </xsl:otherwise>
3624  </xsl:choose>
3625</xsl:template>
3626
3627<xsl:template match="back" mode="toc">
3628
3629  <!-- <xsl:apply-templates select="references" mode="toc" /> -->
3630
3631  <xsl:if test="//cref and $xml2rfc-comments='yes' and $xml2rfc-inline!='yes'">
3632    <li xmlns="http://www.w3.org/1999/xhtml">
3633      <xsl:call-template name="insert-toc-line">
3634        <xsl:with-param name="target" select="concat($anchor-prefix,'.comments')"/>
3635        <xsl:with-param name="title" select="'Editorial Comments'"/>
3636      </xsl:call-template>
3637    </li>
3638  </xsl:if>
3639
3640  <xsl:if test="$xml2rfc-ext-authors-section!='end'">
3641    <xsl:apply-templates select="/rfc/front" mode="toc"/>
3642  </xsl:if>
3643  <xsl:apply-templates select="*[not(self::references)]" mode="toc"/>
3644
3645  <xsl:if test="$xml2rfc-ext-authors-section='end'">
3646    <xsl:apply-templates select="/rfc/front" mode="toc"/>
3647  </xsl:if>
3648
3649  <!-- copyright statements -->
[440]3650  <xsl:if test="not($xml2rfc-private) and not($no-copylong)">
[6]3651    <li xmlns="http://www.w3.org/1999/xhtml">
3652      <xsl:call-template name="insert-toc-line">
3653        <xsl:with-param name="target" select="concat($anchor-prefix,'.ipr')"/>
3654        <xsl:with-param name="title" select="'Intellectual Property and Copyright Statements'"/>
3655      </xsl:call-template>
3656    </li>
3657  </xsl:if>
3658 
3659  <!-- insert the index if index entries exist -->
3660  <xsl:if test="//iref">
3661    <li xmlns="http://www.w3.org/1999/xhtml">
3662      <xsl:call-template name="insert-toc-line">
3663        <xsl:with-param name="target" select="concat($anchor-prefix,'.index')"/>
3664        <xsl:with-param name="title" select="'Index'"/>
3665      </xsl:call-template>
3666    </li>
3667  </xsl:if>
3668
3669</xsl:template>
3670
3671<xsl:template match="front" mode="toc">
3672 
[329]3673  <xsl:variable name="authors-title">
3674    <xsl:call-template name="get-authors-section-title"/>
3675  </xsl:variable>
3676  <xsl:variable name="authors-number">
3677    <xsl:call-template name="get-authors-section-number"/>
3678  </xsl:variable>
[6]3679
[329]3680  <xsl:if test="$authors-number!='suppress'">
3681    <li xmlns="http://www.w3.org/1999/xhtml">
3682      <xsl:call-template name="insert-toc-line">
3683        <xsl:with-param name="target" select="concat($anchor-prefix,'.authors')"/>
3684        <xsl:with-param name="title" select="$authors-title"/>
3685        <xsl:with-param name="number" select="$authors-number"/>
3686      </xsl:call-template>
3687    </li>
3688  </xsl:if>
3689
[6]3690</xsl:template>
3691
3692<xsl:template name="references-toc">
3693
3694  <!-- distinguish two cases: (a) single references element (process
3695  as toplevel section; (b) multiple references sections (add one toplevel
3696  container with subsection) -->
3697
3698  <xsl:variable name="refsecs" select="/rfc/back/references|/rfc/back/ed:replace/ed:ins/references"/>
3699   
3700  <xsl:choose>
3701    <xsl:when test="count($refsecs) = 0">
3702      <!-- nop -->
3703    </xsl:when>
3704    <xsl:when test="count($refsecs) = 1">
3705      <xsl:for-each select="$refsecs">
3706        <xsl:variable name="title">
3707          <xsl:choose>
3708            <xsl:when test="@title!=''"><xsl:value-of select="@title"/></xsl:when>
3709            <xsl:otherwise>References</xsl:otherwise>
3710          </xsl:choose>
3711        </xsl:variable>
3712     
3713        <li xmlns="http://www.w3.org/1999/xhtml">
3714          <xsl:call-template name="insert-toc-line">
3715            <xsl:with-param name="number">
3716              <xsl:call-template name="get-references-section-number"/>
3717            </xsl:with-param>
3718            <xsl:with-param name="target" select="concat($anchor-prefix,'.references')"/>
3719            <xsl:with-param name="title" select="$title"/>
3720          </xsl:call-template>
3721        </li>
3722      </xsl:for-each>
3723    </xsl:when>
3724    <xsl:otherwise>
3725      <li xmlns="http://www.w3.org/1999/xhtml">
3726        <!-- insert pseudo container -->   
3727        <xsl:call-template name="insert-toc-line">
3728          <xsl:with-param name="number">
3729            <xsl:call-template name="get-references-section-number"/>
3730          </xsl:with-param>
3731          <xsl:with-param name="target" select="concat($anchor-prefix,'.references')"/>
3732          <xsl:with-param name="title" select="'References'"/>
3733        </xsl:call-template>
3734 
3735        <ul class="toc">
3736          <!-- ...with subsections... -->   
3737          <xsl:for-each select="$refsecs">
3738            <xsl:variable name="title">
3739              <xsl:choose>
3740                <xsl:when test="@title!=''"><xsl:value-of select="@title"/></xsl:when>
3741                <xsl:otherwise>References</xsl:otherwise>
3742              </xsl:choose>
3743            </xsl:variable>
3744         
3745            <xsl:variable name="sectionNumber">
3746              <xsl:call-template name="get-section-number"/>
3747            </xsl:variable>
3748   
3749            <xsl:variable name="num">
3750              <xsl:number level="any"/>
3751            </xsl:variable>
3752   
3753            <li>
3754              <xsl:call-template name="insert-toc-line">
3755                <xsl:with-param name="number" select="$sectionNumber"/>
3756                <xsl:with-param name="target" select="concat($anchor-prefix,'.references','.',$num)"/>
3757                <xsl:with-param name="title" select="$title"/>
3758              </xsl:call-template>
3759            </li>
3760          </xsl:for-each>
3761        </ul>
3762      </li>
3763    </xsl:otherwise>
3764  </xsl:choose>
3765</xsl:template>
3766
3767<xsl:template match="section|appendix" mode="toc">
3768  <xsl:variable name="sectionNumber">
3769    <xsl:call-template name="get-section-number"/>
3770  </xsl:variable>
3771
3772  <xsl:variable name="target">
3773    <xsl:choose>
3774      <xsl:when test="@anchor"><xsl:value-of select="@anchor"/></xsl:when>
3775       <xsl:otherwise><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$sectionNumber"/></xsl:otherwise>
3776    </xsl:choose>
3777  </xsl:variable>
3778
3779  <!-- obtain content, just to check whether we need to recurse at all -->
3780  <xsl:variable name="content">
3781    <li xmlns="http://www.w3.org/1999/xhtml">
3782      <xsl:call-template name="insert-toc-line">
3783        <xsl:with-param name="number" select="$sectionNumber"/>
3784        <xsl:with-param name="target" select="$target"/>
3785        <xsl:with-param name="title" select="@title"/>
3786        <xsl:with-param name="tocparam" select="@toc"/>
3787        <xsl:with-param name="oldtitle" select="@ed:old-title"/>
3788        <xsl:with-param name="waschanged" select="@ed:resolves"/>
3789      </xsl:call-template>
3790   
3791      <ul class="toc">
3792        <xsl:apply-templates mode="toc"/>
3793      </ul>
3794    </li>
3795  </xsl:variable>
3796 
3797  <xsl:if test="$content!=''">
3798    <li xmlns="http://www.w3.org/1999/xhtml">
3799      <xsl:call-template name="insert-toc-line">
3800        <xsl:with-param name="number" select="$sectionNumber"/>
3801        <xsl:with-param name="target" select="$target"/>
3802        <xsl:with-param name="title" select="@title"/>
3803        <xsl:with-param name="tocparam" select="@toc"/>
3804        <xsl:with-param name="oldtitle" select="@ed:old-title"/>
3805        <xsl:with-param name="waschanged" select="@ed:resolves"/>
3806      </xsl:call-template>
3807   
3808      <!-- obtain nested content, just to check whether we need to recurse at all -->
3809      <xsl:variable name="nested-content">
3810        <ul class="toc">
3811          <xsl:apply-templates mode="toc"/>
3812        </ul>
3813      </xsl:variable>
3814     
3815      <!-- only recurse if we need to (do not produce useless list container) -->     
3816      <xsl:if test="$nested-content!=''">
3817        <ul class="toc">
3818          <xsl:apply-templates mode="toc"/>
3819        </ul>
3820      </xsl:if>
3821    </li>
3822  </xsl:if>
3823</xsl:template>
3824
3825<xsl:template match="middle" mode="toc">
3826  <xsl:apply-templates mode="toc"/>
3827  <xsl:call-template name="references-toc"/>
3828</xsl:template>
3829
3830<xsl:template match="rfc" mode="toc">
3831  <xsl:apply-templates select="middle|back" mode="toc"/>
3832</xsl:template>
3833
3834<xsl:template match="ed:del|ed:ins|ed:replace" mode="toc">
3835  <xsl:apply-templates mode="toc"/>
3836</xsl:template>
3837
3838<xsl:template match="*|text()" mode="toc"/>
3839
3840
3841<xsl:template name="insertTocAppendix">
3842 
3843  <xsl:if test="//figure[@title!='' or @anchor!='']">
3844    <ul xmlns="http://www.w3.org/1999/xhtml" class="toc">
3845      <xsl:for-each select="//figure[@title!='' or @anchor!='']">
3846        <xsl:variable name="title">Figure <xsl:value-of select="position()"/><xsl:if test="@title">: <xsl:value-of select="@title"/></xsl:if>
3847        </xsl:variable>
3848        <li>
3849          <xsl:call-template name="insert-toc-line">
3850            <xsl:with-param name="target" select="concat($anchor-prefix,'.figure.',position())"/>
3851            <xsl:with-param name="title" select="$title"/>
3852          </xsl:call-template>
3853        </li>
3854      </xsl:for-each>
3855    </ul>
3856  </xsl:if>
3857 
3858  <!-- experimental -->
3859  <xsl:if test="//ed:issue">
3860    <xsl:call-template name="insertIssuesList"/>
3861  </xsl:if>
3862
3863</xsl:template>
3864
3865<xsl:template name="referencename">
3866  <xsl:param name="node"/>
3867 
3868  <xsl:for-each select="$node">
3869    <xsl:choose>
3870      <xsl:when test="$xml2rfc-symrefs!='no' and ancestor::ed:del">
3871        <xsl:variable name="unprefixed" select="substring-after(@anchor,'deleted-')"/>
3872        <xsl:choose>
3873          <xsl:when test="$unprefixed!=''">
3874