source: rfc2629xslt/rfc2629toXHTML.xslt @ 447

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

Update to latest version of rfc2629.xslt and experimental version of xml2rfc.tcl.

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