merge trunk to 3.3
[cdmlib.git] / cdmlib-print / src / main / resources / stylesheets / pdf / flore-afrique-centrale.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE xsl:stylesheet [<!ENTITY mdash "&#x2014;" > <!ENTITY ndash "&#x2013;" > <!ENTITY ndash "&#x2715;" >]>
3
4 <!--
5
6 CDM XSL Transformation
7 Target Format: Flore d'Afrique Centrale
8
9 -->
10 <xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="http://exslt.org/common"
11 xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
12
13 <xsl:param name="abstract"/>
14 <xsl:param name="title"/>
15
16
17 <!-- ############### Constants and definitions ################### -->
18
19 <!-- **********************************
20 ** global definitions
21 *********************************** -->
22 <xsl:param name="global-family-font">Times</xsl:param>
23 <xsl:param name="global-size-font">10pt</xsl:param>
24 <xsl:param name="global-title-font">10pt</xsl:param>
25 <xsl:param name="global-line-height">12pt</xsl:param>
26
27 <xsl:param name="global-width-page">159mm</xsl:param>
28 <xsl:param name="global-height-page">244mm</xsl:param>
29
30 <xsl:param name="global-indentation">0mm</xsl:param>
31
32 <!-- **********************************
33 ** definitions for taxon pages
34 *********************************** -->
35 <xsl:param name="taxon-first-page-top-margin">66mm</xsl:param>
36 <xsl:param name="taxon-page-top-margin">32mm</xsl:param>
37 <xsl:param name="taxon-page-inner-margin">21mm</xsl:param>
38 <xsl:param name="taxon-page-bottom-margin">32mm</xsl:param>
39 <xsl:param name="graphic-height">150mm</xsl:param>
40
41 <xsl:param name="taxon-region-body-outer-margin">24mm</xsl:param>
42
43 <xsl:param name="taxon-region-before-extent">0mm</xsl:param>
44 <xsl:param name="taxon-region-after-extent">0mm</xsl:param>
45
46 <xsl:param name="content-bg-color">white</xsl:param>
47 <xsl:param name="taxon-header-family-font">Times</xsl:param>
48 <xsl:param name="taxon-header-before-bg-color">white</xsl:param>
49 <xsl:param name="taxon-header-after-bg-color">white</xsl:param>
50 <xsl:param name="taxon-header-size-font">7pt</xsl:param>
51
52 <xsl:param name="distribution-size-font">8pt</xsl:param>
53
54 <xsl:param name="taxon-name-indentation">4mm</xsl:param>
55 <xsl:param name="taxon-name-size-font">8pt</xsl:param>
56 <xsl:param name="taxon-name-line-height">9.6pt</xsl:param>
57
58 <xsl:param name="taxon-header-style-font">italic</xsl:param>
59 <xsl:param name="taxon-header-page-number-size-font">10pt</xsl:param>
60 <xsl:param name="taxon-header-page-number-align-text">end</xsl:param>
61 <xsl:param name="taxon-header-page-number-margin">11mm</xsl:param>
62
63 <xsl:param name="taxon-page-number-initial">1</xsl:param>
64
65 <!-- hardcoded ranks -->
66 <xsl:param name="uuidFamily">af5f2481-3192-403f-ae65-7c957a0f02b6</xsl:param>
67 <xsl:param name="uuidGenus">1b11c34c-48a8-4efa-98d5-84f7f66ef43a</xsl:param>
68 <xsl:param name="uuidSubgenus">78786e16-2a70-48af-a608-494023b91904</xsl:param>
69
70
71 <!-- **********************************
72 ** html support
73 *********************************** -->
74
75 <!-- format html i tags in text as italic -->
76 <!--xsl:template match="i">
77 <fo:inline font-style="italic">
78 <xsl:value-of select="."/>
79 </fo:inline>
80 </xsl:template-->
81
82 <!-- format html b tags in text as bold -->
83 <xsl:template match="b">
84 <fo:inline font-weight="bold">
85 <xsl:apply-templates/>
86 </fo:inline>
87 </xsl:template>
88
89 <!-- ########################################################################## -->
90
91
92 <!-- start xsl output -->
93 <xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="no"/>
94 <xsl:param name="versionParam" select="'1.0'"/>
95
96 <!-- root element: root -->
97 <xsl:template match="root">
98 <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
99
100 <!-- defines page layout -->
101 <fo:layout-master-set>
102
103 <!-- layout for odd taxon pages -->
104 <fo:simple-page-master master-name="taxon_page_first" page-height="{$global-height-page}"
105 page-width="{$global-width-page}" margin-top="{$taxon-first-page-top-margin}"
106 margin-bottom="{$taxon-page-bottom-margin}" margin-left="{$taxon-page-inner-margin}">
107 <fo:region-body margin-right="{$taxon-region-body-outer-margin}"/>
108 <fo:region-before extent="{$taxon-region-before-extent}" region-name="odd-before"/>
109 <fo:region-after extent="{$taxon-region-after-extent}" region-name="odd-after"/>
110 </fo:simple-page-master>
111
112 <!-- layout for odd taxon pages -->
113 <fo:simple-page-master master-name="taxon_page_odd" page-height="{$global-height-page}"
114 page-width="{$global-width-page}" margin-top="{$taxon-page-top-margin}"
115 margin-bottom="{$taxon-page-bottom-margin}" margin-left="{$taxon-page-inner-margin}">
116 <fo:region-body margin-right="{$taxon-region-body-outer-margin}"/>
117 <fo:region-before extent="{$taxon-region-before-extent}" region-name="odd-before"/>
118 <fo:region-after extent="{$taxon-region-after-extent}" region-name="odd-after"/>
119 </fo:simple-page-master>
120
121 <!-- layout for even taxon pages -->
122 <fo:simple-page-master master-name="taxon_page_even" page-height="{$global-height-page}"
123 page-width="{$global-width-page}" margin-top="{$taxon-page-top-margin}"
124 margin-bottom="{$taxon-page-bottom-margin}" margin-left="0"
125 margin-right="{$taxon-page-inner-margin}">
126 <fo:region-body margin-left="{$taxon-region-body-outer-margin}"/>
127 <fo:region-before extent="{$taxon-region-before-extent}" region-name="even-before"/>
128 <fo:region-after extent="{$taxon-region-after-extent}" region-name="even-after"/>
129
130 <!--fo:leader leader-pattern="rule" leader-length="10mm"/-->
131
132 </fo:simple-page-master>
133
134
135 <!-- defines repeatable page-sequence for layout of taxa -->
136 <fo:page-sequence-master master-name="taxon_page">
137 <fo:repeatable-page-master-alternatives>
138 <fo:conditional-page-master-reference master-reference="taxon_page_first"
139 page-position="first"/>
140 <fo:conditional-page-master-reference master-reference="taxon_page_even"
141 page-position="rest" odd-or-even="even"/>
142 <fo:conditional-page-master-reference master-reference="taxon_page_odd"
143 page-position="rest" odd-or-even="odd"/>
144 <!-- <fo:conditional-page-master-reference master-reference="mclBoook_taxon_page_even"
145 page-position="last"/>-->
146 </fo:repeatable-page-master-alternatives>
147 </fo:page-sequence-master>
148 </fo:layout-master-set>
149 <!-- end: defines page layout -->
150
151 <!-- page sequence for taxon view -->
152 <fo:page-sequence master-reference="taxon_page"
153 initial-page-number="{$taxon-page-number-initial}" force-page-count="no-force">
154
155 <fo:static-content flow-name="odd-before">
156 <xsl:call-template name="right-extent"/>
157 </fo:static-content>
158
159 <fo:static-content flow-name="even-before">
160 <xsl:call-template name="left-extent"/>
161 </fo:static-content>
162
163
164
165 <!-- format taxa -->
166 <fo:flow flow-name="xsl-region-body">
167
168 <!--fo:block><xsl:value-of select="$abstract"/></fo:block-->
169
170 <fo:block font-family="{$global-family-font}" font-size="{$global-size-font}"
171 line-height="{$global-line-height}" linefeed-treatment="preserve">
172
173 <fo:block text-align="center" font-weight="bold" font-size="global-title-font" linefeed-treatment="preserve">
174 <xsl:value-of select="$title"/>
175 <xsl:text>&#xA;</xsl:text>
176 <xsl:text>&#xA;</xsl:text>
177 </fo:block>
178 <fo:block linefeed-treatment="preserve">
179 <fo:inline font-weight="bold"><xsl:text>Abstract. </xsl:text></fo:inline>
180 <xsl:value-of select="$abstract"/>
181 <xsl:text>&#xA;</xsl:text>
182 </fo:block>
183
184 <xsl:for-each select="//TaxonNode">
185 <xsl:apply-templates select="."/>
186 </xsl:for-each>
187
188 <fo:block text-align="center" text-transform="uppercase" font-weight="bold" linefeed-treatment="preserve">
189 <xsl:text>&#xA;</xsl:text>
190 <xsl:text>REFERENCES</xsl:text>
191 </fo:block>
192 <xsl:text>&#xA;</xsl:text>
193 <xsl:call-template name="References"/>
194
195 <fo:block text-align="center" font-weight="bold" linefeed-treatment="preserve">
196 <xsl:text>&#xA;</xsl:text>
197 <xsl:text>Noms scientifiques</xsl:text>
198 </fo:block>
199 <xsl:text>&#xA;</xsl:text>
200 <xsl:call-template name="scientific-name-index"/>
201 </fo:block>
202 </fo:flow>
203 </fo:page-sequence>
204 </fo:root>
205 </xsl:template>
206
207 <!-- TODO shorten this so that not repeating code for creating author in each xsl:when statement -->
208 <xsl:template name="scientific-name-index">
209 <!-- create a variable for the sorted scientific names for the index, then once sorted can select preceding to get the first occurance of
210 the genusOrUninomial in the list-->
211 <xsl:variable name="sortedcopy">
212 <xsl:for-each select="//name">
213 <xsl:sort select="genusOrUninomial" data-type="text" order="ascending"></xsl:sort>
214 <xsl:sort select="specificEpithet" data-type="text" order="ascending"></xsl:sort>
215 <xsl:copy-of select="."/>
216 </xsl:for-each>
217 </xsl:variable>
218
219 <fo:block margin-bottom="5mm" text-align="justify">
220 <xsl:for-each select="$sortedcopy/*"><!-- or select="//name/genusOrUninomial-->
221
222 <xsl:variable name="genus" select="."/>
223 <xsl:choose>
224 <!-- family -->
225 <xsl:when test="rank/uuid='af5f2481-3192-403f-ae65-7c957a0f02b6'">
226 <fo:inline font-style="italic">
227 <xsl:apply-templates select="genusOrUninomial"/>
228 </fo:inline>
229 <xsl:for-each select="taggedName/e">
230 <xsl:if test="type='authors'">
231 <xsl:text> </xsl:text>
232 <xsl:value-of select="text"/>
233 </xsl:if>
234 </xsl:for-each>
235 </xsl:when>
236 <!-- genus -->
237 <xsl:when test="rank/uuid='1b11c34c-48a8-4efa-98d5-84f7f66ef43a'">
238 <fo:block>
239 <fo:inline font-style="italic">
240 <xsl:apply-templates select="genusOrUninomial"/>
241 </fo:inline>
242 <xsl:for-each select="taggedName/e">
243 <xsl:if test="type='authors'">
244 <xsl:text> </xsl:text>
245 <xsl:value-of select="text"/>
246 </xsl:if>
247 </xsl:for-each>
248 </fo:block>
249 </xsl:when>
250 <!-- subgenus -->
251 <xsl:when test="rank/uuid='78786e16-2a70-48af-a608-494023b91904'">
252 <fo:block>
253 <xsl:apply-templates select="rank/representation_L10n"/>
254 <xsl:text> </xsl:text>
255 <fo:inline font-style="italic">
256 <xsl:apply-templates select="genusOrUninomial"/>
257 </fo:inline>
258 <xsl:for-each select="taggedName/e">
259 <xsl:if test="type='authors'">
260 <xsl:text> </xsl:text>
261 <xsl:value-of select="text"/>
262 </xsl:if>
263 </xsl:for-each>
264 </fo:block>
265 </xsl:when>
266 <!-- species -->
267 <xsl:when test="rank/uuid='b301f787-f319-4ccc-a10f-b4ed3b99a86d'">
268
269 <!--first occurance of the genusOrUninomial in the list is not indented -->
270 <xsl:choose>
271 <xsl:when test="not(preceding::genusOrUninomial[1] = genusOrUninomial)">
272 <fo:block>
273 <fo:inline font-style="italic">
274 <xsl:apply-templates select="genusOrUninomial"/>
275 <xsl:text> </xsl:text>
276 <xsl:apply-templates select="specificEpithet"/>
277 </fo:inline>
278 <xsl:text> </xsl:text>
279 <!--xsl:apply-templates select="rank/titleCache"/-->
280 <xsl:for-each select="taggedName/e">
281 <xsl:if test="type='authors'">
282 <xsl:text> </xsl:text>
283 <xsl:value-of select="text"/>
284 </xsl:if>
285 </xsl:for-each>
286
287 </fo:block>
288 </xsl:when>
289 <xsl:otherwise>
290 <fo:block text-indent="{$taxon-name-indentation}">
291 <fo:inline font-style="italic">
292 <xsl:apply-templates select="specificEpithet"/>
293 </fo:inline>
294 <xsl:text> </xsl:text>
295 <!--xsl:apply-templates select="rank/titleCache"/--><!-- for debugging -->
296 <xsl:for-each select="taggedName/e">
297 <xsl:if test="type='authors'">
298 <xsl:text> </xsl:text>
299 <xsl:value-of select="text"/>
300 </xsl:if>
301 </xsl:for-each>
302 </fo:block>
303 </xsl:otherwise>
304 </xsl:choose>
305
306
307 </xsl:when>
308 <!-- variant d5feb6a5-af5c-45ef-9878-bb4f36aaf490-->
309 <xsl:when test="rank/uuid='d5feb6a5-af5c-45ef-9878-bb4f36aaf490'">
310 <fo:block text-indent="{$taxon-name-indentation}">
311 <xsl:text>&ndash; </xsl:text> <!--concat ndash-->
312 <xsl:apply-templates select="rank/representation_L10n_abbreviatedLabel"/>
313 <xsl:text> </xsl:text>
314 <fo:inline font-style="italic">
315 <xsl:apply-templates select="specificEpithet"/>
316 </fo:inline>
317
318 <xsl:for-each select="taggedName/e">
319 <xsl:if test="type='authors'">
320 <xsl:text> </xsl:text>
321 <xsl:value-of select="text"/>
322 </xsl:if>
323 </xsl:for-each>
324 </fo:block>
325 </xsl:when>
326 <!-- sub-species 462a7819-8b00-4190-8313-88b5be81fad5-->
327 <xsl:when test="rank/uuid='462a7819-8b00-4190-8313-88b5be81fad5'">
328 <fo:block text-indent="{$taxon-name-indentation}">
329 <!--xsl:apply-templates select="specificEpithet"/--><!--remove - just for testing -->
330 <xsl:text>- </xsl:text>
331 <xsl:apply-templates select="rank/representation_L10n_abbreviatedLabel"/>
332 <xsl:text> </xsl:text>
333 <fo:inline font-style="italic">
334 <xsl:apply-templates select="infraSpecificEpithet"/>
335 </fo:inline>
336 <!--xsl:variable name="full-name">
337 <xsl:apply-templates select="../taggedName"/> we only want to add the authors from taggedName if taggedName/e/type='author' select text
338 </xsl:variable-->
339 <!--fo:inline font-style="bold">
340 <xsl:apply-templates select="$full-name"></xsl:apply-templates>
341 </fo:inline-->
342 <!--xsl:apply-templates select="substring-after(' ', $full-name)"></xsl:apply-templates-->
343 <!--xsl:call-template name="dispay-author-name">
344 <xsl:with-param name="e" select="../taggedName/e"/>
345 </xsl:call-template-->
346 <xsl:for-each select="taggedName/e">
347 <xsl:if test="type='authors'">
348 <xsl:text> </xsl:text>
349 <xsl:value-of select="text"/>
350 </xsl:if>
351 </xsl:for-each>
352 </fo:block>
353 </xsl:when>
354 <!--xsl:otherwise-->
355 <!-- for debugging LORNA DEBUGGING XSLT CHOOSE: <xsl:value-of
356 select="../rank/uuid"/>: <xsl:value-of select="../titleCache"/>
357 </xsl:otherwise!-->
358 </xsl:choose>
359 </xsl:for-each>
360 </fo:block>
361 </xsl:template>
362
363
364 <xsl:template name="dispay-author-name"> <!-- call this template with node e - don't display uninomial for species -->
365 <xsl:param name="e"/>
366 <xsl:if test="$e/type='authors'">
367 <xsl:text>++++++</xsl:text>
368 <xsl:value-of select="$e/text"/>
369 </xsl:if>
370 </xsl:template>
371
372 <!-- HEADER -->
373
374 <xsl:template name="right-extent">
375 <!--fo:block text-align="center">Page <fo:page-number/>
376 </fo:block-->
377 <fo:block font-family="{$taxon-header-family-font}" font-style="{$taxon-header-style-font}"
378 font-size="{$taxon-header-size-font}">
379 <!-- No pagination at the moment -->
380 <fo:block font-size="{$taxon-header-page-number-size-font}" font-style="normal"
381 padding-top="95%" text-align="end">| <fo:page-number padding-right="10%"
382 border-right-width="11mm"/></fo:block>
383 <!--text-align="{$taxon-header-page-number-align-text}"> | <fo:page-number/></fo:block> -->
384 <!--margin-right="{$taxon-region-body-outer-margin}" -->
385 <!-- &#x2014; -->
386 <fo:block color="white">-</fo:block>
387 <fo:block>
388 <fo:retrieve-marker retrieve-class-name="pageTitleMarker"
389 retrieve-position="first-starting-within-page" retrieve-boundary="document"/>
390 <xsl:text> </xsl:text>
391 <fo:retrieve-marker retrieve-class-name="pageTitleSectionMarker"
392 retrieve-position="first-starting-within-page" retrieve-boundary="document"/>
393 </fo:block>
394 </fo:block>
395 </xsl:template>
396
397 <xsl:template name="left-extent">
398 <fo:block font-family="{$taxon-header-family-font}" font-style="{$taxon-header-style-font}"
399 font-size="{$taxon-header-size-font}">
400 <fo:block font-size="{$taxon-header-page-number-size-font}" font-style="normal"
401 padding-top="95%" text-align="start"><fo:page-number padding-left="10%"
402 border-right-width="11mm"/> |</fo:block>
403 <!-- No pagination at the moment
404 <fo:block font-size="{$taxon-header-page-number-size-font}"
405 text-align="{$taxon-header-page-number-align-text}"> &#x2014; <fo:page-number/> &#x2014;
406 </fo:block> -->
407 </fo:block>
408 </xsl:template>
409
410 <!--xsl:template name="odd-after-header">
411 <fo:block font-family="{$taxon-header-family-font}" font-style="{$taxon-header-style-font}"
412 font-size="{$taxon-header-size-font}">
413 <fo:block>
414 <fo:inline>
415 <fo:retrieve-marker retrieve-class-name="pageTitleMarker"
416 retrieve-position="last-starting-within-page" retrieve-boundary="document"/>
417 <fo:retrieve-marker retrieve-class-name="pageTitleSectionMarker"
418 retrieve-position="last-starting-within-page" retrieve-boundary="document"/>
419 </fo:inline>
420 </fo:block>
421 </fo:block>
422 </xsl:template-->
423
424
425 <!--xsl:template name="even-before-header">
426 <fo:block font-family="{$taxon-header-family-font}" font-style="{$taxon-header-style-font}"
427 font-size="{$taxon-header-size-font}"-->
428 <!--
429 No pagination at the moment
430 <fo:block color="white" font-size="{$taxon-header-page-number-size-font}">-</fo:block>
431 <fo:block color="white">-</fo:block>-->
432 <!--
433 <fo:block>
434 <fo:inline>
435 <fo:retrieve-marker retrieve-class-name="pageTitleMarker"
436 retrieve-position="first-starting-within-page" retrieve-boundary="document"/>
437 <fo:retrieve-marker retrieve-class-name="pageTitleSectionMarker"
438 retrieve-position="first-starting-within-page" retrieve-boundary="document"/>
439 </fo:inline>
440 </fo:block>
441 </fo:block>
442
443 </xsl:template-->
444
445 <xsl:template name="even-after-header">
446 <fo:block font-family="{$taxon-header-family-font}" font-style="{$taxon-header-style-font}"
447 font-size="{$taxon-header-size-font}">
448 <fo:block>
449 <fo:inline>
450 <fo:retrieve-marker retrieve-class-name="pageTitleMarker"
451 retrieve-position="last-starting-within-page" retrieve-boundary="document"/>
452 <fo:retrieve-marker retrieve-class-name="pageTitleSectionMarker"
453 retrieve-position="last-starting-within-page" retrieve-boundary="document"/>
454 </fo:inline>
455 </fo:block>
456 <!-- No pagination at the moment
457 <fo:block color="white">-</fo:block>
458 <fo:block font-size="{$taxon-header-page-number-size-font}"
459 text-align="{$taxon-header-page-number-align-text}"> &#x2014; <fo:page-number/> &#x2014;
460 </fo:block> -->
461 </fo:block>
462 </xsl:template>
463
464 <!-- GENERAL -->
465
466 <xsl:template match="TaxonNode" name="TaxonNode">
467 <xsl:apply-templates select="Taxon"/>
468 </xsl:template>
469
470 <xsl:template match="Taxon" name="Taxon">
471 <xsl:call-template name="title"/>
472 <xsl:apply-templates select="synonymy"/>
473 <xsl:apply-templates select="descriptions"/>
474 <xsl:apply-templates select="key"/>
475 </xsl:template>
476
477
478 <xsl:template name="title">
479 <fo:block margin-bottom="5mm">
480 <!-- we need to find a way to store the uuid in a variable xsl:parameter did not work or i was using it wrong -->
481 <xsl:choose>
482 <!-- family -->
483 <xsl:when test="name/rank/uuid='af5f2481-3192-403f-ae65-7c957a0f02b6'">
484 <fo:block font-weight="bold" text-align="center" text-transform="uppercase">
485 <xsl:apply-templates select="name/genusOrUninomial"/>
486 <xsl:text> FAMILY</xsl:text>
487 </fo:block>
488 </xsl:when>
489 <!-- genus -->
490 <xsl:when test="name/rank/uuid='1b11c34c-48a8-4efa-98d5-84f7f66ef43a'">
491 <fo:block font-weight="bold" text-align="center" text-transform="uppercase">
492 <xsl:apply-templates select="name/genusOrUninomial"/>
493 </fo:block>
494 </xsl:when>
495 <!-- subgenus -->
496 <xsl:when test="name/rank/uuid='78786e16-2a70-48af-a608-494023b91904'">
497 <fo:block font-weight="bold" text-align="center">
498 <xsl:apply-templates select="name/rank/representation_L10n"/>
499 <xsl:text> </xsl:text>
500 <xsl:apply-templates select="name/genusOrUninomial"/>
501 </fo:block>
502 </xsl:when>
503 <!-- species -->
504 <xsl:when test="name/rank/uuid='b301f787-f319-4ccc-a10f-b4ed3b99a86d'">
505 <fo:block font-weight="bold" text-align="center">
506 <xsl:apply-templates select="name/genusOrUninomial"/>
507 <xsl:text> </xsl:text>
508 <xsl:apply-templates select="name/specificEpithet"/>
509 </fo:block>
510 </xsl:when>
511 <xsl:otherwise>
512 <!-- for debugging --> Unformatted title for rank uuid: <xsl:value-of
513 select="name/rank/uuid"/>: <xsl:value-of select="name/titleCache"/>
514 </xsl:otherwise>
515 </xsl:choose>
516 </fo:block>
517 </xsl:template>
518
519 <!-- NAME -->
520
521 <xsl:template match="name">
522 <xsl:apply-templates select="taggedName"/>
523 <xsl:apply-templates select="nomenclaturalReference"/>
524 </xsl:template>
525
526 <xsl:template match="taggedName">
527 <xsl:for-each select="e">
528 <xsl:choose>
529 <xsl:when test="type='name'">
530 <fo:inline font-style="italic">
531 <xsl:value-of select="text"/>
532 </fo:inline>
533 <xsl:text> </xsl:text>
534 </xsl:when>
535 <xsl:when test="type='authors'">
536 <xsl:value-of select="text"/>
537 </xsl:when>
538 <xsl:otherwise>
539 <xsl:value-of select="text"/>
540 <xsl:text> </xsl:text>
541 </xsl:otherwise>
542 </xsl:choose>
543 </xsl:for-each>
544 </xsl:template>
545
546
547 <!-- first date in brackets -->
548 <xsl:template match="nomenclaturalReference">
549 <xsl:text> (</xsl:text>
550 <fo:inline>
551 <xsl:value-of select="authorTeam/titleCache"/>
552 <xsl:text> </xsl:text>
553 <xsl:value-of select="datePublished/start"/>: </fo:inline>
554 <xsl:text> </xsl:text>
555 <fo:inline>
556 <xsl:value-of select="../nomenclaturalMicroReference"/>
557 </fo:inline>
558 <xsl:text>)</xsl:text>
559 </xsl:template>
560
561 <!-- DESCRIPTIONS -->
562
563 <xsl:template match="descriptions" name="descriptions">
564 <xsl:for-each select="features/feature">
565 <xsl:choose>
566 <xsl:when test="count(feature)!=0">
567 <xsl:call-template name="secondLevelDescriptionElements"/>
568 </xsl:when>
569 <xsl:otherwise>
570 <!-- everything except Citation -->
571 <xsl:if test="uuid!='99b2842f-9aa7-42fa-bd5f-7285311e0101'">
572 <xsl:call-template name="descriptionElements"/>
573 </xsl:if>
574 <!--xsl:apply-templates select="media/e/representations/e/parts/e/uri"/-->
575 </xsl:otherwise>
576 </xsl:choose>
577 </xsl:for-each>
578 </xsl:template>
579
580 <xsl:template name="descriptionElements">
581 <xsl:choose>
582 <xsl:when test="supportsCommonTaxonName='true'">
583 <!-- for example Vernacular Name -->
584 <xsl:call-template name="commonTaxonName"/>
585 </xsl:when>
586 <xsl:otherwise>
587 <!-- for example Habitat, Material Examined -->
588 <xsl:call-template name="textData"/>
589 </xsl:otherwise>
590 </xsl:choose>
591 </xsl:template>
592
593 <xsl:template name="secondLevelDescriptionElements">
594 <fo:block text-align="justify" margin-bottom="5mm">
595 <!--fo:external-graphic src='http://lully.snv.jussieu.fr/xper2AppletThumbnailsMaker/sdd/images/ant_anatomy2.jpg'/-->
596 <xsl:for-each select="feature">
597
598 <xsl:variable name="representation" select="representation_L10n"/>
599 <xsl:if test="not(starts-with($representation, 'Material'))">
600 <!--xsl:if test="not(starts-with($representation, 'Figures'))"-->
601 <fo:inline keep-with-next.within-line="always">
602
603 <xsl:if test="not(starts-with($representation, 'Figures'))">
604 <!-- The headings are in English - do we want to remove them altogether or have French headings -->
605 <!--fo:inline text-decoration="underline" keep-with-next.within-line="always">
606
607 <xsl:value-of select="representation_L10n"/>
608 </fo:inline>
609 <fo:inline>: </fo:inline-->
610 </xsl:if>
611
612 <xsl:for-each select="descriptionelements/descriptionelement">
613
614 <xsl:variable name="desc_element_text" select="multilanguageText_L10n/text"/>
615
616 <!-- filter out repeated description element text. Lorna - could do this in the CDM so it doesn't occur in the XML but not sure why it's happening-->
617 <xsl:variable name="prev_desc_element_text"
618 select="preceding-sibling::descriptionelement[1]/multilanguageText_L10n/text"/>
619
620 <fo:inline font-size="9pt" space-after="5mm">
621
622 <xsl:if test="not(starts-with($desc_element_text, 'Figure'))">
623
624 <xsl:choose>
625 <xsl:when test="position() = 1">
626 <xsl:apply-templates select="multilanguageText_L10n/text"/>
627 </xsl:when>
628 <xsl:otherwise>
629 <xsl:if test="$desc_element_text != $prev_desc_element_text">
630 <!-- checked in the tax editor and looks like only descriptionelement[1] refers to the species so don't need below-->
631 <!--xsl:apply-templates select="multilanguageText_L10n/text"/-->
632 </xsl:if>
633 </xsl:otherwise>
634 </xsl:choose>
635
636 </xsl:if>
637
638 </fo:inline>
639
640 <!--xsl:apply-templates select="multilanguageText_L10n/text"/-->
641 <!--xsl:apply-templates select="media"/-->
642
643 <!--TODO Lorna we need to work out which description element contains the uri node for each figure
644 and place it next to the appropriate taxon in the output-->
645
646 <!--xsl:if test="not(starts-with($representation, 'Figures'))"-->
647 <!--xsl:if test="position() = 1"-->
648 <!--xsl:value-of select="../../../../../../Taxon/name/titleCache"/-->
649
650 <!-- if it has the title map don't show it in the image section -->
651
652 <xsl:if test="not(starts-with(media/e/title_L10n,'Map'))">
653 <xsl:apply-templates select="media/e/representations/e/parts/e/uri"/>
654 </xsl:if>
655
656
657
658
659 <!--xsl:call-template name="uri">
660 <xsl:with-param name="uri-node" select="media/e/representations/e/parts/e/uri"/>
661 </xsl:call-template-->
662 <!--/xsl:if-->
663 <!--xsl:apply-templates select="e[1]/name[1]/homotypicalGroup[1]/typifiedNames[1]/e/taxonBases[1]/e/descriptions[1]/e/elements[1]/e[1]/media[1]/e/representations[1]/e/parts[1]/e/uri"></xsl:apply-templates-->
664
665 </xsl:for-each>
666
667 <xsl:text> </xsl:text>
668 </fo:inline>
669 </xsl:if>
670 <!--/xsl:if-->
671 </xsl:for-each>
672
673 </fo:block>
674
675 </xsl:template>
676
677 <!-- IMAGES -->
678
679 <xsl:template match="uri">
680 <!--xsl:template name="uri"-->
681
682 <xsl:param name="uri-node"/>
683 <xsl:variable name="graphic" select="."/>
684 <xsl:variable name="title" select="../../../../../title_L10n"/>
685 <!--fo:block text-align="center"-->
686 <fo:block keep-together.within-page="always">
687
688 <!--xsl:variable name="graphic" select="e/representations/e/parts/e/uri"/-->
689
690 <!-- Is there a description element of type Figure for this TaxonNode?-->
691
692 <xsl:choose>
693 <!--xsl:when test="contains($graphic,'jpg')"-->
694 <!-- this is temporary to include the Maps as images for Quentin, in the longer term we'll generate the maps using the web service-->
695 <xsl:when test="starts-with($title,'Map')">
696 <fo:block keep-with-next="always" text-align="center">
697
698 <!--fo:inline text-align="center"-->
699 <fo:external-graphic content-height="scale-to-fit" height="50mm"
700 scaling="uniform" src="{$graphic}" padding-before="30" padding-after="2"
701 display-align="center"/>
702 <!--/fo:inline-->
703 </fo:block>
704 </xsl:when>
705 <xsl:otherwise>
706
707 <fo:block keep-with-next="always" text-align="center">
708
709 <!--fo:inline text-align="center"-->
710 <fo:external-graphic content-height="scale-to-fit" height="{$graphic-height}"
711 scaling="uniform" src="{$graphic}" padding-before="30" padding-after="2"
712 display-align="center"/>
713 <!--/fo:inline-->
714 </fo:block>
715 <fo:block>
716 <fo:leader leader-pattern="rule" leader-alignment="{$taxon-page-inner-margin}"
717 rule-thickness="0.8pt" leader-length="114mm"/>
718
719 </fo:block>
720 </xsl:otherwise>
721 </xsl:choose>
722
723 <!--fo:block-->
724
725 <!--fo:leader leader-pattern="rule" leader-length="120mm"/-->
726 <fo:inline font-size="{$taxon-name-size-font}">
727 <!--go back up to the description element and get the text for the Figure legend -->
728 <xsl:apply-templates select="../../../../../../../multilanguageText_L10n/text"/>
729 </fo:inline>
730 </fo:block>
731 </xsl:template>
732
733
734 <xsl:template match="text">
735 <!--fo:block font-size="9pt" space-after="5mm" -->
736 <!--xsl:apply-templates select="node()"/-->
737 <!--xsl:call-template name="add-markup">
738 <xsl:with-param name="str" select="."/>
739
740 <xsl:with-param name="tag-name" select="b"/>
741 </xsl:call-template-->
742 <xsl:choose>
743 <xsl:when test="contains(.,&quot;&lt;b&gt;&quot;)">
744 <xsl:call-template name="add-markup">
745 <xsl:with-param name="str" select="."/>
746 <!--xsl:with-param name="tag-name" select="b"/-->
747 <xsl:with-param name="tag-name">b</xsl:with-param>
748 </xsl:call-template>
749 </xsl:when>
750 <xsl:otherwise>
751 <xsl:call-template name="add-markup">
752 <xsl:with-param name="str" select="."/>
753 <xsl:with-param name="tag-name">i</xsl:with-param>
754 </xsl:call-template>
755 </xsl:otherwise>
756 </xsl:choose>
757
758 <!--/fo:block -->
759 </xsl:template>
760
761 <!-- TODO Can this template be made shorter by less nesting in the xsl:choose statements -->
762 <xsl:template name="add-markup">
763 <xsl:param name="str"/>
764 <xsl:param name="tag-name"/>
765
766 <xsl:variable name="opening-tag">
767 <xsl:value-of select="concat('&lt;', $tag-name, '&gt;')"> </xsl:value-of>
768 </xsl:variable>
769 <xsl:variable name="closing-tag">
770 <xsl:value-of select="concat('&lt;/', $tag-name, '&gt;')"> </xsl:value-of>
771 </xsl:variable>
772 <xsl:variable name="before-tag" select="substring-before($str, $opening-tag)"/>
773
774 <xsl:choose>
775 <xsl:when test="contains($str, $opening-tag)">
776 <!--xsl:variable name="before-tag" select="substring-before($str, $opening-tag)"/-->
777 <xsl:variable name="inside-tag"
778 select="substring-before(substring-after($str,$opening-tag),$closing-tag)"/>
779 <xsl:variable name="after-tag" select="substring-after($str, $closing-tag)"/>
780 <xsl:choose>
781 <xsl:when test="contains($before-tag, '#x2014;')">
782 <xsl:call-template name="replace-string">
783 <xsl:with-param name="text" select="$before-tag"/>
784 <xsl:with-param name="replace" select="'&amp;#x2014;'" />
785 <xsl:with-param name="with" select="'&mdash;'"/>
786 </xsl:call-template>
787 </xsl:when>
788 <xsl:otherwise>
789 <xsl:choose>
790 <xsl:when test="contains($before-tag, '#x2013;')">
791 <xsl:call-template name="replace-string">
792 <xsl:with-param name="text" select="$before-tag"/>
793 <xsl:with-param name="replace" select="'&amp;#x2013;'" />
794 <xsl:with-param name="with" select="'&ndash;'"/>
795 </xsl:call-template>
796 </xsl:when>
797 <xsl:otherwise>
798 <xsl:choose>
799 <xsl:when test="contains($str, '#x2716;')">
800 <xsl:call-template name="replace-string">
801 <xsl:with-param name="text" select="$before-tag"/>
802 <xsl:with-param name="replace" select="'&amp;#x2715;'" />
803 <xsl:with-param name="with" select="'&ndash;'"/>
804 </xsl:call-template>
805 </xsl:when>
806 <xsl:otherwise>
807 <xsl:value-of select="$before-tag"/>
808 </xsl:otherwise>
809 </xsl:choose>
810 </xsl:otherwise>
811 </xsl:choose>
812 </xsl:otherwise>
813 </xsl:choose>
814 <!-- add BOLD or italics when inside the appropriate tags -->
815 <xsl:choose>
816 <xsl:when test="$tag-name = 'b'">
817 <fo:inline font-weight="bold">
818 <xsl:value-of select="$inside-tag"/>
819 </fo:inline>
820 </xsl:when>
821 <xsl:otherwise>
822 <fo:inline font-style="italic">
823 <xsl:value-of select="$inside-tag"/>
824 </fo:inline>
825 </xsl:otherwise>
826 </xsl:choose>
827 <!-- call template recursively with the remaining text after the tag -->
828 <xsl:call-template name="add-markup">
829 <xsl:with-param name="str" select="$after-tag"/>
830 <xsl:with-param name="tag-name" select="$tag-name"/>
831 </xsl:call-template>
832 </xsl:when>
833 <xsl:otherwise>
834 <xsl:choose>
835 <xsl:when test="contains($str, '#x2014;')">
836 <xsl:call-template name="replace-string">
837 <xsl:with-param name="text" select="$before-tag"/>
838 <xsl:with-param name="replace" select="'&amp;#x2014;'" />
839 <xsl:with-param name="with" select="'&mdash;'"/>
840 </xsl:call-template>
841 </xsl:when>
842 <xsl:otherwise>
843 <xsl:choose>
844 <xsl:when test="contains($str, '#x2013;')">
845 <xsl:call-template name="replace-string">
846 <xsl:with-param name="text" select="$before-tag"/>
847 <xsl:with-param name="replace" select="'&amp;#x2013;'" />
848 <xsl:with-param name="with" select="'&ndash;'"/>
849 </xsl:call-template>
850 </xsl:when>
851 <xsl:otherwise>
852 <xsl:choose>
853 <xsl:when test="contains($str, '#x2716;')">
854 <xsl:call-template name="replace-string">
855 <xsl:with-param name="text" select="$before-tag"/>
856 <xsl:with-param name="replace" select="'&amp;#x2715;'" />
857 <xsl:with-param name="with" select="'&ndash;'"/>
858 </xsl:call-template>
859 </xsl:when>
860 <xsl:otherwise>
861 <xsl:value-of select="$str"/>
862 </xsl:otherwise>
863 </xsl:choose>
864 </xsl:otherwise>
865 </xsl:choose>
866 </xsl:otherwise>
867 </xsl:choose>
868 </xsl:otherwise>
869 </xsl:choose>
870 </xsl:template>
871
872 <xsl:template name="replace-string">
873 <xsl:param name="text"/>
874 <xsl:param name="replace"/>
875 <xsl:param name="with"/>
876 <xsl:choose>
877 <xsl:when test="contains($text,$replace)">
878 <xsl:value-of select="substring-before($text,$replace)"/>
879 <xsl:value-of select="$with"/>
880 <xsl:call-template name="replace-string">
881 <xsl:with-param name="text"
882 select="substring-after($text,$replace)"/>
883 <xsl:with-param name="replace" select="$replace"/>
884 <xsl:with-param name="with" select="$with"/>
885 </xsl:call-template>
886 </xsl:when>
887 <xsl:otherwise>
888 <xsl:value-of select="$text"/>
889 </xsl:otherwise>
890 </xsl:choose>
891 </xsl:template>
892
893 <xsl:template name="remove_ampersands">
894 <xsl:param name="str"/>
895 <xsl:choose>
896 <xsl:when test="contains($str,&quot;amp;&quot;)"> </xsl:when>
897 </xsl:choose>
898 </xsl:template>
899
900 <xsl:template name="remove">
901 <xsl:param name="value"/>
902 <xsl:value-of select="concat(substring-before($value, 'amp;'), substring-after($value, 'amp;'))"
903 />
904 </xsl:template>
905
906 <!--xsl:template match="i">
907 <fo:inline font-style="italic">
908 <xsl:apply-templates select="node()"/>
909 </fo:inline>
910 </xsl:template-->
911
912 <xsl:template match="i">
913 <fo:inline font-style="italic">
914 <xsl:apply-templates/>
915 </fo:inline>
916 </xsl:template>
917
918 <xsl:template match="i//text()">
919 <fo:inline font-style="italic">
920 <xsl:apply-templates/>
921 </fo:inline>
922 </xsl:template>
923
924
925 <xsl:template name="commonTaxonName">
926 <fo:inline font-weight="bold">
927 <xsl:value-of select="representation_L10n"/>
928 </fo:inline>
929 <xsl:text> &mdash; </xsl:text>
930 <xsl:for-each select="descriptionelements/descriptionelement">
931 <fo:inline>
932 <xsl:choose>
933 <xsl:when test="position() != last()">
934 <xsl:value-of select="name"/> (<xsl:value-of select="language/representation_L10n"/>), </xsl:when>
935 <xsl:otherwise>
936 <xsl:value-of select="name"/> (<xsl:value-of select="language/representation_L10n"
937 />).</xsl:otherwise>
938 </xsl:choose>
939 </fo:inline>
940 </xsl:for-each>
941 </xsl:template>
942
943 <xsl:template name="commonTaxonNameold2">
944 <fo:inline font-weight="bold">
945 <xsl:value-of select="representation_L10n"/>
946 </fo:inline>
947 <xsl:text> &mdash; </xsl:text>
948 <xsl:for-each select="descriptionelements/descriptionelement">
949 <fo:inline>
950 <xsl:value-of select="name"/> (<xsl:value-of select="language/representation_L10n"/>) <xsl:choose>
951 <xsl:when test="position() != last()">,</xsl:when>
952 <xsl:otherwise>.</xsl:otherwise>
953 </xsl:choose>
954 </fo:inline>
955 </xsl:for-each>
956 </xsl:template>
957
958 <xsl:template name="commonTaxonNameold">
959 <fo:inline font-weight="bold">
960 <xsl:value-of select="representation_L10n"/>
961 </fo:inline>
962 <xsl:text> &mdash; </xsl:text>
963 <xsl:for-each select="descriptionelements/descriptionelement">
964 <fo:inline>
965 <xsl:value-of select="name"/> (<xsl:value-of select="language/representation_L10n"/>),
966 </fo:inline>
967 </xsl:for-each>
968 </xsl:template>
969
970 <xsl:template name="textData">
971 <fo:block text-align="justify" margin-bottom="5mm">
972 <!-- show all feature headlines except "ditribution" -->
973 <!--xsl:if test="uuid!='9fc9d10c-ba50-49ee-b174-ce83fc3f80c6'">
974 <fo:inline font-weight="bold">
975 <xsl:value-of select="representation_L10n"/>
976 </fo:inline>
977 <xsl:text> – </xsl:text>
978 </xsl:if-->
979 <xsl:choose>
980 <!-- 9fc9d10c-ba50-49ee-b174-ce83fc3f80c6 is Distribution -->
981 <xsl:when test="uuid!='9fc9d10c-ba50-49ee-b174-ce83fc3f80c6'">
982 <fo:inline font-weight="bold">
983 <xsl:value-of select="representation_L10n"/>
984 <!-- e.g. Habitat -->
985 </fo:inline>
986 <xsl:text> &mdash; </xsl:text>
987 </xsl:when>
988 <xsl:otherwise>
989 <fo:inline font-weight="bold" keep-with-next="always">
990 <xsl:text> Matériel examiné </xsl:text>
991 <xsl:text>&#xA;</xsl:text>
992 </fo:inline>
993 </xsl:otherwise>
994
995 </xsl:choose>
996 <!--xsl:for-each select="descriptionelements/descriptionelement">
997 <fo:inline>
998 <xsl:text>LINE 609</xsl:text>
999 <xsl:apply-templates select="multilanguageText_L10n/text"/>
1000 </fo:inline>
1001 </xsl:for-each-->
1002
1003 <!-- LORNA TRY IMAGE HERE -->
1004 <!--xsl:apply-templates select="descriptionelements/descriptionelement[1]/media/e/representations/e/parts/e/uri"/-->
1005
1006 <xsl:apply-templates
1007 select="descriptionelements/descriptionelement[1]/multilanguageText_L10n/text"/>
1008
1009 <!-- get the map associated with the distribution, this is temporarily stored as a media object jpg created by
1010 Quentin's GIS software -->
1011 <xsl:if test="uuid='9fc9d10c-ba50-49ee-b174-ce83fc3f80c6'">
1012
1013 <!-- get the map attached to the feature 'Figures' - temporary solution - we will generatee the map using the web service-->
1014 <xsl:if test="starts-with(../feature/feature/representation_L10n[.='Figures']/../descriptionelements/descriptionelement[1]/media/e/title_L10n,'Map')">
1015 <xsl:apply-templates select="../feature/feature/representation_L10n[.='Figures']/../descriptionelements/descriptionelement[1]/media/e/representations/e/parts/e/uri"/>
1016 </xsl:if>
1017
1018 </xsl:if>
1019
1020 </fo:block>
1021 </xsl:template>
1022
1023 <xsl:template match="key" name="key">
1024 <!--fo:block margin-bottom="5mm" line-height="{$taxon-name-line-height}" font-size="{$taxon-name-size-font}"-->
1025 <fo:block linefeed-treatment="preserve">
1026
1027 <fo:block font-weight="bold" text-align="center">
1028 <xsl:value-of select="HashMap/titleCache"/>
1029 </fo:block>
1030 <xsl:if test="HashMap/records/e">
1031 <xsl:text>&#xA;</xsl:text>
1032 <fo:table>
1033 <fo:table-column column-width="5mm"/>
1034 <fo:table-column column-width="5mm"/>
1035 <fo:table-column column-width="69mm"/>
1036 <fo:table-column column-width="36mm"/>
1037 <fo:table-body>
1038 <!--xsl:if test="ArrayList/e"-->
1039 <xsl:for-each select="HashMap/records/e">
1040
1041 <!-- TaxonLinkDto or PolytomousKeyNodeLinkDto-->
1042 <fo:table-row>
1043 <fo:table-cell>
1044 <fo:block>
1045 <xsl:if test="edgeNumber = 1">
1046 <xsl:value-of select="nodeNumber"/>
1047 <xsl:text>.</xsl:text>
1048 </xsl:if>
1049 </fo:block>
1050 </fo:table-cell>
1051 <fo:table-cell>
1052 <fo:block>&ndash;</fo:block>
1053 </fo:table-cell>
1054 <fo:table-cell>
1055 <!--fo:block>
1056 <xsl:apply-templates select="childStatement"/-->
1057 <!--xsl:value-of select="concat(childStatement, '..............')"/-->
1058 <!--xsl:text>.......................................................................................</xsl:text>
1059 </fo:block-->
1060 <fo:block text-align="justify" text-align-last="justify">
1061 <!-- leader-length="auto"-->
1062 <xsl:value-of select="childStatement"/>
1063 <xsl:text> </xsl:text>
1064 <fo:leader leader-pattern="dots"/>
1065 </fo:block>
1066
1067 </fo:table-cell>
1068 <fo:table-cell display-align="after">
1069 <fo:block font-style="italic" text-align="justify" text-align-last="justify">
1070 <!-- leader-length="auto" text-align="right"-->
1071 <fo:leader leader-pattern="dots"/>
1072 <xsl:choose>
1073 <xsl:when test="links/e[1]/class = 'PolytomousKeyNodeLinkDto'">
1074 <xsl:value-of select="links/e[1]/nodeNumber"/>
1075 </xsl:when>
1076 <xsl:when test="links/e[1]/class = 'TaxonLinkDto'">
1077 <xsl:variable name="taxonUuid" select="links/e[1]/uuid"/>
1078 <xsl:variable name="genus"
1079 select="//Taxon/uuid[.=$taxonUuid]/../name/genusOrUninomial"/>
1080 <xsl:choose>
1081 <xsl:when test="taxonUuid = $uuidSubgenus">
1082 <xsl:variable name="repr"
1083 select="//Taxon/uuid[.='71cd0e8d-47eb-4c66-829a-e21c705ee660']/../name/rank/representation_L10n"/>
1084 <!--xsl:value-of select="concat($substring($genus,1,1), '. ', $repr)"/-->
1085 <xsl:value-of select="concat($genus, '. ', $repr)"/>
1086 </xsl:when>
1087 <xsl:when test="taxonUuid = $uuidGenus">
1088 <fo:block font-weight="bold" text-align="center"
1089 text-transform="uppercase">
1090 <xsl:apply-templates select="$genus"/>
1091 </fo:block>
1092 </xsl:when>
1093 <xsl:otherwise>
1094 <xsl:variable name="specificEpithet"
1095 select="//Taxon/uuid[.=$taxonUuid]/../name/specificEpithet"/>
1096 <!-- abbreviate the genus for species names -->
1097 <!--xsl:value-of select="concat(substring($genus,1,1), '. ', $specificEpithet)"/-->
1098 <xsl:value-of select="concat($genus, '. ', $specificEpithet)"/>
1099 </xsl:otherwise>
1100 </xsl:choose>
1101 </xsl:when>
1102 <xsl:otherwise/>
1103 </xsl:choose>
1104 </fo:block>
1105 </fo:table-cell>
1106 </fo:table-row>
1107 </xsl:for-each>
1108
1109 </fo:table-body>
1110 </fo:table>
1111 <fo:leader leader-pattern="rule" leader-length="100%"/>
1112 <xsl:text>&#xA;</xsl:text>
1113 </xsl:if>
1114 <!-- new line for the end of the section -->
1115 <xsl:text>&#xA;</xsl:text>
1116 </fo:block>
1117 </xsl:template>
1118
1119
1120 <!-- SYNONYMY BLOCK -->
1121
1122 <xsl:template match="synonymy" name="synonymy">
1123 <fo:block margin-bottom="5mm" line-height="{$taxon-name-line-height}"
1124 font-size="{$taxon-name-size-font}">
1125 <fo:block text-align="justify" text-indent="-{$taxon-name-indentation}"
1126 start-indent="{$taxon-name-indentation}">
1127 <xsl:apply-templates select="../name"/>
1128 <!--xsl:call-template name="citations"/-->
1129 <!-- 99b2842f-9aa7-42fa-bd5f-7285311e0101 is Citation -->
1130 <xsl:call-template name="citations">
1131 <xsl:with-param name="descriptionelements"
1132 select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
1133 <xsl:with-param name="name-uuid" select="../name/uuid"/>
1134 </xsl:call-template>
1135 <!--xsl:text>.**********</xsl:text-->
1136 <xsl:apply-templates select="homotypicSynonymsByHomotypicGroup"/>
1137 <xsl:apply-templates select="../name/typeDesignations"/>
1138 </fo:block>
1139 <xsl:apply-templates select="heterotypicSynonymyGroups"/>
1140 </fo:block>
1141 </xsl:template>
1142
1143 <xsl:template match="homotypicSynonymsByHomotypicGroup">
1144 <xsl:for-each select="e">
1145 <xsl:text> - </xsl:text>
1146 <xsl:apply-templates select="name"/>
1147 <xsl:call-template name="citations">
1148 <!--LORNA Pass the description elements for the citation 99b2842f-9aa7-42fa-bd5f-7285311e0101 -->
1149 <xsl:with-param name="descriptionelements"
1150 select="../../../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
1151 <xsl:with-param name="name-uuid" select="name/uuid"/>
1152 </xsl:call-template>
1153 </xsl:for-each>
1154
1155 <!--xsl:apply-templates select="e[1]/name[1]/homotypicalGroup[1]/typifiedNames[1]/e/taxonBases[1]/e/descriptions[1]/e/elements[1]/e[1]/media[1]/e/representations[1]/e/parts[1]/e/uri"></xsl:apply-templates-->
1156 </xsl:template>
1157
1158 <xsl:template match="heterotypicSynonymyGroups">
1159 <xsl:for-each select="e">
1160 <fo:block text-align="start" text-indent="-{$taxon-name-indentation}"
1161 start-indent="{$taxon-name-indentation}">
1162 <xsl:for-each select="e">
1163 <xsl:apply-templates select="name"/>
1164 <xsl:call-template name="citations">
1165 <xsl:with-param name="descriptionelements"
1166 select="../../../../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
1167 <xsl:with-param name="name-uuid" select="name/uuid"/>
1168
1169 </xsl:call-template>
1170 <xsl:apply-templates select="name/typeDesignations"/>
1171 </xsl:for-each>
1172 <!--xsl:apply-templates select="e[1]/name/typeDesignations" /-->
1173 </fo:block>
1174 </xsl:for-each>
1175
1176 </xsl:template>
1177
1178 <xsl:template name="citations">
1179 <xsl:param name="name-uuid"/>
1180 <xsl:param name="descriptionelements"/>
1181 <!--xsl:for-each
1182 select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements/descriptionelement"-->
1183 <xsl:for-each select="$descriptionelements/descriptionelement">
1184 <!-- TODO sorting only works for the first citation, implement correctly -->
1185 <xsl:sort select="sources/e[1]/citation/datePublished/start"/>
1186 <xsl:for-each select="sources/e">
1187
1188 <xsl:variable name="lastname_text" select="citation/authorTeam/lastname"/>
1189 <xsl:variable name="prev_lastname_text" select="preceding-sibling::e[1]/citation/authorTeam/lastname"/>
1190
1191 <xsl:if test="nameUsedInSource/uuid=$name-uuid">
1192 <xsl:text>; </xsl:text>
1193 <fo:inline>
1194 <!--xsl:value-of select="citation/authorTeam/titleCache"/-->
1195 <!--TODO wrap this in a variable and compare the previous variable to this one to see if we're dealing with the same name-->
1196 <xsl:for-each select="citation/authorTeam/teamMembers/e">
1197 <xsl:value-of select="lastname"/>
1198 <xsl:choose>
1199 <xsl:when test="position() != last()">
1200 <xsl:text> &amp; </xsl:text>
1201 </xsl:when>
1202 </xsl:choose>
1203 </xsl:for-each>
1204
1205 <xsl:choose>
1206 <xsl:when test="$lastname_text != $prev_lastname_text">
1207 <xsl:value-of select="citation/authorTeam/lastname"/><!--TODO We print lastname here as well as the author list is this a mistake?-->
1208
1209 <xsl:text> (</xsl:text>
1210 <xsl:value-of select="citation/datePublished/start"/>
1211 <xsl:if test="citationMicroReference != ''">
1212 <xsl:text>: </xsl:text>
1213 <xsl:value-of select="citationMicroReference"/>
1214 </xsl:if>
1215 <xsl:text>)</xsl:text>
1216 </xsl:when>
1217 <xsl:otherwise>
1218 <xsl:text> </xsl:text><!-- TODO For the first ref with a particlar name we should open brackets -->
1219 <xsl:value-of select="citation/datePublished/start"/>
1220 <xsl:if test="citationMicroReference != ''">
1221 <xsl:text>: </xsl:text>
1222 <xsl:value-of select="citationMicroReference"/>
1223 </xsl:if>
1224 </xsl:otherwise>
1225 </xsl:choose>
1226 </fo:inline>
1227 </xsl:if>
1228 </xsl:for-each>
1229 </xsl:for-each>
1230 </xsl:template>
1231
1232 <xsl:template name="citationsworks">
1233 <xsl:param name="name-uuid"/>
1234 <xsl:param name="descriptionelements"/>
1235 <!--xsl:for-each
1236 select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements/descriptionelement"-->
1237 <xsl:for-each select="$descriptionelements/descriptionelement">
1238 <!-- TODO sorting only works for the first citation, implement correctly -->
1239 <xsl:sort select="sources/e[1]/citation/datePublished/start"/>
1240 <xsl:for-each select="sources/e">
1241
1242 <xsl:if test="nameUsedInSource/uuid=$name-uuid">
1243 <xsl:text>; </xsl:text>
1244 <fo:inline>
1245 <!--xsl:value-of select="citation/authorTeam/titleCache"/-->
1246 <xsl:for-each select="citation/authorTeam/teamMembers/e">
1247 <xsl:value-of select="lastname"/>
1248 <xsl:choose>
1249 <xsl:when test="position() != last()">
1250 <xsl:text> &amp; </xsl:text>
1251 </xsl:when>
1252 </xsl:choose>
1253 </xsl:for-each>
1254
1255 <xsl:value-of select="citation/authorTeam/lastname"/>
1256 <xsl:text> (</xsl:text>
1257 <xsl:value-of select="citation/datePublished/start"/>
1258 <xsl:text>: </xsl:text>
1259 <xsl:value-of select="citationMicroReference"/>
1260 <xsl:text>)</xsl:text>
1261 </fo:inline>
1262 </xsl:if>
1263 </xsl:for-each>
1264 </xsl:for-each>
1265 </xsl:template>
1266
1267
1268 <!-- this template is for the list of all citations at the end of the PDF -->
1269 <!-- references are under //citation and under //nomenclaturalReference and //inReference-->
1270 <!-- could try //class[.='Reference']/parent::node() to get all References -->
1271 <xsl:key name="citations-by-uuid" match="//citation | //nomenclaturalReference" use="uuid" />
1272 <!--xsl:key name="nomenclaturalrefs-by-uuid" match="//nomenclaturalReference" use="uuid" /-->
1273
1274 <xsl:template name="References">
1275 <!-- new line for the end of the section -->
1276 <xsl:text>&#xA;</xsl:text>
1277
1278 <!--nomenclaturalReference or citation-->
1279 <!-- problem with this is that if the same reference occurs under citaiton and under nomenclaturalReference it appears twice -->
1280 <!--xsl:for-each select="//nomenclaturalReference[count(. | key('nomenclaturalrefs-by-uuid', uuid)[1]) = 1] | //citation[count(. | key('citations-by-uuid', uuid)[1]) = 1]"-->
1281
1282 <xsl:for-each select="//nomenclaturalReference[count(. | key('citations-by-uuid', uuid)[1]) = 1] | //citation[count(. | key('citations-by-uuid', uuid)[1]) = 1]">
1283 <!--xsl:for-each select="//nomenclaturalReference[count(. | key('nomenclaturalrefs-by-uuid', uuid)[1]) = 1]"-->
1284 <!--xsl:for-each select="//nomenclaturalReference"-->
1285 <xsl:sort select="authorTeam/lastname | authorTeam/teamMembers/e[1]/lastname" />
1286 <xsl:sort select="datePublished/start"></xsl:sort>
1287
1288 <fo:block linefeed-treatment="preserve" text-align="justify" text-indent="-{$taxon-name-indentation}" start-indent="{$taxon-name-indentation}">
1289
1290 <fo:inline>
1291 <!-- filter out repeated citation uuids. Could write a controller method in the CDM to get all unique references for a TaxonNode -->
1292
1293 <!--I am only listing references which have at least one author name. If there are other references in the database - why don't these have an author name-->
1294 <xsl:if test="authorTeam/teamMembers/e[1]/lastname != '' or authorTeam/lastname != ''">
1295 <!--xsl:text>&#xA;</xsl:text-->
1296 <xsl:choose>
1297 <xsl:when test="authorTeam/teamMembers/e[1]/lastname != ''">
1298 <xsl:for-each select="authorTeam/teamMembers/e">
1299 <fo:inline>
1300 <xsl:value-of select="lastname"/>
1301 <xsl:text> </xsl:text>
1302 <xsl:value-of select="firstname"/>
1303 <xsl:choose>
1304 <xsl:when test="position() != last()">
1305 <xsl:text> &amp; </xsl:text>
1306 </xsl:when>
1307 </xsl:choose>
1308 </fo:inline>
1309 </xsl:for-each>
1310 </xsl:when>
1311 <xsl:otherwise test="authorTeam/lastname != ''">
1312 <fo:inline>
1313 <xsl:value-of select="authorTeam/lastname"/>
1314 <xsl:text> </xsl:text>
1315 <xsl:value-of select="authorTeam/firstname"/>
1316 </fo:inline>
1317 </xsl:otherwise>
1318 </xsl:choose>
1319
1320 <xsl:if test="datePublished/start != ''">
1321 <xsl:text> (</xsl:text>
1322 <xsl:value-of select="datePublished/start"/>
1323 <xsl:text>) </xsl:text>
1324 </xsl:if>
1325
1326 <xsl:apply-templates select="title"/>
1327 <xsl:apply-templates select="volume"/>
1328 <xsl:apply-templates select="pages"/>
1329 <xsl:apply-templates select="placePublished"/>
1330 <xsl:apply-templates select="publisher"/>
1331
1332 <!-- if inReference has child nodes-->
1333 <xsl:if test="count(inReference/*) &gt; 0">
1334
1335 <xsl:text>In </xsl:text>
1336 <xsl:apply-templates select="inReference/title"/>
1337 <xsl:apply-templates select="inReference/volume"/>
1338 <xsl:apply-templates select="inReference/pages"/>
1339 <xsl:apply-templates select="inReference/placePublished"/>
1340 <xsl:apply-templates select="inReference/publisher"/>
1341 </xsl:if>
1342 <!--add template match to self:: that works for the above whether it's a citation or nomenclaturalReference -->
1343 <!-- new line for the end of the section -->
1344 <xsl:text>&#xA;</xsl:text>
1345 </xsl:if>
1346 </fo:inline>
1347 </fo:block>
1348 </xsl:for-each>
1349 </xsl:template>
1350
1351 <xsl:template match="*">
1352
1353 <xsl:value-of select="."/>
1354
1355 <xsl:if test="name(.) = 'title' or name(.) = 'publisher' or name(.) = 'pages'">
1356 <!-- . if pages or publisher or title - comma if placePublished -->
1357 <xsl:text>. </xsl:text>
1358 </xsl:if>
1359
1360 <xsl:if test="name(.) = 'volume'">
1361 <xsl:text>: </xsl:text>
1362 </xsl:if>
1363
1364 <xsl:if test="(../type = 'Book' or ../type = 'BookSection') and name(.) = 'placePublished' and . != ''">
1365 <xsl:text>, </xsl:text>
1366 </xsl:if>
1367
1368
1369 </xsl:template>
1370
1371
1372 <xsl:template name="Referencesold">
1373
1374 <!-- need to sort by lastname of the first author i.e. //citation/authorTeam/teamMembers/e[1]/lastname -->
1375 <xsl:for-each select="//citation">
1376
1377 <!-- TODO sorting only works for the first citation, implement correctly -->
1378 <xsl:sort select="authorTeam/lastname"/>
1379 <xsl:sort select="authorTeam/teamMembers/e[1]/lastname"/>
1380 <fo:block>
1381 <fo:inline>
1382
1383 <!-- filter out repeated citation uuids. Could write a controller method in the CDM to get all unique references for a TaxonNode -->
1384 <xsl:variable name="prev_citation_uuid" select="preceding-sibling::citation/uuid"/>
1385 <xsl:variable name="citation_uuid" select="uuid"/>
1386 <xsl:text>preceeding:</xsl:text>
1387 <xsl:value-of select="preceding-sibling::citation[1]/uuid"></xsl:value-of>
1388 <xsl:text>current:</xsl:text>
1389 <xsl:value-of select="uuid"></xsl:value-of>
1390
1391 <!--xsl:value-of select="preceding-sibling::citation/uuid"></xsl:value-of-->
1392
1393 <!--xsl:if test="$citation_uuid != $prev_citation_uuid"-->
1394 <xsl:if test="preceding-sibling::citation[1]/uuid != uuid">
1395
1396 <!-- .[not(preceding-sibling::Link[@personId = current()/@personId -->
1397 <xsl:choose>
1398
1399 <xsl:when test="authorTeam/teamMembers/e[1]/lastname != '' or authorTeam/lastname != ''">
1400
1401 <xsl:choose>
1402 <xsl:when test="authorTeam/teamMembers/e[1]/lastname != ''">
1403 <xsl:for-each select="authorTeam/teamMembers/e">
1404 <fo:inline font-weight="bold">
1405 <xsl:value-of select="lastname"/>
1406 <xsl:choose>
1407 <xsl:when test="position() != last()">
1408 <xsl:text> &amp; </xsl:text>
1409 </xsl:when>
1410 </xsl:choose>
1411 </fo:inline>
1412 </xsl:for-each>
1413 </xsl:when>
1414 <xsl:otherwise test="authorTeam/lastname != ''">
1415 <fo:inline font-weight="bold">
1416 <xsl:value-of select="authorTeam/lastname"/>
1417 </fo:inline>
1418 </xsl:otherwise>
1419 </xsl:choose>
1420
1421 <xsl:if test="datePublished/start != ''">
1422 <xsl:text> (</xsl:text>
1423 <xsl:value-of select="datePublished/start"/>
1424 <xsl:text>) </xsl:text>
1425 </xsl:if>
1426 <xsl:value-of select="title"/>
1427 <xsl:text>.</xsl:text>
1428 <xsl:value-of select="pages"/>
1429 <xsl:text>.</xsl:text>
1430
1431 <!-- new line for the end of the section -->
1432 <xsl:text>&#xA;</xsl:text>
1433
1434 </xsl:when>
1435 <!--xsl:otherwise>
1436 <xsl:text>HELLO&#xA;</xsl:text>
1437 </xsl:otherwise-->
1438 </xsl:choose>
1439 </xsl:if>
1440
1441 </fo:inline>
1442
1443 </fo:block>
1444 <xsl:text>&#xA;</xsl:text>
1445 </xsl:for-each>
1446
1447
1448
1449
1450 </xsl:template>
1451
1452 <xsl:template match="typeDesignations">
1453 <xsl:for-each select="child::*">
1454 <fo:inline>
1455 <xsl:text> - Type: </xsl:text>
1456 <xsl:choose>
1457 <xsl:when test="class='SpecimenTypeDesignation'">
1458 <xsl:value-of select="typeSpecimen/titleCache"/>
1459 </xsl:when>
1460 </xsl:choose>
1461 </fo:inline>
1462 </xsl:for-each>
1463 </xsl:template>
1464
1465
1466 </xsl:stylesheet>