source: proiecte/HadoopJUnit/hadoop-0.20.1/src/docs/cn/src/documentation/skins/common/xslt/fo/d2fo.xml @ 120

Last change on this file since 120 was 120, checked in by (none), 14 years ago

Added the mail files for the Hadoop JUNit Project

  • Property svn:executable set to *
File size: 36.8 KB
Line 
1<?xml version="1.0"?>
2<!--
3  Licensed to the Apache Software Foundation (ASF) under one or more
4  contributor license agreements.  See the NOTICE file distributed with
5  this work for additional information regarding copyright ownership.
6  The ASF licenses this file to You under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with
8  the License.  You may obtain a copy of the License at
9
10      http://www.apache.org/licenses/LICENSE-2.0
11
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  See the License for the specific language governing permissions and
16  limitations under the License.
17-->
18<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
19                xmlns:fo="http://www.w3.org/1999/XSL/Format"
20                version="1.0">
21<xsl:param name="l10n.gentext.language" select="'zh_cn'"/>
22<!-- left, justify, right -->
23  <xsl:variable name="text-align" select="string(//skinconfig/pdf/page/@text-align)"/>
24<!-- print URL of external links -->
25  <xsl:variable name="show-external-urls" select="//skinconfig/pdf/show-external-urls"/>
26<!-- Get the section depth to use when generating the minitoc (default is 2) -->
27  <xsl:variable name="toc-max-depth" select="number(//skinconfig/toc/@max-depth)"/>
28<!-- The page size to be used -->
29  <xsl:variable name="pagesize"
30                select="string(//skinconfig/pdf/page/@size)"/>
31<!-- The page orientation ("portrait" or "landscape") -->
32  <xsl:variable name="pageorientation"
33                select="string(//skinconfig/pdf/page/@orientation)"/>
34<!-- Double-sided printing toggle -->
35  <xsl:variable name="doublesided"
36                select="string(//skinconfig/pdf/margins/@double-sided)"/>
37<!-- The top page margin -->
38  <xsl:variable name="topmargin"
39                select="string(//skinconfig/pdf/margins/top)"/>
40<!-- The bottom page margin -->
41  <xsl:variable name="bottommargin"
42                select="string(//skinconfig/pdf/margins/bottom)"/>
43<!-- The inner page margin (always the left margin if
44  double-sided printing is off, alternating between left and right if
45  it's on) -->
46  <xsl:variable name="innermargin"
47                select="string(//skinconfig/pdf/margins/inner)"/>
48<!-- The outer page margin (always the right margin if
49  double-sided printing is off, alternating between right and left if
50  it's on)-->
51  <xsl:variable name="outermargin"
52                select="string(//skinconfig/pdf/margins/outer)"/>
53  <xsl:param name="numbersections" select="'true'"/>
54<!-- page breaks after TOC and each page if an aggregate document -->
55  <xsl:variable name="page-break-top-sections" select="'true'"/>
56<!-- page numbering format -->
57  <xsl:variable name="page-numbering-format" select="string(//skinconfig/pdf/page-numbering-format)"/>
58<!-- Section depth at which we stop numbering and just indent -->
59  <xsl:param name="numbering-max-depth" select="'3'"/>
60  <xsl:param name="imagesdir" select="."/>
61  <xsl:param name="xmlbasedir"/>
62  <xsl:include href="pdfoutline.xsl"/>
63  <xsl:include href="footerinfo.xsl"/>
64<!-- Determine page height for various page sizes (US Letter portrait
65  is the default) -->
66<!-- FIXME: JJP:would this be better of a file? -->
67  <xsl:variable name="pageheight">
68    <xsl:choose>
69      <xsl:when test="$pageorientation = 'landscape'">
70        <xsl:choose>
71          <xsl:when test="$pagesize = 'a0'">841mm</xsl:when>
72          <xsl:when test="$pagesize = 'a1'">594mm</xsl:when>
73          <xsl:when test="$pagesize = 'a2'">420mm</xsl:when>
74          <xsl:when test="$pagesize = 'a3'">297mm</xsl:when>
75          <xsl:when test="$pagesize = 'a4'">210mm</xsl:when>
76          <xsl:when test="$pagesize = 'a5'">148mm</xsl:when>
77          <xsl:when test="$pagesize = 'executive'">7.25in</xsl:when>
78          <xsl:when test="$pagesize = 'folio'">8.5in</xsl:when>
79          <xsl:when test="$pagesize = 'ledger'">11in</xsl:when>
80          <xsl:when test="$pagesize = 'legal'">8.5in</xsl:when>
81          <xsl:when test="$pagesize = 'letter'">8.5in</xsl:when>
82          <xsl:when test="$pagesize = 'quarto'">8.5in</xsl:when>
83          <xsl:when test="$pagesize = 'tabloid'">11in</xsl:when>
84          <xsl:otherwise>8.5in</xsl:otherwise>
85        </xsl:choose>
86      </xsl:when>
87      <xsl:otherwise>
88        <xsl:choose>
89          <xsl:when test="$pagesize = 'a0'">1189mm</xsl:when>
90          <xsl:when test="$pagesize = 'a1'">841mm</xsl:when>
91          <xsl:when test="$pagesize = 'a2'">594mm</xsl:when>
92          <xsl:when test="$pagesize = 'a3'">420mm</xsl:when>
93          <xsl:when test="$pagesize = 'a4'">297mm</xsl:when>
94          <xsl:when test="$pagesize = 'a5'">210mm</xsl:when>
95          <xsl:when test="$pagesize = 'executive'">10.5in</xsl:when>
96          <xsl:when test="$pagesize = 'folio'">13in</xsl:when>
97          <xsl:when test="$pagesize = 'ledger'">17in</xsl:when>
98          <xsl:when test="$pagesize = 'legal'">14in</xsl:when>
99          <xsl:when test="$pagesize = 'quarto'">10.83in</xsl:when>
100          <xsl:when test="$pagesize = 'tabloid'">17in</xsl:when>
101          <xsl:otherwise>11in</xsl:otherwise>
102        </xsl:choose>
103      </xsl:otherwise>
104    </xsl:choose>
105  </xsl:variable>
106<!-- Determine page width for various page sizes (US Letter portrait
107  is the default) -->
108  <xsl:variable name="pagewidth">
109    <xsl:choose>
110      <xsl:when test="$pageorientation = 'landscape'">
111        <xsl:choose>
112          <xsl:when test="$pagesize = 'a0'">1189mm</xsl:when>
113          <xsl:when test="$pagesize = 'a1'">841mm</xsl:when>
114          <xsl:when test="$pagesize = 'a2'">594mm</xsl:when>
115          <xsl:when test="$pagesize = 'a3'">420mm</xsl:when>
116          <xsl:when test="$pagesize = 'a4'">297mm</xsl:when>
117          <xsl:when test="$pagesize = 'a5'">210mm</xsl:when>
118          <xsl:when test="$pagesize = 'executive'">10.5in</xsl:when>
119          <xsl:when test="$pagesize = 'folio'">13in</xsl:when>
120          <xsl:when test="$pagesize = 'ledger'">17in</xsl:when>
121          <xsl:when test="$pagesize = 'legal'">14in</xsl:when>
122          <xsl:when test="$pagesize = 'quarto'">10.83in</xsl:when>
123          <xsl:when test="$pagesize = 'tabloid'">17in</xsl:when>
124          <xsl:otherwise>11in</xsl:otherwise>
125        </xsl:choose>
126      </xsl:when>
127      <xsl:otherwise>
128        <xsl:choose>
129          <xsl:when test="$pagesize = 'a0'">841mm</xsl:when>
130          <xsl:when test="$pagesize = 'a1'">594mm</xsl:when>
131          <xsl:when test="$pagesize = 'a2'">420mm</xsl:when>
132          <xsl:when test="$pagesize = 'a3'">297mm</xsl:when>
133          <xsl:when test="$pagesize = 'a4'">210mm</xsl:when>
134          <xsl:when test="$pagesize = 'a5'">148mm</xsl:when>
135          <xsl:when test="$pagesize = 'executive'">7.25in</xsl:when>
136          <xsl:when test="$pagesize = 'folio'">8.5in</xsl:when>
137          <xsl:when test="$pagesize = 'ledger'">11in</xsl:when>
138          <xsl:when test="$pagesize = 'legal'">8.5in</xsl:when>
139          <xsl:when test="$pagesize = 'letter'">8.5in</xsl:when>
140          <xsl:when test="$pagesize = 'quarto'">8.5in</xsl:when>
141          <xsl:when test="$pagesize = 'tabloid'">11in</xsl:when>
142          <xsl:otherwise>8.5in</xsl:otherwise>
143        </xsl:choose>
144      </xsl:otherwise>
145    </xsl:choose>
146  </xsl:variable>
147  <xsl:template match="/">
148    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
149      <fo:layout-master-set>
150        <fo:simple-page-master master-name="first-page"
151          page-height="{$pageheight}"
152          page-width="{$pagewidth}"
153          margin-top="{$topmargin}"
154          margin-bottom="{$bottommargin}"
155          margin-left="{$innermargin}"
156          margin-right="{$outermargin}">
157          <fo:region-body
158            margin-top="0.5in"
159            margin-bottom=".5in"/>
160          <fo:region-after
161            region-name="first-footer"
162            extent=".5in"
163            display-align="before"/>
164        </fo:simple-page-master>
165        <fo:simple-page-master master-name="even-page"
166          page-height="{$pageheight}"
167          page-width="{$pagewidth}"
168          margin-top="{$topmargin}"
169          margin-bottom="{$bottommargin}">
170          <xsl:choose>
171            <xsl:when test="$doublesided = 'true'">
172              <xsl:attribute name="margin-left">
173                <xsl:value-of select="$outermargin"/>
174              </xsl:attribute>
175              <xsl:attribute name="margin-right">
176                <xsl:value-of select="$innermargin"/>
177              </xsl:attribute>
178            </xsl:when>
179            <xsl:otherwise>
180              <xsl:attribute name="margin-left">
181                <xsl:value-of select="$innermargin"/>
182              </xsl:attribute>
183              <xsl:attribute name="margin-right">
184                <xsl:value-of select="$outermargin"/>
185              </xsl:attribute>
186            </xsl:otherwise>
187          </xsl:choose>
188          <fo:region-before
189            region-name="even-header"
190            extent="0.5in"
191            border-bottom="0.5pt solid"/>
192          <fo:region-body
193            margin-top="0.5in"
194            margin-bottom=".5in"/>
195          <fo:region-after
196            region-name="even-footer"
197            extent=".5in"
198            display-align="before"/>
199        </fo:simple-page-master>
200        <fo:simple-page-master master-name="odd-page"
201          page-height="{$pageheight}"
202          page-width="{$pagewidth}"
203          margin-top="{$topmargin}"
204          margin-bottom="{$bottommargin}"
205          margin-left="{$innermargin}"
206          margin-right="{$outermargin}">
207          <fo:region-before
208            region-name="odd-header"
209            extent="0.5in"
210            border-bottom="0.5pt solid"/>
211          <fo:region-body
212            margin-top="0.5in"
213            margin-bottom=".5in"/>
214          <fo:region-after
215            region-name="odd-footer"
216            extent=".5in"
217            display-align="before"/>
218        </fo:simple-page-master>
219        <fo:page-sequence-master master-name="book">
220          <fo:repeatable-page-master-alternatives>
221            <fo:conditional-page-master-reference
222              page-position="first"
223              master-reference="first-page"/>
224            <fo:conditional-page-master-reference
225              odd-or-even="odd"
226              master-reference="odd-page"/>
227            <fo:conditional-page-master-reference
228              odd-or-even="even"
229              master-reference="even-page"/>
230          </fo:repeatable-page-master-alternatives>
231        </fo:page-sequence-master>
232      </fo:layout-master-set>
233      <xsl:apply-templates select="/site/document" mode="outline"/>
234      <fo:page-sequence master-reference="book">
235        <xsl:apply-templates select="/site/document"/>
236      </fo:page-sequence>
237    </fo:root>
238  </xsl:template>
239  <xsl:template match="document">
240    <fo:title>
241      <xsl:value-of select="header/title"/>
242    </fo:title>
243    <fo:static-content flow-name="first-footer">
244      <fo:block
245        border-top="0.25pt solid"
246        padding-before="6pt"
247        text-align="center">
248        <xsl:apply-templates select="footer"/>
249      </fo:block>
250<!-- don't list page number on first page if it's contents is just the TOC -->
251      <xsl:if test="not($toc-max-depth > 0 and $page-break-top-sections)">
252        <xsl:call-template name="insertPageNumber">
253          <xsl:with-param name="text-align">start</xsl:with-param>
254        </xsl:call-template>
255      </xsl:if>
256      <xsl:call-template name="info"/>
257    </fo:static-content>
258    <fo:static-content flow-name="even-header">
259      <fo:block
260        font-size="70%"
261        text-align="end"
262        font-style="italic">
263        <xsl:value-of select="header/title"/>
264      </fo:block>
265    </fo:static-content>
266    <fo:static-content flow-name="even-footer">
267      <fo:block
268        border-top="0.25pt solid"
269        padding-before="6pt"
270        text-align="center">
271        <xsl:apply-templates select="footer"/>
272      </fo:block>
273      <xsl:call-template name="insertPageNumber">
274        <xsl:with-param name="text-align">end</xsl:with-param>
275      </xsl:call-template>
276      <xsl:call-template name="info"/>
277    </fo:static-content>
278    <fo:static-content flow-name="odd-header">
279      <fo:block
280        font-size="70%"
281        text-align="start"
282        font-style="italic">
283        <xsl:value-of select="header/title"/>
284      </fo:block>
285    </fo:static-content>
286    <fo:static-content flow-name="odd-footer">
287      <fo:block
288        border-top="0.25pt solid"
289        padding-before="6pt"
290        text-align="center">
291        <xsl:apply-templates select="footer"/>
292      </fo:block>
293      <xsl:call-template name="insertPageNumber">
294        <xsl:with-param name="text-align">start</xsl:with-param>
295      </xsl:call-template>
296      <xsl:call-template name="info"/>
297    </fo:static-content>
298    <fo:flow flow-name="xsl-region-body">
299      <fo:block
300        padding-before="24pt"
301        padding-after="24pt"
302        font-size="24pt"
303        font-weight="bold"
304        id="{generate-id()}">
305        <xsl:value-of select="header/title"/>
306      </fo:block>
307      <fo:block
308        text-align="{$text-align}"
309        padding-before="18pt"
310        padding-after="18pt">
311        <xsl:apply-templates/>
312      </fo:block>
313<!-- Total number of pages calculation... -->
314      <fo:block id="term"/>
315    </fo:flow>
316  </xsl:template>
317  <xsl:template match="abstract">
318    <fo:block
319      font-size="12pt"
320      text-align="center"
321      space-before="20pt"
322      space-after="25pt"
323      width="7.5in"
324      font-family="serif"
325      font-style="italic">
326      <xsl:call-template name="insertPageBreaks"/>
327      <xsl:apply-templates/>
328    </fo:block>
329  </xsl:template>
330  <xsl:template match="notice">
331    <fo:block
332      font-size="10pt"
333      text-align="left"
334      space-before="20pt"
335      width="7.5in"
336      font-family="serif"
337      border-top="0.25pt solid"
338      border-bottom="0.25pt solid"
339      padding-before="6pt"
340      padding-after="6pt">
341      <xsl:call-template name="insertPageBreaks"/>
342<!-- insert i18n stuff here -->
343      NOTICE: <xsl:apply-templates/>
344    </fo:block>
345  </xsl:template>
346  <xsl:template match="anchor">
347    <fo:block id="{@id}"/>
348    <xsl:apply-templates/>
349  </xsl:template>
350  <xsl:template match="section">
351    <xsl:param name="level">0</xsl:param>
352    <xsl:variable name="size">
353<!-- 14pt for level 1 12pt for level 2 -->
354      <xsl:value-of select="14-number($level)"/>
355    </xsl:variable>
356    <xsl:variable name="background-color" select="//skinconfig/colors/color[@name='body']/@value"/>
357    <xsl:variable name="heading-color" select="//skinconfig/colors/color[@name='subheading']/@value"/>
358    <xsl:variable name="heading-type" select="//skinconfig/headings/@type"/>
359    <fo:block
360      font-family="serif"
361      font-size="{$size}pt"
362      font-weight="bold"
363      space-before="12pt"
364      space-after="4pt">
365      <xsl:call-template name="insertPageBreaks"/>
366      <xsl:if test="$heading-type = 'boxed'">
367        <xsl:attribute name="background-color">
368          <xsl:value-of select="$heading-color"/>
369        </xsl:attribute>
370      </xsl:if>
371      <xsl:attribute name="id">
372        <xsl:choose>
373          <xsl:when test="normalize-space(@id)!=''">
374            <xsl:value-of select="@id"/>
375          </xsl:when>
376          <xsl:otherwise>
377            <xsl:value-of select="generate-id()"/>
378          </xsl:otherwise>
379        </xsl:choose>
380      </xsl:attribute>
381      <xsl:if test="$numbersections = 'true' and number($level) &lt; $numbering-max-depth+1">
382        <xsl:number format="1.1.1.1.1.1.1" count="section" level="multiple"/>
383<xsl:text>. </xsl:text>
384      </xsl:if>
385<!-- For sections 4  or more nestings deep, indent instead of number -->
386      <xsl:if test="number($level) &gt; $numbering-max-depth+1">
387        <xsl:attribute name="start-indent">
388          <xsl:value-of select="4+number($level)"/>
389<xsl:text>pt</xsl:text>
390        </xsl:attribute>
391      </xsl:if>
392      <xsl:value-of select="title"/>
393    </fo:block>
394    <xsl:if test="$heading-type = 'underlined'">
395<!-- The non-breaking space in this block is required, otherwise
396      the block won't be rendered at all. -->
397      <fo:block
398        font-family="serif"
399        font-size="{10 div (number($level) +1 )}pt"
400        background-color="{$heading-color}">&#160;</fo:block>
401    </xsl:if>
402    <fo:block
403        background-color="{$background-color}">
404      <xsl:apply-templates>
405        <xsl:with-param name="level" select="number($level)+1"/>
406      </xsl:apply-templates>
407    </fo:block>
408  </xsl:template>
409  <xsl:template match="title">
410<!-- do nothing as titles are handled in their parent templates -->
411  </xsl:template>
412  <xsl:template match="subtitle">
413    <xsl:param name="level">0</xsl:param>
414    <xsl:variable name="size" select="16-(number($level)*1.5)"/>
415    <fo:block
416      font-weight="bold"
417      font-size="{$size}pt">
418      <xsl:call-template name="insertPageBreaks"/>
419      <xsl:apply-templates/>
420    </fo:block>
421  </xsl:template>
422  <xsl:template match="authors">
423    <fo:block
424      space-before="20pt"
425      font-weight="bold"
426      font-size="9pt">
427      <xsl:call-template name="insertPageBreaks"/>
428<!-- insert i18n stuff here -->
429      by
430      <xsl:for-each select="person">
431        <xsl:value-of select="@name"/>
432        <xsl:if test="not(position() = last())">, </xsl:if>
433      </xsl:for-each>
434    </fo:block>
435  </xsl:template>
436  <xsl:template match="p">
437    <xsl:choose>
438      <xsl:when test="ancestor::li and not(preceding-sibling::*)">
439        <fo:block
440          space-after="4pt"
441          font-family="serif">
442          <xsl:call-template name="insertPageBreaks"/>
443          <xsl:apply-templates/>
444        </fo:block>
445      </xsl:when>
446      <xsl:otherwise>
447        <fo:block
448          space-before="4pt"
449          space-after="4pt"
450          font-family="serif">
451          <xsl:call-template name="insertPageBreaks"/>
452          <xsl:apply-templates/>
453        </fo:block>
454      </xsl:otherwise>
455    </xsl:choose>
456  </xsl:template>
457  <xsl:template match="source">
458    <xsl:variable name="color" select="//skinconfig/colors/color[@name='code']/@value"/>
459    <fo:block
460      font-family="monospace"
461      font-size="10pt"
462      background-color="{$color}"
463      white-space-collapse="false"
464      linefeed-treatment="preserve"
465      white-space-treatment="preserve"
466      wrap-option="wrap"
467      text-align="start">
468      <xsl:call-template name="insertPageBreaks"/>
469      <xsl:apply-templates/>
470    </fo:block>
471  </xsl:template>
472  <xsl:template match="ol|ul">
473    <fo:list-block
474      provisional-distance-between-starts="18pt"
475      provisional-label-separation="3pt"
476      text-align="start">
477      <xsl:apply-templates/>
478    </fo:list-block>
479  </xsl:template>
480  <xsl:template match="ol/li">
481    <fo:list-item>
482      <xsl:if test="not(following-sibling::li[1])">
483        <xsl:attribute name="space-after">6pt"</xsl:attribute>
484      </xsl:if>
485      <fo:list-item-label
486        end-indent="label-end()">
487        <fo:block>
488          <xsl:number format="1."/>
489        </fo:block>
490      </fo:list-item-label>
491      <fo:list-item-body
492        start-indent="body-start()">
493        <fo:block
494          font-family="serif">
495          <xsl:apply-templates/>
496        </fo:block>
497      </fo:list-item-body>
498    </fo:list-item>
499  </xsl:template>
500<!-- Emulate browser handling of these invalid combinations that our DTD
501  unfortunately allows -->
502  <xsl:template match="ul/ul | ul/ol | ol/ul | ol/ol">
503    <fo:list-item>
504      <fo:list-item-label end-indent="label-end()">
505        <fo:block></fo:block>
506      </fo:list-item-label>
507      <fo:list-item-body start-indent="body-start()">
508        <fo:block font-family="serif">
509          <xsl:apply-templates/>
510        </fo:block>
511      </fo:list-item-body>
512    </fo:list-item>
513  </xsl:template>
514  <xsl:template match="ul/li">
515    <fo:list-item>
516      <xsl:if test="not(following-sibling::li[1])">
517        <xsl:attribute name="space-after">6pt</xsl:attribute>
518      </xsl:if>
519      <fo:list-item-label end-indent="label-end()">
520        <fo:block>&#x2022;</fo:block>
521      </fo:list-item-label>
522      <fo:list-item-body start-indent="body-start()">
523        <fo:block
524          font-family="serif">
525          <xsl:apply-templates/>
526        </fo:block>
527      </fo:list-item-body>
528    </fo:list-item>
529  </xsl:template>
530  <xsl:template match="dl">
531    <fo:list-block
532      provisional-distance-between-starts="18pt"
533      provisional-label-separation="3pt"
534      text-align="start">
535      <xsl:apply-templates/>
536    </fo:list-block>
537  </xsl:template>
538  <xsl:template match="dt">
539    <fo:list-item>
540      <fo:list-item-label end-indent="label-end()">
541        <fo:block></fo:block>
542      </fo:list-item-label>
543      <fo:list-item-body start-indent="body-start()">
544        <fo:block
545          font-weight="bold">
546          <xsl:apply-templates/>
547        </fo:block>
548      </fo:list-item-body>
549    </fo:list-item>
550  </xsl:template>
551  <xsl:template match="dd">
552    <fo:list-item>
553      <fo:list-item-label end-indent="label-end()">
554        <fo:block></fo:block>
555      </fo:list-item-label>
556      <fo:list-item-body start-indent="body-start()">
557        <fo:block>
558          <xsl:apply-templates/>
559        </fo:block>
560      </fo:list-item-body>
561    </fo:list-item>
562  </xsl:template>
563  <xsl:template match="strong">
564    <fo:inline font-weight="bold">
565      <xsl:apply-templates/>
566    </fo:inline>
567  </xsl:template>
568  <xsl:template match="em">
569    <fo:inline font-style="italic">
570      <xsl:apply-templates/>
571    </fo:inline>
572  </xsl:template>
573  <xsl:template match="code">
574    <fo:inline font-family="monospace">
575      <xsl:apply-templates/>
576    </fo:inline>
577  </xsl:template>
578  <xsl:template match="warning">
579    <xsl:variable name="color" select="//skinconfig/colors/color[@name='warning']/@value"/>
580    <fo:block
581      margin-left="0.25in"
582      margin-right="0.25in"
583      font-weight="bold"
584      font-size="10pt"
585      font-family="serif"
586      space-before="10pt"
587      border-before-style="solid"
588      border-start-style="solid"
589      border-end-style="solid"
590      border-color="{$color}"
591      background-color="{$color}"
592      color="#ffffff">
593      <xsl:call-template name="insertPageBreaks"/>
594      <xsl:choose>
595        <xsl:when test="@label">
596          <xsl:value-of select="@label"/>
597        </xsl:when>
598        <xsl:otherwise>Warning: </xsl:otherwise>
599      </xsl:choose>
600      <xsl:value-of select="title"/>
601    </fo:block>
602    <fo:block
603      margin-left="0.25in"
604      margin-right="0.25in"
605      font-family="serif"
606      font-size="8pt"
607      border-after-style="solid"
608      border-start-style="solid"
609      border-end-style="solid"
610      border-color="{$color}"
611      background-color="#fff0f0"
612      padding-start="3pt"
613      padding-end="3pt"
614      padding-before="3pt"
615      padding-after="3pt"
616      space-after="10pt">
617      <xsl:apply-templates/>
618    </fo:block>
619  </xsl:template>
620  <xsl:template match="note">
621    <xsl:variable name="color" select="//skinconfig/colors/color[@name='note']/@value"/>
622    <fo:block
623      margin-left="0.25in"
624      margin-right="0.25in"
625      font-weight="bold"
626      font-size="10pt"
627      color="#ffffff"
628      font-family="serif"
629      space-before="10pt"
630      border-before-style="solid"
631      border-start-style="solid"
632      border-end-style="solid"
633      border-color="{$color}"
634      background-color="{$color}">
635      <xsl:call-template name="insertPageBreaks"/>
636      <xsl:choose>
637        <xsl:when test="@label">
638          <xsl:value-of select="@label"/>
639        </xsl:when>
640<!-- insert i18n stuff here -->
641        <xsl:otherwise>Note: </xsl:otherwise>
642      </xsl:choose>
643      <xsl:value-of select="title"/>
644    </fo:block>
645    <fo:block
646      margin-left="0.25in"
647      margin-right="0.25in"
648      font-family="serif"
649      font-size="8pt"
650      space-after="10pt"
651      border-after-style="solid"
652      border-start-style="solid"
653      border-end-style="solid"
654      border-color="{$color}"
655      background-color="#F0F0FF"
656      padding-start="3pt"
657      padding-end="3pt"
658      padding-before="3pt"
659      padding-after="3pt">
660      <xsl:apply-templates/>
661    </fo:block>
662  </xsl:template>
663  <xsl:template match="fixme">
664    <xsl:variable name="color" select="//skinconfig/colors/color[@name='fixme']/@value"/>
665    <fo:block
666      margin-left="0.25in"
667      margin-right="0.25in"
668      font-weight="bold"
669      font-size="10pt"
670      color="#FFFFFF"
671      font-family="serif"
672      space-before="10pt"
673      border-before-style="solid"
674      border-start-style="solid"
675      border-end-style="solid"
676      border-color="{$color}"
677      background-color="{$color}">
678      <xsl:call-template name="insertPageBreaks"/>
679<!-- insert i18n stuff here -->
680      FIXME (<xsl:value-of select="&#x40;author"/>): <xsl:value-of select="title"/>
681    </fo:block>
682    <fo:block
683      margin-left="0.25in"
684      margin-right="0.25in"
685      font-family="serif"
686      font-size="8pt"
687      space-after="10pt"
688      border-after-style="solid"
689      border-start-style="solid"
690      border-end-style="solid"
691      border-color="{$color}"
692      background-color="#FFF0F0"
693      padding-start="3pt"
694      padding-end="3pt"
695      padding-before="3pt"
696      padding-after="3pt">
697      <xsl:apply-templates/>
698    </fo:block>
699  </xsl:template>
700  <xsl:template match="link|fork|jump">
701    <xsl:variable name="color" select="//skinconfig/colors/color[@name = 'body']/@link"/>
702    <xsl:choose>
703      <xsl:when test="starts-with(@href, '#')">
704        <fo:basic-link color="{$color}" text-decoration="underline" internal-destination="{substring(@href,2)}">
705          <xsl:apply-templates/>
706        </fo:basic-link>
707      </xsl:when>
708      <xsl:otherwise>
709        <fo:basic-link color="{$color}" text-decoration="underline" external-destination="{@href}">
710          <xsl:apply-templates/>
711        </fo:basic-link>
712        <xsl:if test="$show-external-urls = 'true' and @href != string(.)">
713          (<xsl:value-of select="@href"/>)
714        </xsl:if>
715      </xsl:otherwise>
716    </xsl:choose>
717  </xsl:template>
718  <xsl:template match="figure|img">
719    <fo:block text-align="center">
720      <xsl:call-template name="insertPageBreaks"/>
721      <xsl:if test="normalize-space(@id)!=''">
722        <xsl:attribute name="id">
723          <xsl:value-of select="@id"/>
724        </xsl:attribute>
725      </xsl:if>
726<!-- Make relative paths absolute -->
727      <xsl:variable name="imgpath">
728        <xsl:choose>
729<!-- resources image dir -->
730          <xsl:when test="starts-with(string(@src),'images/')">
731            <xsl:value-of select="concat($imagesdir,substring-after(@src,'images'))"/>
732          </xsl:when>
733          <xsl:when test="contains(string(@src),'/images/')">
734            <xsl:value-of select="concat($imagesdir,substring-after(@src,'/images'))"/>
735          </xsl:when>
736<!-- already absolute -->
737          <xsl:when test="contains(string(@src),':') or starts-with(string(@src),'/')">
738            <xsl:value-of select="@src"/>
739          </xsl:when>
740<!-- relative to document -->
741          <xsl:otherwise>
742            <xsl:value-of select="concat($xmlbasedir,@src)"/>
743          </xsl:otherwise>
744        </xsl:choose>
745      </xsl:variable>
746      <fo:external-graphic src="{$imgpath}">
747        <xsl:if test="@height">
748          <xsl:attribute name="height">
749            <xsl:value-of select="@height"/>
750          </xsl:attribute>
751        </xsl:if>
752        <xsl:if test="@width">
753          <xsl:attribute name="width">
754            <xsl:value-of select="@width"/>
755          </xsl:attribute>
756        </xsl:if>
757      </fo:external-graphic>
758<!-- alt text -->
759      <xsl:if test="//skinconfig/pdf/show-image-alt-text='true'">
760        <xsl:if test="normalize-space(@alt)!=''">
761          <fo:block>
762            <xsl:value-of select="@alt"/>
763          </fo:block>
764        </xsl:if>
765      </xsl:if>
766    </fo:block>
767  </xsl:template>
768  <xsl:template match="table">
769<!-- FIXME: Apache FOP must have column widths specified at present,
770         this section can be removed when this limitation is removed from Fop.
771         Unfortunately, this means that each column is a fixed width,
772         but at least the table displays! -->
773    <xsl:variable name="max-number-columns-td">
774      <xsl:for-each select="tr">
775        <xsl:sort select="count(td|th)" data-type="number"
776          order="descending"/>
777        <xsl:if test="position() = 1">
778          <xsl:value-of select="count(td|th)"/>
779        </xsl:if>
780      </xsl:for-each>
781    </xsl:variable>
782    <xsl:variable name="max-number-columns-colspan">
783      <xsl:for-each select="tr">
784        <xsl:sort select="count(td|th)" data-type="number"
785          order="descending"/>
786        <xsl:if test="position() = 1">
787          <xsl:value-of
788            select="sum(td/@colspan|th/@colspan)"/>
789        </xsl:if>
790      </xsl:for-each>
791    </xsl:variable>
792    <xsl:variable name="max-number-columns">
793      <xsl:choose>
794        <xsl:when
795          test="$max-number-columns-colspan&gt;$max-number-columns-td">
796          <xsl:value-of
797            select="$max-number-columns-colspan"/>
798        </xsl:when>
799        <xsl:otherwise>
800          <xsl:value-of select="$max-number-columns-td"/>
801        </xsl:otherwise>
802      </xsl:choose>
803    </xsl:variable>
804    <xsl:variable name="column-width">
805      <xsl:value-of select="6.25 div number($max-number-columns)"/>in
806    </xsl:variable>
807    <fo:table>
808      <fo:table-column>
809        <xsl:attribute name="column-width">
810          <xsl:value-of select="$column-width"/>
811        </xsl:attribute>
812        <xsl:attribute name="number-columns-repeated">
813          <xsl:value-of select="number($max-number-columns)"/>
814        </xsl:attribute>
815      </fo:table-column>
816<!-- End of hack for Fop support (if removing this hack, remember
817           you need the <fo:table> element) -->
818      <fo:table-body
819        font-size="10pt"
820        font-family="sans-serif">
821        <xsl:apply-templates select="tr"/>
822      </fo:table-body>
823    </fo:table>
824<!-- FIXME: Apache Fop does not support the caption element yet.
825         This hack will display the table caption accordingly. -->
826    <xsl:if test="caption">
827      <fo:block
828        text-align="center"
829        font-weight="bold">
830<!-- insert i18n stuff here -->
831        Table
832        <xsl:text> </xsl:text>
833        <xsl:number count="table" level="multiple"/>
834<xsl:text>: </xsl:text>
835        <xsl:value-of select="caption"/>
836      </fo:block>
837    </xsl:if>
838  </xsl:template>
839  <xsl:template match="tr">
840    <fo:table-row>
841      <xsl:apply-templates/>
842    </fo:table-row>
843  </xsl:template>
844  <xsl:template match="th">
845    <xsl:variable name="border-color" select="//skinconfig/colors/color[@name = 'table']/@value"/>
846    <xsl:variable name="background-color" select="$border-color"/>
847    <fo:table-cell
848        padding-before="4pt"
849        padding-after="4pt"
850        padding-start="4pt"
851        padding-end="4pt"
852        color="#FFFFFF"
853        background-color="{$background-color}"
854        border="1pt solid {$border-color}">
855      <xsl:attribute name="number-columns-spanned">
856        <xsl:value-of select="@colspan"/>
857      </xsl:attribute>
858      <xsl:attribute name="number-rows-spanned">
859        <xsl:value-of select="@rowspan"/>
860      </xsl:attribute>
861      <fo:block
862          text-align="center">
863        <xsl:apply-templates/>
864      </fo:block>
865    </fo:table-cell>
866  </xsl:template>
867  <xsl:template match="td">
868    <xsl:variable name="border-color" select="//skinconfig/colors/color[@name = 'table']/@value"/>
869    <xsl:variable name="background-color" select="//skinconfig/colors/color[@name = 'table-cell']/@value"/>
870    <fo:table-cell
871      padding-before="4pt"
872      padding-after="4pt"
873      padding-start="4pt"
874      padding-end="4pt"
875      background-color="{$background-color}"
876      border="1pt solid {$border-color}">
877      <xsl:attribute name="number-columns-spanned">
878        <xsl:value-of select="@colspan"/>
879      </xsl:attribute>
880      <xsl:attribute name="number-rows-spanned">
881        <xsl:value-of select="@rowspan"/>
882      </xsl:attribute>
883      <fo:block>
884        <xsl:apply-templates/>
885      </fo:block>
886    </fo:table-cell>
887  </xsl:template>
888  <xsl:template match="br">
889    <fo:block></fo:block>
890  </xsl:template>
891  <xsl:template match="legal">
892    <fo:inline
893      font-size="8pt">
894      <xsl:apply-templates/>
895    </fo:inline>
896  </xsl:template>
897  <xsl:template match="body[count(//section) != 0]">
898    <xsl:if test="$toc-max-depth > 0">
899      <fo:block font-family="serif" font-size="14pt" font-weight="bold"
900      space-after="5pt" space-before="5pt" text-align="justify" width="7.5in">
901        <xsl:call-template name="insertPageBreaks"/>
902<!-- insert i18n stuff here -->
903<xsl:text>Table of contents</xsl:text>
904      </fo:block>
905      <fo:block font-family="sans" font-size="12pt" space-after="5pt"
906      space-before="0pt" text-align="justify" width="7.5in">
907        <xsl:if test="$page-break-top-sections">
908          <xsl:attribute name="break-after">page</xsl:attribute>
909        </xsl:if>
910        <xsl:apply-templates select="section" mode="toc" />
911      </fo:block>
912    </xsl:if>
913    <xsl:apply-templates />
914  </xsl:template>
915  <xsl:template match="section" mode="toc">
916<!-- FIXME: see bug FOR-640 -->
917    <xsl:param name="depth" select="'1'"/>
918    <fo:block space-before="5pt" text-align-last="justify" start-indent=".5em" text-indent=".5em">
919      <fo:inline>
920        <xsl:variable name="id">
921          <xsl:choose>
922            <xsl:when test="normalize-space(@id)!=''">
923              <xsl:value-of select="@id"/>
924            </xsl:when>
925            <xsl:otherwise>
926              <xsl:value-of select="generate-id()"/>
927            </xsl:otherwise>
928          </xsl:choose>
929        </xsl:variable>
930        <fo:basic-link internal-destination="{$id}">
931          <xsl:value-of select="substring('&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;', 0, 2 * $depth - 1)" />
932          <fo:inline font-size="10pt">
933            <xsl:number count="section" format="1.1.1.1.1.1.1" level="multiple" />
934          </fo:inline>
935<xsl:text> </xsl:text>
936          <xsl:value-of select="title" />
937          <fo:leader leader-pattern="dots" />
938          <fo:page-number-citation ref-id="{$id}" />
939        </fo:basic-link>
940      </fo:inline>
941      <xsl:if test="$toc-max-depth > $depth">
942        <xsl:apply-templates select="section" mode="toc">
943          <xsl:with-param name="depth" select="$depth + 1"/>
944        </xsl:apply-templates>
945      </xsl:if>
946    </fo:block>
947  </xsl:template>
948<!-- ====================================================================== -->
949<!-- Local Extensions section -->
950<!-- ====================================================================== -->
951  <xsl:template match="citation">
952    <fo:inline>
953     [<xsl:value-of select="@def"/>]
954   </fo:inline>
955  </xsl:template>
956  <xsl:template match="p[@class='quote']">
957    <fo:block start-indent="1em"
958     space-before="4pt"
959     space-after="4pt"
960     background-color="#f0f0f0"
961     font-family="monospace">
962      <xsl:call-template name="insertPageBreaks"/>
963      <xsl:apply-templates/>
964    </fo:block>
965  </xsl:template>
966  <xsl:template name="insertPageBreaks">
967<!-- if marked as a 'pageBreakBefore', and we're breaking on pages, and were not the first node -->
968    <xsl:if test="contains(@class, 'pageBreakBefore') and preceding-sibling::node()">
969      <xsl:attribute name="break-before">page</xsl:attribute>
970    </xsl:if>
971<!-- if marked as a 'pageBreakAfter', and we're breaking on pages, and were not the last node -->
972    <xsl:if test="contains(@class, 'pageBreakAfter') and following-sibling::node()">
973      <xsl:attribute name="break-after">page</xsl:attribute>
974    </xsl:if>
975  </xsl:template>
976<!-- Display the document numerotation -->
977  <xsl:template name="insertPageNumber">
978    <xsl:param name="text-align" select="'start'"/>
979    <xsl:variable name="prefixe" select="substring-before($page-numbering-format,'1')"/>
980    <xsl:variable name="sep" select="substring-before(substring-after($page-numbering-format,'1'),'1')"/>
981    <xsl:variable name="postfixe">
982      <xsl:choose>
983        <xsl:when test="contains(substring-after($page-numbering-format,'1'),'1')">
984          <xsl:value-of select="substring-after(substring-after($page-numbering-format,'1'),'1')"/>
985        </xsl:when>
986        <xsl:otherwise>
987          <xsl:value-of select="substring-after($page-numbering-format,'1')"/>
988        </xsl:otherwise>
989      </xsl:choose>
990    </xsl:variable>
991<!-- if 'page-numbering-format' contains 1 digits, the page number is displayed in the footer -->
992    <xsl:if test="contains($page-numbering-format,'1')">
993      <fo:block font-size="70%" text-align="{$text-align}">
994<!-- if the separator is not found, the total page number is skipped -->
995        <xsl:value-of select="$prefixe"/>
996        <fo:page-number/>
997        <xsl:if test="$sep != ''">
998          <xsl:value-of select="$sep"/>
999          <fo:page-number-citation ref-id="term"/>
1000        </xsl:if>
1001        <xsl:value-of select="$postfixe"/>
1002      </fo:block>
1003    </xsl:if>
1004  </xsl:template>
1005<!-- ====================================================================== -->
1006<!-- Temporary section - subject to change on short notice  -->
1007<!-- ====================================================================== -->
1008  <xsl:template match="//style">
1009<!-- HACK: The OpenOffice.org input plugin currently produces
1010   intermediate documents that contain a style element, invalid per
1011   the Forrest Document DTD. This style element must be ignored
1012   here. To find out why this is done this way, read the comments
1013   attached to issue FOR-433. -->
1014  </xsl:template>
1015</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.