- no change (just updated "last edited" for svn)
[cdmlib.git] / cdmlib-print / src / main / resources / stylesheets / pdf / caryophyllales.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">30mm</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"/--> <!-- sections don't have stitles as just creating a name list -->
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">
485 <xsl:apply-templates select="name/genusOrUninomial"/>
486 </fo:block>
487 </xsl:when>
488 <!-- genus -->
489 <!-- we don't show the genus as a title for the caryophyllales -->
490 <xsl:when test="name/rank/uuid='1b11c34c-48a8-4efa-98d5-84f7f66ef43a'">
491 <fo:block>
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>
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>
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
523 <xsl:variable name="fontstyle">
524 <xsl:choose>
525 <xsl:when test="rank/uuid='af5f2481-3192-403f-ae65-7c957a0f02b6'">
526 <xsl:value-of select="'bold'" />
527 </xsl:when>
528 <xsl:otherwise>
529 <xsl:value-of select="'regular'" />
530 </xsl:otherwise>
531 </xsl:choose>
532 </xsl:variable>
533 <fo:block font-weight="{$fontstyle}">
534 <xsl:apply-templates select="taggedName"/>
535 <xsl:apply-templates select="nomenclaturalReference"/>
536 </fo:block>
537 </xsl:template>
538
539 <xsl:template match="taggedName">
540 <xsl:for-each select="e">
541 <xsl:choose>
542 <xsl:when test="type='name'">
543 <fo:inline font-style="italic">
544 <xsl:value-of select="text"/>
545 </fo:inline>
546 <xsl:text> </xsl:text>
547 </xsl:when>
548 <xsl:when test="type='authors'">
549 <xsl:value-of select="text"/>
550 </xsl:when>
551 <xsl:otherwise>
552 <xsl:value-of select="text"/>
553 <xsl:text> </xsl:text>
554 </xsl:otherwise>
555 </xsl:choose>
556 </xsl:for-each>
557 </xsl:template>
558
559
560 <!-- first date in brackets -->
561 <xsl:template match="nomenclaturalReference">
562 <xsl:text> (</xsl:text>
563 <fo:inline>
564 <xsl:value-of select="authorTeam/titleCache"/>
565 <xsl:text> </xsl:text>
566 <xsl:value-of select="datePublished/start"/>: </fo:inline>
567 <xsl:text> </xsl:text>
568 <fo:inline>
569 <xsl:value-of select="../nomenclaturalMicroReference"/>
570 </fo:inline>
571 <xsl:text>)</xsl:text>
572 </xsl:template>
573
574 <!-- DESCRIPTIONS -->
575
576 <xsl:template match="descriptions" name="descriptions">
577 <xsl:for-each select="features/feature">
578 <xsl:choose>
579 <xsl:when test="count(feature)!=0">
580 <xsl:call-template name="secondLevelDescriptionElements"/>
581 </xsl:when>
582 <xsl:otherwise>
583 <!-- everything except Citation -->
584 <xsl:if test="uuid!='99b2842f-9aa7-42fa-bd5f-7285311e0101'">
585 <xsl:call-template name="descriptionElements"/>
586 </xsl:if>
587 <!--xsl:apply-templates select="media/e/representations/e/parts/e/uri"/-->
588 </xsl:otherwise>
589 </xsl:choose>
590 </xsl:for-each>
591 </xsl:template>
592
593 <xsl:template name="descriptionElements">
594 <xsl:choose>
595 <xsl:when test="supportsCommonTaxonName='true'">
596 <!-- for example Vernacular Name -->
597 <xsl:call-template name="commonTaxonName"/>
598 </xsl:when>
599 <xsl:otherwise>
600 <!-- for example Habitat, Material Examined -->
601 <xsl:call-template name="textData"/>
602 </xsl:otherwise>
603 </xsl:choose>
604 </xsl:template>
605
606 <xsl:template name="secondLevelDescriptionElements">
607 <fo:block text-align="justify" margin-bottom="5mm">
608 <!--fo:external-graphic src='http://lully.snv.jussieu.fr/xper2AppletThumbnailsMaker/sdd/images/ant_anatomy2.jpg'/-->
609 <xsl:for-each select="feature">
610
611 <xsl:variable name="representation" select="representation_L10n"/>
612 <xsl:if test="not(starts-with($representation, 'Material'))">
613 <!--xsl:if test="not(starts-with($representation, 'Figures'))"-->
614 <fo:inline keep-with-next.within-line="always">
615
616 <xsl:if test="not(starts-with($representation, 'Figures'))">
617 <!-- The headings are in English - do we want to remove them altogether or have French headings -->
618 <!--fo:inline text-decoration="underline" keep-with-next.within-line="always">
619
620 <xsl:value-of select="representation_L10n"/>
621 </fo:inline>
622 <fo:inline>: </fo:inline-->
623 </xsl:if>
624
625 <xsl:for-each select="descriptionelements/descriptionelement">
626
627 <xsl:variable name="desc_element_text" select="multilanguageText_L10n/text"/>
628
629 <!-- 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-->
630 <xsl:variable name="prev_desc_element_text"
631 select="preceding-sibling::descriptionelement[1]/multilanguageText_L10n/text"/>
632
633 <fo:inline font-size="9pt" space-after="5mm">
634
635 <xsl:if test="not(starts-with($desc_element_text, 'Figure'))">
636
637 <xsl:choose>
638 <xsl:when test="position() = 1">
639 <xsl:apply-templates select="multilanguageText_L10n/text"/>
640 </xsl:when>
641 <xsl:otherwise>
642 <xsl:if test="$desc_element_text != $prev_desc_element_text">
643 <!-- checked in the tax editor and looks like only descriptionelement[1] refers to the species so don't need below-->
644 <!--xsl:apply-templates select="multilanguageText_L10n/text"/-->
645 </xsl:if>
646 </xsl:otherwise>
647 </xsl:choose>
648
649 </xsl:if>
650
651 </fo:inline>
652
653 <!--xsl:apply-templates select="multilanguageText_L10n/text"/-->
654 <!--xsl:apply-templates select="media"/-->
655
656 <!--TODO Lorna we need to work out which description element contains the uri node for each figure
657 and place it next to the appropriate taxon in the output-->
658
659 <!--xsl:if test="not(starts-with($representation, 'Figures'))"-->
660 <!--xsl:if test="position() = 1"-->
661 <!--xsl:value-of select="../../../../../../Taxon/name/titleCache"/-->
662
663 <!-- if it has the title map don't show it in the image section -->
664
665 <xsl:if test="not(starts-with(media/e/title_L10n,'Map'))">
666 <xsl:apply-templates select="media/e/representations/e/parts/e/uri"/>
667 </xsl:if>
668
669
670
671
672 <!--xsl:call-template name="uri">
673 <xsl:with-param name="uri-node" select="media/e/representations/e/parts/e/uri"/>
674 </xsl:call-template-->
675 <!--/xsl:if-->
676 <!--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-->
677
678 </xsl:for-each>
679
680 <xsl:text> </xsl:text>
681 </fo:inline>
682 </xsl:if>
683 <!--/xsl:if-->
684 </xsl:for-each>
685
686 </fo:block>
687
688 </xsl:template>
689
690 <!-- IMAGES -->
691
692 <xsl:template match="uri">
693 <!--xsl:template name="uri"-->
694
695 <xsl:param name="uri-node"/>
696 <xsl:variable name="graphic" select="."/>
697 <xsl:variable name="title" select="../../../../../title_L10n"/>
698 <!--fo:block text-align="center"-->
699
700 <!--xsl:variable name="graphic" select="e/representations/e/parts/e/uri"/-->
701
702 <!-- Is there a description element of type Figure for this TaxonNode?-->
703
704 <xsl:choose>
705
706 <!--xsl:when test="contains($graphic,'jpg')"-->
707 <xsl:when test="starts-with($title,'Map')">
708 <fo:block keep-with-next="always" text-align="center">
709
710 <!--fo:inline text-align="center"-->
711 <fo:external-graphic content-height="scale-to-fit" height="50mm"
712 scaling="uniform" src="{$graphic}" padding-before="30" padding-after="2"
713 display-align="center"/>
714 <!--/fo:inline-->
715 </fo:block>
716 </xsl:when>
717 <xsl:otherwise>
718
719 <fo:block keep-with-next="always" text-align="center">
720
721 <!--fo:inline text-align="center"-->
722 <fo:external-graphic content-height="scale-to-fit" height="{$graphic-height}"
723 scaling="uniform" src="{$graphic}" padding-before="30" padding-after="2"
724 display-align="center"/>
725 <!--/fo:inline-->
726 </fo:block>
727 <fo:block>
728 <fo:leader leader-pattern="rule" leader-alignment="{$taxon-page-inner-margin}"
729 rule-thickness="0.8pt" leader-length="114mm"/>
730
731 </fo:block>
732 </xsl:otherwise>
733 </xsl:choose>
734
735 <fo:block>
736
737 <!--fo:leader leader-pattern="rule" leader-length="120mm"/-->
738 <fo:inline font-size="{$taxon-name-size-font}">
739 <!--go back up to the description element and get the text for the Figure legend -->
740 <xsl:apply-templates select="../../../../../../../multilanguageText_L10n/text"/>
741 </fo:inline>
742 </fo:block>
743 </xsl:template>
744
745
746 <xsl:template match="text">
747 <!--fo:block font-size="9pt" space-after="5mm" -->
748 <!--xsl:apply-templates select="node()"/-->
749 <!--xsl:call-template name="add-markup">
750 <xsl:with-param name="str" select="."/>
751
752 <xsl:with-param name="tag-name" select="b"/>
753 </xsl:call-template-->
754 <xsl:choose>
755 <xsl:when test="contains(.,&quot;&lt;b&gt;&quot;)">
756 <xsl:call-template name="add-markup">
757 <xsl:with-param name="str" select="."/>
758 <!--xsl:with-param name="tag-name" select="b"/-->
759 <xsl:with-param name="tag-name">b</xsl:with-param>
760 </xsl:call-template>
761 </xsl:when>
762 <xsl:otherwise>
763 <xsl:call-template name="add-markup">
764 <xsl:with-param name="str" select="."/>
765 <xsl:with-param name="tag-name">i</xsl:with-param>
766 </xsl:call-template>
767 </xsl:otherwise>
768 </xsl:choose>
769
770 <!--/fo:block -->
771 </xsl:template>
772
773 <!-- TODO Can this template be made shorter by less nesting in the xsl:choose statements -->
774 <xsl:template name="add-markup">
775 <xsl:param name="str"/>
776 <xsl:param name="tag-name"/>
777
778 <xsl:variable name="opening-tag">
779 <xsl:value-of select="concat('&lt;', $tag-name, '&gt;')"> </xsl:value-of>
780 </xsl:variable>
781 <xsl:variable name="closing-tag">
782 <xsl:value-of select="concat('&lt;/', $tag-name, '&gt;')"> </xsl:value-of>
783 </xsl:variable>
784
785 <xsl:choose>
786 <xsl:when test="contains($str, $opening-tag)">
787 <xsl:variable name="before-tag" select="substring-before($str, $opening-tag)"/>
788 <xsl:variable name="inside-tag"
789 select="substring-before(substring-after($str,$opening-tag),$closing-tag)"/>
790 <xsl:variable name="after-tag" select="substring-after($str, $closing-tag)"/>
791 <xsl:choose>
792 <xsl:when test="contains($before-tag, '#x2014;')">
793 <xsl:call-template name="replace-string">
794 <xsl:with-param name="text" select="$before-tag"/>
795 <xsl:with-param name="replace" select="'&amp;#x2014;'" />
796 <xsl:with-param name="with" select="'&mdash;'"/>
797 </xsl:call-template>
798 </xsl:when>
799 <xsl:otherwise>
800 <xsl:choose>
801 <xsl:when test="contains($before-tag, '#x2013;')">
802 <xsl:call-template name="replace-string">
803 <xsl:with-param name="text" select="$before-tag"/>
804 <xsl:with-param name="replace" select="'&amp;#x2013;'" />
805 <xsl:with-param name="with" select="'&ndash;'"/>
806 </xsl:call-template>
807 </xsl:when>
808 <xsl:otherwise>
809 <xsl:choose>
810 <xsl:when test="contains($str, '#x2716;')">
811 <xsl:call-template name="replace-string">
812 <xsl:with-param name="text" select="$before-tag"/>
813 <xsl:with-param name="replace" select="'&amp;#x2715;'" />
814 <xsl:with-param name="with" select="'&ndash;'"/>
815 </xsl:call-template>
816 </xsl:when>
817 <xsl:otherwise>
818 <xsl:value-of select="$before-tag"/>
819 </xsl:otherwise>
820 </xsl:choose>
821 </xsl:otherwise>
822 </xsl:choose>
823 </xsl:otherwise>
824 </xsl:choose>
825 <!-- add BOLD or italics when inside the appropriate tags -->
826 <xsl:choose>
827 <xsl:when test="$tag-name = 'b'">
828 <fo:inline font-weight="bold">
829 <xsl:value-of select="$inside-tag"/>
830 </fo:inline>
831 </xsl:when>
832 <xsl:otherwise>
833 <fo:inline font-style="italic">
834 <xsl:value-of select="$inside-tag"/>
835 </fo:inline>
836 </xsl:otherwise>
837 </xsl:choose>
838 <!-- call template recursively with the remaining text after the tag -->
839 <xsl:call-template name="add-markup">
840 <xsl:with-param name="str" select="$after-tag"/>
841 <xsl:with-param name="tag-name" select="$tag-name"/>
842 </xsl:call-template>
843 </xsl:when>
844 <xsl:otherwise>
845 <xsl:choose>
846 <xsl:when test="contains($str, '#x2014;')">
847 <xsl:call-template name="replace-string">
848 <xsl:with-param name="text" select="$before-tag"/>
849 <xsl:with-param name="replace" select="'&amp;#x2014;'" />
850 <xsl:with-param name="with" select="'&mdash;'"/>
851 </xsl:call-template>
852 </xsl:when>
853 <xsl:otherwise>
854 <xsl:choose>
855 <xsl:when test="contains($str, '#x2013;')">
856 <xsl:call-template name="replace-string">
857 <xsl:with-param name="text" select="$before-tag"/>
858 <xsl:with-param name="replace" select="'&amp;#x2013;'" />
859 <xsl:with-param name="with" select="'&ndash;'"/>
860 </xsl:call-template>
861 </xsl:when>
862 <xsl:otherwise>
863 <xsl:choose>
864 <xsl:when test="contains($str, '#x2716;')">
865 <xsl:call-template name="replace-string">
866 <xsl:with-param name="text" select="$before-tag"/>
867 <xsl:with-param name="replace" select="'&amp;#x2715;'" />
868 <xsl:with-param name="with" select="'&ndash;'"/>
869 </xsl:call-template>
870 </xsl:when>
871 <xsl:otherwise>
872 <xsl:value-of select="$str"/>
873 </xsl:otherwise>
874 </xsl:choose>
875 </xsl:otherwise>
876 </xsl:choose>
877 </xsl:otherwise>
878 </xsl:choose>
879 </xsl:otherwise>
880 </xsl:choose>
881 </xsl:template>
882
883 <xsl:template name="replace-string">
884 <xsl:param name="text"/>
885 <xsl:param name="replace"/>
886 <xsl:param name="with"/>
887 <xsl:choose>
888 <xsl:when test="contains($text,$replace)">
889 <xsl:value-of select="substring-before($text,$replace)"/>
890 <xsl:value-of select="$with"/>
891 <xsl:call-template name="replace-string">
892 <xsl:with-param name="text"
893 select="substring-after($text,$replace)"/>
894 <xsl:with-param name="replace" select="$replace"/>
895 <xsl:with-param name="with" select="$with"/>
896 </xsl:call-template>
897 </xsl:when>
898 <xsl:otherwise>
899 <xsl:value-of select="$text"/>
900 </xsl:otherwise>
901 </xsl:choose>
902 </xsl:template>
903
904 <xsl:template name="remove_ampersands">
905 <xsl:param name="str"/>
906 <xsl:choose>
907 <xsl:when test="contains($str,&quot;amp;&quot;)"> </xsl:when>
908 </xsl:choose>
909 </xsl:template>
910
911 <xsl:template name="remove">
912 <xsl:param name="value"/>
913 <xsl:value-of select="concat(substring-before($value, 'amp;'), substring-after($value, 'amp;'))"
914 />
915 </xsl:template>
916
917 <!--xsl:template match="i">
918 <fo:inline font-style="italic">
919 <xsl:apply-templates select="node()"/>
920 </fo:inline>
921 </xsl:template-->
922
923 <xsl:template match="i">
924 <fo:inline font-style="italic">
925 <xsl:apply-templates/>
926 </fo:inline>
927 </xsl:template>
928
929 <xsl:template match="i//text()">
930 <fo:inline font-style="italic">
931 <xsl:apply-templates/>
932 </fo:inline>
933 </xsl:template>
934
935
936 <xsl:template name="commonTaxonName">
937 <fo:inline font-weight="bold">
938 <xsl:value-of select="representation_L10n"/>
939 </fo:inline>
940 <xsl:text> &mdash; </xsl:text>
941 <xsl:for-each select="descriptionelements/descriptionelement">
942 <fo:inline>
943 <xsl:choose>
944 <xsl:when test="position() != last()">
945 <xsl:value-of select="name"/> (<xsl:value-of select="language/representation_L10n"/>), </xsl:when>
946 <xsl:otherwise>
947 <xsl:value-of select="name"/> (<xsl:value-of select="language/representation_L10n"
948 />).</xsl:otherwise>
949 </xsl:choose>
950 </fo:inline>
951 </xsl:for-each>
952 </xsl:template>
953
954 <xsl:template name="commonTaxonNameold2">
955 <fo:inline font-weight="bold">
956 <xsl:value-of select="representation_L10n"/>
957 </fo:inline>
958 <xsl:text> &mdash; </xsl:text>
959 <xsl:for-each select="descriptionelements/descriptionelement">
960 <fo:inline>
961 <xsl:value-of select="name"/> (<xsl:value-of select="language/representation_L10n"/>) <xsl:choose>
962 <xsl:when test="position() != last()">,</xsl:when>
963 <xsl:otherwise>.</xsl:otherwise>
964 </xsl:choose>
965 </fo:inline>
966 </xsl:for-each>
967 </xsl:template>
968
969 <xsl:template name="commonTaxonNameold">
970 <fo:inline font-weight="bold">
971 <xsl:value-of select="representation_L10n"/>
972 </fo:inline>
973 <xsl:text> &mdash; </xsl:text>
974 <xsl:for-each select="descriptionelements/descriptionelement">
975 <fo:inline>
976 <xsl:value-of select="name"/> (<xsl:value-of select="language/representation_L10n"/>),
977 </fo:inline>
978 </xsl:for-each>
979 </xsl:template>
980
981 <xsl:template name="textData">
982 <fo:block text-align="justify" margin-bottom="5mm">
983 <!-- show all feature headlines except "ditribution" -->
984 <!--xsl:if test="uuid!='9fc9d10c-ba50-49ee-b174-ce83fc3f80c6'">
985 <fo:inline font-weight="bold">
986 <xsl:value-of select="representation_L10n"/>
987 </fo:inline>
988 <xsl:text> – </xsl:text>
989 </xsl:if-->
990 <xsl:choose>
991 <!-- 9fc9d10c-ba50-49ee-b174-ce83fc3f80c6 is Distribution -->
992 <xsl:when test="uuid!='9fc9d10c-ba50-49ee-b174-ce83fc3f80c6'">
993 <fo:inline font-weight="bold">
994 <xsl:value-of select="representation_L10n"/>
995 <!-- e.g. Habitat -->
996 </fo:inline>
997 <xsl:text> &mdash; </xsl:text>
998 </xsl:when>
999 <xsl:otherwise>
1000 <fo:inline font-weight="bold" keep-with-next="always">
1001 <xsl:text> Matériel examiné </xsl:text>
1002 <xsl:text>&#xA;</xsl:text>
1003 </fo:inline>
1004 </xsl:otherwise>
1005
1006 </xsl:choose>
1007 <!--xsl:for-each select="descriptionelements/descriptionelement">
1008 <fo:inline>
1009 <xsl:text>LINE 609</xsl:text>
1010 <xsl:apply-templates select="multilanguageText_L10n/text"/>
1011 </fo:inline>
1012 </xsl:for-each-->
1013
1014 <!-- LORNA TRY IMAGE HERE -->
1015 <!--xsl:apply-templates select="descriptionelements/descriptionelement[1]/media/e/representations/e/parts/e/uri"/-->
1016
1017 <xsl:apply-templates
1018 select="descriptionelements/descriptionelement[1]/multilanguageText_L10n/text"/>
1019
1020 <!-- get the map associated with the distribution, this is temporarily stored as a media object jpg created by
1021 Quentin's GIS software -->
1022 <xsl:if test="uuid='9fc9d10c-ba50-49ee-b174-ce83fc3f80c6'">
1023
1024 <!-- get the map attached to the feature 'Figures' -->
1025 <xsl:apply-templates
1026 select="../feature/feature/representation_L10n[.='Figures']/../descriptionelements/descriptionelement[1]/media/e/representations/e/parts/e/uri"/>
1027 <!--media/e/representations/e/parts/e/uri media/e/title_L10n[.='Map']/../representations/e/parts/e/uri"/-->
1028 </xsl:if>
1029
1030 </fo:block>
1031 </xsl:template>
1032
1033 <xsl:template match="key" name="key">
1034 <!--fo:block margin-bottom="5mm" line-height="{$taxon-name-line-height}" font-size="{$taxon-name-size-font}"-->
1035 <fo:block linefeed-treatment="preserve">
1036
1037 <fo:block font-weight="bold" text-align="center">
1038 <xsl:value-of select="HashMap/titleCache"/>
1039 </fo:block>
1040 <xsl:if test="HashMap/records/e">
1041 <xsl:text>&#xA;</xsl:text>
1042 <fo:table>
1043 <fo:table-column column-width="5mm"/>
1044 <fo:table-column column-width="5mm"/>
1045 <fo:table-column column-width="69mm"/>
1046 <fo:table-column column-width="36mm"/>
1047 <fo:table-body>
1048 <!--xsl:if test="ArrayList/e"-->
1049 <xsl:for-each select="HashMap/records/e">
1050
1051 <!-- TaxonLinkDto or PolytomousKeyNodeLinkDto-->
1052 <fo:table-row>
1053 <fo:table-cell>
1054 <fo:block>
1055 <xsl:if test="edgeNumber = 1">
1056 <xsl:value-of select="nodeNumber"/>
1057 <xsl:text>.</xsl:text>
1058 </xsl:if>
1059 </fo:block>
1060 </fo:table-cell>
1061 <fo:table-cell>
1062 <fo:block>&ndash;</fo:block>
1063 </fo:table-cell>
1064 <fo:table-cell>
1065 <!--fo:block>
1066 <xsl:apply-templates select="childStatement"/-->
1067 <!--xsl:value-of select="concat(childStatement, '..............')"/-->
1068 <!--xsl:text>.......................................................................................</xsl:text>
1069 </fo:block-->
1070 <fo:block text-align="justify" text-align-last="justify">
1071 <!-- leader-length="auto"-->
1072 <xsl:value-of select="childStatement"/>
1073 <xsl:text> </xsl:text>
1074 <fo:leader leader-pattern="dots"/>
1075 </fo:block>
1076
1077 </fo:table-cell>
1078 <fo:table-cell display-align="after">
1079 <fo:block font-style="italic" text-align="justify" text-align-last="justify">
1080 <!-- leader-length="auto" text-align="right"-->
1081 <fo:leader leader-pattern="dots"/>
1082 <xsl:choose>
1083 <xsl:when test="links/e[1]/class = 'PolytomousKeyNodeLinkDto'">
1084 <xsl:value-of select="links/e[1]/nodeNumber"/>
1085 </xsl:when>
1086 <xsl:when test="links/e[1]/class = 'TaxonLinkDto'">
1087 <xsl:variable name="taxonUuid" select="links/e[1]/uuid"/>
1088 <xsl:variable name="genus"
1089 select="//Taxon/uuid[.=$taxonUuid]/../name/genusOrUninomial"/>
1090 <xsl:choose>
1091 <xsl:when test="taxonUuid = $uuidSubgenus">
1092 <xsl:variable name="repr"
1093 select="//Taxon/uuid[.='71cd0e8d-47eb-4c66-829a-e21c705ee660']/../name/rank/representation_L10n"/>
1094 <!--xsl:value-of select="concat($substring($genus,1,1), '. ', $repr)"/-->
1095 <xsl:value-of select="concat($genus, '. ', $repr)"/>
1096 </xsl:when>
1097 <xsl:when test="taxonUuid = $uuidGenus">
1098 <fo:block font-weight="bold" text-align="center"
1099 text-transform="uppercase">
1100 <xsl:apply-templates select="$genus"/>
1101 </fo:block>
1102 </xsl:when>
1103 <xsl:otherwise>
1104 <xsl:variable name="specificEpithet"
1105 select="//Taxon/uuid[.=$taxonUuid]/../name/specificEpithet"/>
1106 <!-- abbreviate the genus for species names -->
1107 <!--xsl:value-of select="concat(substring($genus,1,1), '. ', $specificEpithet)"/-->
1108 <xsl:value-of select="concat($genus, '. ', $specificEpithet)"/>
1109 </xsl:otherwise>
1110 </xsl:choose>
1111 </xsl:when>
1112 <xsl:otherwise/>
1113 </xsl:choose>
1114 </fo:block>
1115 </fo:table-cell>
1116 </fo:table-row>
1117 </xsl:for-each>
1118
1119 </fo:table-body>
1120 </fo:table>
1121 <fo:leader leader-pattern="rule" leader-length="100%"/>
1122 <xsl:text>&#xA;</xsl:text>
1123 </xsl:if>
1124 <!-- new line for the end of the section -->
1125 <xsl:text>&#xA;</xsl:text>
1126 </fo:block>
1127 </xsl:template>
1128
1129
1130 <!-- SYNONYMY BLOCK -->
1131
1132 <xsl:template match="synonymy" name="synonymy">
1133 <!--fo:block margin-bottom="5mm" line-height="{$taxon-name-line-height}"
1134 font-size="{$taxon-name-size-font}"-->
1135 <fo:block text-align="justify" text-indent="-{$taxon-name-indentation}"
1136 start-indent="{$taxon-name-indentation}">
1137 <xsl:apply-templates select="../name"/>
1138 <!--xsl:call-template name="citations"/-->
1139 <!-- 99b2842f-9aa7-42fa-bd5f-7285311e0101 is Citation -->
1140 <xsl:call-template name="citations">
1141 <xsl:with-param name="descriptionelements"
1142 select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
1143 <xsl:with-param name="name-uuid" select="../name/uuid"/>
1144 </xsl:call-template>
1145 <!--xsl:text>.**********</xsl:text-->
1146 <xsl:apply-templates select="homotypicSynonymsByHomotypicGroup"/>
1147 <xsl:apply-templates select="../name/typeDesignations"/>
1148 </fo:block>
1149 <xsl:apply-templates select="heterotypicSynonymyGroups"/>
1150 <!--/fo:block-->
1151 </xsl:template>
1152
1153 <xsl:template match="homotypicSynonymsByHomotypicGroup">
1154 <xsl:for-each select="e">
1155 <xsl:text> - </xsl:text>
1156 <xsl:apply-templates select="name"/>
1157 <xsl:call-template name="citations">
1158 <!--LORNA Pass the description elements for the citation 99b2842f-9aa7-42fa-bd5f-7285311e0101 -->
1159 <xsl:with-param name="descriptionelements"
1160 select="../../../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
1161 <xsl:with-param name="name-uuid" select="name/uuid"/>
1162 </xsl:call-template>
1163 </xsl:for-each>
1164
1165 <!--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-->
1166 </xsl:template>
1167
1168 <xsl:template match="heterotypicSynonymyGroups">
1169 <xsl:for-each select="e">
1170 <fo:block text-align="start" text-indent="-{$taxon-name-indentation}"
1171 start-indent="{$taxon-name-indentation}">
1172 <xsl:for-each select="e">
1173 <xsl:apply-templates select="name"/>
1174 <xsl:call-template name="citations">
1175 <xsl:with-param name="descriptionelements"
1176 select="../../../../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
1177 <xsl:with-param name="name-uuid" select="name/uuid"/>
1178
1179 </xsl:call-template>
1180 <xsl:apply-templates select="name/typeDesignations"/>
1181 </xsl:for-each>
1182 <!--xsl:apply-templates select="e[1]/name/typeDesignations" /-->
1183 </fo:block>
1184 </xsl:for-each>
1185
1186 </xsl:template>
1187
1188 <xsl:template name="citations">
1189 <xsl:param name="name-uuid"/>
1190 <xsl:param name="descriptionelements"/>
1191 <!--xsl:for-each
1192 select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements/descriptionelement"-->
1193 <xsl:for-each select="$descriptionelements/descriptionelement">
1194 <!-- TODO sorting only works for the first citation, implement correctly -->
1195 <xsl:sort select="sources/e[1]/citation/datePublished/start"/>
1196 <xsl:for-each select="sources/e">
1197
1198 <xsl:variable name="lastname_text" select="citation/authorTeam/lastname"/>
1199 <xsl:variable name="prev_lastname_text" select="preceding-sibling::e[1]/citation/authorTeam/lastname"/>
1200
1201 <xsl:if test="nameUsedInSource/uuid=$name-uuid">
1202 <xsl:text>; </xsl:text>
1203 <fo:inline>
1204 <!--xsl:value-of select="citation/authorTeam/titleCache"/-->
1205 <!--TODO wrap this in a variable and compare the previous variable to this one to see if we're dealing with the same name-->
1206 <xsl:for-each select="citation/authorTeam/teamMembers/e">
1207 <xsl:value-of select="lastname"/>
1208 <xsl:choose>
1209 <xsl:when test="position() != last()">
1210 <xsl:text> &amp; </xsl:text>
1211 </xsl:when>
1212 </xsl:choose>
1213 </xsl:for-each>
1214
1215 <xsl:choose>
1216 <xsl:when test="$lastname_text != $prev_lastname_text">
1217 <xsl:value-of select="citation/authorTeam/lastname"/><!--TODO We print lastname here as well as the author list is this a mistake?-->
1218
1219 <xsl:text> (</xsl:text>
1220 <xsl:value-of select="citation/datePublished/start"/>
1221 <xsl:text>: </xsl:text>
1222 <xsl:value-of select="citationMicroReference"/>
1223 <xsl:text>)</xsl:text>
1224 </xsl:when>
1225 <xsl:otherwise>
1226 <xsl:text> </xsl:text><!-- TODO For the first ref with a particlar name we should open brackets -->
1227 <xsl:value-of select="citation/datePublished/start"/>
1228 <xsl:if test="citationMicroReference != ''">
1229 <xsl:text>: </xsl:text>
1230 <xsl:value-of select="citationMicroReference"/>
1231 </xsl:if>
1232 </xsl:otherwise>
1233 </xsl:choose>
1234 </fo:inline>
1235 </xsl:if>
1236 </xsl:for-each>
1237 </xsl:for-each>
1238 </xsl:template>
1239
1240 <xsl:template name="citationsworks">
1241 <xsl:param name="name-uuid"/>
1242 <xsl:param name="descriptionelements"/>
1243 <!--xsl:for-each
1244 select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements/descriptionelement"-->
1245 <xsl:for-each select="$descriptionelements/descriptionelement">
1246 <!-- TODO sorting only works for the first citation, implement correctly -->
1247 <xsl:sort select="sources/e[1]/citation/datePublished/start"/>
1248 <xsl:for-each select="sources/e">
1249
1250 <xsl:if test="nameUsedInSource/uuid=$name-uuid">
1251 <xsl:text>; </xsl:text>
1252 <fo:inline>
1253 <!--xsl:value-of select="citation/authorTeam/titleCache"/-->
1254 <xsl:for-each select="citation/authorTeam/teamMembers/e">
1255 <xsl:value-of select="lastname"/>
1256 <xsl:choose>
1257 <xsl:when test="position() != last()">
1258 <xsl:text> &amp; </xsl:text>
1259 </xsl:when>
1260 </xsl:choose>
1261 </xsl:for-each>
1262
1263 <xsl:value-of select="citation/authorTeam/lastname"/>
1264 <xsl:text> (</xsl:text>
1265 <xsl:value-of select="citation/datePublished/start"/>
1266 <xsl:text>: </xsl:text>
1267 <xsl:value-of select="citationMicroReference"/>
1268 <xsl:text>)</xsl:text>
1269 </fo:inline>
1270 </xsl:if>
1271 </xsl:for-each>
1272 </xsl:for-each>
1273 </xsl:template>
1274
1275
1276 <!-- this template is for the list of all citations at the end of the PDF -->
1277 <!-- references are under //citation and under //nomenclaturalReference and //inReference-->
1278 <!-- could try //class[.='Reference']/parent::node() to get all References -->
1279 <xsl:key name="citations-by-uuid" match="//citation | //nomenclaturalReference" use="uuid" />
1280 <!--xsl:key name="nomenclaturalrefs-by-uuid" match="//nomenclaturalReference" use="uuid" /-->
1281
1282 <xsl:template name="References">
1283 <!-- new line for the end of the section -->
1284 <xsl:text>&#xA;</xsl:text>
1285
1286 <!--nomenclaturalReference or citation-->
1287 <!-- problem with this is that if the same reference occurs under citaiton and under nomenclaturalReference it appears twice -->
1288 <!--xsl:for-each select="//nomenclaturalReference[count(. | key('nomenclaturalrefs-by-uuid', uuid)[1]) = 1] | //citation[count(. | key('citations-by-uuid', uuid)[1]) = 1]"-->
1289
1290 <xsl:for-each select="//nomenclaturalReference[count(. | key('citations-by-uuid', uuid)[1]) = 1] | //citation[count(. | key('citations-by-uuid', uuid)[1]) = 1]">
1291 <!--xsl:for-each select="//nomenclaturalReference[count(. | key('nomenclaturalrefs-by-uuid', uuid)[1]) = 1]"-->
1292 <!--xsl:for-each select="//nomenclaturalReference"-->
1293 <xsl:sort select="authorTeam/lastname | authorTeam/teamMembers/e[1]/lastname" />
1294 <xsl:sort select="datePublished/start"></xsl:sort>
1295
1296 <fo:block linefeed-treatment="preserve" text-align="justify" text-indent="-{$taxon-name-indentation}" start-indent="{$taxon-name-indentation}">
1297
1298 <fo:inline>
1299 <!-- filter out repeated citation uuids. Could write a controller method in the CDM to get all unique references for a TaxonNode -->
1300
1301 <!--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-->
1302 <xsl:if test="authorTeam/teamMembers/e[1]/lastname != '' or authorTeam/lastname != ''">
1303 <!--xsl:text>&#xA;</xsl:text-->
1304 <xsl:choose>
1305 <xsl:when test="authorTeam/teamMembers/e[1]/lastname != ''">
1306 <xsl:for-each select="authorTeam/teamMembers/e">
1307 <fo:inline>
1308 <xsl:value-of select="lastname"/>
1309 <xsl:text> </xsl:text>
1310 <xsl:value-of select="firstname"/>
1311 <xsl:choose>
1312 <xsl:when test="position() != last()">
1313 <xsl:text> &amp; </xsl:text>
1314 </xsl:when>
1315 </xsl:choose>
1316 </fo:inline>
1317 </xsl:for-each>
1318 </xsl:when>
1319 <xsl:otherwise test="authorTeam/lastname != ''">
1320 <fo:inline>
1321 <xsl:value-of select="authorTeam/lastname"/>
1322 <xsl:text> </xsl:text>
1323 <xsl:value-of select="authorTeam/firstname"/>
1324 </fo:inline>
1325 </xsl:otherwise>
1326 </xsl:choose>
1327
1328 <xsl:if test="datePublished/start != ''">
1329 <xsl:text> (</xsl:text>
1330 <xsl:value-of select="datePublished/start"/>
1331 <xsl:text>) </xsl:text>
1332 </xsl:if>
1333
1334 <xsl:apply-templates select="title"/>
1335 <xsl:apply-templates select="volume"/>
1336 <xsl:apply-templates select="pages"/>
1337 <xsl:apply-templates select="placePublished"/>
1338 <xsl:apply-templates select="publisher"/>
1339
1340 <!-- if inReference has child nodes-->
1341 <xsl:if test="count(inReference/*) &gt; 0">
1342
1343 <xsl:text>In </xsl:text>
1344 <xsl:apply-templates select="inReference/title"/>
1345 <xsl:apply-templates select="inReference/volume"/>
1346 <xsl:apply-templates select="inReference/pages"/>
1347 <xsl:apply-templates select="inReference/placePublished"/>
1348 <xsl:apply-templates select="inReference/publisher"/>
1349 </xsl:if>
1350 <!--add template match to self:: that works for the above whether it's a citation or nomenclaturalReference -->
1351 <!-- new line for the end of the section -->
1352 <xsl:text>&#xA;</xsl:text>
1353 </xsl:if>
1354 </fo:inline>
1355 </fo:block>
1356 </xsl:for-each>
1357 </xsl:template>
1358
1359 <xsl:template match="*">
1360
1361 <xsl:value-of select="."/>
1362
1363 <xsl:if test="name(.) = 'title' or name(.) = 'publisher' or name(.) = 'pages'">
1364 <!-- . if pages or publisher or title - comma if placePublished -->
1365 <xsl:text>. </xsl:text>
1366 </xsl:if>
1367
1368 <xsl:if test="name(.) = 'volume'">
1369 <xsl:text>: </xsl:text>
1370 </xsl:if>
1371
1372 <xsl:if test="(../type = 'Book' or ../type = 'BookSection') and name(.) = 'placePublished' and . != ''">
1373 <xsl:text>, </xsl:text>
1374 </xsl:if>
1375
1376
1377 </xsl:template>
1378
1379
1380 <xsl:template name="Referencesold">
1381
1382 <!-- need to sort by lastname of the first author i.e. //citation/authorTeam/teamMembers/e[1]/lastname -->
1383 <xsl:for-each select="//citation">
1384
1385 <!-- TODO sorting only works for the first citation, implement correctly -->
1386 <xsl:sort select="authorTeam/lastname"/>
1387 <xsl:sort select="authorTeam/teamMembers/e[1]/lastname"/>
1388 <fo:block>
1389 <fo:inline>
1390
1391 <!-- filter out repeated citation uuids. Could write a controller method in the CDM to get all unique references for a TaxonNode -->
1392 <xsl:variable name="prev_citation_uuid" select="preceding-sibling::citation/uuid"/>
1393 <xsl:variable name="citation_uuid" select="uuid"/>
1394 <xsl:text>preceeding:</xsl:text>
1395 <xsl:value-of select="preceding-sibling::citation[1]/uuid"></xsl:value-of>
1396 <xsl:text>current:</xsl:text>
1397 <xsl:value-of select="uuid"></xsl:value-of>
1398
1399 <!--xsl:value-of select="preceding-sibling::citation/uuid"></xsl:value-of-->
1400
1401 <!--xsl:if test="$citation_uuid != $prev_citation_uuid"-->
1402 <xsl:if test="preceding-sibling::citation[1]/uuid != uuid">
1403
1404 <!-- .[not(preceding-sibling::Link[@personId = current()/@personId -->
1405 <xsl:choose>
1406
1407 <xsl:when test="authorTeam/teamMembers/e[1]/lastname != '' or authorTeam/lastname != ''">
1408
1409 <xsl:choose>
1410 <xsl:when test="authorTeam/teamMembers/e[1]/lastname != ''">
1411 <xsl:for-each select="authorTeam/teamMembers/e">
1412 <fo:inline font-weight="bold">
1413 <xsl:value-of select="lastname"/>
1414 <xsl:choose>
1415 <xsl:when test="position() != last()">
1416 <xsl:text> &amp; </xsl:text>
1417 </xsl:when>
1418 </xsl:choose>
1419 </fo:inline>
1420 </xsl:for-each>
1421 </xsl:when>
1422 <xsl:otherwise test="authorTeam/lastname != ''">
1423 <fo:inline font-weight="bold">
1424 <xsl:value-of select="authorTeam/lastname"/>
1425 </fo:inline>
1426 </xsl:otherwise>
1427 </xsl:choose>
1428
1429 <xsl:if test="datePublished/start != ''">
1430 <xsl:text> (</xsl:text>
1431 <xsl:value-of select="datePublished/start"/>
1432 <xsl:text>) </xsl:text>
1433 </xsl:if>
1434 <xsl:value-of select="title"/>
1435 <xsl:text>.</xsl:text>
1436 <xsl:value-of select="pages"/>
1437 <xsl:text>.</xsl:text>
1438
1439 <!-- new line for the end of the section -->
1440 <xsl:text>&#xA;</xsl:text>
1441
1442 </xsl:when>
1443 <!--xsl:otherwise>
1444 <xsl:text>HELLO&#xA;</xsl:text>
1445 </xsl:otherwise-->
1446 </xsl:choose>
1447 </xsl:if>
1448
1449 </fo:inline>
1450
1451 </fo:block>
1452 <xsl:text>&#xA;</xsl:text>
1453 </xsl:for-each>
1454
1455
1456
1457
1458 </xsl:template>
1459
1460 <xsl:template match="typeDesignations">
1461 <xsl:for-each select="child::*">
1462 <fo:inline>
1463
1464 <xsl:choose>
1465 <xsl:when test="class='SpecimenTypeDesignation'">
1466 <xsl:text> - Typus: </xsl:text>
1467 <xsl:value-of select="typeSpecimen/titleCache"/>
1468 </xsl:when>
1469 <xsl:when test="class='NameTypeDesignation'">
1470 <xsl:text> - Typus: </xsl:text>
1471 <xsl:value-of select="typeName/titleCache"/>
1472 </xsl:when>
1473 </xsl:choose>
1474 </fo:inline>
1475 </xsl:for-each>
1476 </xsl:template>
1477
1478
1479 </xsl:stylesheet>