added xsl stylesheet for FdAC
[cdmlib.git] / cdmlib-print / src / main / resources / stylesheets / pdf / flore-afrique-centrale.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
5
6 <!-- ############### Constants and definitions ################### -->
7
8 <!-- **********************************
9 ** global definitions
10 *********************************** -->
11 <xsl:param name="global-family-font">Times</xsl:param>
12 <xsl:param name="global-size-font">10pt</xsl:param>
13 <xsl:param name="global-line-height">12pt</xsl:param>
14
15 <xsl:param name="global-width-page">159mm</xsl:param>
16 <xsl:param name="global-height-page">244mm</xsl:param>
17
18 <xsl:param name="global-indentation">0mm</xsl:param>
19
20 <!-- **********************************
21 ** definitions for taxon pages
22 *********************************** -->
23 <xsl:param name="taxon-page-top-margin">32mm</xsl:param>
24 <xsl:param name="taxon-page-inner-margin">21mm</xsl:param>
25 <xsl:param name="taxon-page-bottom-margin">32mm</xsl:param>
26
27 <xsl:param name="taxon-region-body-outer-margin">24mm</xsl:param>
28
29 <xsl:param name="taxon-region-before-extent">0mm</xsl:param>
30 <xsl:param name="taxon-region-after-extent">0mm</xsl:param>
31
32 <xsl:param name="content-bg-color">white</xsl:param>
33 <xsl:param name="taxon-header-family-font">Times</xsl:param>
34 <xsl:param name="taxon-header-before-bg-color">white</xsl:param>
35 <xsl:param name="taxon-header-after-bg-color">white</xsl:param>
36 <xsl:param name="taxon-header-size-font">7pt</xsl:param>
37
38
39 <xsl:param name="taxon-name-indentation">4mm</xsl:param>
40 <xsl:param name="taxon-name-size-font">8pt</xsl:param>
41 <xsl:param name="taxon-name-line-height">9.6pt</xsl:param>
42
43 <xsl:param name="taxon-header-style-font">italic</xsl:param>
44 <xsl:param name="taxon-header-page-number-size-font">10pt</xsl:param>
45 <xsl:param name="taxon-header-page-number-align-text">end</xsl:param>
46
47 <xsl:param name="taxon-page-number-initial">1</xsl:param>
48
49 <!-- hardcoded ranks -->
50 <xsl:param name="uuidFamily">210a8214-4e69-401a-8e47-c7940d990bdd</xsl:param>
51 <xsl:param name="uuidGenus">1b11c34c-48a8-4efa-98d5-84f7f66ef43a</xsl:param>
52 <xsl:param name="uuidSubgenus">78786e16-2a70-48af-a608-494023b91904</xsl:param>
53
54 <!-- **********************************
55 ** html support
56 *********************************** -->
57
58 <!-- format html i tags in text as italic -->
59 <xsl:template match="i">
60 <fo:inline font-style="italic">
61 <xsl:value-of select="."/>
62 </fo:inline>
63 </xsl:template>
64
65 <!-- format html b tags in text as bold -->
66 <xsl:template match="b">
67 <fo:inline font-weight="bold">
68 <xsl:apply-templates/>
69 </fo:inline>
70 </xsl:template>
71
72 <!-- ########################################################################## -->
73
74
75 <!-- start xsl output -->
76 <xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="no"/>
77 <xsl:param name="versionParam" select="'1.0'"/>
78
79 <!-- root element: root -->
80 <xsl:template match="root">
81 <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
82
83 <!-- defines page layout -->
84 <fo:layout-master-set>
85
86 <!-- layout for odd taxon pages -->
87 <fo:simple-page-master
88 master-name="taxon_page_odd"
89 page-height="{$global-height-page}"
90 page-width="{$global-width-page}"
91 margin-top="{$taxon-page-top-margin}"
92 margin-bottom="{$taxon-page-bottom-margin}"
93 margin-left="{$taxon-page-inner-margin}"
94 margin-right="">
95 <fo:region-body
96 margin-right="{$taxon-region-body-outer-margin}"/>
97 <fo:region-before extent="{$taxon-region-before-extent}" region-name="odd-before"/>
98 <fo:region-after extent="{$taxon-region-after-extent}" region-name="odd-after"/>
99 </fo:simple-page-master>
100
101 <!-- layout for even taxon pages -->
102 <fo:simple-page-master
103 master-name="taxon_page_even"
104 page-height="{$global-height-page}"
105 page-width="{$global-width-page}"
106 margin-top="{$taxon-page-top-margin}"
107 margin-bottom="{$taxon-page-bottom-margin}"
108 margin-left="0"
109 margin-right="{$taxon-page-inner-margin}">
110 <fo:region-body
111 margin-left="{$taxon-region-body-outer-margin}"/>
112 <fo:region-before extent="{$taxon-region-before-extent}" region-name="even-before"/>
113 <fo:region-after extent="{$taxon-region-after-extent}" region-name="even-after"/>
114 </fo:simple-page-master>
115
116
117
118 <!-- defines repeatable page-sequence for layout of taxa -->
119 <fo:page-sequence-master master-name="taxon_page">
120 <fo:repeatable-page-master-alternatives>
121 <fo:conditional-page-master-reference master-reference="taxon_page_odd"
122 page-position="first"/>
123 <fo:conditional-page-master-reference master-reference="taxon_page_even"
124 page-position="rest" odd-or-even="even"/>
125 <fo:conditional-page-master-reference master-reference="taxon_page_odd"
126 page-position="rest" odd-or-even="odd"/>
127 <!-- <fo:conditional-page-master-reference master-reference="mclBoook_taxon_page_even"
128 page-position="last"/>-->
129 </fo:repeatable-page-master-alternatives>
130 </fo:page-sequence-master>
131 </fo:layout-master-set>
132 <!-- end: defines page layout -->
133
134 <!-- page sequence for taxon view -->
135 <fo:page-sequence master-reference="taxon_page"
136 initial-page-number="{$taxon-page-number-initial}" force-page-count="no-force">
137
138 <fo:static-content flow-name="odd-before">
139 <xsl:call-template name="right-extent"/>
140 </fo:static-content>
141
142 <fo:static-content flow-name="even-before">
143 <xsl:call-template name="left-extent"/>
144 </fo:static-content>
145
146 <!-- format taxa -->
147 <fo:flow flow-name="xsl-region-body">
148 <fo:block font-family="{$global-family-font}" font-size="{$global-size-font}"
149 line-height="{$global-line-height}">
150 <xsl:for-each select="//TaxonNode">
151 <xsl:apply-templates select="."/>
152 </xsl:for-each>
153 </fo:block>
154 </fo:flow>
155
156 </fo:page-sequence>
157 </fo:root>
158 </xsl:template>
159
160 <!-- HEADER -->
161
162 <xsl:template name="right-extent">
163
164 <fo:block font-family="{$taxon-header-family-font}" font-style="{$taxon-header-style-font}"
165 font-size="{$taxon-header-size-font}">
166 <!-- No pagination at the moment
167 <fo:block font-size="{$taxon-header-page-number-size-font}"
168 text-align="{$taxon-header-page-number-align-text}"> &#x2014; <fo:page-number/> &#x2014; </fo:block>
169 <fo:block color="white">-</fo:block> -->
170 <fo:block>
171 <fo:retrieve-marker retrieve-class-name="pageTitleMarker"
172 retrieve-position="first-starting-within-page" retrieve-boundary="document"/>
173 <xsl:text> </xsl:text>
174 <fo:retrieve-marker retrieve-class-name="pageTitleSectionMarker"
175 retrieve-position="first-starting-within-page" retrieve-boundary="document"/>
176 </fo:block>
177 </fo:block>
178
179 </xsl:template>
180
181 <xsl:template name="left-extent">
182 <fo:block font-family="{$taxon-header-family-font}" font-style="{$taxon-header-style-font}"
183 font-size="{$taxon-header-size-font}">
184 <!-- No pagination at the moment
185 <fo:block font-size="{$taxon-header-page-number-size-font}"
186 text-align="{$taxon-header-page-number-align-text}"> &#x2014; <fo:page-number/> &#x2014;
187 </fo:block> -->
188 </fo:block>
189 </xsl:template>
190
191 <!--xsl:template name="odd-after-header">
192 <fo:block font-family="{$taxon-header-family-font}" font-style="{$taxon-header-style-font}"
193 font-size="{$taxon-header-size-font}">
194 <fo:block>
195 <fo:inline>
196 <fo:retrieve-marker retrieve-class-name="pageTitleMarker"
197 retrieve-position="last-starting-within-page" retrieve-boundary="document"/>
198 <fo:retrieve-marker retrieve-class-name="pageTitleSectionMarker"
199 retrieve-position="last-starting-within-page" retrieve-boundary="document"/>
200 </fo:inline>
201 </fo:block>
202 </fo:block>
203 </xsl:template-->
204
205
206 <!--xsl:template name="even-before-header">
207 <fo:block font-family="{$taxon-header-family-font}" font-style="{$taxon-header-style-font}"
208 font-size="{$taxon-header-size-font}"-->
209 <!--
210 No pagination at the moment
211 <fo:block color="white" font-size="{$taxon-header-page-number-size-font}">-</fo:block>
212 <fo:block color="white">-</fo:block>-->
213 <!--
214 <fo:block>
215 <fo:inline>
216 <fo:retrieve-marker retrieve-class-name="pageTitleMarker"
217 retrieve-position="first-starting-within-page" retrieve-boundary="document"/>
218 <fo:retrieve-marker retrieve-class-name="pageTitleSectionMarker"
219 retrieve-position="first-starting-within-page" retrieve-boundary="document"/>
220 </fo:inline>
221 </fo:block>
222 </fo:block>
223
224 </xsl:template-->
225
226 <xsl:template name="even-after-header">
227 <fo:block font-family="{$taxon-header-family-font}" font-style="{$taxon-header-style-font}"
228 font-size="{$taxon-header-size-font}">
229 <fo:block>
230 <fo:inline>
231 <fo:retrieve-marker retrieve-class-name="pageTitleMarker"
232 retrieve-position="last-starting-within-page" retrieve-boundary="document"/>
233 <fo:retrieve-marker retrieve-class-name="pageTitleSectionMarker"
234 retrieve-position="last-starting-within-page" retrieve-boundary="document"/>
235 </fo:inline>
236 </fo:block>
237 <!-- No pagination at the moment
238 <fo:block color="white">-</fo:block>
239 <fo:block font-size="{$taxon-header-page-number-size-font}"
240 text-align="{$taxon-header-page-number-align-text}"> &#x2014; <fo:page-number/> &#x2014;
241 </fo:block> -->
242 </fo:block>
243 </xsl:template>
244
245 <!-- GENERAL -->
246
247 <xsl:template match="TaxonNode" name="TaxonNode">
248 <xsl:apply-templates select="Taxon"/>
249 </xsl:template>
250
251 <xsl:template match="Taxon" name="Taxon">
252 <xsl:call-template name="title"/>
253 <xsl:apply-templates select="synonymy"/>
254 <xsl:apply-templates select="descriptions"/>
255 </xsl:template>
256
257
258 <xsl:template name="title">
259 <fo:block margin-bottom="5mm">
260 <!-- we need to find a way to store the uuid in a variable xsl:parameter did not work or i was using it wrong -->
261 <xsl:choose>
262 <!-- family -->
263 <xsl:when test="name/rank/uuid='af5f2481-3192-403f-ae65-7c957a0f02b6'">
264 <fo:block text-align="center" text-transform="uppercase">
265 <xsl:apply-templates select="name/genusOrUninomial"/>
266 </fo:block>
267 </xsl:when>
268 <!-- genus -->
269 <xsl:when test="name/rank/uuid='1b11c34c-48a8-4efa-98d5-84f7f66ef43a'">
270 <fo:block font-weight="bold" text-align="center" text-transform="uppercase">
271 <xsl:apply-templates select="name/genusOrUninomial"/>
272 </fo:block>
273 </xsl:when>
274 <!-- subgenus -->
275 <xsl:when test="name/rank/uuid='78786e16-2a70-48af-a608-494023b91904'">
276 <fo:block font-weight="bold" text-align="center">
277 <xsl:apply-templates select="name/rank/representation_L10n"/>
278 <xsl:text> </xsl:text>
279 <xsl:apply-templates select="name/genusOrUninomial"/>
280 </fo:block>
281 </xsl:when>
282 <!-- species -->
283 <xsl:when test="name/rank/uuid='b301f787-f319-4ccc-a10f-b4ed3b99a86d'">
284 <fo:block font-weight="bold" text-align="center">
285 <xsl:apply-templates select="name/genusOrUninomial"/>
286 <xsl:text> </xsl:text>
287 <xsl:apply-templates select="name/specificEpithet"/>
288 </fo:block>
289 </xsl:when>
290 <xsl:otherwise>
291 <!-- for debugging --> Unformatted title for rank uuid: <xsl:value-of
292 select="name/rank/uuid"/>: <xsl:value-of select="name/titleCache"/>
293 </xsl:otherwise>
294 </xsl:choose>
295 </fo:block>
296 </xsl:template>
297
298 <!-- NAME -->
299
300 <xsl:template match="name">
301 <xsl:apply-templates select="taggedName"/>
302 <xsl:apply-templates select="nomenclaturalReference"/>
303 <xsl:call-template name="citations"/>
304 </xsl:template>
305
306 <xsl:template match="taggedName">
307 <xsl:for-each select="e">
308 <xsl:choose>
309 <xsl:when test="type='name'">
310 <fo:inline font-style="italic">
311 <xsl:value-of select="text"/>
312 </fo:inline>
313 <xsl:text> </xsl:text>
314 </xsl:when>
315 <xsl:when test="type='authors'">
316 <xsl:value-of select="text"/>
317 </xsl:when>
318 <xsl:otherwise>
319 <xsl:value-of select="text"/>
320 <xsl:text> </xsl:text>
321 </xsl:otherwise>
322 </xsl:choose>
323 </xsl:for-each>
324 </xsl:template>
325
326 <xsl:template match="nomenclaturalReference">
327 <xsl:text> (</xsl:text>
328 <fo:inline><xsl:value-of
329 select="authorTeam/titleCache"/>
330 <xsl:value-of select="datePublished/start"/>:
331 </fo:inline>
332 <xsl:text> </xsl:text>
333 <fo:inline>
334 <xsl:value-of select="../nomenclaturalMicroReference"/>
335 </fo:inline>
336 <xsl:text>)</xsl:text>
337 </xsl:template>
338
339 <!-- DESCRIPTIONS -->
340
341 <xsl:template match="descriptions" name="descriptions">
342 <xsl:for-each select="features/feature">
343 <xsl:choose>
344 <xsl:when test="count(feature)!=0">
345 <xsl:call-template name="secondLevelDescriptionElements"/>
346 </xsl:when>
347 <xsl:otherwise>
348 <!-- everything except Citation -->
349 <xsl:if test="uuid!='99b2842f-9aa7-42fa-bd5f-7285311e0101'">
350 <xsl:call-template name="descriptionElements"/>
351 </xsl:if>
352 </xsl:otherwise>
353 </xsl:choose>
354 </xsl:for-each>
355 </xsl:template>
356
357 <xsl:template name="descriptionElements">
358 <xsl:choose>
359 <xsl:when test="supportsCommonTaxonName='true'">
360 <xsl:call-template name="commonTaxonName"/>
361 </xsl:when>
362 <xsl:otherwise>
363 <xsl:call-template name="textData"/>
364 </xsl:otherwise>
365 </xsl:choose>
366 </xsl:template>
367
368 <xsl:template name="secondLevelDescriptionElements">
369 <fo:block text-align="justify" margin-bottom="5mm">
370 <xsl:for-each select="feature">
371 <fo:inline>
372 <fo:inline text-decoration="underline">
373 <xsl:value-of select="representation_L10n"/>:
374 </fo:inline>
375 <xsl:for-each select="descriptionelements/descriptionelement">
376 <fo:inline>
377 <xsl:value-of
378 select="multilanguageText_L10n/text"/>
379 </fo:inline>
380 </xsl:for-each>
381 <xsl:text> </xsl:text>
382 </fo:inline>
383 </xsl:for-each>
384 </fo:block>
385 </xsl:template>
386
387 <xsl:template name="commonTaxonName">
388 <fo:inline font-weight="bold">
389 <xsl:value-of select="representation_L10n"/>
390 </fo:inline>
391 <xsl:text> – </xsl:text>
392 <xsl:for-each select="descriptionelements/descriptionelement">
393 <fo:inline>
394 <xsl:value-of select="name"/> (<xsl:value-of
395 select="language/representation_L10n"/>), </fo:inline>
396 </xsl:for-each>
397 </xsl:template>
398
399 <xsl:template name="textData">
400 <fo:block text-align="justify" margin-bottom="5mm">
401 <!-- show all feature headlines except "ditribution" -->
402 <xsl:if test="uuid!='9fc9d10c-ba50-49ee-b174-ce83fc3f80c6'">
403 <fo:inline font-weight="bold">
404 <xsl:value-of select="representation_L10n"/>
405 </fo:inline>
406 <xsl:text> – </xsl:text>
407 </xsl:if>
408 <xsl:for-each select="descriptionelements/descriptionelement">
409 <fo:inline>
410 <xsl:apply-templates select="multilanguageText_L10n/text"/>
411 </fo:inline>
412 </xsl:for-each>
413 </fo:block>
414 </xsl:template>
415
416
417 <!-- SYNONYMY BLOCK -->
418
419 <xsl:template match="synonymy" name="synonymy">
420 <fo:block margin-bottom="5mm" line-height="{$taxon-name-line-height}" font-size="{$taxon-name-size-font}">
421 <fo:block text-align="justify"
422 text-indent="-{$taxon-name-indentation}" start-indent="{$taxon-name-indentation}">
423 <xsl:apply-templates select="../name"/>
424 <!--xsl:call-template name="citations"/-->
425 <xsl:text>.</xsl:text>
426 <xsl:apply-templates select="homotypicSynonymsByHomotypicGroup"/>
427 <xsl:apply-templates select="../name/typeDesignations"/>
428 </fo:block>
429 <xsl:apply-templates select="heterotypicSynonymyGroups"/>
430 </fo:block>
431 </xsl:template>
432
433 <xsl:template match="homotypicSynonymsByHomotypicGroup">
434 <xsl:for-each select="e">
435 <xsl:text> - </xsl:text>
436 <xsl:apply-templates select="name"/>
437 </xsl:for-each>
438 </xsl:template>
439
440 <xsl:template match="heterotypicSynonymyGroups">
441 <xsl:for-each select="e">
442 <fo:block text-align="start"
443 text-indent="-{$taxon-name-indentation}" start-indent="{$taxon-name-indentation}">
444 <xsl:for-each select="e">
445 <xsl:apply-templates select="name"/>
446 </xsl:for-each>
447 <xsl:apply-templates select="e[1]/name/typeDesignations" />
448 </fo:block>
449 </xsl:for-each>
450 </xsl:template>
451
452 <xsl:template name="citations">
453 <xsl:for-each
454 select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements/descriptionelement">
455 <!-- TODO sorting only works for the first citation, implement correctly -->
456 <xsl:sort select="sources/e[1]/citation/datePublished/start"/>
457 <xsl:for-each select="sources/e">
458 <xsl:if test="true">
459 <xsl:text>; </xsl:text>
460 <fo:inline>
461 <xsl:value-of select="citation/authorTeam/titleCache"/>
462 <xsl:text> (</xsl:text>
463 <xsl:value-of select="citation/datePublished/start"/>
464 <xsl:text>: </xsl:text>
465 <xsl:value-of select="citationMicroReference"/>
466 <xsl:text>)</xsl:text>
467 </fo:inline>
468 </xsl:if>
469 </xsl:for-each>
470 </xsl:for-each>
471 </xsl:template>
472
473 <xsl:template match="typeDesignations">
474 <xsl:for-each select="child::*">
475 <fo:inline>
476 <xsl:text> - Type: </xsl:text>
477 <xsl:choose>
478 <xsl:when test="class='SpecimenTypeDesignation'">
479 <xsl:value-of select="typeSpecimen/titleCache"/>
480 </xsl:when>
481 </xsl:choose>
482 </fo:inline>
483 </xsl:for-each>
484 </xsl:template>
485
486 </xsl:stylesheet>