source: rfc2629xslt/rfc2629toXHTML.xslt @ 440

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

update to latest version of rfc2629.xslt, add <workgroup> element throughout

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