source: rfc2629xslt/rfc2629toFO.xslt @ 2627

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

bump up document dates, update to latest version of rfc2629.xslt

  • Property svn:eol-style set to native
File size: 109.0 KB
RevLine 
[6]1<!--
[588]2    XSLT transformation from RFC2629 XML format to XSL-FO
[6]3     
[2610]4    Copyright (c) 2006-2014, Julian Reschke (julian.reschke@greenbytes.de)
[6]5    All rights reserved.
6
7    Redistribution and use in source and binary forms, with or without
8    modification, are permitted provided that the following conditions are met:
9
10    * Redistributions of source code must retain the above copyright notice,
11      this list of conditions and the following disclaimer.
12    * Redistributions in binary form must reproduce the above copyright notice,
13      this list of conditions and the following disclaimer in the documentation
14      and/or other materials provided with the distribution.
15    * Neither the name of Julian Reschke nor the names of its contributors
16      may be used to endorse or promote products derived from this software
17      without specific prior written permission.
18
19    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29    POSSIBILITY OF SUCH DAMAGE.
30-->
31
[440]32<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
[6]33    version="1.0"
[440]34
[285]35    xmlns:ed="http://greenbytes.de/2002/rfcedit"
36    xmlns:exslt="http://exslt.org/common"
[6]37    xmlns:fo="http://www.w3.org/1999/XSL/Format"
[285]38    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
39    xmlns:myns="mailto:julian.reschke@greenbytes.de?subject=rcf2629.xslt"
40    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
[6]41    xmlns:x="http://purl.org/net/xml2rfc/ext"
42
[440]43    exclude-result-prefixes="ed exslt msxsl myns rdf x"
[6]44>
45
46<xsl:import href="rfc2629.xslt" />
47
[2610]48<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
[6]49
[329]50<!-- page sizes as per <http://tools.ietf.org/html/draft-rfc-editor-rfc2223bis-08#section-3.2> -->
51<xsl:attribute-set name="page">
52  <xsl:attribute name="margin-left">1in</xsl:attribute>
53  <xsl:attribute name="margin-right">1in</xsl:attribute>
54  <xsl:attribute name="page-height">11in</xsl:attribute>
55  <xsl:attribute name="page-width">8.5in</xsl:attribute>
56</xsl:attribute-set>
57
[246]58<xsl:attribute-set name="base">
[704]59  <xsl:attribute name="font-family">serif</xsl:attribute>
60  <xsl:attribute name="font-size">10pt</xsl:attribute>
[6]61</xsl:attribute-set>
62
[246]63<xsl:attribute-set name="h1">
[704]64  <xsl:attribute name="font-weight">bold</xsl:attribute>
65  <xsl:attribute name="font-size">14pt</xsl:attribute>
66  <xsl:attribute name="keep-with-next">always</xsl:attribute>
67  <xsl:attribute name="space-before">14pt</xsl:attribute>
68  <xsl:attribute name="space-after">7pt</xsl:attribute>
[6]69</xsl:attribute-set>
70
71<xsl:attribute-set name="h2">
[704]72  <xsl:attribute name="font-weight">bold</xsl:attribute>
73  <xsl:attribute name="font-size">12pt</xsl:attribute>
74  <xsl:attribute name="keep-with-next">always</xsl:attribute>
75  <xsl:attribute name="space-before">12pt</xsl:attribute>
76  <xsl:attribute name="space-after">6pt</xsl:attribute>
[6]77</xsl:attribute-set>
78
79<xsl:attribute-set name="h3">
[704]80  <xsl:attribute name="font-weight">bold</xsl:attribute>
81  <xsl:attribute name="font-size">11pt</xsl:attribute>
82  <xsl:attribute name="keep-with-next">always</xsl:attribute>
83  <xsl:attribute name="space-before">11pt</xsl:attribute>
84  <xsl:attribute name="space-after">3pt</xsl:attribute>
[6]85</xsl:attribute-set>
86
87<xsl:attribute-set name="comment">
[704]88  <xsl:attribute name="font-weight">bold</xsl:attribute>
89  <xsl:attribute name="background-color">yellow</xsl:attribute>
[6]90</xsl:attribute-set>
91
[246]92<xsl:attribute-set name="external-link">
93  <xsl:attribute name="color">blue</xsl:attribute>
94  <xsl:attribute name="text-decoration">underline</xsl:attribute>
95</xsl:attribute-set>
[6]96
[246]97<xsl:attribute-set name="index">
[704]98  <xsl:attribute name="font-size">9pt</xsl:attribute>
[246]99</xsl:attribute-set>
100
[6]101<xsl:attribute-set name="internal-link">
102  <xsl:attribute name="color">#000080</xsl:attribute>
103</xsl:attribute-set>
104
[246]105<xsl:attribute-set name="newpage">
[571]106  <xsl:attribute name="page-break-before">
107    <xsl:choose>
108      <xsl:when test="$xml2rfc-ext-duplex='yes'">right</xsl:when>
109      <xsl:otherwise>always</xsl:otherwise>
110    </xsl:choose>
111  </xsl:attribute>
[246]112</xsl:attribute-set>
113
114<xsl:attribute-set name="title">
115  <xsl:attribute name="text-align">center</xsl:attribute>
116  <xsl:attribute name="font-weight">bold</xsl:attribute>
117  <xsl:attribute name="font-size">18pt</xsl:attribute>
118  <xsl:attribute name="space-before">3em</xsl:attribute>
119  <xsl:attribute name="space-after">3em</xsl:attribute>
[6]120</xsl:attribute-set>
121
122<xsl:template match="abstract">
[246]123  <fo:block xsl:use-attribute-sets="h1" id="{concat($anchor-prefix,'.abstract')}">Abstract</fo:block>
[704]124  <xsl:apply-templates />
[6]125</xsl:template>
126
127<!-- optimize empty lines starting artwork -->
128<xsl:template match="artwork/text()[0=count(preceding-sibling::node())]">
129  <xsl:choose>
130    <xsl:when test="substring(.,1,1)='&#10;'">
131      <xsl:value-of select="substring(.,2)" />
132    </xsl:when>
133    <xsl:otherwise>
134      <xsl:value-of select="." />
135    </xsl:otherwise>
136  </xsl:choose>
137</xsl:template>
138
139<xsl:template name="add-artwork-attr">
140  <xsl:choose>
[440]141    <xsl:when test="@type='abnf' or @type='abnf2045' or @type='abnf2616' or @type='application/xml-dtd' or @type='application/relax-ng-compact-syntax'">
[6]142      <!-- just display inline -->
143    </xsl:when>
144
145    <xsl:when test="starts-with(@type,'message/http') and contains(@type,'msgtype=&quot;request&quot;')">
146      <xsl:attribute name="background-color">#f0f0f0</xsl:attribute>
147      <xsl:attribute name="border-style">dotted</xsl:attribute>
148      <xsl:attribute name="border-width">thin</xsl:attribute>
149    </xsl:when>
150
151    <xsl:when test="starts-with(@type,'message/http')">
152      <xsl:attribute name="background-color">#f8f8f8</xsl:attribute>
153      <xsl:attribute name="border-style">dotted</xsl:attribute>
154      <xsl:attribute name="border-width">thin</xsl:attribute>
155    </xsl:when>
156
157    <xsl:when test="starts-with(@type,'text/plain') or @type='example' or @type='code'">
158      <xsl:attribute name="background-color">#f8f8f8</xsl:attribute>
159      <xsl:attribute name="border-style">dotted</xsl:attribute>
160      <xsl:attribute name="border-width">thin</xsl:attribute>
161    </xsl:when>
162
163    <xsl:otherwise>
164      <xsl:attribute name="background-color">#dddddd</xsl:attribute>
165      <xsl:attribute name="font-size">9pt</xsl:attribute>
166    </xsl:otherwise>
167  </xsl:choose>
[329]168 
[689]169  <xsl:choose>
170    <xsl:when test="@align='center'">
171      <xsl:attribute name="text-align">center</xsl:attribute>
172    </xsl:when>
173    <xsl:when test="@align='right'">
174      <xsl:attribute name="text-align">right</xsl:attribute>
175    </xsl:when>
176    <xsl:otherwise/>
177  </xsl:choose>
[6]178</xsl:template>
179
180<xsl:template match="artwork">
[704]181  <xsl:if test="@x:isCodeComponent='yes'">
182    <fo:block font-family="monospace" color="gray">&lt;CODE BEGINS></fo:block>
183  </xsl:if>
184  <fo:block font-family="monospace" padding=".5em"
[6]185    white-space-treatment="preserve" linefeed-treatment="preserve"
186    white-space-collapse="false" page-break-inside="avoid">
187    <xsl:call-template name="add-artwork-attr"/>
188    <xsl:apply-templates/>
189  </fo:block>
[704]190  <xsl:if test="@x:isCodeComponent='yes'">
191    <fo:block font-family="monospace" color="gray">&lt;CODE ENDS></fo:block>
192  </xsl:if>
[6]193</xsl:template>
194
195<xsl:template match="artwork[@src and starts-with(@type,'image/')]">
[704]196  <fo:block>
[689]197    <xsl:choose>
198      <xsl:when test="@align='center'">
199        <xsl:attribute name="text-align">center</xsl:attribute>
200      </xsl:when>
201      <xsl:when test="@align='right'">
202        <xsl:attribute name="text-align">right</xsl:attribute>
203      </xsl:when>
204      <xsl:otherwise/>
205    </xsl:choose>
206    <fo:external-graphic scaling-method="integer-pixels" src="url({@src})">
207    </fo:external-graphic>
208  </fo:block>
[6]209</xsl:template>
210
211<xsl:template match="author">
[329]212  <fo:block start-indent="2em" space-before=".5em" space-after=".5em">
213    <fo:block>
214      <fo:wrapper font-weight="bold"><xsl:value-of select="@fullname" /></fo:wrapper>
215      <xsl:if test="@role">
216        <fo:wrapper> (<xsl:value-of select="@role" />)</fo:wrapper>
217      </xsl:if>
[799]218      <!-- annotation support for Martin "uuml" Duerst -->
219      <xsl:if test="@x:annotation">
220        <xsl:text> </xsl:text>
221        <fo:wrapper font-style="italic"><xsl:value-of select="@x:annotation"/></fo:wrapper>
222      </xsl:if>
[329]223    </fo:block>
224    <fo:block><xsl:value-of select="organization" /></fo:block>
[704]225    <xsl:for-each select="address/postal/street">
[329]226      <fo:block><xsl:value-of select="." /></fo:block>
227    </xsl:for-each>
[704]228    <xsl:if test="address/postal/city">
[329]229      <fo:block><xsl:value-of select="concat(address/postal/city,', ',address/postal/region,' ',address/postal/code)" /></fo:block>
[704]230    </xsl:if>
231    <xsl:if test="address/postal/country">
[329]232      <fo:block><xsl:value-of select="address/postal/country" /></fo:block>
[6]233    </xsl:if>
[704]234    <xsl:if test="address/phone">
[329]235      <fo:block>Phone:&#0160;<fo:basic-link external-destination="url('tel:{translate(address/phone,' ','')}')" xsl:use-attribute-sets="external-link"><xsl:value-of select="address/phone" /></fo:basic-link></fo:block>
236    </xsl:if>
[704]237    <xsl:if test="address/facsimile">
[329]238      <fo:block>Fax:&#0160;<fo:basic-link external-destination="url('tel:{translate(address/facsimile,' ','')}')" xsl:use-attribute-sets="external-link"><xsl:value-of select="address/facsimile" /></fo:basic-link></fo:block>
239    </xsl:if>
[704]240    <xsl:for-each select="address/email">
[329]241      <xsl:variable name="email">
242        <xsl:call-template name="extract-email"/>
243      </xsl:variable>
244      <fo:block>EMail:&#0160;
245        <xsl:choose>
246          <xsl:when test="$xml2rfc-linkmailto='no'">
247              <xsl:value-of select="$email" />
248          </xsl:when>
249          <xsl:otherwise>
250            <fo:basic-link external-destination="url('mailto:{$email}')" xsl:use-attribute-sets="external-link"><xsl:value-of select="$email" /></fo:basic-link>
251          </xsl:otherwise>
252        </xsl:choose>
253      </fo:block>
254    </xsl:for-each>
[704]255    <xsl:for-each select="address/uri">
[329]256      <xsl:variable name="uri">
257        <xsl:call-template name="extract-uri"/>
258      </xsl:variable>
[799]259      <fo:block>
260        <xsl:text>URI:&#0160;</xsl:text>
261        <fo:basic-link external-destination="url('{$uri}')" xsl:use-attribute-sets="external-link"><xsl:value-of select="$uri" /></fo:basic-link>
262        <xsl:if test="@x:annotation">
263          <xsl:text> </xsl:text>
264          <fo:wrapper font-style="italic"><xsl:value-of select="@x:annotation"/></fo:wrapper>
265        </xsl:if>
266      </fo:block>
[329]267    </xsl:for-each>
[6]268  </fo:block>
269</xsl:template>
270
271<xsl:template match="back">
[662]272  <!-- done in parent template -->
[6]273</xsl:template>
274
275
276<xsl:template match="figure">
277
278  <xsl:variable name="anch">
279    <xsl:call-template name="get-figure-anchor"/>
280  </xsl:variable>
281
282  <fo:block space-before=".5em" space-after=".5em" id="{$anch}" page-break-inside="avoid">
283    <xsl:if test="not(ancestor::t)">
284      <xsl:attribute name="start-indent">2em</xsl:attribute>
285    </xsl:if>
286    <xsl:call-template name="add-anchor"/>
[704]287    <xsl:apply-templates />
[189]288    <xsl:if test="(@title!='' or @anchor!='') and not(@suppress-title='true')">
[2627]289      <xsl:variable name="n"><xsl:call-template name="get-figure-number"/></xsl:variable>
[6]290      <fo:block text-align="center" space-before=".5em" space-after="1em">Figure <xsl:value-of select="$n"/><xsl:if test="@title!=''">: <xsl:value-of select="@title" /></xsl:if></fo:block>
291    </xsl:if>
292  </fo:block>
293</xsl:template>
294           
295<xsl:template match="front">
296
297  <xsl:if test="$xml2rfc-topblock!='no'">
[704]298    <!-- collect information for left column -->
[6]299     
[704]300    <xsl:variable name="leftColumn">
[6]301      <xsl:call-template name="collectLeftHeaderColumn" /> 
302    </xsl:variable>
303 
304    <!-- collect information for right column -->
305     
306    <xsl:variable name="rightColumn">
307      <xsl:call-template name="collectRightHeaderColumn" />   
308    </xsl:variable>
309     
310      <!-- insert the collected information -->
311     
[704]312    <fo:table width="100%" table-layout="fixed">
[6]313      <fo:table-column column-width="proportional-column-width(1)" />
314      <fo:table-column column-width="proportional-column-width(1)" />
315      <fo:table-body>
316        <xsl:choose>
317          <xsl:when test="function-available('exslt:node-set')">
[704]318             <xsl:call-template name="emitheader">
319               <xsl:with-param name="lc" select="exslt:node-set($leftColumn)" />   
320               <xsl:with-param name="rc" select="exslt:node-set($rightColumn)" />   
[6]321            </xsl:call-template>
322          </xsl:when>   
323          <xsl:otherwise>   
[704]324             <xsl:call-template name="emitheader">
325               <xsl:with-param name="lc" select="$leftColumn" />   
326               <xsl:with-param name="rc" select="$rightColumn" />   
[6]327            </xsl:call-template>
328          </xsl:otherwise>   
329        </xsl:choose>
[704]330      </fo:table-body>
331    </fo:table>
[6]332  </xsl:if>
333     
[246]334  <fo:block xsl:use-attribute-sets="title">
[6]335    <xsl:apply-templates select="/rfc/front/title" mode="get-text-content" />
336    <xsl:if test="/rfc/@docName">
[246]337      <fo:block font-size="80%"><xsl:value-of select="/rfc/@docName" /></fo:block>
[6]338    </xsl:if>
[662]339  </fo:block>
[6]340 
[704]341  <xsl:if test="$xml2rfc-private='' and not($abstract-first)">
[662]342    <xsl:call-template name="emit-ietf-preamble"/>
[6]343  </xsl:if>
344 
[446]345  <xsl:apply-templates select="x:boilerplate"/>
[704]346  <xsl:apply-templates select="abstract" />
[1145]347  <xsl:apply-templates select="note[@title!='IESG Note' or $xml2rfc-private!='']" />
[6]348
[704]349  <xsl:if test="$xml2rfc-private='' and $abstract-first">
[662]350    <xsl:call-template name="emit-ietf-preamble"/>
351  </xsl:if>
352
[704]353  <xsl:if test="$xml2rfc-toc='yes'">
354    <xsl:apply-templates select="/" mode="toc" />
355    <!--<xsl:call-template name="insertTocAppendix" />-->
356  </xsl:if>
[6]357
358</xsl:template>
359   
360<xsl:template match="eref[node()]">
361  <fo:basic-link external-destination="url('{@target}')" xsl:use-attribute-sets="external-link">
[754]362    <xsl:call-template name="format-uri">
363      <xsl:with-param name="s" select="."/>
364    </xsl:call-template>
[6]365  </fo:basic-link>
366  <fo:footnote>
367    <fo:inline font-size="6pt" vertical-align="super"><xsl:number level="any" count="eref[node()]" /></fo:inline>
368    <fo:footnote-body>
369      <fo:block font-size="8pt" start-indent="2em" text-align="left">
370        <fo:inline font-size="6pt" vertical-align="super"><xsl:number level="any" count="eref[node()]" /></fo:inline>
371        <xsl:text> </xsl:text>
372        <xsl:value-of select="@target" />
373      </fo:block>
374    </fo:footnote-body>
375  </fo:footnote>
376</xsl:template>
377
378<xsl:template match="eref[not(node())]">
379  <xsl:text>&lt;</xsl:text>
380  <fo:basic-link external-destination="url('{@target}')" xsl:use-attribute-sets="external-link">
381    <xsl:call-template name="format-uri">
382      <xsl:with-param name="s" select="@target"/>
383    </xsl:call-template>
384  </fo:basic-link>
385  <xsl:text>&gt;</xsl:text>
386</xsl:template>
387
388<!-- processed in a later stage -->
389<xsl:template match="iref[not(ancestor::t) and not(parent::section)]">
[704]390  <fo:block>
[6]391    <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix" />.iref.<xsl:number level="any"/></xsl:attribute>
392    <xsl:choose>
393      <xsl:when test="@primary='true'">
394        <xsl:attribute name="index-key">
395          <xsl:value-of select="concat('item=',@item,',subitem=',@subitem,',primary')"/>
396        </xsl:attribute>
397      </xsl:when>
398      <xsl:otherwise>
399        <xsl:attribute name="index-key">
400          <xsl:value-of select="concat('item=',@item,',subitem=',@subitem)"/>
401        </xsl:attribute>
402      </xsl:otherwise>
403    </xsl:choose>
404  </fo:block>
405</xsl:template>
406
407<xsl:template match="iref[parent::section]">
408  <!-- processed on section level -->
409</xsl:template>
410
411<xsl:template match="iref[ancestor::t and not(parent::section)]">
[704]412  <fo:inline>
[6]413    <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix" />.iref.<xsl:number level="any"/></xsl:attribute>
414    <xsl:choose>
415      <xsl:when test="@primary='true'">
416        <xsl:attribute name="index-key">
417          <xsl:value-of select="concat('item=',@item,',subitem=',@subitem,',primary')"/>
418        </xsl:attribute>
419      </xsl:when>
420      <xsl:otherwise>
421        <xsl:attribute name="index-key">
422          <xsl:value-of select="concat('item=',@item,',subitem=',@subitem)"/>
423        </xsl:attribute>
424      </xsl:otherwise>
425    </xsl:choose>
426  </fo:inline>
427</xsl:template>
428
429<xsl:template match="iref" mode="iref-start">
430  <fo:index-range-begin>
431    <xsl:attribute name="id"><xsl:value-of select="$anchor-prefix" />.iref.<xsl:number level="any"/></xsl:attribute>
432    <xsl:choose>
433      <xsl:when test="@primary='true'">
434        <xsl:attribute name="index-key">
435          <xsl:value-of select="concat('item=',@item,',subitem=',@subitem,',primary')"/>
436        </xsl:attribute>
437      </xsl:when>
438      <xsl:otherwise>
439        <xsl:attribute name="index-key">
440          <xsl:value-of select="concat('item=',@item,',subitem=',@subitem)"/>
441        </xsl:attribute>
442      </xsl:otherwise>
443    </xsl:choose>
444  </fo:index-range-begin>
445</xsl:template>
446
447<xsl:template match="iref" mode="iref-end">
448  <fo:index-range-end>
449    <xsl:attribute name="ref-id"><xsl:value-of select="$anchor-prefix" />.iref.<xsl:number level="any"/></xsl:attribute>
450  </fo:index-range-end>
451</xsl:template>
452
453<xsl:template match="list[@style='hanging']" priority="1">
454
455  <xsl:variable name="width">
456    <xsl:choose>
457      <xsl:when test="@x:indent">
458        <xsl:value-of select="@x:indent"/>
459      </xsl:when>
460      <xsl:otherwise>
461        <!-- find longest label and use it to calculate indentation-->
462        <xsl:variable name="l">
463          <xsl:for-each select="t">
464            <xsl:sort select="string-length(@hangText)" order="descending" data-type="number"/>
465            <xsl:if test="position()=1">
466              <xsl:value-of select="@hangText" />
467            </xsl:if>
468          </xsl:for-each>
469        </xsl:variable>
470        <xsl:value-of select="concat(format-number(string-length($l) * 0.8, '#.0'),'em')"/>
471      </xsl:otherwise>
472    </xsl:choose>
473  </xsl:variable>
474
475  <fo:list-block provisional-distance-between-starts="{$width}">
476    <xsl:apply-templates />
477  </fo:list-block>
478</xsl:template>
479
480<xsl:template match="list[@style='hanging']/x:lt" priority="1">
481  <fo:list-item space-before=".25em" space-after=".25em">
[588]482    <xsl:call-template name="copy-anchor"/>
[6]483    <fo:list-item-label end-indent="label-end()"><fo:block><xsl:value-of select="@hangText" /></fo:block></fo:list-item-label>
484    <fo:list-item-body start-indent="body-start()">
485      <xsl:for-each select="t">
486        <fo:block>
487          <xsl:if test="position()!=1">
488            <xsl:attribute name="space-before">.25em</xsl:attribute>
489          </xsl:if>
490          <xsl:apply-templates />
491        </fo:block>
492      </xsl:for-each>
493    </fo:list-item-body>
494  </fo:list-item>
495</xsl:template>
496
497<xsl:template match="list[@style='hanging']/t | list[@style='hanging']/ed:replace/ed:ins/t" priority="1">
498  <fo:list-item space-before=".25em" space-after=".25em">
[588]499    <xsl:call-template name="copy-anchor"/>
[6]500    <fo:list-item-label end-indent="label-end()"><fo:block><xsl:value-of select="@hangText" /></fo:block></fo:list-item-label>
501    <fo:list-item-body start-indent="body-start()"><fo:block><xsl:apply-templates /></fo:block></fo:list-item-body>
502  </fo:list-item>
503</xsl:template>
504
505<xsl:template match="list[@style='symbols']" priority="1">
506  <fo:list-block provisional-distance-between-starts="1.5em">
507    <xsl:apply-templates />
508  </fo:list-block>
509</xsl:template>
510
511<xsl:template match="list[@style='symbols']/t" priority="1">
512  <fo:list-item space-before=".25em" space-after=".25em">
[588]513    <xsl:call-template name="copy-anchor"/>
[6]514    <fo:list-item-label end-indent="label-end()"><fo:block>&#x2022;</fo:block></fo:list-item-label>
515    <fo:list-item-body start-indent="body-start()"><fo:block><xsl:apply-templates /></fo:block></fo:list-item-body>
516  </fo:list-item>
517</xsl:template>
518
519<xsl:template match="list[@style='symbols']/x:lt" priority="1">
520  <fo:list-item space-before=".25em" space-after=".25em">
[588]521    <xsl:call-template name="copy-anchor"/>
[6]522    <fo:list-item-label end-indent="label-end()"><fo:block>&#x2022;</fo:block></fo:list-item-label>
523    <fo:list-item-body start-indent="body-start()">
524      <xsl:for-each select="t">
525        <fo:block>
526          <xsl:if test="position()!=1">
527            <xsl:attribute name="space-before">.25em</xsl:attribute>
528          </xsl:if>
529          <xsl:apply-templates />
530        </fo:block>
531      </xsl:for-each>
532    </fo:list-item-body>
533  </fo:list-item>
534</xsl:template>
535
536<xsl:template match="list">
537  <xsl:if test="@style!='' and @style!='empty' and @style">
[329]538    <xsl:call-template name="warning">
539      <xsl:with-param name="msg">unknown style '<xsl:value-of select="@style"/>' for list, continueing with default format.</xsl:with-param>
540    </xsl:call-template>
[6]541  </xsl:if>
542  <fo:list-block provisional-distance-between-starts="2em">
543    <xsl:apply-templates />
544  </fo:list-block>
545</xsl:template>
546
547<xsl:template match="list/t">
548  <fo:list-item space-before=".25em" space-after=".25em">
[588]549    <xsl:call-template name="copy-anchor"/>
[6]550    <fo:list-item-label end-indent="label-end()"><fo:block></fo:block></fo:list-item-label>
551    <fo:list-item-body start-indent="body-start()"><fo:block><xsl:apply-templates /></fo:block></fo:list-item-body>
552  </fo:list-item>
553</xsl:template>
554
555<xsl:template match="list[@style='numbers' or @style='letters']" priority="1">
556  <fo:list-block provisional-distance-between-starts="1.5em">
557    <xsl:apply-templates />
558  </fo:list-block>
559</xsl:template>
560
561<xsl:template match="list[@style='numbers' or @style='letters']/t" priority="1">
562  <fo:list-item space-before=".25em" space-after=".25em">
[588]563    <xsl:call-template name="copy-anchor"/>
[6]564    <fo:list-item-label end-indent="label-end()">
565      <fo:block>
566        <xsl:choose>
567          <xsl:when test="ancestor::list/@style='numbers'"><xsl:number/>.</xsl:when>
568          <xsl:when test="ancestor::list/@style='letters'"><xsl:number format="a"/>.</xsl:when>
569          <xsl:otherwise>???</xsl:otherwise>
570        </xsl:choose>
571      </fo:block>
572    </fo:list-item-label>
573    <fo:list-item-body start-indent="body-start()"><fo:block><xsl:apply-templates /></fo:block></fo:list-item-body>
574  </fo:list-item>
575</xsl:template>
576
577<xsl:template match="list[@style='numbers' or @style='letters']/x:lt" priority="1">
578  <fo:list-item space-before=".25em" space-after=".25em">
[588]579    <xsl:call-template name="copy-anchor"/>
[6]580    <fo:list-item-label end-indent="label-end()">
581      <fo:block>
582        <xsl:choose>
583          <xsl:when test="ancestor::list/@style='numbers'"><xsl:number/>.</xsl:when>
584          <xsl:when test="ancestor::list/@style='letters'"><xsl:number format="a"/>.</xsl:when>
585          <xsl:otherwise>???</xsl:otherwise>
586        </xsl:choose>
587      </fo:block>
588    </fo:list-item-label>
589    <fo:list-item-body start-indent="body-start()">
590      <xsl:for-each select="t">
591        <fo:block>
592          <xsl:if test="position()!=1">
593            <xsl:attribute name="space-before">.25em</xsl:attribute>
594          </xsl:if>
595          <xsl:apply-templates />
596        </fo:block>
597      </xsl:for-each>
598    </fo:list-item-body>
599  </fo:list-item>
600</xsl:template>
601
602<!-- special case: nested -->
603<xsl:template match="list//t//list[@style='letters']/t" priority="9">
604  <fo:list-item space-before=".25em" space-after=".25em">
[588]605    <xsl:call-template name="copy-anchor"/>
[6]606    <fo:list-item-label end-indent="label-end()"><fo:block><xsl:number format="A"/>.</fo:block></fo:list-item-label>
607    <fo:list-item-body start-indent="body-start()"><fo:block><xsl:apply-templates /></fo:block></fo:list-item-body>
608  </fo:list-item>
609</xsl:template>
610
611<xsl:template match="list[starts-with(@style,'format ')]" priority="1">
612  <fo:list-block provisional-distance-between-starts="{string-length(@style) - string-length('format ')}em">
613    <xsl:apply-templates />
614  </fo:list-block>
615</xsl:template>
616
[2610]617<xsl:template match="list[starts-with(@style,'format ')]/t" priority="1">
[6]618  <xsl:variable name="list" select=".." />
619  <xsl:variable name="format" select="substring-after(../@style,'format ')" />
620  <xsl:variable name="pos">
621    <xsl:choose>
622      <xsl:when test="$list/@counter">
623        <xsl:number level="any" count="list[@counter=$list/@counter or (not(@counter) and @style=concat('format ',$list/@counter))]/t" />
624      </xsl:when>
625      <xsl:otherwise>
626        <xsl:number level="any" count="list[concat('format ',@counter)=$list/@style or (not(@counter) and @style=$list/@style)]/t" />
627      </xsl:otherwise>
628    </xsl:choose>
629  </xsl:variable>
630  <fo:list-item space-before=".25em" space-after=".25em">
[588]631    <xsl:call-template name="copy-anchor"/>
[6]632    <fo:list-item-label end-indent="label-end()">
633      <fo:block>
[2610]634        <xsl:call-template name="expand-format-percent">
635          <xsl:with-param name="format" select="$format"/>
636          <xsl:with-param name="pos" select="$pos"/>
637        </xsl:call-template>
[6]638      </fo:block>
639    </fo:list-item-label>
640    <fo:list-item-body start-indent="body-start()">
641      <fo:block>
642        <xsl:apply-templates />
643      </fo:block>
644    </fo:list-item-body>
645  </fo:list-item>
646</xsl:template>
647
648<xsl:template match="middle">
[704]649  <xsl:apply-templates />
[6]650</xsl:template>
651               
652<xsl:template match="note">
653  <xsl:variable name="num"><xsl:number count="note"/></xsl:variable>
[246]654  <fo:block xsl:use-attribute-sets="h1" id="{concat($anchor-prefix,'.note.',$num)}"><xsl:value-of select="@title" /></fo:block>
[704]655  <xsl:apply-templates />
[6]656</xsl:template>
657
658<xsl:template match="preamble">
[704]659  <fo:block space-after=".5em">
[588]660    <xsl:call-template name="copy-anchor"/>
[6]661    <xsl:apply-templates />
662  </fo:block>
663</xsl:template>
664
665<xsl:template match="postamble">
[704]666  <fo:block space-before=".5em"><xsl:apply-templates /></fo:block>
[6]667</xsl:template>
668
669<xsl:template match="reference">
670
671  <xsl:variable name="target">
672    <xsl:choose>
673      <xsl:when test="@target"><xsl:value-of select="@target" /></xsl:when>
[704]674      <xsl:when test="seriesInfo/@name='RFC'"><xsl:value-of select="concat($rfcUrlPrefix,seriesInfo[@name='RFC']/@value,'.txt')" /></xsl:when>
675      <xsl:when test="seriesInfo[starts-with(.,'RFC')]">
[6]676        <xsl:variable name="rfcRef" select="seriesInfo[starts-with(.,'RFC')]" />
[704]677        <xsl:value-of select="concat($rfcUrlPrefix,substring-after (normalize-space($rfcRef), ' '),'.txt')" />
[6]678      </xsl:when>
679      <xsl:otherwise />
680    </xsl:choose>
[704]681  </xsl:variable>
[6]682
683  <fo:list-item space-after=".5em">
684    <fo:list-item-label end-indent="label-end()">
685      <fo:block id="{@anchor}">
686        <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
687          <xsl:attribute name="index-key">
688            <xsl:value-of select="concat('xrefitem=',@anchor)"/>
689          </xsl:attribute>
690        </xsl:if>
691        <xsl:call-template name="referencename">
692          <xsl:with-param name="node" select="." />
693        </xsl:call-template>
694      </fo:block>
695    </fo:list-item-label>
[704]696   
[6]697    <fo:list-item-body start-indent="body-start()"><fo:block>
698
699      <xsl:for-each select="front/author">
700        <xsl:variable name="initials">
701          <xsl:call-template name="format-initials"/>
702        </xsl:variable>
[2280]703        <xsl:variable name="truncated-initials">
704          <xsl:call-template name="truncate-initials">
705            <xsl:with-param name="initials" select="$initials"/>
706          </xsl:call-template>
707        </xsl:variable>
[6]708        <xsl:choose>
709          <xsl:when test="@surname and @surname!=''">
[704]710            <xsl:choose>
[6]711              <xsl:when test="@surname and position()=last() and position()!=1">
[832]712                <xsl:value-of select="concat($truncated-initials,' ',@surname)" />
[6]713              </xsl:when>
714              <xsl:when test="@surname">
[832]715                <xsl:value-of select="concat(@surname,', ',$truncated-initials)" />
[6]716              </xsl:when>
[704]717              <xsl:when test="organization/text()">
[6]718                <xsl:value-of select="organization" />
719              </xsl:when>
720              <xsl:otherwise />
721            </xsl:choose>
722            <xsl:if test="@role='editor'">
723              <xsl:text>, Ed.</xsl:text>
724            </xsl:if>
725            <xsl:choose>
726              <xsl:when test="position()=last() - 1">
727                <xsl:if test="last() &gt; 2">,</xsl:if>
728                <xsl:text> and </xsl:text>
729              </xsl:when>
730              <xsl:otherwise>
731                <xsl:text>, </xsl:text>
732              </xsl:otherwise>
733            </xsl:choose>
734          </xsl:when>
735          <xsl:when test="organization/text()">
736            <xsl:value-of select="organization" />
737            <xsl:choose>
738              <xsl:when test="position()=last() - 1">
739                <xsl:if test="last() &gt; 2">,</xsl:if>
740                <xsl:text> and </xsl:text>
741              </xsl:when>
742              <xsl:otherwise>
743                <xsl:text>, </xsl:text>
744              </xsl:otherwise>
745            </xsl:choose>
746          </xsl:when>
747          <xsl:otherwise />
748        </xsl:choose>
749      </xsl:for-each>
750
[981]751      <xsl:if test="not(front/title/@x:quotes='false')">"<!--&#8220;--></xsl:if>
[6]752      <xsl:choose>
753        <xsl:when test="string-length($target) &gt; 0">
[446]754          <fo:basic-link external-destination="url('{$target}')" xsl:use-attribute-sets="external-link"><xsl:value-of select="normalize-space(front/title)" /></fo:basic-link>
[6]755        </xsl:when>
756        <xsl:otherwise>
[446]757          <xsl:value-of select="normalize-space(front/title)" />
[6]758        </xsl:otherwise>
759      </xsl:choose>
[981]760      <xsl:if test="not(front/title/@x:quotes='false')">"<!--&#8221;--></xsl:if>
[6]761     
762      <xsl:for-each select="seriesInfo">
763        <xsl:text>, </xsl:text>
764        <xsl:choose>
765          <xsl:when test="not(@name) and not(@value) and ./text()"><xsl:value-of select="." /></xsl:when>
[704]766          <xsl:otherwise>
[6]767            <xsl:value-of select="@name" />
768            <xsl:if test="@value!=''">&#0160;<xsl:value-of select="@value" /></xsl:if>
769            <xsl:if test="translate(@name,$ucase,$lcase)='internet-draft'"> (work in progress)</xsl:if>
770          </xsl:otherwise>
771        </xsl:choose>
772      </xsl:for-each>
773
[981]774      <!-- avoid hacks using seriesInfo when it's not really series information -->
775      <xsl:for-each select="x:prose">
776        <xsl:text>, </xsl:text>
777        <xsl:value-of select="."/>
778      </xsl:for-each>
779
[6]780      <xsl:if test="front/date/@year!=''">
781        <xsl:text>, </xsl:text>
782        <xsl:value-of select="front/date/@month" />&#0160;<xsl:value-of select="front/date/@year" />
783      </xsl:if>
784     
785      <xsl:if test="@target">
786        <xsl:text>, &lt;</xsl:text>
787        <xsl:call-template name="format-uri">
788          <xsl:with-param name="s" select="@target"/>
789        </xsl:call-template>
790        <xsl:text>&gt;</xsl:text>
791      </xsl:if>
792
793      <xsl:text>.</xsl:text>
794     
795      <xsl:for-each select="annotation">
796        <fo:block><xsl:apply-templates /></fo:block>
797      </xsl:for-each>
798     
799    </fo:block></fo:list-item-body>
800  </fo:list-item>
801</xsl:template>
802
803<xsl:template match="references">
804
805  <xsl:variable name="name">
806    <xsl:number/>     
807  </xsl:variable>
808
809  <!-- insert pseudo section when needed -->
810  <xsl:if test="$name='1' and count(/*/back/references)!=1">
[246]811    <fo:block id="{$anchor-prefix}.references" xsl:use-attribute-sets="h1">
[6]812      <xsl:if test="$name='1'">
813        <xsl:attribute name="page-break-before">always</xsl:attribute>
814      </xsl:if>
815      <xsl:variable name="sectionNumber">
816        <xsl:call-template name="get-references-section-number"/>
817      </xsl:variable>
818      <xsl:call-template name="emit-section-number">
819        <xsl:with-param name="no" select="$sectionNumber"/>
820      </xsl:call-template>
[704]821      <xsl:text>&#160;&#160;</xsl:text>
822      <xsl:value-of select="$xml2rfc-refparent"/>
[6]823    </fo:block>
824  </xsl:if>
825
826  <xsl:choose>
827    <xsl:when test="count(/*/back/references)=1">
[246]828      <fo:block id="{$anchor-prefix}.references" xsl:use-attribute-sets="h1 newpage">
[662]829        <xsl:variable name="sectionNumber">
830          <xsl:call-template name="get-section-number"/>
831        </xsl:variable>
832        <xsl:call-template name="emit-section-number">
833          <xsl:with-param name="no" select="$sectionNumber"/>
834        </xsl:call-template>
835        <xsl:text>&#160;&#160;</xsl:text>
[6]836        <xsl:choose>
837          <xsl:when test="@title!=''"><xsl:value-of select="@title"/></xsl:when>
[704]838          <xsl:otherwise><xsl:value-of select="$xml2rfc-refparent"/></xsl:otherwise>
[6]839        </xsl:choose>
840      </fo:block>
841    </xsl:when>
842    <xsl:otherwise>
843      <fo:block id="{$anchor-prefix}.references.{$name}" xsl:use-attribute-sets="h2">
[662]844        <xsl:variable name="sectionNumber">
845          <xsl:call-template name="get-section-number"/>
846        </xsl:variable>
847        <xsl:call-template name="emit-section-number">
848          <xsl:with-param name="no" select="$sectionNumber"/>
849        </xsl:call-template>
850        <xsl:text>&#160;&#160;</xsl:text>
[6]851        <xsl:choose>
852          <xsl:when test="@title!=''"><xsl:value-of select="@title"/></xsl:when>
[704]853          <xsl:otherwise><xsl:value-of select="$xml2rfc-refparent"/></xsl:otherwise>
[6]854        </xsl:choose>
855      </fo:block>
856    </xsl:otherwise>
857  </xsl:choose>
858
859  <!-- find longest label and use it to calculate indentation-->
860  <xsl:variable name="l">
861    <xsl:choose>
862      <xsl:when test="$xml2rfc-symrefs='no'">[99]</xsl:when>
863      <xsl:otherwise>
864        <xsl:for-each select="//reference">
865          <xsl:sort select="string-length(@anchor)" order="descending" data-type="number"/>
866          <xsl:if test="position()=1">
867            <xsl:value-of select="@anchor" />
868          </xsl:if>
869        </xsl:for-each>
870      </xsl:otherwise>
871    </xsl:choose>
872  </xsl:variable>
873
874  <fo:list-block provisional-distance-between-starts="{string-length($l) * 0.8}em">
875    <xsl:choose>
876      <xsl:when test="$xml2rfc-sortrefs='yes'">
877        <xsl:apply-templates>
878          <xsl:sort select="@anchor" />
879        </xsl:apply-templates>
880      </xsl:when>
881      <xsl:otherwise>
882        <xsl:apply-templates />
883      </xsl:otherwise>
884    </xsl:choose>
885  </fo:list-block>
886</xsl:template>
887
888<xsl:template match="rfc">
[704]889  <fo:root xsl:use-attribute-sets="base">
[6]890   
[704]891    <fo:layout-master-set>
892      <fo:simple-page-master master-name="first-page" xsl:use-attribute-sets="page">
[6]893        <fo:region-body margin-bottom="1in" margin-top="1in"/>
[704]894         <fo:region-after extent="1cm" region-name="footer"/>
[6]895      </fo:simple-page-master>
[704]896      <fo:simple-page-master master-name="other-pages-right" xsl:use-attribute-sets="page">
[6]897        <fo:region-body margin-bottom="1in" margin-top="1in" />
[704]898        <fo:region-before extent="1cm" region-name="header-right"/>
899        <fo:region-after extent="1cm" region-name="footer-right"/>
[6]900      </fo:simple-page-master>
[704]901      <fo:simple-page-master master-name="other-pages-left" xsl:use-attribute-sets="page">
[571]902        <fo:region-body margin-bottom="1in" margin-top="1in" />
[704]903        <fo:region-before extent="1cm" region-name="header-left"/>
904        <fo:region-after extent="1cm" region-name="footer-left"/>
[571]905      </fo:simple-page-master>
[704]906      <fo:simple-page-master master-name="other-pages-dc-right" xsl:use-attribute-sets="page">
[6]907        <fo:region-body margin-bottom="1in" margin-top="1in" column-count="2"/>
[704]908        <fo:region-before extent="1cm" region-name="header-right"/>
909        <fo:region-after extent="1cm" region-name="footer-right"/>
[6]910      </fo:simple-page-master>
[704]911      <fo:simple-page-master master-name="other-pages-dc-left" xsl:use-attribute-sets="page">
[571]912        <fo:region-body margin-bottom="1in" margin-top="1in" column-count="2"/>
[704]913        <fo:region-before extent="1cm" region-name="header-left"/>
914        <fo:region-after extent="1cm" region-name="footer-left"/>
[571]915      </fo:simple-page-master>
[704]916      <fo:page-sequence-master master-name="sequence"> 
917        <fo:single-page-master-reference master-reference="first-page" />
[571]918        <xsl:choose>
919          <xsl:when test="$xml2rfc-ext-duplex='yes'">
920            <fo:repeatable-page-master-alternatives>
921              <fo:conditional-page-master-reference odd-or-even="even" master-reference="other-pages-left"/>
922              <fo:conditional-page-master-reference odd-or-even="odd" master-reference="other-pages-right"/>
923            </fo:repeatable-page-master-alternatives>
924          </xsl:when>
925          <xsl:otherwise>
[704]926            <fo:repeatable-page-master-reference master-reference="other-pages-right" /> 
[571]927          </xsl:otherwise>
928        </xsl:choose>
[704]929      </fo:page-sequence-master>
930      <fo:page-sequence-master master-name="sequence-dc"> 
[571]931        <xsl:choose>
932          <xsl:when test="$xml2rfc-ext-duplex='yes'">
933            <fo:repeatable-page-master-alternatives>
934              <fo:conditional-page-master-reference odd-or-even="even" master-reference="other-pages-dc-left"/>
935              <fo:conditional-page-master-reference odd-or-even="odd" master-reference="other-pages-dc-right"/>
936            </fo:repeatable-page-master-alternatives>
937          </xsl:when>
938          <xsl:otherwise>
[704]939            <fo:repeatable-page-master-reference master-reference="other-pages-dc-right" /> 
[571]940          </xsl:otherwise>
941        </xsl:choose>
[704]942      </fo:page-sequence-master>
943    </fo:layout-master-set>
[6]944
[329]945    <fo:declarations>
946      <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
947        <rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/">
948          <dc:title><xsl:value-of select="/rfc/front/title"/></dc:title>
949          <dc:creator><xsl:call-template name="get-author-summary" /></dc:creator>
950          <dc:description><xsl:value-of select="normalize-space(/rfc/front/abstract)"/></dc:description>
[588]951          <xsl:if test="/rfc/@number">
952            <dc:isPartOf>urn:ISSN:2070-1721</dc:isPartOf>
953          </xsl:if>     
[329]954          <xsl:if test="/rfc/front/keyword" xmlns:pdf="http://ns.adobe.com/pdf/1.3/">
955            <pdf:Keywords>
956              <xsl:for-each select="/rfc/front/keyword">
957                <xsl:value-of select="."/>
958                <xsl:if test="position()!=last()">, </xsl:if>
959              </xsl:for-each>
960            </pdf:Keywords>
961          </xsl:if>
962        </rdf:Description>
963      </rdf:RDF>
964    </fo:declarations>
965   
[6]966    <fo:bookmark-tree>
967      <xsl:apply-templates select="." mode="bookmarks" />
968    </fo:bookmark-tree>
969
970    <xsl:variable name="lang"><xsl:call-template name="get-lang"/></xsl:variable>
971
[704]972    <fo:page-sequence master-reference="sequence" language="{$lang}">
[571]973      <xsl:if test="$xml2rfc-ext-duplex='yes'">
974        <xsl:attribute name="force-page-count">even</xsl:attribute>
975      </xsl:if>
[6]976
977      <xsl:call-template name="insertHeader" />
978      <xsl:call-template name="insertFooter" />
979     
[704]980      <fo:flow flow-name="xsl-region-body">
981       
[662]982        <!-- process front & middle section, but not back -->
983        <xsl:apply-templates />
984       
985        <!-- because it requires multiple page masters -->
986        <!-- references first -->
[704]987        <xsl:apply-templates select="back/references" />
[662]988       
989        <xsl:if test="$xml2rfc-ext-authors-section!='end'">
990          <xsl:call-template name="insertAuthors" />
991        </xsl:if>
992       
993        <!-- add all other top-level sections under <back> -->
[704]994        <xsl:apply-templates select="back/*[not(self::references)]" />
[662]995     
[704]996      </fo:flow>
[6]997    </fo:page-sequence>
998   
999    <xsl:if test="$has-index">
[571]1000      <fo:page-sequence master-reference="sequence-dc" language="{$lang}">
1001        <xsl:if test="$xml2rfc-ext-duplex='yes'">
1002          <xsl:attribute name="force-page-count">even</xsl:attribute>
1003        </xsl:if>
[6]1004        <xsl:call-template name="insertHeader" />
1005        <xsl:call-template name="insertFooter" />
[704]1006        <fo:flow flow-name="xsl-region-body" xsl:use-attribute-sets="index">
1007          <xsl:call-template name="insertIndex" />   
1008        </fo:flow>
[6]1009      </fo:page-sequence>
1010    </xsl:if>
[662]1011
[704]1012    <xsl:if test="$xml2rfc-ext-authors-section='end' or ($xml2rfc-private='' and not($no-copylong))">
1013      <fo:page-sequence master-reference="sequence" language="{$lang}">
[662]1014        <xsl:if test="$xml2rfc-ext-duplex='yes'">
1015          <xsl:attribute name="force-page-count">even</xsl:attribute>
1016        </xsl:if>
1017 
1018        <xsl:call-template name="insertHeader" />
1019        <xsl:call-template name="insertFooter" />
1020       
[704]1021        <fo:flow flow-name="xsl-region-body">
1022         
[662]1023          <xsl:if test="$xml2rfc-ext-authors-section='end'">
1024            <xsl:call-template name="insertAuthors" />
1025          </xsl:if>
1026 
[704]1027          <xsl:if test="$xml2rfc-private=''">
1028            <!-- copyright statements -->
[662]1029            <xsl:variable name="copyright">
1030              <xsl:call-template name="insertCopyright" />
1031            </xsl:variable>
1032         
1033            <!-- emit it -->
1034            <xsl:choose>
1035              <xsl:when test="function-available('exslt:node-set')">
1036                <xsl:apply-templates select="exslt:node-set($copyright)/node()" />
1037              </xsl:when>
1038              <xsl:otherwise> <!--proceed with fingers crossed-->
1039                <xsl:variable name="temp" select="$copyright"/>
1040                <xsl:apply-templates select="$temp/node()" />
1041              </xsl:otherwise>
1042            </xsl:choose>
1043          </xsl:if>
1044         
[704]1045        </fo:flow>
[662]1046      </fo:page-sequence>
1047    </xsl:if>
[6]1048   
[704]1049  </fo:root>
[6]1050</xsl:template>
1051
1052
1053<xsl:template name="section-maker">
1054  <xsl:variable name="sectionNumber">
[446]1055    <xsl:choose>
1056      <xsl:when test="@myns:unnumbered"></xsl:when>
1057      <xsl:when test="ancestor::x:boilerplate"></xsl:when>
1058      <xsl:otherwise><xsl:call-template name="get-section-number" /></xsl:otherwise>
1059    </xsl:choose>
[6]1060  </xsl:variable>
1061
1062  <xsl:if test="$sectionNumber!=''">
1063    <xsl:attribute name="id"><xsl:value-of select="concat($anchor-prefix,'.section.',$sectionNumber)"/>
1064  </xsl:attribute></xsl:if>
1065 
1066  <xsl:call-template name="add-anchor" />
1067 
[662]1068  <xsl:if test="$sectionNumber!='' and not(contains($sectionNumber,'unnumbered-'))">
[6]1069    <xsl:call-template name="emit-section-number">
1070      <xsl:with-param name="no" select="$sectionNumber"/>
1071    </xsl:call-template>
1072    <xsl:text>&#0160;&#0160;</xsl:text>
1073  </xsl:if>
1074  <xsl:value-of select="@title" />
1075
1076</xsl:template>
1077
[446]1078<xsl:template match="section[count(ancestor::section) = 0 and (@myns:notoclink or ancestor::x:boilerplate)]">
[6]1079
[246]1080  <fo:block xsl:use-attribute-sets="h1">
[6]1081    <xsl:call-template name="section-maker" />
1082  </fo:block>
1083
1084  <xsl:apply-templates select="iref" mode="iref-start"/>
1085  <xsl:apply-templates />
1086  <xsl:apply-templates select="iref" mode="iref-end"/>
1087</xsl:template>
1088
[446]1089<xsl:template match="section[count(ancestor::section) = 0 and not(@myns:notoclink or ancestor::x:boilerplate)]">
[6]1090
[246]1091  <fo:block xsl:use-attribute-sets="h1 newpage">
[6]1092    <xsl:call-template name="section-maker" />
1093  </fo:block>
1094
1095  <xsl:apply-templates select="iref" mode="iref-start"/>
1096  <xsl:apply-templates />
1097  <xsl:apply-templates select="iref" mode="iref-end"/>
1098</xsl:template>
1099
1100<xsl:template match="section[count(ancestor::section) = 1]">
1101  <fo:block xsl:use-attribute-sets="h2">
1102    <xsl:call-template name="section-maker" />
1103  </fo:block>
1104
1105  <xsl:apply-templates select="iref" mode="iref-start"/>
1106  <xsl:apply-templates />
1107  <xsl:apply-templates select="iref" mode="iref-end"/>
1108</xsl:template>
1109
1110<xsl:template match="section[count(ancestor::section) &gt; 1]">
1111  <fo:block xsl:use-attribute-sets="h3">
1112    <xsl:call-template name="section-maker" />
1113  </fo:block>
1114
1115  <xsl:apply-templates select="iref" mode="iref-start"/>
1116  <xsl:apply-templates />
1117  <xsl:apply-templates select="iref" mode="iref-end"/>
1118</xsl:template>
1119
1120<xsl:template match="spanx[@style='emph' or not(@style)]">
1121  <fo:wrapper font-style="italic">
[588]1122    <xsl:call-template name="copy-anchor"/>
[6]1123    <xsl:apply-templates />
1124  </fo:wrapper>
1125</xsl:template>
1126
1127<xsl:template match="spanx[@style='strong']">
1128  <fo:wrapper font-weight="bold">
[588]1129    <xsl:call-template name="copy-anchor"/>
[6]1130    <xsl:apply-templates />
1131  </fo:wrapper>
1132</xsl:template>
1133
[1845]1134<xsl:template match="spanx[@style='verb' or @style='vbare']">
[6]1135  <fo:wrapper font-family="monospace">
[588]1136    <xsl:call-template name="copy-anchor"/>
[6]1137    <xsl:apply-templates/>
1138  </fo:wrapper>
1139</xsl:template>
1140
1141<xsl:template match="t">
[704]1142  <fo:block space-before=".5em" space-after=".5em">
[6]1143    <xsl:call-template name="insert-justification"/>
1144    <xsl:choose>
1145      <xsl:when test="parent::x:blockquote">
1146        <xsl:attribute name="start-indent">4em</xsl:attribute>
1147      </xsl:when>
[329]1148      <xsl:when test="parent::x:note">
1149        <xsl:attribute name="start-indent">4em</xsl:attribute>
1150      </xsl:when>
[6]1151      <xsl:otherwise>
1152        <xsl:attribute name="start-indent">2em</xsl:attribute>
1153      </xsl:otherwise>
1154    </xsl:choose>
[588]1155    <xsl:call-template name="copy-anchor"/>
[6]1156    <xsl:apply-templates />
1157  </fo:block>
1158</xsl:template>
1159               
1160<xsl:template match="vspace">
1161  <fo:block/>
1162</xsl:template>
1163
1164<xsl:template name="render-section-ref">
1165  <xsl:param name="from" />
1166  <xsl:param name="to" />
1167  <xsl:variable name="target" select="$from/@target" />
1168
1169  <xsl:variable name="refname">
1170    <xsl:for-each select="$to">
1171      <xsl:call-template name="get-section-type">
1172        <xsl:with-param name="prec" select="$from/preceding-sibling::node()[1]" />
1173      </xsl:call-template>
1174    </xsl:for-each>
1175  </xsl:variable>
1176  <xsl:variable name="refnum">
1177    <xsl:for-each select="$to">
1178      <xsl:call-template name="get-section-number" />
1179    </xsl:for-each>
1180  </xsl:variable>
1181  <xsl:choose>
1182    <xsl:when test="@format='counter'">
1183      <xsl:value-of select="$refnum"/>
1184    </xsl:when>
[2610]1185    <xsl:when test="@format='none'">
1186      <!-- Nothing to do -->
1187    </xsl:when>
[6]1188    <xsl:when test="@format='title'">
1189      <xsl:value-of select="$to/@title"/>
1190    </xsl:when>
1191    <xsl:otherwise>
1192      <xsl:value-of select="normalize-space(concat($refname,'&#160;',$refnum))"/>
1193    </xsl:otherwise>
1194  </xsl:choose>
1195</xsl:template>
1196
1197<xsl:template match="xref[node()]">
[704]1198  <xsl:variable name="target" select="@target" />
[6]1199  <xsl:variable name="node" select="//*[@anchor=$target]" />
1200  <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>
1201  <xsl:choose>
1202    <xsl:when test="@x:fmt='none'">
1203      <fo:basic-link internal-destination="{$target}" xsl:use-attribute-sets="internal-link">
[440]1204        <xsl:if test="$node/self::reference and $xml2rfc-ext-include-references-in-index='yes'">
[6]1205          <xsl:attribute name="id">
1206            <xsl:value-of select="$anchor"/>
1207          </xsl:attribute>
1208          <xsl:attribute name="index-key">
1209            <xsl:value-of select="concat('xrefitem=',@target)"/>
1210          </xsl:attribute>
1211        </xsl:if>
1212        <!-- insert id when a backlink to this xref is needed in the index -->
1213        <xsl:variable name="ireftargets" select="//iref[@x:for-anchor=$target] | //iref[@x:for-anchor='' and ../@anchor=$target]"/>
1214        <xsl:if test="$ireftargets">
1215          <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1216        </xsl:if>
1217        <xsl:for-each select="$ireftargets">
1218          <fo:wrapper index-key="{concat('item=',@item,',subitem=',@subitem)}" />
1219        </xsl:for-each>
1220        <xsl:apply-templates/>
1221      </fo:basic-link>
1222    </xsl:when>
[662]1223   
[440]1224    <xsl:when test="$node/self::section or $node/self::appendix">
[662]1225      <xsl:choose>
1226        <xsl:when test="@format='none'">
1227          <fo:basic-link internal-destination="{$target}" xsl:use-attribute-sets="internal-link">
1228            <!-- insert id when a backlink to this xref is needed in the index -->
1229            <xsl:variable name="ireftargets" select="//iref[@x:for-anchor=$target] | //iref[@x:for-anchor='' and ../@anchor=$target]"/>
1230            <xsl:if test="$ireftargets">
1231              <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1232            </xsl:if>
1233            <xsl:for-each select="$ireftargets">
1234              <fo:wrapper index-key="{concat('item=',@item,',subitem=',@subitem)}" />
1235            </xsl:for-each>
1236            <xsl:apply-templates/>
1237          </fo:basic-link>
1238        </xsl:when>
1239        <xsl:otherwise>
1240          <xsl:apply-templates/>
1241          <xsl:text> (</xsl:text>
1242          <fo:basic-link internal-destination="{$target}" xsl:use-attribute-sets="internal-link">
1243            <!-- insert id when a backlink to this xref is needed in the index -->
1244            <xsl:variable name="ireftargets" select="//iref[@x:for-anchor=$target] | //iref[@x:for-anchor='' and ../@anchor=$target]"/>
1245            <xsl:if test="$ireftargets">
1246              <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1247            </xsl:if>
1248            <xsl:for-each select="$ireftargets">
1249              <fo:wrapper index-key="{concat('item=',@item,',subitem=',@subitem)}" />
1250            </xsl:for-each>
1251            <xsl:call-template name="render-section-ref">
1252              <xsl:with-param name="from" select="."/>
1253              <xsl:with-param name="to" select="$node"/>
1254            </xsl:call-template>
1255          </fo:basic-link>
1256          <xsl:text>)</xsl:text>
1257        </xsl:otherwise>
1258      </xsl:choose>
[6]1259    </xsl:when>
[662]1260   
[6]1261    <xsl:otherwise>
1262      <fo:basic-link internal-destination="{$target}" xsl:use-attribute-sets="internal-link">
1263        <xsl:value-of select="." />
1264      </fo:basic-link>
[329]1265      <xsl:if test="not(@format='none')">
1266        <xsl:for-each select="//reference[@anchor=$target]">
1267          &#160;<xsl:call-template name="referencename"><xsl:with-param name="node" select="." /></xsl:call-template>
1268        </xsl:for-each>
1269      </xsl:if>
[6]1270    </xsl:otherwise>
1271  </xsl:choose>
1272
1273</xsl:template>
1274
1275<xsl:template match="xref[not(node())]">
1276
[2610]1277  <xsl:variable name="xref" select="."/>
1278  <xsl:variable name="target" select="@target"/>
[6]1279  <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>
1280  <xsl:variable name="node" select="//*[@anchor=$target]" />
1281  <xsl:if test="count($node)=0 and not(ancestor::ed:del)">
1282    <xsl:message>Undefined target: <xsl:value-of select="@target" /></xsl:message>
1283    <span class="error">Undefined target: <xsl:value-of select="@target" /></span>
1284  </xsl:if>
1285
1286  <xsl:choose>
1287
1288    <!-- Section links -->
[440]1289    <xsl:when test="$node/self::section or $node/self::appendix">
[6]1290      <fo:basic-link internal-destination="{$target}" xsl:use-attribute-sets="internal-link">
1291        <!-- insert id when a backlink to this xref is needed in the index -->
1292        <xsl:variable name="ireftargets" select="//iref[@x:for-anchor=$target] | //iref[@x:for-anchor='' and ../@anchor=$target]"/>
1293        <xsl:if test="$ireftargets">
1294          <xsl:attribute name="id"><xsl:value-of select="$anchor"/></xsl:attribute>
1295        </xsl:if>
1296        <xsl:for-each select="$ireftargets">
1297          <fo:wrapper index-key="{concat('item=',@item,',subitem=',@subitem)}" />
1298        </xsl:for-each>
1299        <xsl:call-template name="render-section-ref">
1300          <xsl:with-param name="from" select="."/>
1301          <xsl:with-param name="to" select="$node"/>
1302        </xsl:call-template>
1303      </fo:basic-link>
1304    </xsl:when>
1305
1306    <!-- Figure links -->
[440]1307    <xsl:when test="$node//self::figure">
[6]1308      <fo:basic-link internal-destination="{$target}" xsl:use-attribute-sets="internal-link">
1309        <xsl:variable name="figcnt">
1310          <xsl:for-each select="$node">
[2627]1311            <xsl:call-template name="get-figure-number"/>
[6]1312          </xsl:for-each>
1313        </xsl:variable>
1314        <xsl:choose>
1315          <xsl:when test="@format='counter'">
1316            <xsl:value-of select="$figcnt" />
1317          </xsl:when>
[2610]1318          <xsl:when test="@format='none'">
1319            <!-- Nothing to do -->
1320          </xsl:when>
[6]1321          <xsl:when test="@format='title'">
1322            <xsl:value-of select="$node/@title" />
1323          </xsl:when>
1324          <xsl:otherwise>
1325            <xsl:value-of select="normalize-space(concat('Figure&#160;',$figcnt))"/>
1326          </xsl:otherwise>
1327        </xsl:choose>
1328      </fo:basic-link>
1329    </xsl:when>
1330
1331    <!-- Table links -->
[440]1332    <xsl:when test="$node/self::texttable">
[6]1333      <fo:basic-link internal-destination="{$target}" xsl:use-attribute-sets="internal-link">
1334        <xsl:variable name="tabcnt">
1335          <xsl:for-each select="$node">
[2627]1336            <xsl:call-template name="get-table-number"/>
[6]1337          </xsl:for-each>
1338        </xsl:variable>
1339        <xsl:choose>
1340          <xsl:when test="@format='counter'">
1341            <xsl:value-of select="$tabcnt" />
1342          </xsl:when>
[2610]1343          <xsl:when test="@format='none'">
1344            <!-- Nothing to do -->
1345          </xsl:when>
[6]1346          <xsl:when test="@format='title'">
1347            <xsl:value-of select="$node/@title" />
1348          </xsl:when>
1349          <xsl:otherwise>
1350            <xsl:value-of select="normalize-space(concat('Table&#160;',$tabcnt))"/>
1351          </xsl:otherwise>
1352        </xsl:choose>
1353      </fo:basic-link>
1354    </xsl:when>
1355
[588]1356    <!-- Paragraph links -->
1357    <xsl:when test="$node/self::t">
1358      <fo:basic-link internal-destination="{$target}" xsl:use-attribute-sets="internal-link">
1359        <xsl:variable name="tcnt">
1360          <xsl:for-each select="$node">
1361            <xsl:call-template name="get-paragraph-number" />
1362          </xsl:for-each>
1363        </xsl:variable>
[2272]1364        <xsl:variable name="pparent" select="$node/.."/>
1365        <xsl:variable name="listtype">
1366          <xsl:choose>
1367            <xsl:when test="$pparent/self::list">
1368              <xsl:value-of select="$pparent/@style"/>
1369            </xsl:when>
1370            <xsl:otherwise></xsl:otherwise>
1371          </xsl:choose>
1372        </xsl:variable>
1373        <xsl:variable name="listindex">
1374          <xsl:choose>
1375            <xsl:when test="$listtype='numbers'">
1376              <xsl:for-each select="$node">
1377                <xsl:number/>
1378              </xsl:for-each>
1379            </xsl:when>
1380            <xsl:when test="$listtype='letters'">
1381              <xsl:for-each select="$node">
1382                <xsl:number format="a"/>
1383              </xsl:for-each>
1384            </xsl:when>
1385            <xsl:otherwise/>
1386          </xsl:choose>
1387        </xsl:variable>
[588]1388        <xsl:choose>
1389          <xsl:when test="@format='counter'">
[2272]1390            <xsl:choose>
1391              <xsl:when test="$listtype!='' and $listindex!=''">
1392                <xsl:value-of select="$listindex"/>
1393              </xsl:when>
1394              <xsl:when test="$listtype!='' and $listindex=''">
1395                <xsl:call-template name="warning">
1396                  <xsl:with-param name="msg" select="concat('Use of format=counter for unsupported list type ',$listtype)"/>
1397                </xsl:call-template>
1398                <xsl:value-of select="$tcnt"/>             
1399              </xsl:when>
1400              <xsl:otherwise>
1401                <xsl:value-of select="$tcnt"/>             
1402              </xsl:otherwise>
1403            </xsl:choose>
[588]1404          </xsl:when>
[2610]1405          <xsl:when test="@format='none'">
1406            <!-- Nothing to do -->
1407          </xsl:when>
[588]1408          <xsl:when test="@format='title'">
1409            <xsl:value-of select="$node/@title" />
1410          </xsl:when>
1411          <xsl:otherwise>
1412            <xsl:value-of select="normalize-space(concat('Paragraph&#160;',substring-after($tcnt,'p.')))"/>
1413          </xsl:otherwise>
1414        </xsl:choose>
1415      </fo:basic-link>
1416    </xsl:when>
1417
1418    <!-- Comment links -->
1419    <xsl:when test="$node/self::cref">
1420      <fo:basic-link internal-destination="{$target}" xsl:use-attribute-sets="internal-link">
1421        <xsl:variable name="name">
1422          <xsl:for-each select="$node">
1423            <xsl:call-template name="get-comment-name" />
1424          </xsl:for-each>
1425        </xsl:variable>
1426        <xsl:choose>
1427          <xsl:when test="@format='counter'">
1428            <xsl:value-of select="$name" />
1429          </xsl:when>
[2610]1430          <xsl:when test="@format='none'">
1431            <!-- Nothing to do -->
1432          </xsl:when>
[588]1433          <xsl:when test="@format='title'">
1434            <xsl:value-of select="$node/@title" />
1435          </xsl:when>
1436          <xsl:otherwise>
1437            <xsl:value-of select="normalize-space(concat('Comment&#160;',$name))"/>
1438          </xsl:otherwise>
1439        </xsl:choose>
1440      </fo:basic-link>
1441    </xsl:when>
1442
[6]1443    <!-- Reference links -->
[440]1444    <xsl:when test="$node/self::reference">
[6]1445      <!--
1446      Formats:
1447     
1448        ()      [XXXX] (Section SS)
1449        ,       [XXXX], Section SS
1450        of      Section SS of [XXXX]
1451        sec     Section SS
1452        number  SS
1453      -->
1454
1455      <xsl:variable name="sec">
1456        <xsl:choose>
1457          <xsl:when test="starts-with(@x:rel,'#') and not(@x:sec) and $node/x:source/@href">
1458            <xsl:variable name="extdoc" select="document($node/x:source/@href)"/>
1459            <xsl:for-each select="$extdoc//*[@anchor=substring-after(current()/@x:rel,'#')]">
1460              <xsl:call-template name="get-section-number"/>
1461            </xsl:for-each>
1462          </xsl:when>
1463          <xsl:otherwise>
1464            <xsl:value-of select="@x:sec"/>
1465          </xsl:otherwise>
1466        </xsl:choose>
1467      </xsl:variable>
1468
1469      <xsl:variable name="fmt">
1470        <xsl:choose>
1471          <xsl:when test="@x:fmt!=''"><xsl:value-of select="@x:fmt"/></xsl:when>
1472          <xsl:when test="ancestor::artwork">,</xsl:when>
1473          <xsl:otherwise>of</xsl:otherwise>
1474        </xsl:choose>
1475      </xsl:variable>
1476
1477      <xsl:if test="$sec!=''">
1478        <xsl:choose>
1479          <xsl:when test="$fmt='of' or $fmt='sec'">
1480            <xsl:text>Section </xsl:text>
1481            <xsl:value-of select="$sec"/>
1482            <xsl:if test="$fmt='of'">
1483              <xsl:text> of </xsl:text>
1484            </xsl:if>
1485          </xsl:when>
1486          <xsl:when test="$fmt='number'">
1487            <xsl:value-of select="$sec"/>
1488          </xsl:when>
1489          <xsl:when test="$fmt=','"/>
1490          <xsl:when test="$fmt='()'"/>
1491          <xsl:otherwise>
1492            <xsl:message>UNKNOWN xref x:fmt: <xsl:value-of select="$fmt"/></xsl:message>
1493          </xsl:otherwise>
1494        </xsl:choose>
1495      </xsl:if>
1496     
1497      <!-- anchor for index -->
1498      <xsl:if test="$xml2rfc-ext-include-references-in-index='yes' and $sec!='' and ($fmt='sec' or $fmt='number')">
1499        <fo:wrapper>
1500          <xsl:attribute name="id">
1501            <xsl:value-of select="$anchor"/>
1502          </xsl:attribute>
1503          <xsl:attribute name="index-key">
1504            <xsl:value-of select="concat('xrefitem=',@target)"/>
1505          </xsl:attribute>
1506          <xsl:if test="$sec!=''">
1507            <fo:wrapper>
1508              <xsl:attribute name="index-key">
1509                <xsl:value-of select="concat('xrefitem=',@target,'#',$sec)"/>
1510              </xsl:attribute>
1511            </fo:wrapper>
1512          </xsl:if>
1513        </fo:wrapper>
1514      </xsl:if>
1515
1516      <xsl:if test="$sec='' or ($fmt!='sec' and $fmt!='number')">
[2610]1517        <xsl:choose>
1518          <xsl:when test="$xref/@format='none'">
1519            <!-- Nothing to do -->
1520          </xsl:when>
1521          <xsl:otherwise>
1522            <fo:basic-link internal-destination="{$target}" xsl:use-attribute-sets="internal-link">
1523              <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
1524                <xsl:attribute name="id">
1525                  <xsl:value-of select="$anchor"/>
1526                </xsl:attribute>
[6]1527                <xsl:attribute name="index-key">
[2610]1528                  <xsl:value-of select="concat('xrefitem=',@target)"/>
[6]1529                </xsl:attribute>
[2610]1530                <xsl:if test="$sec!=''">
1531                  <fo:wrapper>
1532                    <xsl:attribute name="index-key">
1533                      <xsl:value-of select="concat('xrefitem=',@target,'#',$sec)"/>
1534                    </xsl:attribute>
1535                  </fo:wrapper>
1536                </xsl:if>
1537              </xsl:if>
1538              <xsl:variable name="val">
1539                <xsl:call-template name="referencename">
1540                  <xsl:with-param name="node" select="$node" />
1541                </xsl:call-template>
1542              </xsl:variable>
1543              <xsl:choose>
1544                <xsl:when test="$fmt='anchor' or $xref/@format='counter'">
1545                  <!-- remove brackets -->
1546                  <xsl:value-of select="substring($val,2,string-length($val)-2)"/>
1547                </xsl:when>
1548                <xsl:when test="$xref/@format='title'">
1549                  <xsl:value-of select="$node/front/title"/>
1550                </xsl:when>
1551                <xsl:otherwise>
1552                  <xsl:value-of select="$val"/>
1553                </xsl:otherwise>
1554              </xsl:choose>
1555            </fo:basic-link>
1556          </xsl:otherwise>
1557        </xsl:choose>
[6]1558      </xsl:if>
1559
1560      <xsl:if test="$sec!=''">
1561        <xsl:choose>
1562          <xsl:when test="$fmt='()'">
1563            <xsl:text> (Section </xsl:text>
1564            <xsl:value-of select="$sec"/>
1565            <xsl:text>)</xsl:text>
1566          </xsl:when>
1567          <xsl:when test="$fmt=','">
1568            <xsl:text>, Section </xsl:text>
1569            <xsl:value-of select="$sec"/>
1570          </xsl:when>
1571          <xsl:otherwise/>
1572        </xsl:choose>
1573      </xsl:if>
1574
1575    </xsl:when>
1576   
1577    <xsl:otherwise>
[588]1578      <xsl:call-template name="error">
1579        <xsl:with-param name="msg" select="concat('xref to unknown element: ',name($node))"/>
1580      </xsl:call-template>
[6]1581    </xsl:otherwise>
1582  </xsl:choose>
1583</xsl:template>
1584
1585<xsl:template match="/">
[704]1586  <xsl:apply-templates />
[6]1587</xsl:template>
1588
1589<xsl:template match="*">
1590  <xsl:message terminate="yes">ERROR: unknown or unexpected element: {<xsl:value-of select="namespace-uri()" />}<xsl:value-of select="local-name()" /><xsl:call-template name="lineno"/>: '<xsl:value-of select="."/>'</xsl:message>
1591</xsl:template>
1592
1593<xsl:template name="emitheader">
[704]1594  <xsl:param name="lc" />
1595  <xsl:param name="rc" />
[6]1596
[704]1597  <xsl:for-each select="$lc/myns:item | $rc/myns:item">
[6]1598    <xsl:variable name="pos" select="position()" />
1599    <xsl:if test="$pos &lt; count($lc/myns:item) + 1 or $pos &lt; count($rc/myns:item) + 1">
1600      <fo:table-row>
1601        <fo:table-cell>
1602          <fo:block>
1603            <xsl:apply-templates select="$lc/myns:item[$pos]/node()" mode="simple-html" />
1604          </fo:block>
1605        </fo:table-cell>
1606        <fo:table-cell>
1607          <fo:block text-align="right">
1608            <xsl:apply-templates select="$rc/myns:item[$pos]/node()" mode="simple-html" />
1609          </fo:block>
1610        </fo:table-cell>
1611      </fo:table-row>
1612    </xsl:if>
[704]1613  </xsl:for-each>
[6]1614</xsl:template>
1615
1616
1617<xsl:template match="text()" mode="simple-html">
1618  <xsl:apply-templates select="." />
1619</xsl:template>
1620
1621<xsl:template match="a" mode="simple-html">
1622  <fo:basic-link external-destination="url('{@href}')" xsl:use-attribute-sets="external-link">
1623    <xsl:apply-templates />
1624  </fo:basic-link>
1625</xsl:template>
1626
1627
1628<!-- produce back section with author information -->
1629<xsl:template name="insertAuthors">
1630
1631  <xsl:variable name="sectionNumber">
1632    <xsl:call-template name="get-authors-section-number"/>
1633  </xsl:variable>
1634
[329]1635  <xsl:if test="$sectionNumber!='suppress'">
1636    <fo:block id="{$anchor-prefix}.authors" xsl:use-attribute-sets="h1 newpage">
1637      <xsl:if test="$sectionNumber != ''">
1638        <xsl:call-template name="emit-section-number">
1639          <xsl:with-param name="no" select="$sectionNumber"/>
1640        </xsl:call-template>
1641        <xsl:text>&#0160;&#0160;</xsl:text>
1642      </xsl:if>
1643      <xsl:call-template name="get-authors-section-title"/>
1644    </fo:block>
1645   
1646    <xsl:apply-templates select="/rfc/front/author" />
1647  </xsl:if>
[6]1648</xsl:template>
1649
1650
1651<!-- generate the index section -->
1652
1653<xsl:template name="insertIndex">
1654
[704]1655  <fo:block xsl:use-attribute-sets="h1 newpage" id="{$anchor-prefix}.index">
[246]1656    <xsl:text>Index</xsl:text>
[6]1657  </fo:block>
1658
1659  <xsl:variable name="irefs" select="//iref[generate-id(.) = generate-id(key('index-first-letter',translate(substring(@item,1,1),$lcase,$ucase)))]"/>
1660  <xsl:variable name="xrefs" select="//reference[generate-id(.) = generate-id(key('index-first-letter',translate(substring(@anchor,1,1),$lcase,$ucase)))]"/>
1661
1662  <xsl:for-each select="$irefs | $xrefs">
1663    <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)" />
1664    <xsl:variable name="letter" select="translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase)"/>
1665           
1666    <xsl:variable name="showit">
1667      <xsl:choose>
1668        <xsl:when test="$xml2rfc-ext-include-references-in-index!='yes'">
1669          <xsl:if test="$irefs[starts-with(translate(@item,$lcase,$ucase),$letter)]">
1670            <xsl:text>yes</xsl:text>
1671          </xsl:if>
1672        </xsl:when>
1673        <xsl:otherwise>
1674          <xsl:text>yes</xsl:text>
1675        </xsl:otherwise>
1676      </xsl:choose>
1677    </xsl:variable>
1678
1679    <xsl:if test="$showit='yes'">
1680      <fo:block space-before="1em" font-weight="bold">
1681        <xsl:value-of select="$letter" />
1682      </fo:block>
1683           
1684      <xsl:for-each select="key('index-first-letter',translate(substring(concat(@item,@anchor),1,1),$lcase,$ucase))">
1685 
[704]1686      <xsl:sort select="translate(concat(@item,@anchor),$lcase,$ucase)" />
[6]1687     
1688        <xsl:choose>
1689          <xsl:when test="self::reference">
1690            <xsl:if test="$xml2rfc-ext-include-references-in-index='yes'">
1691           
1692              <xsl:variable name="entries" select="//xref[@target=current()/@anchor and not(ancestor::ed:del)]" />
1693             
1694              <xsl:if test="$entries">
1695                <fo:block start-indent="1em" hyphenate="true">
1696                  <fo:wrapper font-style="italic"><xsl:value-of select="concat(@anchor,' ')" /></fo:wrapper>
1697 
1698                  <fo:index-page-citation-list merge-sequential-page-numbers="merge">
1699                    <fo:index-key-reference page-number-treatment="link" ref-index-key="{concat('xrefitem=',@anchor,',primary')}" font-weight="bold"/>
1700                    <fo:index-key-reference page-number-treatment="link" ref-index-key="{concat('xrefitem=',@anchor)}"/>
1701                  </fo:index-page-citation-list>
1702
1703                  <xsl:variable name="rs2" select="$entries[@x:sec]"/>
1704
1705                  <xsl:if test="$rs2">
1706                    <xsl:for-each select="$rs2">
1707                      <xsl:sort select="substring-before(concat(@x:sec,'.'),'.')" data-type="number"/>
[588]1708                      <xsl:sort select="substring(@x:sec,2+string-length(substring-before(@x:sec,'.')))" data-type="number"/>
[6]1709                      <xsl:if test="generate-id(.) = generate-id(key('index-xref-by-sec',concat(@target,'..',@x:sec)))">
1710                        <fo:block start-indent="2em" hyphenate="true">
[272]1711                          <fo:wrapper font-style="italic">
1712                            <xsl:choose>
1713                              <xsl:when test="translate(substring(@x:sec,1,1),$ucase,'')=''">
1714                                <xsl:text>Appendix </xsl:text>
1715                              </xsl:when>
1716                              <xsl:otherwise>
1717                                <xsl:text>Section </xsl:text>
1718                              </xsl:otherwise>
1719                            </xsl:choose>
1720                            <xsl:value-of select="@x:sec"/>
1721                            <xsl:text> </xsl:text>
1722                          </fo:wrapper>
[6]1723                          <fo:index-page-citation-list merge-sequential-page-numbers="merge">
1724                            <fo:index-key-reference page-number-treatment="link" ref-index-key="{concat('xrefitem=',@target,'#',@x:sec)}"/>
1725                          </fo:index-page-citation-list>
1726                        </fo:block>
1727                      </xsl:if>
1728                    </xsl:for-each>
1729                  </xsl:if>
1730
1731                  <xsl:if test="current()/x:source/@href">
1732                    <xsl:variable name="rs3" select="$entries[not(@x:sec) and @x:rel]"/>
1733                    <xsl:if test="$rs3">
1734                      <xsl:variable name="doc" select="document(current()/x:source/@href)"/>
1735                      <xsl:for-each select="$rs3">
1736                        <xsl:sort select="count($doc//*[@anchor and following::*/@anchor=substring-after(current()/@x:rel,'#')])" order="ascending" data-type="number"/>
1737                        <xsl:if test="generate-id(.) = generate-id(key('index-xref-by-anchor',concat(@target,'..',@x:rel)))">
1738                          <fo:block start-indent="2em" hyphenate="true">
1739                            <xsl:variable name="sec">
1740                              <xsl:for-each select="$doc//*[@anchor=substring-after(current()/@x:rel,'#')]">
1741                                <xsl:call-template name="get-section-number"/>
1742                              </xsl:for-each>
1743                            </xsl:variable>
[272]1744                            <fo:wrapper font-style="italic">
1745                              <xsl:choose>
1746                                <xsl:when test="translate(substring($sec,1,1),$ucase,'')=''">
1747                                  <xsl:text>Appendix </xsl:text>
1748                                </xsl:when>
1749                                <xsl:otherwise>
1750                                  <xsl:text>Section </xsl:text>
1751                                </xsl:otherwise>
1752                              </xsl:choose>
1753                              <xsl:value-of select="$sec"/>
1754                              <xsl:text> </xsl:text>
1755                            </fo:wrapper>
[6]1756                            <fo:index-page-citation-list merge-sequential-page-numbers="merge">
1757                              <fo:index-key-reference page-number-treatment="link" ref-index-key="{concat('xrefitem=',@target,'#',$sec)}"/>
1758                            </fo:index-page-citation-list>
1759                          </fo:block>
1760                        </xsl:if>
1761                      </xsl:for-each>
1762                    </xsl:if>
1763                  </xsl:if>
1764
1765                </fo:block>
1766              </xsl:if>
1767
1768            </xsl:if>
1769          </xsl:when>
1770          <xsl:otherwise>
[704]1771            <xsl:if test="generate-id(.) = generate-id(key('index-item',@item))">
[6]1772           
1773              <xsl:variable name="item" select="@item"/>
1774              <xsl:variable name="in-artwork" select="count(//iref[@item=$item and @primary='true' and ancestor::artwork])!=0"/>
1775       
1776              <fo:block start-indent="1em" hyphenate="true">
1777                <xsl:choose>
1778                  <xsl:when test="$in-artwork">
1779                    <fo:wrapper font-family="monospace"><xsl:value-of select="concat(@item,' ')" /></fo:wrapper>
1780                  </xsl:when>
1781                  <xsl:otherwise>
1782                    <xsl:value-of select="concat(@item,' ')" />
1783                  </xsl:otherwise>
1784                </xsl:choose>
1785               
1786                <xsl:variable name="entries" select="key('index-item',@item)[not(@subitem) or @subitem='']"/>
1787                                       
1788                <xsl:if test="$entries">
1789                  <fo:index-page-citation-list merge-sequential-page-numbers="merge">
1790                    <fo:index-key-reference page-number-treatment="link" ref-index-key="{concat('item=',@item,',subitem=',@subitem,',primary')}" font-weight="bold"/>
1791                    <fo:index-key-reference page-number-treatment="link" ref-index-key="{concat('item=',@item,',subitem=',@subitem)}"/>
1792                  </fo:index-page-citation-list>
1793                </xsl:if>
1794     
1795              </fo:block>
1796                   
1797              <xsl:for-each select="key('index-item',@item)[@subitem and @subitem!='']">
[704]1798              <xsl:sort select="translate(@subitem,$lcase,$ucase)" />
[6]1799           
[704]1800                <xsl:if test="generate-id(.) = generate-id(key('index-item-subitem',concat(@item,'..',@subitem)))">
[6]1801               
1802                  <xsl:variable name="itemsubitem" select="concat(@item,'..',@subitem)"/>
1803                  <xsl:variable name="in-artwork2" select="count(//iref[concat(@item,'..',@subitem)=$itemsubitem and @primary='true' and ancestor::artwork])!=0"/>
1804                             
1805                  <fo:block start-indent="2em" hyphenate="true">
1806                 
1807                    <xsl:choose>
[440]1808                      <xsl:when test="$in-artwork2">
[6]1809                        <fo:wrapper font-family="monospace"><xsl:value-of select="concat(@subitem,' ')" /></fo:wrapper>
1810                      </xsl:when>
1811                      <xsl:otherwise>
1812                        <xsl:value-of select="concat(@subitem,' ')" />
1813                      </xsl:otherwise>
1814                    </xsl:choose>
1815     
1816                    <xsl:variable name="entries2" select="key('index-item-subitem',concat(@item,'..',@subitem))" />
1817                   
1818                    <xsl:if test="$entries2">
1819                      <fo:index-page-citation-list merge-sequential-page-numbers="merge">
1820                        <fo:index-key-reference page-number-treatment="link" ref-index-key="{concat('item=',@item,',subitem=',@subitem,',primary')}" font-weight="bold"/>
1821                        <fo:index-key-reference page-number-treatment="link" ref-index-key="{concat('item=',@item,',subitem=',@subitem)}" />
1822                      </fo:index-page-citation-list>
1823                    </xsl:if>
1824     
1825                  </fo:block>
1826                </xsl:if>
1827              </xsl:for-each>
1828                     
1829            </xsl:if>
1830          </xsl:otherwise>
1831        </xsl:choose>
1832   
1833                 
1834      </xsl:for-each>           
1835    </xsl:if>
1836  </xsl:for-each>
1837</xsl:template>
1838
1839
1840
1841<xsl:template match="/" mode="toc">
[704]1842  <fo:block xsl:use-attribute-sets="h1 newpage" id="{concat($anchor-prefix,'.toc')}">
[246]1843    <xsl:text>Table of Contents</xsl:text>
[6]1844  </fo:block>
1845
1846  <xsl:apply-templates mode="toc" />
1847</xsl:template>
1848
[754]1849<xsl:template name="back-toc">
[6]1850
[662]1851  <xsl:apply-templates select="references" mode="toc" />
[6]1852
1853  <xsl:if test="$xml2rfc-ext-authors-section!='end'">
1854    <xsl:apply-templates select="/rfc/front" mode="toc" />
1855  </xsl:if>
1856
[754]1857  <xsl:apply-templates select="back/*[not(self::references)]" mode="toc" />
[6]1858
[662]1859  <!-- insert the index if index entries exist -->
1860  <xsl:if test="$has-index">
1861    <xsl:call-template name="insert-toc-line">
1862      <xsl:with-param name="target" select="concat($anchor-prefix,'.index')"/>
1863      <xsl:with-param name="title" select="'Index'"/>
1864    </xsl:call-template>
1865  </xsl:if>
1866
[6]1867  <xsl:if test="$xml2rfc-ext-authors-section='end'">
1868    <xsl:apply-templates select="/rfc/front" mode="toc" />
1869  </xsl:if>
1870
1871  <!-- copyright statements -->
[704]1872  <xsl:if test="$xml2rfc-private='' and not($no-copylong)">
[6]1873    <xsl:call-template name="insert-toc-line">
1874      <xsl:with-param name="target" select="concat($anchor-prefix,'.ipr')"/>
1875      <xsl:with-param name="title" select="'Intellectual Property and Copyright Statements'"/>
1876    </xsl:call-template>
1877  </xsl:if>
1878 
1879</xsl:template>
1880
1881<xsl:template match="front" mode="toc">
1882 
1883  <xsl:variable name="authors-title">
1884    <xsl:call-template name="get-authors-section-title"/>
1885  </xsl:variable>
1886  <xsl:variable name="authors-number">
1887    <xsl:call-template name="get-authors-section-number"/>
1888  </xsl:variable>
[329]1889  <xsl:if test="$authors-number!='suppress'">
1890    <xsl:call-template name="insert-toc-line">
1891      <xsl:with-param name="target" select="concat($anchor-prefix,'.authors')"/>
1892      <xsl:with-param name="title" select="$authors-title"/>
1893      <xsl:with-param name="number" select="$authors-number"/>
1894    </xsl:call-template>
1895  </xsl:if>
[6]1896
1897</xsl:template>
1898
1899<xsl:template name="references-toc">
1900
1901  <!-- distinguish two cases: (a) single references element (process
1902  as toplevel section; (b) multiple references sections (add one toplevel
1903  container with subsection) -->
1904
1905  <xsl:choose>
1906    <xsl:when test="count(/*/back/references) = 0">
1907      <!-- nop -->
1908    </xsl:when>
1909    <xsl:when test="count(/*/back/references) = 1">
1910      <xsl:for-each select="/*/back/references">
1911        <xsl:variable name="title">
1912          <xsl:choose>
1913            <xsl:when test="@title!=''"><xsl:value-of select="@title" /></xsl:when>
[704]1914            <xsl:otherwise><xsl:value-of select="$xml2rfc-refparent"/></xsl:otherwise>
[6]1915          </xsl:choose>
1916        </xsl:variable>
1917     
1918        <xsl:call-template name="insert-toc-line">
1919          <xsl:with-param name="number">
1920            <xsl:call-template name="get-references-section-number"/>
1921          </xsl:with-param>
1922          <xsl:with-param name="target" select="concat($anchor-prefix,'.references')"/>
1923          <xsl:with-param name="title" select="$title"/>
1924        </xsl:call-template>
1925      </xsl:for-each>
1926    </xsl:when>
1927    <xsl:otherwise>
1928      <!-- insert pseudo container -->   
1929      <xsl:call-template name="insert-toc-line">
1930        <xsl:with-param name="number">
1931          <xsl:call-template name="get-references-section-number"/>
1932        </xsl:with-param>
1933        <xsl:with-param name="target" select="concat($anchor-prefix,'.references')"/>
[704]1934        <xsl:with-param name="title" select="$xml2rfc-refparent"/>
[6]1935      </xsl:call-template>
1936 
1937      <!-- ...with subsections... -->   
1938      <xsl:for-each select="/*/back/references">
1939        <xsl:variable name="title">
1940          <xsl:choose>
1941            <xsl:when test="@title!=''"><xsl:value-of select="@title" /></xsl:when>
[704]1942            <xsl:otherwise><xsl:value-of select="$xml2rfc-refparent"/></xsl:otherwise>
[6]1943          </xsl:choose>
1944        </xsl:variable>
1945     
1946        <xsl:variable name="sectionNumber">
1947          <xsl:call-template name="get-section-number" />
1948        </xsl:variable>
1949
1950        <xsl:variable name="num">
1951          <xsl:number/>
1952        </xsl:variable>
1953
1954        <xsl:call-template name="insert-toc-line">
1955          <xsl:with-param name="number" select="$sectionNumber"/>
1956          <xsl:with-param name="target" select="concat($anchor-prefix,'.references','.',$num)"/>
1957          <xsl:with-param name="title" select="$title"/>
1958        </xsl:call-template>
1959      </xsl:for-each>
1960    </xsl:otherwise>
1961  </xsl:choose>
1962</xsl:template>
1963
1964<xsl:template match="section" mode="toc">
1965  <xsl:variable name="sectionNumber">
1966    <xsl:call-template name="get-section-number" />
1967  </xsl:variable>
1968
1969  <xsl:variable name="target">
1970    <xsl:choose>
1971      <xsl:when test="@anchor"><xsl:value-of select="@anchor" /></xsl:when>
1972       <xsl:otherwise><xsl:value-of select="$anchor-prefix"/>.section.<xsl:value-of select="$sectionNumber" /></xsl:otherwise>
1973    </xsl:choose>
1974  </xsl:variable>
1975
1976  <xsl:call-template name="insert-toc-line">
1977    <xsl:with-param name="number" select="$sectionNumber"/>
1978    <xsl:with-param name="target" select="$target"/>
1979    <xsl:with-param name="title" select="@title"/>
1980    <xsl:with-param name="tocparam" select="@toc"/>
1981  </xsl:call-template>
1982 
1983  <xsl:if test=".//section">
1984    <xsl:apply-templates mode="toc" />
1985  </xsl:if>
1986</xsl:template>
1987
1988<xsl:template name="insert-toc-line">
1989  <xsl:param name="number" />
1990  <xsl:param name="target" />
1991  <xsl:param name="title" />
1992  <xsl:param name="tocparam" />
1993 
1994  <xsl:variable name="depth" select="string-length(translate($number,'.ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890&#167;','.'))" />
1995 
1996  <!-- handle tocdepth parameter -->
1997  <xsl:choose>
1998    <xsl:when test="($tocparam='' or $tocparam='default') and string-length(translate($number,'.ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890&#167;','.')) &gt;= $parsedTocDepth">
1999      <!-- dropped entry because of depth-->
2000    </xsl:when>
2001    <xsl:when test="$tocparam='exclude'">
2002      <!-- dropped entry because excluded -->
2003    </xsl:when>
2004    <xsl:when test="$depth = 0">
2005      <fo:block space-before="1em" font-weight="bold" text-align-last="justify">
[662]2006        <xsl:if test="$number!='' and not(contains($number,'unnumbered-'))">
[6]2007          <xsl:value-of select="$number" />
2008          <xsl:if test="$xml2rfc-ext-sec-no-trailing-dots='yes'">.</xsl:if>
2009          <xsl:text>&#0160;&#0160;</xsl:text>
2010        </xsl:if>
2011        <fo:basic-link internal-destination="{$target}" xsl:use-attribute-sets="internal-link"><xsl:value-of select="$title"/></fo:basic-link>
2012        <fo:leader leader-pattern="dots"/>
2013        <fo:page-number-citation ref-id="{$target}"/>
2014      </fo:block>
2015    </xsl:when>
2016    <xsl:when test="$depth = 1">
2017      <fo:block space-before="0.5em" text-align-last="justify">
[662]2018        <xsl:if test="$number!='' and not(contains($number,'unnumbered-'))">
[6]2019          <xsl:value-of select="$number" />
2020          <xsl:if test="$xml2rfc-ext-sec-no-trailing-dots='yes'">.</xsl:if>
2021          <xsl:text>&#0160;&#0160;&#0160;&#0160;</xsl:text>
2022        </xsl:if>
2023        <fo:basic-link internal-destination="{$target}" xsl:use-attribute-sets="internal-link"><xsl:value-of select="$title"/></fo:basic-link>
2024        <fo:leader leader-pattern="dots"/>
2025        <fo:page-number-citation ref-id="{$target}"/>
2026      </fo:block>
2027    </xsl:when>
2028    <xsl:otherwise>
2029      <fo:block text-align-last="justify">
2030        <xsl:text>&#0160;&#0160;</xsl:text>
[662]2031        <xsl:if test="$number!='' and not(contains($number,'unnumbered-'))">
[6]2032          <xsl:value-of select="$number" />
2033          <xsl:if test="$xml2rfc-ext-sec-no-trailing-dots='yes'">.</xsl:if>
2034          <xsl:text>&#0160;&#0160;&#0160;&#0160;</xsl:text>
2035        </xsl:if>
2036        <fo:basic-link internal-destination="{$target}" xsl:use-attribute-sets="internal-link"><xsl:value-of select="$title"/></fo:basic-link>
2037        <fo:leader leader-pattern="dots"/>
2038        <fo:page-number-citation ref-id="{$target}"/>
2039      </fo:block>
2040    </xsl:otherwise>
2041  </xsl:choose>
2042
2043</xsl:template>
2044
2045
2046<!--
2047<xsl:template name="rfclist">
[704]2048  <xsl:param name="list" />
2049  <xsl:choose>
2050      <xsl:when test="contains($list,',')">
2051          <xsl:variable name="rfcNo" select="substring-before($list,',')" />
2052          <a href="{concat($rfcUrlPrefix,$rfcNo,'.txt')}"><xsl:value-of select="$rfcNo" /></a>,
2053          <xsl:call-template name="rfclist">
2054              <xsl:with-param name="list" select="normalize-space(substring-after($list,','))" />
[6]2055            </xsl:call-template>
2056        </xsl:when>
2057        <xsl:otherwise>
[704]2058          <xsl:variable name="rfcNo" select="$list" />
2059          <a href="{concat($rfcUrlPrefix,$rfcNo,'.txt')}"><xsl:value-of select="$rfcNo" /></a>
2060         </xsl:otherwise>
[6]2061    </xsl:choose>
2062</xsl:template>
2063-->
2064
2065<xsl:template name="insertHeader">
[571]2066  <xsl:variable name="left">
2067    <xsl:call-template name="get-header-left" />
2068  </xsl:variable>
2069  <xsl:variable name="center">
2070    <xsl:call-template name="get-header-center" />
2071  </xsl:variable>
2072  <xsl:variable name="right">
2073    <xsl:call-template name="get-header-right" />
2074  </xsl:variable>
2075
2076  <fo:static-content flow-name="header-right">
[6]2077    <fo:block space-after=".5cm" />
2078    <fo:table width="100%" text-align="center" table-layout="fixed">
2079      <fo:table-column column-width="proportional-column-width({(string-length($left)+string-length($right)) div 2})" />
2080      <fo:table-column column-width="proportional-column-width({string-length($center)})" />
2081      <fo:table-column column-width="proportional-column-width({(string-length($left)+string-length($right)) div 2})" />
2082      <fo:table-body>
2083        <fo:table-row>
2084          <fo:table-cell>
2085            <fo:block text-align="start">
2086              <xsl:value-of select="$left" />
[704]2087             </fo:block>
[6]2088          </fo:table-cell>
2089          <fo:table-cell text-align="center">
2090            <fo:block>
2091              <xsl:value-of select="$center" />
[704]2092             </fo:block>
[6]2093          </fo:table-cell>
2094          <fo:table-cell text-align="end">
2095            <fo:block>
2096              <xsl:value-of select="$right" />
[704]2097             </fo:block>
[6]2098          </fo:table-cell>
2099        </fo:table-row>
2100      </fo:table-body>
2101    </fo:table>
2102  </fo:static-content>
[571]2103
2104  <fo:static-content flow-name="header-left">
2105    <fo:block space-after=".5cm" />
2106    <fo:table width="100%" text-align="center" table-layout="fixed">
2107      <fo:table-column column-width="proportional-column-width({(string-length($left)+string-length($right)) div 2})" />
2108      <fo:table-column column-width="proportional-column-width({string-length($center)})" />
2109      <fo:table-column column-width="proportional-column-width({(string-length($left)+string-length($right)) div 2})" />
2110      <fo:table-body>
2111        <fo:table-row>
2112          <fo:table-cell text-align="start">
2113            <fo:block>
2114              <xsl:value-of select="$right" />
[704]2115             </fo:block>
[571]2116          </fo:table-cell>
2117          <fo:table-cell text-align="center">
2118            <fo:block>
2119              <xsl:value-of select="$center" />
[704]2120             </fo:block>
[571]2121          </fo:table-cell>
2122          <fo:table-cell>
2123            <fo:block text-align="end">
2124              <xsl:value-of select="$left" />
[704]2125             </fo:block>
[571]2126          </fo:table-cell>
2127        </fo:table-row>
2128      </fo:table-body>
2129    </fo:table>
2130  </fo:static-content>
2131
[6]2132</xsl:template>
2133
2134<xsl:template name="insertFooter">
[571]2135  <xsl:variable name="left">
2136    <xsl:call-template name="get-author-summary" />
2137  </xsl:variable>
2138  <xsl:variable name="center">
[1103]2139    <xsl:call-template name="get-bottom-center" />
[571]2140  </xsl:variable>
2141  <xsl:variable name="right">[Page 999]</xsl:variable>
2142
2143  <fo:static-content flow-name="footer-right">
[6]2144    <fo:table text-align="center" width="100%" table-layout="fixed">
2145      <fo:table-column column-width="proportional-column-width({(string-length($left)+string-length($right)) div 2})" />
2146      <fo:table-column column-width="proportional-column-width({string-length($center)})" />
2147      <fo:table-column column-width="proportional-column-width({(string-length($left)+string-length($right)) div 2})" />
2148      <fo:table-body>
2149        <fo:table-row>
2150          <fo:table-cell>
2151            <fo:block text-align="start">
2152              <xsl:value-of select="$left" />
[704]2153             </fo:block>
[6]2154          </fo:table-cell>
2155          <fo:table-cell>
2156            <fo:block text-align="center">
2157              <xsl:value-of select="$center" />
[704]2158             </fo:block>
[6]2159          </fo:table-cell>
2160          <fo:table-cell>
2161            <fo:block text-align="end">[Page <fo:page-number />]</fo:block>
2162          </fo:table-cell>
2163        </fo:table-row>
2164      </fo:table-body>
2165    </fo:table>
2166  </fo:static-content>
[571]2167
2168  <fo:static-content flow-name="footer-left">
2169    <fo:table text-align="center" width="100%" table-layout="fixed">
2170      <fo:table-column column-width="proportional-column-width({(string-length($left)+string-length($right)) div 2})" />
2171      <fo:table-column column-width="proportional-column-width({string-length($center)})" />
2172      <fo:table-column column-width="proportional-column-width({(string-length($left)+string-length($right)) div 2})" />
2173      <fo:table-body>
2174        <fo:table-row>
2175          <fo:table-cell>
2176            <fo:block text-align="start">[Page <fo:page-number />]</fo:block>
2177          </fo:table-cell>
2178          <fo:table-cell>
2179            <fo:block text-align="center">
2180              <xsl:value-of select="$center" />
[704]2181             </fo:block>
[571]2182          </fo:table-cell>
2183          <fo:table-cell>
2184            <fo:block text-align="end">
2185              <xsl:value-of select="$left" />
[704]2186             </fo:block>
[571]2187          </fo:table-cell>
2188        </fo:table-row>
2189      </fo:table-body>
2190    </fo:table>
2191  </fo:static-content>
2192
[6]2193</xsl:template>
2194
2195<!-- change tracking -->
2196
2197<xsl:template match="ed:annotation" />
2198<xsl:template match="ed:del" />
2199<xsl:template match="ed:issue" />
2200<xsl:template match="ed:ins">
2201  <xsl:apply-templates />
2202</xsl:template>
[329]2203<xsl:template match="ed:issueref">
2204  <xsl:apply-templates />
2205</xsl:template>
[6]2206
2207<xsl:template match="ed:replace">
2208  <!--<xsl:variable name="no">change<xsl:number level="any"/></xsl:variable>
2209  <fo:change-bar-begin change-bar-class="{$no}" change-bar-style="solid" change-bar-color="red" change-bar-offset="2mm"/>-->
2210  <xsl:apply-templates />
2211  <!--<fo:change-bar-end change-bar-class="{$no}"/>-->
2212</xsl:template>
2213
2214<!-- extensions -->
2215
2216<xsl:template match="ed:link" />
2217
[2610]2218<xsl:template match="x:feedback" />
[6]2219
2220<xsl:template match="node()" mode="bookmarks">
2221  <xsl:apply-templates mode="bookmarks"/>
2222</xsl:template>
2223
2224<xsl:template match="abstract" mode="bookmarks">
2225  <fo:bookmark internal-destination="{concat($anchor-prefix,'.abstract')}">
2226    <fo:bookmark-title>Abstract</fo:bookmark-title>
2227    <xsl:apply-templates mode="bookmarks"/>
2228  </fo:bookmark>
2229</xsl:template>
2230
2231<xsl:template match="note" mode="bookmarks">
2232  <xsl:variable name="num">
2233    <xsl:number count="note" />
2234  </xsl:variable>
2235  <fo:bookmark internal-destination="{concat($anchor-prefix,'.note.',$num)}">
2236    <fo:bookmark-title><xsl:value-of select="@title"/></fo:bookmark-title>
2237    <xsl:apply-templates mode="bookmarks"/>
2238  </fo:bookmark>
2239</xsl:template>
2240
2241<xsl:template match="section[not(@myns:unnumbered)]" mode="bookmarks">
2242  <xsl:variable name="sectionNumber"><xsl:call-template name="get-section-number" /></xsl:variable>
2243  <fo:bookmark internal-destination="{$anchor-prefix}.section.{$sectionNumber}">
2244    <fo:bookmark-title>
[662]2245      <xsl:if test="$sectionNumber!='' and not(contains($sectionNumber,'unnumbered-'))">
2246        <xsl:value-of select="$sectionNumber"/>
2247        <xsl:if test="$xml2rfc-ext-sec-no-trailing-dots='yes'">.</xsl:if>
2248        <xsl:text> </xsl:text>
2249      </xsl:if>
2250      <xsl:value-of select="@title"/>
[6]2251    </fo:bookmark-title>
2252    <xsl:apply-templates mode="bookmarks"/>
2253  </fo:bookmark>
2254</xsl:template>
2255
2256<xsl:template match="section[@myns:unnumbered]" mode="bookmarks">
2257  <fo:bookmark internal-destination="{@anchor}">
2258    <fo:bookmark-title><xsl:value-of select="@title"/></fo:bookmark-title>
2259    <xsl:apply-templates mode="bookmarks"/>
2260  </fo:bookmark>
2261</xsl:template>
2262
2263<xsl:template match="back" mode="bookmarks">
2264
[662]2265  <xsl:call-template name="references-bookmarks" />
2266
[6]2267  <xsl:if test="$xml2rfc-ext-authors-section!='end'">
2268    <xsl:apply-templates select="/rfc/front" mode="bookmarks" />
2269  </xsl:if>
2270 
2271  <xsl:apply-templates select="*[not(self::references)]" mode="bookmarks" />
2272
[662]2273  <!-- insert the index if index entries exist -->
2274  <xsl:if test="$has-index">
2275    <fo:bookmark internal-destination="{concat($anchor-prefix,'.index')}">
2276      <fo:bookmark-title>Index</fo:bookmark-title>
2277    </fo:bookmark>
2278  </xsl:if>
2279
[6]2280  <xsl:if test="$xml2rfc-ext-authors-section='end'">
2281    <xsl:apply-templates select="/rfc/front" mode="bookmarks" />
2282  </xsl:if>
2283
[704]2284  <xsl:if test="$xml2rfc-private='' and not($no-copylong)">
[6]2285    <!-- copyright statements -->
2286    <fo:bookmark internal-destination="{concat($anchor-prefix,'.ipr')}">
2287      <fo:bookmark-title>Intellectual Property and Copyright Statements</fo:bookmark-title>
2288    </fo:bookmark>
2289  </xsl:if>
2290 
2291</xsl:template>
2292
2293<xsl:template match="front" mode="bookmarks">
2294
2295  <xsl:variable name="authors-number">
2296    <xsl:call-template name="get-authors-section-number"/>
2297  </xsl:variable>
2298
2299  <xsl:variable name="title">
2300    <xsl:if test="$authors-number!=''">
2301      <xsl:value-of select="$authors-number"/>
2302      <xsl:text> </xsl:text>
2303    </xsl:if>
2304    <xsl:call-template name="get-authors-section-title"/>
2305  </xsl:variable>
2306
[329]2307  <xsl:if test="$authors-number!='suppress'">
2308    <fo:bookmark internal-destination="{concat($anchor-prefix,'.authors')}">
2309      <fo:bookmark-title><xsl:value-of select="$title"/></fo:bookmark-title>
2310    </fo:bookmark>
2311  </xsl:if>
[6]2312</xsl:template>
2313
2314<xsl:template match="middle" mode="bookmarks">
2315  <xsl:apply-templates mode="bookmarks" />
2316</xsl:template>
2317
2318<xsl:template name="references-bookmarks">
2319
2320  <!-- distinguish two cases: (a) single references element (process
2321  as toplevel section; (b) multiple references sections (add one toplevel
2322  container with subsection) -->
2323
2324  <xsl:choose>
[329]2325    <xsl:when test="count(/*/back/references) = 0">
2326      <!-- nothing to do -->
2327    </xsl:when>
[6]2328    <xsl:when test="count(/*/back/references) = 1">
2329      <xsl:for-each select="/*/back/references">
2330        <xsl:variable name="title">
2331          <xsl:choose>
2332            <xsl:when test="@title!=''"><xsl:value-of select="@title" /></xsl:when>
[704]2333            <xsl:otherwise><xsl:value-of select="$xml2rfc-refparent"/></xsl:otherwise>
[6]2334          </xsl:choose>
2335        </xsl:variable>
2336     
2337        <fo:bookmark internal-destination="{$anchor-prefix}.references">
2338          <fo:bookmark-title>
2339            <xsl:call-template name="get-references-section-number"/>
2340            <xsl:if test="$xml2rfc-ext-sec-no-trailing-dots='yes'">.</xsl:if>
2341            <xsl:text> </xsl:text>
2342            <xsl:value-of select="$title"/>
2343          </fo:bookmark-title>
2344        </fo:bookmark>
2345      </xsl:for-each>
2346    </xsl:when>
2347    <xsl:otherwise>
2348      <!-- insert pseudo container -->   
2349      <fo:bookmark internal-destination="{$anchor-prefix}.references">
2350        <fo:bookmark-title>
2351          <xsl:call-template name="get-references-section-number"/>
2352          <xsl:if test="$xml2rfc-ext-sec-no-trailing-dots='yes'">.</xsl:if>
[704]2353          <xsl:text> </xsl:text>
2354          <xsl:value-of select="$xml2rfc-refparent"/>
[6]2355        </fo:bookmark-title>
2356
2357        <!-- ...with subsections... -->   
2358        <xsl:for-each select="/*/back/references">
2359          <xsl:variable name="title">
2360            <xsl:choose>
2361              <xsl:when test="@title!=''"><xsl:value-of select="@title" /></xsl:when>
[704]2362              <xsl:otherwise><xsl:value-of select="$xml2rfc-refparent"/></xsl:otherwise>
[6]2363            </xsl:choose>
2364          </xsl:variable>
2365       
2366          <xsl:variable name="sectionNumber">
2367            <xsl:call-template name="get-section-number" />
2368            <xsl:if test="$xml2rfc-ext-sec-no-trailing-dots='yes'">.</xsl:if>
2369          </xsl:variable>
2370 
2371          <xsl:variable name="num">
2372            <xsl:number/>
2373          </xsl:variable>
2374 
2375          <fo:bookmark internal-destination="{$anchor-prefix}.references.{$num}">
2376            <fo:bookmark-title><xsl:value-of select="concat($sectionNumber,' ',$title)"/></fo:bookmark-title>
2377          </fo:bookmark>
2378        </xsl:for-each>
2379      </fo:bookmark>
2380
2381    </xsl:otherwise>
2382  </xsl:choose>
2383</xsl:template>
2384
2385<xsl:template match="rfc" mode="bookmarks">
[1145]2386  <xsl:if test="$xml2rfc-private='' and not($abstract-first)">
2387    <xsl:call-template name="emit-ietf-preamble-bookmarks"/>   
[6]2388  </xsl:if>
2389 
2390  <xsl:apply-templates select="front/abstract" mode="bookmarks"/>
[1145]2391  <xsl:apply-templates select="front/note[@title!='IESG Note' or $xml2rfc-private!='']" mode="bookmarks"/>
[6]2392
[1145]2393  <xsl:if test="$xml2rfc-private='' and $abstract-first">
2394    <xsl:call-template name="emit-ietf-preamble-bookmarks"/>   
2395  </xsl:if>
2396
[329]2397  <xsl:if test="$xml2rfc-toc='yes'">
[6]2398    <fo:bookmark internal-destination="{concat($anchor-prefix,'.toc')}">
2399      <fo:bookmark-title>Table of Contents</fo:bookmark-title>
2400    </fo:bookmark>
2401  </xsl:if>
2402 
2403  <xsl:apply-templates select="middle|back" mode="bookmarks"/>
2404</xsl:template>
2405
[1145]2406<xsl:template name="emit-ietf-preamble-bookmarks">
2407  <!-- Get status info formatted as per RFC2629-->
2408  <xsl:variable name="preamble"><xsl:call-template name="insertPreamble" /></xsl:variable>
2409 
2410  <!-- emit it -->
2411  <xsl:choose>
2412    <xsl:when test="function-available('exslt:node-set')">
2413      <xsl:apply-templates select="exslt:node-set($preamble)/node()" mode="bookmarks"/>
2414    </xsl:when>
2415    <xsl:otherwise>
2416      <xsl:variable name="temp" select="$preamble"/>
2417      <xsl:apply-templates select="$temp/node()" mode="bookmarks"/>
2418    </xsl:otherwise>
2419  </xsl:choose>
2420</xsl:template>
2421
[6]2422<!-- experimental table formatting -->
2423
2424<xsl:template name="sum-widths">
2425  <xsl:param name="list"/>
2426  <xsl:choose>
2427    <xsl:when test="count($list)=0">
2428      <xsl:value-of select="0"/>
2429    </xsl:when>
2430    <xsl:when test="count($list)=1">
2431      <xsl:value-of select="number(substring-before($list[1],'%'))"/>
2432    </xsl:when>
2433    <xsl:otherwise>
2434      <xsl:variable name="remainder">
2435        <xsl:call-template name="sum-widths">
2436          <xsl:with-param name="list" select="$list[position()>1]" />
2437        </xsl:call-template>
2438      </xsl:variable>
2439      <xsl:value-of select="$remainder + number(substring-before($list[1],'%'))" />
2440    </xsl:otherwise>
2441  </xsl:choose>
2442</xsl:template>
2443
2444<!--
2445<xsl:attribute-set name="all-borders-solid">
2446  <xsl:attribute name="border-left-style">solid</xsl:attribute>
2447  <xsl:attribute name="border-right-style">solid</xsl:attribute>
2448  <xsl:attribute name="border-top-style">solid</xsl:attribute>
2449  <xsl:attribute name="border-bottom-style">solid</xsl:attribute>
2450  <xsl:attribute name="border-left-width">thin</xsl:attribute>
2451  <xsl:attribute name="border-right-width">thin</xsl:attribute>
2452  <xsl:attribute name="border-top-width">thin</xsl:attribute>
2453  <xsl:attribute name="border-bottom-width">thin</xsl:attribute>
2454  <xsl:attribute name="padding-left">0.5em</xsl:attribute>
2455  <xsl:attribute name="padding-right">0.5em</xsl:attribute>
2456</xsl:attribute-set>
2457
2458-->
2459
2460<xsl:template match="texttable">
2461
2462  <xsl:variable name="style">
2463    <xsl:choose>
2464      <xsl:when test="@style!=''">
2465        <xsl:value-of select="@style"/>
2466      </xsl:when>
2467      <xsl:otherwise>full</xsl:otherwise>
2468    </xsl:choose>
2469  </xsl:variable>
2470
2471  <xsl:variable name="anch">
2472    <xsl:call-template name="get-table-anchor"/>
2473  </xsl:variable>
2474
2475  <fo:block space-before=".5em" space-after=".5em" start-indent="2em" id="{$anch}">
2476    <xsl:call-template name="add-anchor"/>
2477    <xsl:apply-templates select="preamble" />
2478    <fo:table>
2479      <xsl:variable name="total-specified">
2480        <xsl:call-template name="sum-widths">
2481          <xsl:with-param name="list" select="ttcol/@width" />
2482        </xsl:call-template>
2483      </xsl:variable>
2484      <xsl:for-each select="ttcol">
2485        <fo:table-column>
2486          <xsl:choose>
2487            <xsl:when test="@width">
2488              <xsl:attribute name="column-width">proportional-column-width(<xsl:value-of select="substring-before(@width,'%')" />)</xsl:attribute>
2489            </xsl:when>
2490            <xsl:otherwise>
2491              <xsl:attribute name="column-width">proportional-column-width(<xsl:value-of select="(100 - number($total-specified)) div count(../ttcol[not(@width)])" />)</xsl:attribute>
2492            </xsl:otherwise>
2493          </xsl:choose>
2494        </fo:table-column>
2495      </xsl:for-each>
[329]2496      <xsl:if test="ttcol!=''">
2497        <!-- skip header when all column titles are empty -->
2498        <fo:table-header start-indent="0em" space-after=".5em">
2499          <fo:table-row>
2500            <xsl:apply-templates select="ttcol" />
2501          </fo:table-row>
2502        </fo:table-header>
2503      </xsl:if>
[6]2504      <fo:table-body start-indent="0em">
[2626]2505        <xsl:if test="$style='all' or $style='full'">
[6]2506          <xsl:attribute name="border-left-style">solid</xsl:attribute>
2507          <xsl:attribute name="border-right-style">solid</xsl:attribute>
2508          <xsl:attribute name="border-top-style">solid</xsl:attribute>
2509          <xsl:attribute name="border-bottom-style">solid</xsl:attribute>
2510          <xsl:attribute name="border-left-width">thin</xsl:attribute>
2511          <xsl:attribute name="border-right-width">thin</xsl:attribute>
2512          <xsl:attribute name="border-top-width">thin</xsl:attribute>
2513          <xsl:attribute name="border-bottom-width">thin</xsl:attribute>
2514        </xsl:if>
2515        <xsl:variable name="columns" select="count(ttcol)" />
[2610]2516        <xsl:choose>
2517          <xsl:when test="not(c)">
2518            <!-- special case: empty body -->
2519            <fo:table-cell><fo:block/></fo:table-cell>
2520          </xsl:when>
2521          <xsl:otherwise>
2522            <xsl:for-each select="c[$columns=1 or (position() mod $columns) = 1]">
2523              <fo:table-row>
2524                <xsl:for-each select=". | following-sibling::c[position() &lt; $columns]">
2525                  <fo:table-cell padding-left="0.5em" padding-right="0.5em">
[2626]2526                    <xsl:if test="$style='all' or $style='full'">
[2610]2527                      <xsl:attribute name="border-left-style">solid</xsl:attribute>
2528                      <xsl:attribute name="border-right-style">solid</xsl:attribute>
2529                      <xsl:attribute name="border-left-width">thin</xsl:attribute>
2530                      <xsl:attribute name="border-right-width">thin</xsl:attribute>
2531                    </xsl:if>
[2626]2532                    <xsl:if test="$style='all'">
[2610]2533                      <xsl:attribute name="border-top-style">solid</xsl:attribute>
2534                      <xsl:attribute name="border-bottom-style">solid</xsl:attribute>
2535                      <xsl:attribute name="border-top-width">thin</xsl:attribute>
2536                      <xsl:attribute name="border-bottom-width">thin</xsl:attribute>
2537                    </xsl:if>
2538                    <fo:block>
2539                      <xsl:variable name="pos" select="position()" />
2540                      <xsl:variable name="col" select="../ttcol[position() = $pos]" />
2541                      <xsl:if test="$col/@align">
2542                        <xsl:attribute name="text-align"><xsl:value-of select="$col/@align" /></xsl:attribute>
2543                      </xsl:if>
2544                      <xsl:apply-templates select="node()" />
2545                    </fo:block>
2546                  </fo:table-cell>
2547                </xsl:for-each>
2548              </fo:table-row>
[6]2549            </xsl:for-each>
[2610]2550          </xsl:otherwise>
2551        </xsl:choose>
[6]2552      </fo:table-body>
2553    </fo:table>
2554    <xsl:apply-templates select="postamble" />
[189]2555    <xsl:if test="(@title!='' or @anchor!='') and not(@suppress-title='true')">
[2627]2556      <xsl:variable name="n"><xsl:call-template name="get-table-number"/></xsl:variable>
[6]2557      <fo:block text-align="center" space-before="1em" space-after="1em">Table <xsl:value-of select="$n"/><xsl:if test="@title!=''">: <xsl:value-of select="@title" /></xsl:if></fo:block>
2558    </xsl:if>
2559  </fo:block>
2560</xsl:template>
2561
2562<xsl:template match="ttcol">
2563  <xsl:variable name="style">
2564    <xsl:choose>
2565      <xsl:when test="../@style!=''">
2566        <xsl:value-of select="../@style"/>
2567      </xsl:when>
2568      <xsl:otherwise>full</xsl:otherwise>
2569    </xsl:choose>
2570  </xsl:variable>
2571
2572  <fo:table-cell padding-left="0.5em" padding-right="0.5em">
[2626]2573    <xsl:if test="$style='all' or $style='full' or $style='headers'">
2574      <xsl:attribute name="border-bottom-style">solid</xsl:attribute>
2575      <xsl:attribute name="border-bottom-width">thin</xsl:attribute>
2576    </xsl:if>
2577    <xsl:if test="$style='all' or $style='full'">
[6]2578      <xsl:attribute name="border-left-style">solid</xsl:attribute>
2579      <xsl:attribute name="border-right-style">solid</xsl:attribute>
2580      <xsl:attribute name="border-top-style">solid</xsl:attribute>
2581      <xsl:attribute name="border-left-width">thin</xsl:attribute>
2582      <xsl:attribute name="border-right-width">thin</xsl:attribute>
2583      <xsl:attribute name="border-top-width">thin</xsl:attribute>
2584    </xsl:if>
2585<!--    <xsl:if test="@width">
2586      <xsl:attribute name="width"><xsl:value-of select="@width" /></xsl:attribute>
2587    </xsl:if> -->
2588    <xsl:choose>
2589      <xsl:when test="@align">
2590        <xsl:attribute name="text-align"><xsl:value-of select="@align" /></xsl:attribute>
2591      </xsl:when>
2592      <xsl:otherwise>
2593        <xsl:attribute name="text-align">left</xsl:attribute>
2594      </xsl:otherwise>
2595    </xsl:choose>
2596    <fo:block font-weight="bold">
2597      <xsl:apply-templates />
2598    </fo:block>
2599  </fo:table-cell>
2600</xsl:template>
2601
2602<xsl:template name="add-anchor">
2603  <xsl:if test="@anchor">
2604    <fo:block id="{@anchor}" />
2605  </xsl:if>
2606</xsl:template>
2607
2608<!-- cref support -->
2609
2610<xsl:template match="cref">
2611  <xsl:if test="$xml2rfc-comments!='no'">
2612    <xsl:variable name="cid">
[588]2613      <xsl:call-template name="get-comment-name"/>
[6]2614    </xsl:variable>
2615   
2616    <xsl:choose>
2617      <xsl:when test="$xml2rfc-inline!='yes'">
2618        <fo:footnote>
2619          <fo:inline>
2620            <fo:basic-link font-size="8pt" vertical-align="super" internal-destination="{$cid}">[<xsl:value-of select="$cid"/>]</fo:basic-link>
2621          </fo:inline>
2622          <fo:footnote-body>
2623            <fo:block font-size="10pt" start-indent="2em" text-align="left" id="{$cid}">
2624              <fo:inline font-size="8pt" vertical-align="super">[<xsl:value-of select="$cid"/>]</fo:inline>
2625              <xsl:text> </xsl:text>
[272]2626              <xsl:apply-templates select="node()"/>
[6]2627              <xsl:if test="@source"> --<xsl:value-of select="@source"/></xsl:if>
2628            </fo:block>
2629          </fo:footnote-body>
2630        </fo:footnote>
2631      </xsl:when>
2632      <xsl:otherwise>
2633        <fo:inline xsl:use-attribute-sets="comment">
2634          <xsl:text>[</xsl:text>
2635          <xsl:value-of select="$cid"/>
2636          <xsl:text>: </xsl:text>
[272]2637          <xsl:apply-templates select="node()"/>
[6]2638          <xsl:if test="@source"> --<xsl:value-of select="@source"/></xsl:if>
2639          <xsl:text>]</xsl:text>
2640        </fo:inline>
2641      </xsl:otherwise>
2642    </xsl:choose>   
2643  </xsl:if>
2644</xsl:template>
2645
2646
2647
2648<xsl:template name="insert-justification">
2649  <xsl:if test="$xml2rfc-ext-justification='always' or $xml2rfc-ext-justification='print'">
2650    <xsl:attribute name="text-align">justify</xsl:attribute>
2651  </xsl:if>
2652</xsl:template>
2653
2654<!-- Extensions -->
2655
2656<!-- Nothing to do for PDF output -->
2657<xsl:template match="x:assign-section-number" />
2658<xsl:template match="x:link" />
2659
2660<!-- Nothing to do here -->
2661<xsl:template match="x:anchor-alias" />
2662
2663<!-- internal ref support -->
2664<xsl:template match="x:ref">
2665  <xsl:variable name="val" select="."/>
2666  <xsl:variable name="target" select="//*[(@anchor and x:anchor-alias/@value=$val) or (@anchor=$val)]"/>
2667  <xsl:choose>
2668    <xsl:when test="$target">
2669      <fo:basic-link internal-destination="{$target/@anchor}" xsl:use-attribute-sets="internal-link">
[588]2670        <xsl:call-template name="copy-anchor"/>
[6]2671        <xsl:apply-templates/>
2672      </fo:basic-link>
2673    </xsl:when>
2674    <xsl:otherwise>
[329]2675      <xsl:call-template name="warning">
2676        <xsl:with-param name="msg">internal link target for '<xsl:value-of select="."/>' does not exist.</xsl:with-param>
2677      </xsl:call-template>
[6]2678      <xsl:apply-templates/>
2679    </xsl:otherwise>
2680  </xsl:choose>
2681</xsl:template>
2682
2683<!-- BCP14 keywords -->
2684<xsl:template match="x:bcp14">
2685  <!-- figure out something that prints well -->
2686  <xsl:apply-templates/>
2687</xsl:template>
2688
[329]2689<!-- Notes -->
2690<xsl:template match="x:note">
2691  <xsl:apply-templates/>
2692</xsl:template>
2693
[6]2694<!-- Quotes -->
2695<xsl:template match="x:blockquote">
2696  <fo:block font-style="italic" space-before=".5em" space-after=".5em" start-indent="3em"
2697      border-left-style="solid" border-left-color="gray" border-left-width=".25em" padding-left=".5em">
2698    <xsl:apply-templates/>
2699  </fo:block>
2700</xsl:template>
2701
2702<xsl:template match="x:q">
2703  <fo:wrapper font-style="italic">
2704    <xsl:text>&#8220;</xsl:text>
2705    <xsl:apply-templates/>
2706    <xsl:text>&#8221;</xsl:text>
2707  </fo:wrapper>
2708</xsl:template>
2709
2710<!-- Definitions -->
2711<xsl:template match="x:dfn">
2712  <fo:wrapper font-style="italic">
[571]2713    <xsl:if test="not(preceding-sibling::x:dfn) and count(following-sibling::list)=1">
2714      <xsl:attribute name="keep-with-next">always</xsl:attribute>
2715    </xsl:if>
[6]2716    <xsl:apply-templates/>
2717  </fo:wrapper>
2718</xsl:template>
2719
2720<!-- Headings -->
2721<xsl:template match="x:h">
2722  <fo:wrapper font-weight="bold">
2723    <xsl:apply-templates/>
2724  </fo:wrapper>
2725</xsl:template>
2726
[329]2727<!-- Highlightinghing -->
2728<xsl:template match="x:highlight">
2729  <fo:wrapper font-weight="bold">
2730    <xsl:apply-templates/>
2731  </fo:wrapper>
2732</xsl:template>
2733
[246]2734<!-- Superscripts -->
2735<xsl:template match="x:sup">
2736  <xsl:text>^</xsl:text> <!-- make this prettier -->
2737  <xsl:apply-templates/>
2738</xsl:template>
2739
[213]2740<!-- measuring lengths -->
2741<xsl:template match="x:length-of">
2742  <xsl:variable name="target" select="//*[@anchor=current()/@target]"/>
2743  <xsl:if test="count($target)!=1">
2744    <xsl:call-template name="error">
2745      <xsl:with-param name="msg" select="concat('@target ',@target,' defined ',count($target),' times.')"/>
2746    </xsl:call-template>
2747  </xsl:if>
2748  <xsl:variable name="content">
2749    <xsl:apply-templates select="$target"/>
2750  </xsl:variable>
2751  <xsl:variable name="lineends" select="string-length($content) - string-length(translate($content,'&#10;',''))"/>
2752  <xsl:variable name="indents">
2753    <xsl:choose>
2754      <xsl:when test="@indented">
2755        <xsl:value-of select="number(@indented) * $lineends"/>
2756      </xsl:when>
2757      <xsl:otherwise>0</xsl:otherwise>
2758    </xsl:choose>
2759  </xsl:variable>
2760  <xsl:value-of select="string-length($content) + $lineends - $indents"/>
2761</xsl:template>
2762
2763<!-- Nop -->
2764<xsl:template match="x:span">
2765  <xsl:apply-templates/>
2766</xsl:template>
2767
[285]2768<!-- XML checking -->
2769<xsl:template match="x:parse-xml">
2770  <xsl:apply-templates/>
2771</xsl:template>
2772
[272]2773<xsl:template match="x:abnf-char-sequence">
2774  <xsl:choose>
2775    <xsl:when test="substring(.,1,1) != '&quot;' or substring(.,string-length(.),1) != '&quot;'">
2776      <xsl:call-template name="error">
2777        <xsl:with-param name="msg" select="'contents of x:abnf-char-sequence needs to be quoted.'" />
2778      </xsl:call-template>
2779    </xsl:when>
2780    <xsl:otherwise>
2781      <xsl:text>%x</xsl:text>
2782      <xsl:call-template name="to-abnf-char-sequence">
2783        <xsl:with-param name="chars" select="substring(.,2,string-length(.)-2)"/>
2784      </xsl:call-template>
2785    </xsl:otherwise>
2786  </xsl:choose>
2787</xsl:template>
2788
[285]2789<!-- inlined RDF support -->
2790<xsl:template match="rdf:Description">
2791  <!-- ignore -->
2792</xsl:template>
2793
[6]2794<!-- box drawing -->
2795
2796<!-- nop for alignment -->
2797<xsl:template match="x:x"/>
2798
2799<!-- box -->
2800<xsl:template match="x:bt|x:bc|x:bb">
2801  <xsl:apply-templates />
2802</xsl:template>
2803
[329]2804<!-- author handling extensions -->
2805<xsl:template match="x:include-author">
2806  <xsl:for-each select="/*/front/author[@anchor=current()/@target]">
2807    <xsl:apply-templates select="."/>
2808  </xsl:for-each>
2809</xsl:template>
2810
[446]2811<!-- boilerplate -->
2812<xsl:template match="x:boilerplate">
2813  <xsl:apply-templates/>
2814</xsl:template>
2815
[6]2816  <!-- experimental: format URI with zero-width spaces to ease line breaks -->
2817 
2818  <xsl:template name="format-uri">
2819    <xsl:param name="s"/>
2820    <xsl:param name="mode"/>
2821   
2822    <xsl:choose>
2823      <!-- optimization for not hypenating the scheme name -->
2824      <xsl:when test="$mode!='after-scheme' and string-length(substring-before($s,':')) > 2">
2825        <xsl:value-of select="concat(substring-before($s,':'),':&#x200b;')"/>
2826        <xsl:call-template name="format-uri">
2827          <xsl:with-param name="s" select="substring-after($s,':')"/>
2828          <xsl:with-param name="mode" select="'after-scheme'"/>
2829        </xsl:call-template>
2830      </xsl:when>
2831      <!-- do no insert break points after hyphens -->
2832      <xsl:when test="starts-with($s,'-')">
2833        <xsl:text>-</xsl:text>
2834        <xsl:call-template name="format-uri">
2835          <xsl:with-param name="s" select="substring($s,2)"/>
2836          <xsl:with-param name="mode" select="'after-scheme'"/>
2837        </xsl:call-template>
2838      </xsl:when>
2839      <!-- last char?-->
2840      <xsl:when test="string-length($s)=1">
2841        <xsl:value-of select="$s"/>
2842      </xsl:when>
2843      <!-- add one zwsp after each character -->
2844      <xsl:when test="$s!=''">
2845        <xsl:value-of select="concat(substring($s,1,1),'&#x200b;')"/>
2846        <xsl:call-template name="format-uri">
2847          <xsl:with-param name="s" select="substring($s,2)"/>
2848          <xsl:with-param name="mode" select="'after-scheme'"/>
2849        </xsl:call-template>
2850      </xsl:when>
2851      <xsl:otherwise>
2852        <!-- done -->
2853      </xsl:otherwise>
2854    </xsl:choose>
2855   
2856  </xsl:template>
2857
[440]2858</xsl:transform>
Note: See TracBrowser for help on using the repository browser.