source: rfc2629xslt/rfc2629toXHTML.xslt @ 502

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

update to latest version of rfc2629.xslt package

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