Added another example with complete files.
[docutils/kirr.git] / sandbox / docbook / examples / report2 / docbook_fo.xsl
blob8f6586213133791e267a10e6ef4d192b3a08613f
1 <xsl:stylesheet
2 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:fo="http://www.w3.org/1999/XSL/Format"
4 xmlns:d="http://docbook.org/ns/docbook"
5 version="1.1">
7 <!--
8 <xsl:import href="/Users/cejohnsonlouisville/Documents/docbook-xsl-ns-1.76.1/fo/docbook.xsl"/>
9 -->
10 <xsl:import href="http://50.56.245.89/xsl-ns/fo/docbook.xsl"/>
11 <xsl:import href="title_page.xsl"/>
12 <xsl:param name="generate.toc">
13 appendix toc,title
14 article/appendix nop
15 article toc,title,figure,table
16 book toc,title,figure,table,example,equation
17 chapter toc,title
18 part toc,title
19 preface toc,title
20 qandadiv toc
21 qandaset toc
22 reference toc,title
23 sect1 toc
24 sect2 toc
25 sect3 toc
26 sect4 toc
27 sect5 toc
28 section toc
29 set toc,title
30 </xsl:param>
31 <xsl:param name="default.table.frame">none</xsl:param>
33 <xsl:param name="section.autolabel" select="1"/>
34 <xsl:param name="fop1.extensions" select="1"/>
37 <xsl:param name="debug"></xsl:param>
38 <xsl:param name="long.table"></xsl:param>
40 <xsl:attribute-set name="article.appendix.title.properties">
41 <xsl:attribute name="margin-{$direction.align.start}">
42 <xsl:text >inherit</xsl:text>
43 </xsl:attribute>
44 </xsl:attribute-set>
46 <xsl:attribute-set name="table.caption">
47 <xsl:attribute name="start-indent">inherit</xsl:attribute>
48 <xsl:attribute name="font-style">italic</xsl:attribute>
49 </xsl:attribute-set>
51 <xsl:attribute-set name="abstract.title.properties" >
52 <xsl:attribute name="font-size">18pt</xsl:attribute>
53 <xsl:attribute name="space-before.conditionality">retain</xsl:attribute>
54 </xsl:attribute-set>
55 <xsl:attribute-set name="formal.object.properties">
56 <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
57 </xsl:attribute-set>
58 <xsl:attribute-set name="table.table.properties">
59 <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
60 </xsl:attribute-set>
63 <xsl:template match="d:article">
64 <xsl:variable name="id">
65 <xsl:call-template name="object.id"/>
66 </xsl:variable>
68 <xsl:call-template name="page.sequence">
69 <xsl:with-param name="master-reference">titlepage</xsl:with-param>
70 <xsl:with-param name="content">
71 <fo:block id="{$id}"
72 xsl:use-attribute-sets="component.titlepage.properties">
73 <xsl:call-template name="article.titlepage"/>
74 </fo:block>
75 <fo:block break-after="page"/>
76 </xsl:with-param>
77 </xsl:call-template>
79 <xsl:call-template name="make.article.tocs"/>
82 <xsl:call-template name="page.sequence">
83 <xsl:with-param name="master-reference">body</xsl:with-param>
84 <xsl:with-param name="content">
85 <xsl:apply-templates
86 select="*[not(self::bibliography)]|processing-instruction()"/>
87 </xsl:with-param>
88 </xsl:call-template>
90 <xsl:if test="d:bibliography">
91 <xsl:call-template name="page.sequence">
92 <xsl:with-param name="master-reference">back</xsl:with-param>
93 <xsl:with-param name="content">
94 <xsl:apply-templates select="bibliography"/>
95 </xsl:with-param>
96 </xsl:call-template>
97 </xsl:if>
98 </xsl:template>
102 <xsl:template name="page.number.format">
103 <xsl:param name="element" select="local-name(.)"/>
104 <xsl:param name="master-reference" select="''"/>
105 <xsl:if test="$debug != ''">
106 </xsl:if>
108 <xsl:choose>
109 <xsl:when test="$element = 'toc'">i</xsl:when>
110 <xsl:when test="$element = 'preface'">i</xsl:when>
111 <xsl:when test="$element = 'dedication'">i</xsl:when>
112 <xsl:otherwise>1</xsl:otherwise>
113 </xsl:choose>
114 </xsl:template>
117 <xsl:attribute-set name="toc.line.properties">
118 <xsl:attribute name="text-align-last">justify</xsl:attribute>
119 <xsl:attribute name="text-align">inherit</xsl:attribute>
120 </xsl:attribute-set>
122 <xsl:template name="header.content_">
123 <xsl:param name="pageclass" select="''"/>
124 <xsl:param name="sequence" select="''"/>
125 <xsl:param name="position" select="''"/>
126 <xsl:param name="gentext-key" select="''"/>
127 <xsl:choose>
128 <xsl:when test="$pageclass = 'body' and $position = 'left'">
129 <fo:block text-align="center">
130 <xsl:apply-templates select="." mode="title.markup"/>
131 </fo:block>
132 </xsl:when>
133 <xsl:when test="$pageclass = 'long.table' and $position = 'left'">
134 <fo:block text-align="center">
135 <xsl:text>Executive Report</xsl:text>
136 </fo:block>
137 </xsl:when>
138 <xsl:when test="$pageclass = 'long.table' and $position = 'after-rule' and ($sequence = 'even' or $sequence = 'odd') ">
139 <fo:block space-before="10pt">
140 <xsl:apply-templates select="self::d:table|descendant::d:table[1]" mode="object.title.markup"/>
141 <xsl:text> (cont.)</xsl:text>
142 </fo:block>
143 </xsl:when>
144 </xsl:choose>
145 </xsl:template>
147 <xsl:template name="table.row.properties">
148 <xsl:variable name="role" select="ancestor::d:table/@role"/>
150 <xsl:variable name="tabstyle">
151 <xsl:call-template name="tabstyle"/>
152 </xsl:variable>
154 <xsl:variable name="bgcolor">
155 <xsl:call-template name="dbfo-attribute">
156 <xsl:with-param name="pis" select="processing-instruction('dbfo')"/>
157 <xsl:with-param name="attribute" select="'bgcolor'"/>
158 </xsl:call-template>
159 </xsl:variable>
161 <xsl:variable name="rownum">
162 <xsl:number from="tgroup" count="row"/>
163 </xsl:variable>
164 <!--
165 <xsl:message >
166 <xsl:if test="$role != 'receive-hours' and $role !=
167 'long-metrics' and $role != 'cutover-costs'">
168 <xsl:value-of select="$role"/>
170 </xsl:if>
171 </xsl:message>
174 <xsl:choose >
176 <xsl:when test="@role = 'continuation-label'">
178 </xsl:when>
179 <xsl:when test="parent::d:tfoot">
180 <xsl:attribute name="border-before-style">solid</xsl:attribute>
181 <xsl:attribute name="border-before-width">1</xsl:attribute>
182 </xsl:when>
183 <xsl:when test="parent::d:thead">
184 <xsl:attribute name="border-after-style">solid</xsl:attribute>
185 <xsl:attribute name="border-after-width">1</xsl:attribute>
186 </xsl:when>
187 <xsl:when test="position() = last() and ($role='receive-hours' or
188 $role = 'cutover-costs' or $role = 'projected-summary')">
189 <xsl:attribute name="border-before-style">solid</xsl:attribute>
190 <xsl:attribute name="border-before-width">1</xsl:attribute>
191 <xsl:attribute name="font-weight">bold</xsl:attribute>
192 </xsl:when>
193 </xsl:choose>
195 </xsl:template>
197 <xsl:template name="table.layout">
198 <xsl:param name="table.content" select="NOTANODE"/>
199 <xsl:choose>
200 <xsl:when test="@role='overall-costs'">
201 <fo:table table-layout="fixed" width="100%">
202 <fo:table-column column-width="proportional-column-width(1)"/>
203 <fo:table-body>
204 <fo:table-row >
205 <fo:table-cell display-align="center">
206 <xsl:copy-of select="$table.content"/>
207 </fo:table-cell>
208 </fo:table-row>
209 </fo:table-body>
210 </fo:table>
211 </xsl:when>
212 <xsl:when test="@role = 'overall-costs_'">
213 <fo:table table-layout="fixed" width="100%">
214 <fo:table-column column-width="proportional-column-width(1)"/>
215 <fo:table-column column-width="100mm"/>
216 <fo:table-column column-width="proportional-column-width(1)"/>
217 <fo:table-body>
218 <fo:table-row>
219 <fo:table-cell column-number="2">
220 <xsl:copy-of select="$table.content"/>
221 </fo:table-cell>
222 </fo:table-row>
223 </fo:table-body>
224 </fo:table>
225 </xsl:when>
226 <xsl:otherwise>
227 <xsl:copy-of select="$table.content"/>
228 </xsl:otherwise>
229 </xsl:choose>
230 </xsl:template>
233 <!--STANDARD STUFF-->
235 <xsl:template match="processing-instruction('hard-pagebreak')">
236 <fo:block break-after='page'/>
237 </xsl:template>
239 <xsl:template name="make.article.tocs">
240 <xsl:variable name="lot-master-reference">
241 <xsl:call-template name="select.pagemaster">
242 <xsl:with-param name="pageclass" select="'lot'"/>
243 </xsl:call-template>
244 </xsl:variable>
246 <xsl:variable name="toc.params">
247 <xsl:call-template name="find.path.params">
248 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
249 </xsl:call-template>
250 </xsl:variable>
252 <xsl:if test="contains($toc.params, 'toc')">
253 <xsl:call-template name="page.sequence">
254 <xsl:with-param name="master-reference"
255 select="$lot-master-reference"/>
256 <xsl:with-param name="element" select="'toc'"/>
257 <xsl:with-param name="gentext-key" select="'TableofContents'"/>
258 <xsl:with-param name="initial-page-number" select="1"/>
259 <xsl:with-param name="content">
260 <xsl:call-template name="component.toc">
261 <xsl:with-param name="toc.title.p"
262 select="contains($toc.params, 'title')"/>
263 </xsl:call-template>
264 </xsl:with-param>
265 </xsl:call-template>
266 </xsl:if>
269 <xsl:if test="contains($toc.params,'figure') and .//d:figure">
270 <xsl:call-template name="page.sequence">
271 <xsl:with-param name="master-reference"
272 select="$lot-master-reference"/>
273 <xsl:with-param name="element" select="'toc'"/>
274 <xsl:with-param name="gentext-key" select="'ListofFigures'"/>
275 <xsl:with-param name="initial.page.number" select="''"/>
276 <xsl:with-param name="content">
277 <xsl:call-template name="list.of.titles">
278 <xsl:with-param name="titles" select="'figure'"/>
279 <xsl:with-param name="nodes" select=".//d:figure"/>
280 </xsl:call-template>
281 </xsl:with-param>
282 </xsl:call-template>
283 </xsl:if>
285 <xsl:if test="contains($toc.params,'table') and .//d:table">
286 <xsl:call-template name="page.sequence">
287 <xsl:with-param name="master-reference"
288 select="$lot-master-reference"/>
289 <xsl:with-param name="element" select="'toc'"/>
290 <xsl:with-param name="gentext-key" select="'ListofTables'"/>
291 <xsl:with-param name="content">
292 <xsl:call-template name="list.of.titles">
293 <xsl:with-param name="titles" select="'table'"/>
294 <xsl:with-param name="nodes" select=".//d:table"/>
295 </xsl:call-template>
296 </xsl:with-param>
297 </xsl:call-template>
298 </xsl:if>
300 <xsl:if test="contains($toc.params,'example') and .//d:example">
301 <xsl:call-template name="page.sequence">
302 <xsl:with-param name="master-reference"
303 select="$lot-master-reference"/>
304 <xsl:with-param name="element" select="'toc'"/>
305 <xsl:with-param name="gentext-key" select="'ListofExample'"/>
306 <xsl:with-param name="content">
307 <xsl:call-template name="list.of.titles">
308 <xsl:with-param name="titles" select="'example'"/>
309 <xsl:with-param name="nodes" select=".//d:example"/>
310 </xsl:call-template>
311 </xsl:with-param>
312 </xsl:call-template>
313 </xsl:if>
315 <xsl:if test="contains($toc.params,'equation') and
316 .//d:equation[d:title or d:info/d:title]">
317 <xsl:call-template name="page.sequence">
318 <xsl:with-param name="master-reference"
319 select="$lot-master-reference"/>
320 <xsl:with-param name="element" select="'toc'"/>
321 <xsl:with-param name="gentext-key" select="'ListofEquations'"/>
322 <xsl:with-param name="content">
323 <xsl:call-template name="list.of.titles">
324 <xsl:with-param name="titles" select="'equation'"/>
325 <xsl:with-param name="nodes"
326 select=".//d:equation[d:title or d:info/d:title]"/>
327 </xsl:call-template>
328 </xsl:with-param>
329 </xsl:call-template>
330 </xsl:if>
332 <xsl:if test="contains($toc.params,'procedure') and
333 .//d:procedure[d:title or d:info/d:title]">
334 <xsl:call-template name="page.sequence">
335 <xsl:with-param name="master-reference"
336 select="$lot-master-reference"/>
337 <xsl:with-param name="element" select="'toc'"/>
338 <xsl:with-param name="gentext-key" select="'ListofProcedures'"/>
339 <xsl:with-param name="content">
340 <xsl:call-template name="list.of.titles">
341 <xsl:with-param name="titles" select="'procedure'"/>
342 <xsl:with-param name="nodes"
343 select=".//d:procedure[d:title or d:info/d:title]"/>
344 </xsl:call-template>
345 </xsl:with-param>
346 </xsl:call-template>
347 </xsl:if>
349 </xsl:template>
352 <xsl:template name="calsTable">
354 <xsl:variable name="keep.together">
355 <xsl:call-template name="pi.dbfo_keep-together"/>
356 </xsl:variable>
358 <xsl:for-each select="d:tgroup">
360 <fo:table xsl:use-attribute-sets="table.table.properties">
361 <xsl:if test="$keep.together != ''">
362 <xsl:attribute name="keep-together.within-column">
363 <xsl:value-of select="$keep.together"/>
364 </xsl:attribute>
365 </xsl:if>
366 <xsl:call-template name="table.frame"/>
367 <xsl:if test="following-sibling::d:tgroup">
368 <xsl:attribute name="border-bottom-width">0pt</xsl:attribute>
369 <xsl:attribute name="border-bottom-style">none</xsl:attribute>
370 <xsl:attribute name="padding-bottom">0pt</xsl:attribute>
371 <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
372 <xsl:attribute name="space-after">0pt</xsl:attribute>
373 <xsl:attribute name="space-after.minimum">0pt</xsl:attribute>
374 <xsl:attribute name="space-after.optimum">0pt</xsl:attribute>
375 <xsl:attribute name="space-after.maximum">0pt</xsl:attribute>
376 </xsl:if>
377 <xsl:if test="preceding-sibling::d:tgroup">
378 <xsl:attribute name="border-top-width">0pt</xsl:attribute>
379 <xsl:attribute name="border-top-style">none</xsl:attribute>
380 <xsl:attribute name="padding-top">0pt</xsl:attribute>
381 <xsl:attribute name="margin-top">0pt</xsl:attribute>
382 <xsl:attribute name="space-before">0pt</xsl:attribute>
383 <xsl:attribute name="space-before.minimum">0pt</xsl:attribute>
384 <xsl:attribute name="space-before.optimum">0pt</xsl:attribute>
385 <xsl:attribute name="space-before.maximum">0pt</xsl:attribute>
386 </xsl:if>
388 <xsl:apply-templates select="."/>
389 </fo:table>
391 <xsl:for-each select="d:mediaobject|d:graphic">
392 <xsl:apply-templates select="."/>
393 </xsl:for-each>
395 </xsl:for-each>
396 <xsl:apply-templates select="d:caption"/>
397 </xsl:template>
399 <xsl:template match="d:caption">
400 <fo:block xsl:use-attribute-sets="table.caption">
401 <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
402 <xsl:apply-templates/>
403 </fo:block>
404 </xsl:template>
406 <xsl:template
407 match="d:para[../../@role='continuation-label']" priority="2">
408 <xsl:for-each select="preceding::d:table[1]">
409 <fo:block>
410 <xsl:apply-templates select="self::d:table" mode="object.title.markup"/>
411 <xsl:text > (cont.)</xsl:text>
412 </fo:block>
413 </xsl:for-each>
415 </xsl:template>
418 </xsl:stylesheet>