source: rfc2629xslt/rfc2629toXHTML.xslt @ 662

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