source: rfc2629xslt/rfc2629toXHTML.xslt @ 285

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

Upgrade to latest version of rfc2629.xslt

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