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