source: rfc2629xslt/rfc2629toXHTML.xslt @ 571

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

Update to latest version of rfc2629.xslt.

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