source: rfc2629xslt/rfc2629toXHTML.xslt @ 814

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

latest versions of rfc2629.xslt and xml2rfc.tcl, bump up document dates

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