Added template to convert html tags within text nodes to xsl:fo italic and bold.
[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;" >]>
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"
11 xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
12
13 <!-- ############### Constants and definitions ################### -->
14
15 <!-- **********************************
16 ** global definitions
17 *********************************** -->
18 <xsl:param name="global-family-font">Times</xsl:param>
19 <xsl:param name="global-size-font">10pt</xsl:param>
20 <xsl:param name="global-line-height">12pt</xsl:param>
21
22 <xsl:param name="global-width-page">159mm</xsl:param>
23 <xsl:param name="global-height-page">244mm</xsl:param>
24
25 <xsl:param name="global-indentation">0mm</xsl:param>
26
27 <!-- **********************************
28 ** definitions for taxon pages
29 *********************************** -->
30 <xsl:param name="taxon-page-top-margin">32mm</xsl:param>
31 <xsl:param name="taxon-page-inner-margin">21mm</xsl:param>
32 <xsl:param name="taxon-page-bottom-margin">32mm</xsl:param>
33 <xsl:param name="graphic-height">150mm</xsl:param>
34
35 <xsl:param name="taxon-region-body-outer-margin">24mm</xsl:param>
36
37 <xsl:param name="taxon-region-before-extent">0mm</xsl:param>
38 <xsl:param name="taxon-region-after-extent">0mm</xsl:param>
39
40 <xsl:param name="content-bg-color">white</xsl:param>
41 <xsl:param name="taxon-header-family-font">Times</xsl:param>
42 <xsl:param name="taxon-header-before-bg-color">white</xsl:param>
43 <xsl:param name="taxon-header-after-bg-color">white</xsl:param>
44 <xsl:param name="taxon-header-size-font">7pt</xsl:param>
45
46
47 <xsl:param name="taxon-name-indentation">4mm</xsl:param>
48 <xsl:param name="taxon-name-size-font">8pt</xsl:param>
49 <xsl:param name="taxon-name-line-height">9.6pt</xsl:param>
50
51 <xsl:param name="taxon-header-style-font">italic</xsl:param>
52 <xsl:param name="taxon-header-page-number-size-font">10pt</xsl:param>
53 <xsl:param name="taxon-header-page-number-align-text">end</xsl:param>
54 <xsl:param name="taxon-header-page-number-margin">11mm</xsl:param>
55
56 <xsl:param name="taxon-page-number-initial">1</xsl:param>
57
58 <!-- hardcoded ranks -->
59 <xsl:param name="uuidFamily">210a8214-4e69-401a-8e47-c7940d990bdd</xsl:param>
60 <xsl:param name="uuidGenus">1b11c34c-48a8-4efa-98d5-84f7f66ef43a</xsl:param>
61 <xsl:param name="uuidSubgenus">78786e16-2a70-48af-a608-494023b91904</xsl:param>
62
63
64 <!-- **********************************
65 ** html support
66 *********************************** -->
67
68 <!-- format html i tags in text as italic -->
69 <!--xsl:template match="i">
70 <fo:inline font-style="italic">
71 <xsl:value-of select="."/>
72 </fo:inline>
73 </xsl:template-->
74
75 <!-- format html b tags in text as bold -->
76 <xsl:template match="b">
77 <fo:inline font-weight="bold">
78 <xsl:apply-templates/>
79 </fo:inline>
80 </xsl:template>
81
82 <!-- ########################################################################## -->
83
84
85 <!-- start xsl output -->
86 <xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="no"/>
87 <xsl:param name="versionParam" select="'1.0'"/>
88
89 <!-- root element: root -->
90 <xsl:template match="root">
91 <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
92
93 <!-- defines page layout -->
94 <fo:layout-master-set>
95
96 <!-- layout for odd taxon pages -->
97 <fo:simple-page-master master-name="taxon_page_odd" page-height="{$global-height-page}"
98 page-width="{$global-width-page}" margin-top="{$taxon-page-top-margin}"
99 margin-bottom="{$taxon-page-bottom-margin}" margin-left="{$taxon-page-inner-margin}">
100 <fo:region-body margin-right="{$taxon-region-body-outer-margin}"/>
101 <fo:region-before extent="{$taxon-region-before-extent}" region-name="odd-before"/>
102 <fo:region-after extent="{$taxon-region-after-extent}" region-name="odd-after"/>
103 </fo:simple-page-master>
104
105 <!-- layout for even taxon pages -->
106 <fo:simple-page-master master-name="taxon_page_even" page-height="{$global-height-page}"
107 page-width="{$global-width-page}" margin-top="{$taxon-page-top-margin}"
108 margin-bottom="{$taxon-page-bottom-margin}" margin-left="0"
109 margin-right="{$taxon-page-inner-margin}">
110 <fo:region-body margin-left="{$taxon-region-body-outer-margin}"/>
111 <fo:region-before extent="{$taxon-region-before-extent}" region-name="even-before"/>
112 <fo:region-after extent="{$taxon-region-after-extent}" region-name="even-after"/>
113
114 <!--fo:leader leader-pattern="rule" leader-length="10mm"/-->
115
116 </fo:simple-page-master>
117
118
119 <!-- defines repeatable page-sequence for layout of taxa -->
120 <fo:page-sequence-master master-name="taxon_page">
121 <fo:repeatable-page-master-alternatives>
122 <fo:conditional-page-master-reference master-reference="taxon_page_odd"
123 page-position="first"/>
124 <fo:conditional-page-master-reference master-reference="taxon_page_even"
125 page-position="rest" odd-or-even="even"/>
126 <fo:conditional-page-master-reference master-reference="taxon_page_odd"
127 page-position="rest" odd-or-even="odd"/>
128 <!-- <fo:conditional-page-master-reference master-reference="mclBoook_taxon_page_even"
129 page-position="last"/>-->
130 </fo:repeatable-page-master-alternatives>
131 </fo:page-sequence-master>
132 </fo:layout-master-set>
133 <!-- end: defines page layout -->
134
135 <!-- page sequence for taxon view -->
136 <fo:page-sequence master-reference="taxon_page"
137 initial-page-number="{$taxon-page-number-initial}" force-page-count="no-force">
138
139 <fo:static-content flow-name="odd-before">
140 <xsl:call-template name="right-extent"/>
141 </fo:static-content>
142
143 <fo:static-content flow-name="even-before">
144 <xsl:call-template name="left-extent"/>
145 </fo:static-content>
146
147 <!-- format taxa -->
148 <fo:flow flow-name="xsl-region-body">
149 <fo:block font-family="{$global-family-font}" font-size="{$global-size-font}"
150 line-height="{$global-line-height}">
151 <xsl:for-each select="//TaxonNode">
152 <xsl:apply-templates select="."/>
153 </xsl:for-each>
154 </fo:block>
155 </fo:flow>
156
157
158 </fo:page-sequence>
159 </fo:root>
160 </xsl:template>
161
162 <!-- HEADER -->
163
164 <xsl:template name="right-extent">
165 <!--fo:block text-align="center">Page <fo:page-number/>
166 </fo:block-->
167 <fo:block font-family="{$taxon-header-family-font}" font-style="{$taxon-header-style-font}"
168 font-size="{$taxon-header-size-font}">
169 <!-- No pagination at the moment -->
170 <fo:block font-size="{$taxon-header-page-number-size-font}" font-style="normal"
171 padding-top="95%" text-align="end">| <fo:page-number padding-right="10%"
172 border-right-width="11mm"/></fo:block>
173 <!--text-align="{$taxon-header-page-number-align-text}"> | <fo:page-number/></fo:block> -->
174 <!--margin-right="{$taxon-region-body-outer-margin}" -->
175 <!-- &#x2014; -->
176 <fo:block color="white">-</fo:block>
177 <fo:block>
178 <fo:retrieve-marker retrieve-class-name="pageTitleMarker"
179 retrieve-position="first-starting-within-page" retrieve-boundary="document"/>
180 <xsl:text> </xsl:text>
181 <fo:retrieve-marker retrieve-class-name="pageTitleSectionMarker"
182 retrieve-position="first-starting-within-page" retrieve-boundary="document"/>
183 </fo:block>
184 </fo:block>
185 </xsl:template>
186
187 <xsl:template name="left-extent">
188 <fo:block font-family="{$taxon-header-family-font}" font-style="{$taxon-header-style-font}"
189 font-size="{$taxon-header-size-font}">
190 <fo:block font-size="{$taxon-header-page-number-size-font}" font-style="normal"
191 padding-top="95%" text-align="start"><fo:page-number padding-left="10%"
192 border-right-width="11mm"/> |</fo:block>
193 <!-- No pagination at the moment
194 <fo:block font-size="{$taxon-header-page-number-size-font}"
195 text-align="{$taxon-header-page-number-align-text}"> &#x2014; <fo:page-number/> &#x2014;
196 </fo:block> -->
197 </fo:block>
198 </xsl:template>
199
200 <!--xsl:template name="odd-after-header">
201 <fo:block font-family="{$taxon-header-family-font}" font-style="{$taxon-header-style-font}"
202 font-size="{$taxon-header-size-font}">
203 <fo:block>
204 <fo:inline>
205 <fo:retrieve-marker retrieve-class-name="pageTitleMarker"
206 retrieve-position="last-starting-within-page" retrieve-boundary="document"/>
207 <fo:retrieve-marker retrieve-class-name="pageTitleSectionMarker"
208 retrieve-position="last-starting-within-page" retrieve-boundary="document"/>
209 </fo:inline>
210 </fo:block>
211 </fo:block>
212 </xsl:template-->
213
214
215 <!--xsl:template name="even-before-header">
216 <fo:block font-family="{$taxon-header-family-font}" font-style="{$taxon-header-style-font}"
217 font-size="{$taxon-header-size-font}"-->
218 <!--
219 No pagination at the moment
220 <fo:block color="white" font-size="{$taxon-header-page-number-size-font}">-</fo:block>
221 <fo:block color="white">-</fo:block>-->
222 <!--
223 <fo:block>
224 <fo:inline>
225 <fo:retrieve-marker retrieve-class-name="pageTitleMarker"
226 retrieve-position="first-starting-within-page" retrieve-boundary="document"/>
227 <fo:retrieve-marker retrieve-class-name="pageTitleSectionMarker"
228 retrieve-position="first-starting-within-page" retrieve-boundary="document"/>
229 </fo:inline>
230 </fo:block>
231 </fo:block>
232
233 </xsl:template-->
234
235 <xsl:template name="even-after-header">
236 <fo:block font-family="{$taxon-header-family-font}" font-style="{$taxon-header-style-font}"
237 font-size="{$taxon-header-size-font}">
238 <fo:block>
239 <fo:inline>
240 <fo:retrieve-marker retrieve-class-name="pageTitleMarker"
241 retrieve-position="last-starting-within-page" retrieve-boundary="document"/>
242 <fo:retrieve-marker retrieve-class-name="pageTitleSectionMarker"
243 retrieve-position="last-starting-within-page" retrieve-boundary="document"/>
244 </fo:inline>
245 </fo:block>
246 <!-- No pagination at the moment
247 <fo:block color="white">-</fo:block>
248 <fo:block font-size="{$taxon-header-page-number-size-font}"
249 text-align="{$taxon-header-page-number-align-text}"> &#x2014; <fo:page-number/> &#x2014;
250 </fo:block> -->
251 </fo:block>
252 </xsl:template>
253
254 <!-- GENERAL -->
255
256 <xsl:template match="TaxonNode" name="TaxonNode">
257 <xsl:apply-templates select="Taxon"/>
258 </xsl:template>
259
260 <xsl:template match="Taxon" name="Taxon">
261 <xsl:call-template name="title"/>
262 <xsl:apply-templates select="synonymy"/>
263 <xsl:apply-templates select="descriptions"/>
264 <xsl:apply-templates select="key"/>
265 </xsl:template>
266
267
268 <xsl:template name="title">
269 <fo:block margin-bottom="5mm">
270 <!-- we need to find a way to store the uuid in a variable xsl:parameter did not work or i was using it wrong -->
271 <xsl:choose>
272 <!-- family -->
273 <xsl:when test="name/rank/uuid='af5f2481-3192-403f-ae65-7c957a0f02b6'">
274 <fo:block text-align="center" text-transform="uppercase">
275 <xsl:apply-templates select="name/genusOrUninomial"/>
276 </fo:block>
277 </xsl:when>
278 <!-- genus -->
279 <xsl:when test="name/rank/uuid='1b11c34c-48a8-4efa-98d5-84f7f66ef43a'">
280 <fo:block font-weight="bold" text-align="center" text-transform="uppercase">
281 <xsl:apply-templates select="name/genusOrUninomial"/>
282 </fo:block>
283 </xsl:when>
284 <!-- subgenus -->
285 <xsl:when test="name/rank/uuid='78786e16-2a70-48af-a608-494023b91904'">
286 <fo:block font-weight="bold" text-align="center">
287 <xsl:apply-templates select="name/rank/representation_L10n"/>
288 <xsl:text> </xsl:text>
289 <xsl:apply-templates select="name/genusOrUninomial"/>
290 </fo:block>
291 </xsl:when>
292 <!-- species -->
293 <xsl:when test="name/rank/uuid='b301f787-f319-4ccc-a10f-b4ed3b99a86d'">
294 <fo:block font-weight="bold" text-align="center">
295 <xsl:apply-templates select="name/genusOrUninomial"/>
296 <xsl:text> </xsl:text>
297 <xsl:apply-templates select="name/specificEpithet"/>
298 </fo:block>
299 </xsl:when>
300 <xsl:otherwise>
301 <!-- for debugging --> Unformatted title for rank uuid: <xsl:value-of
302 select="name/rank/uuid"/>: <xsl:value-of select="name/titleCache"/>
303 </xsl:otherwise>
304 </xsl:choose>
305 </fo:block>
306 </xsl:template>
307
308 <!-- NAME -->
309
310 <xsl:template match="name">
311 <xsl:apply-templates select="taggedName"/>
312 <xsl:apply-templates select="nomenclaturalReference"/>
313 </xsl:template>
314
315 <xsl:template match="taggedName">
316 <xsl:for-each select="e">
317 <xsl:choose>
318 <xsl:when test="type='name'">
319 <fo:inline font-style="italic">
320 <xsl:value-of select="text"/>
321 </fo:inline>
322 <xsl:text> </xsl:text>
323 </xsl:when>
324 <xsl:when test="type='authors'">
325 <xsl:value-of select="text"/>
326 </xsl:when>
327 <xsl:otherwise>
328 <xsl:value-of select="text"/>
329 <xsl:text> </xsl:text>
330 </xsl:otherwise>
331 </xsl:choose>
332 </xsl:for-each>
333 </xsl:template>
334
335 <!-- first date in brackets -->
336 <xsl:template match="nomenclaturalReference">
337 <xsl:text> (</xsl:text>
338 <fo:inline>
339 <xsl:value-of select="authorTeam/titleCache"/>
340 <xsl:text> </xsl:text>
341 <xsl:value-of select="datePublished/start"/>: </fo:inline>
342 <xsl:text> </xsl:text>
343 <fo:inline>
344 <xsl:value-of select="../nomenclaturalMicroReference"/>
345 </fo:inline>
346 <xsl:text>)</xsl:text>
347 </xsl:template>
348
349 <!-- DESCRIPTIONS -->
350
351 <xsl:template match="descriptions" name="descriptions">
352 <xsl:for-each select="features/feature">
353 <xsl:choose>
354 <xsl:when test="count(feature)!=0">
355 <xsl:call-template name="secondLevelDescriptionElements"/>
356 </xsl:when>
357 <xsl:otherwise>
358 <!-- everything except Citation -->
359 <xsl:if test="uuid!='99b2842f-9aa7-42fa-bd5f-7285311e0101'">
360 <xsl:call-template name="descriptionElements"/>
361 </xsl:if>
362 <!--xsl:apply-templates select="media/e/representations/e/parts/e/uri"/-->
363 </xsl:otherwise>
364 </xsl:choose>
365 </xsl:for-each>
366 </xsl:template>
367
368 <xsl:template name="descriptionElements">
369 <xsl:choose>
370 <xsl:when test="supportsCommonTaxonName='true'">
371 <!-- for example Vernacular Name -->
372 <xsl:call-template name="commonTaxonName"/>
373 </xsl:when>
374 <xsl:otherwise>
375 <!-- for example Habitat, Material Examined -->
376 <xsl:call-template name="textData"/>
377 </xsl:otherwise>
378 </xsl:choose>
379 </xsl:template>
380
381 <xsl:template name="secondLevelDescriptionElements">
382 <fo:block text-align="justify" margin-bottom="5mm">
383 <!--fo:external-graphic src='http://lully.snv.jussieu.fr/xper2AppletThumbnailsMaker/sdd/images/ant_anatomy2.jpg'/-->
384 <xsl:for-each select="feature">
385
386 <xsl:variable name="representation" select="representation_L10n"/>
387 <xsl:if test="not(starts-with($representation, 'Material'))">
388 <!--xsl:if test="not(starts-with($representation, 'Figures'))"-->
389 <fo:inline keep-with-next.within-line="always">
390
391 <xsl:if test="not(starts-with($representation, 'Figures'))">
392 <fo:inline text-decoration="underline" keep-with-next.within-line="always">
393
394 <xsl:value-of select="representation_L10n"/>
395 </fo:inline>
396 <fo:inline>: </fo:inline>
397 </xsl:if>
398
399 <xsl:for-each select="descriptionelements/descriptionelement">
400
401 <xsl:variable name="desc_element_text" select="multilanguageText_L10n/text"/>
402
403 <!-- 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-->
404 <xsl:variable name="prev_desc_element_text"
405 select="preceding-sibling::descriptionelement[1]/multilanguageText_L10n/text"/>
406
407 <fo:inline font-size="9pt" space-after="5mm">
408
409 <xsl:if test="not(starts-with($desc_element_text, 'Figure'))">
410
411 <xsl:choose>
412 <xsl:when test="position() = 1">
413 <xsl:apply-templates select="multilanguageText_L10n/text"/>
414 </xsl:when>
415 <xsl:otherwise>
416 <xsl:if test="$desc_element_text != $prev_desc_element_text">
417 <!-- checked in the tax editor and looks like only descriptionelement[1] refers to the species so don't need below-->
418 <!--xsl:apply-templates select="multilanguageText_L10n/text"/-->
419 </xsl:if>
420 </xsl:otherwise>
421 </xsl:choose>
422
423 </xsl:if>
424
425 </fo:inline>
426
427 <!--xsl:apply-templates select="multilanguageText_L10n/text"/-->
428 <!--xsl:apply-templates select="media"/-->
429
430 <!--TODO Lorna we need to work out which description element contains the uri node for each figure
431 and place it next to the appropriate taxon in the output-->
432
433 <!--xsl:if test="not(starts-with($representation, 'Figures'))"-->
434 <xsl:if test="position() = 1">
435 <!--xsl:value-of select="../../../../../../Taxon/name/titleCache"/-->
436 <xsl:apply-templates select="media/e/representations/e/parts/e/uri"/>
437 </xsl:if>
438 <!--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-->
439
440 </xsl:for-each>
441
442 <xsl:text> </xsl:text>
443 </fo:inline>
444 </xsl:if>
445 <!--/xsl:if-->
446 </xsl:for-each>
447
448
449 <!--xsl:apply-templates select="../../../../../../../../../synonymy[1]/homotypicSynonymsByHomotypicGroup[1]/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-->
450
451 </fo:block>
452
453 </xsl:template>
454
455 <!-- IMAGES -->
456
457 <!--xsl:template match="media"-->
458 <xsl:template match="uriprob">
459 <fo:block>
460 <xsl:variable name="graphic" select="."/>
461 <fo:external-graphic content-height="450%" scaling="uniform" src="{$graphic}"
462 padding-before="100" padding-after="30"/>
463 <!--xsl:apply-templates select="../multilanguageText_L10n/text"/-->
464 <fo:inline font-size="{$taxon-name-size-font}">
465 <xsl:apply-templates select="../../../../../../../multilanguageText_L10n/text"/>
466 </fo:inline>
467 </fo:block>
468 </xsl:template>
469
470 <xsl:template match="uri">
471 <!--fo:block text-align="center"-->
472 <fo:block keep-with-next="always" text-align="center">
473
474 <!--fo:inline text-align="center"-->
475 <!--xsl:variable name="graphic" select="e/representations/e/parts/e/uri"/-->
476
477 <!-- Is there a description element of type Figure for this TaxonNode?-->
478
479 <xsl:variable name="graphic" select="."/>
480
481 <fo:external-graphic content-height="scale-to-fit" height="{$graphic-height}"
482 scaling="uniform" src="{$graphic}" padding-before="30" padding-after="2"
483 display-align="center"/>
484 <!--/fo:inline-->
485 </fo:block>
486 <fo:block>
487 <fo:leader leader-pattern="rule" leader-alignment="{$taxon-page-inner-margin}"
488 rule-thickness="0.8pt" leader-length="114mm"/>
489 </fo:block>
490 <fo:block>
491
492 <!--fo:leader leader-pattern="rule" leader-length="120mm"/-->
493 <fo:inline font-size="{$taxon-name-size-font}">
494 <!--go back up to the description element and get the text for the Figure legend -->
495 <xsl:apply-templates select="../../../../../../../multilanguageText_L10n/text"/>
496 </fo:inline>
497 </fo:block>
498 </xsl:template>
499
500
501 <xsl:template match="text">
502 <!--fo:block font-size="9pt" space-after="5mm" -->
503 <!--xsl:apply-templates select="node()"/-->
504 <!--xsl:call-template name="add-markup">
505 <xsl:with-param name="str" select="."/>
506
507 <xsl:with-param name="tag-name" select="b"/>
508 </xsl:call-template-->
509 <xsl:choose>
510 <xsl:when test="contains(.,&quot;&lt;b&gt;&quot;)">
511 <xsl:call-template name="add-markup">
512 <xsl:with-param name="str" select="."/>
513 <!--xsl:with-param name="tag-name" select="b"/-->
514 <xsl:with-param name="tag-name">b</xsl:with-param>
515 </xsl:call-template>
516 </xsl:when>
517 <xsl:otherwise>
518 <xsl:call-template name="add-markup">
519 <xsl:with-param name="str" select="."/>
520 <xsl:with-param name="tag-name">i</xsl:with-param>
521 </xsl:call-template>
522 </xsl:otherwise>
523 </xsl:choose>
524
525 <!--/fo:block -->
526 </xsl:template>
527
528 <!-- TODO Make this templates shorter by creating generic template for replacing html codes 2013 and 2014-->
529 <!-- TODO - make this more generic so it call also handle bold tags -->
530 <xsl:template name="add-markup">
531 <xsl:param name="str"/>
532 <xsl:param name="tag-name"/>
533 <xsl:variable name="opening-tag">
534 <xsl:value-of select="concat('&quot;&lt;', $tag-name, '&gt;&quot;')"> </xsl:value-of>
535 </xsl:variable>
536 <xsl:variable name="closing-tag">
537 <xsl:value-of select="concat('&quot;&lt;/', $tag-name, '&gt;&quot;')"> </xsl:value-of>
538 </xsl:variable>
539
540 <xsl:choose>
541 <!--select="concat(substring-before($value, '&amp;#x2013;')-->
542 <!--xsl:when test="contains($str,&quot;&lt;{$tag-name}&gt;&quot;)"-->
543 <xsl:when test="contains($str, $opening-tag)">
544 <xsl:variable name="before-first-i"
545 select="substring-before($str, $opening-tag)"/>
546 <!--xsl:variable name="inside-first-i" select="substring-before(substring-after($str,'&lt;{$tag-name}&gt;'),'&lt;/{$tag-name}&gt;')"/-->
547 <xsl:variable name="inside-first-i" select="substring-before(substring-after($str,$opening-tag),$closing-tag)"/>
548 <xsl:variable name="after-first-i" select="substring-after($str, $closing-tag)"/>
549 <!--xsl:variable name="after-first-i" select="substring-after($str,&quot;&lt;/{$tag-name}&gt;&quot;)"/-->
550 <xsl:choose>
551 <xsl:when test="contains($before-first-i, '#x2014;')">
552 <xsl:call-template name="replace-mdash-html">
553 <xsl:with-param name="value" select="$before-first-i"/>
554 </xsl:call-template>
555 </xsl:when>
556 <xsl:otherwise>
557 <xsl:choose>
558 <xsl:when test="contains($before-first-i, '#x2013;')">
559 <xsl:call-template name="replace-ndash-html">
560 <xsl:with-param name="value" select="$before-first-i"/>
561 </xsl:call-template>
562 </xsl:when>
563 <xsl:otherwise>
564 <xsl:value-of select="$before-first-i"/>
565 </xsl:otherwise>
566 </xsl:choose>
567 <!--xsl:value-of select="$before-first-i"/></xsl:otherwise-->
568 </xsl:otherwise>
569 </xsl:choose>
570 <fo:inline font-style="italic" font-weight="bold">
571 <xsl:value-of select="$inside-first-i"/>
572 </fo:inline>
573 <xsl:call-template name="add-markup">
574 <xsl:with-param name="str" select="$after-first-i"/>
575 <xsl:with-param name="tag-name" select="$tag-name"/>
576 </xsl:call-template>
577 </xsl:when>
578 <xsl:otherwise>
579 <xsl:choose>
580 <xsl:when test="contains($str, '#x2014;')">
581 <xsl:call-template name="replace-mdash-html">
582 <xsl:with-param name="value" select="$str"/>
583 </xsl:call-template>
584 </xsl:when>
585 <xsl:otherwise>
586 <xsl:choose>
587 <xsl:when test="contains($str, '#x2013;')">
588 <xsl:call-template name="replace-ndash-html">
589 <xsl:with-param name="value" select="$str"/>
590 </xsl:call-template>
591 </xsl:when>
592 <xsl:otherwise>
593 <xsl:value-of select="$str"/>
594 </xsl:otherwise>
595 </xsl:choose>
596 </xsl:otherwise>
597 </xsl:choose>
598 </xsl:otherwise>
599 </xsl:choose>
600 </xsl:template>
601
602 <xsl:template name="replace-mdash-html-new">
603 <xsl:param name="value"/>
604 <xsl:choose>
605 <xsl:when test="contains($value, '#x2013;')">
606 <xsl:variable name="replaced-ndash"
607 select="concat(substring-before($value, '&amp;#x2013;'), '&ndash;', substring-after($value, '&amp;#x2013;'))"/>
608 <xsl:value-of
609 select="concat(substring-before($replaced-ndash, '&amp;#x2014;'), '&mdash;', substring-after($replaced-ndash, '&amp;#x2014;'))"
610 />
611 </xsl:when>
612 <xsl:otherwise>
613 <xsl:value-of
614 select="concat(substring-before($value, '&amp;#x2014;'), '&mdash;', substring-after($value, '&amp;#x2014;'))"
615 />
616 </xsl:otherwise>
617 </xsl:choose>
618
619 </xsl:template>
620
621 <xsl:template name="replace-ndash-html">
622 <xsl:param name="value"/>
623 <xsl:value-of
624 select="concat(substring-before($value, '&amp;#x2013;'), '&ndash;', substring-after($value, '&amp;#x2013;'))"
625 />
626 </xsl:template>
627
628 <xsl:template name="replace-mdash-html">
629 <xsl:param name="value"/>
630 <xsl:value-of
631 select="concat(substring-before($value, '&amp;#x2014;'), '&mdash;', substring-after($value, '&amp;#x2014;'))"
632 />
633 </xsl:template>
634
635 <xsl:template name="remove_ampersands">
636 <xsl:param name="str"/>
637 <xsl:choose>
638 <xsl:when test="contains($str,&quot;amp;&quot;)"> </xsl:when>
639 </xsl:choose>
640 </xsl:template>
641
642 <xsl:template name="remove">
643 <xsl:param name="value"/>
644 <xsl:value-of select="concat(substring-before($value, 'amp;'), substring-after($value, 'amp;'))"
645 />
646 </xsl:template>
647
648 <!--xsl:template match="i">
649 <fo:inline font-style="italic">
650 <xsl:apply-templates select="node()"/>
651 </fo:inline>
652 </xsl:template-->
653
654 <xsl:template match="i">
655 <fo:inline font-style="italic">
656 <xsl:apply-templates/>
657 </fo:inline>
658 </xsl:template>
659
660 <xsl:template match="i//text()">
661 <fo:inline font-style="italic">
662 <xsl:apply-templates/>
663 </fo:inline>
664 </xsl:template>
665
666
667 <xsl:template name="commonTaxonName">
668 <fo:inline font-weight="bold">
669 <xsl:value-of select="representation_L10n"/>
670 </fo:inline>
671 <xsl:text> &mdash; </xsl:text>
672 <xsl:for-each select="descriptionelements/descriptionelement">
673 <fo:inline>
674 <xsl:choose>
675 <xsl:when test="position() != last()">
676 <xsl:value-of select="name"/> (<xsl:value-of select="language/representation_L10n"/>), </xsl:when>
677 <xsl:otherwise>
678 <xsl:value-of select="name"/> (<xsl:value-of select="language/representation_L10n"
679 />).</xsl:otherwise>
680 </xsl:choose>
681 </fo:inline>
682 </xsl:for-each>
683 </xsl:template>
684
685 <xsl:template name="commonTaxonNameold2">
686 <fo:inline font-weight="bold">
687 <xsl:value-of select="representation_L10n"/>
688 </fo:inline>
689 <xsl:text> &mdash; </xsl:text>
690 <xsl:for-each select="descriptionelements/descriptionelement">
691 <fo:inline>
692 <xsl:value-of select="name"/> (<xsl:value-of select="language/representation_L10n"/>) <xsl:choose>
693 <xsl:when test="position() != last()">,</xsl:when>
694 <xsl:otherwise>.</xsl:otherwise>
695 </xsl:choose>
696 </fo:inline>
697 </xsl:for-each>
698 </xsl:template>
699
700 <xsl:template name="commonTaxonNameold">
701 <fo:inline font-weight="bold">
702 <xsl:value-of select="representation_L10n"/>
703 </fo:inline>
704 <xsl:text> &mdash; </xsl:text>
705 <xsl:for-each select="descriptionelements/descriptionelement">
706 <fo:inline>
707 <xsl:value-of select="name"/> (<xsl:value-of select="language/representation_L10n"/>),
708 </fo:inline>
709 </xsl:for-each>
710 </xsl:template>
711
712 <xsl:template name="textData">
713 <fo:block text-align="justify" margin-bottom="5mm">
714 <!-- show all feature headlines except "ditribution" -->
715 <!--xsl:if test="uuid!='9fc9d10c-ba50-49ee-b174-ce83fc3f80c6'">
716 <fo:inline font-weight="bold">
717 <xsl:value-of select="representation_L10n"/>
718 </fo:inline>
719 <xsl:text> – </xsl:text>
720 </xsl:if-->
721 <xsl:choose>
722 <!-- 9fc9d10c-ba50-49ee-b174-ce83fc3f80c6 is Distribution -->
723 <xsl:when test="uuid!='9fc9d10c-ba50-49ee-b174-ce83fc3f80c6'">
724 <fo:inline font-weight="bold">
725 <xsl:value-of select="representation_L10n"/>
726 <!-- e.g. Habitat -->
727 </fo:inline>
728 <xsl:text> &mdash; </xsl:text>
729 </xsl:when>
730 <xsl:otherwise>
731 <fo:inline font-weight="bold">
732 <xsl:text> Matériel examiné </xsl:text>
733 </fo:inline>
734 </xsl:otherwise>
735
736 </xsl:choose>
737 <!--xsl:for-each select="descriptionelements/descriptionelement">
738 <fo:inline>
739 <xsl:text>LINE 609</xsl:text>
740 <xsl:apply-templates select="multilanguageText_L10n/text"/>
741 </fo:inline>
742 </xsl:for-each-->
743
744 <!-- LORNA TRY IMAGE HERE -->
745 <!--xsl:apply-templates select="descriptionelements/descriptionelement[1]/media/e/representations/e/parts/e/uri"/-->
746
747 <xsl:apply-templates
748 select="descriptionelements/descriptionelement[1]/multilanguageText_L10n/text"/>
749 </fo:block>
750 </xsl:template>
751
752 <xsl:template match="key" name="key">
753 <!--fo:block margin-bottom="5mm" line-height="{$taxon-name-line-height}" font-size="{$taxon-name-size-font}"-->
754 <fo:block linefeed-treatment="preserve">
755
756 <fo:block font-weight="bold" text-align="center">
757 <xsl:value-of select="HashMap/titleCache"/>
758 </fo:block>
759 <xsl:if test="HashMap/records/e">
760 <xsl:text>&#xA;</xsl:text>
761 <fo:table>
762 <fo:table-column column-width="5mm"/>
763 <fo:table-column column-width="5mm"/>
764 <fo:table-column column-width="69mm"/>
765 <fo:table-column column-width="36mm"/>
766 <fo:table-body>
767 <!--xsl:if test="ArrayList/e"-->
768 <xsl:for-each select="HashMap/records/e">
769
770 <!-- TaxonLinkDto or PolytomousKeyNodeLinkDto-->
771 <fo:table-row>
772 <fo:table-cell>
773 <fo:block>
774 <xsl:if test="edgeNumber = 1">
775 <xsl:value-of select="nodeNumber"/>
776 <xsl:text>.</xsl:text>
777 </xsl:if>
778 </fo:block>
779 </fo:table-cell>
780 <fo:table-cell>
781 <fo:block>&ndash;</fo:block>
782 </fo:table-cell>
783 <fo:table-cell>
784 <!--fo:block>
785 <xsl:apply-templates select="childStatement"/-->
786 <!--xsl:value-of select="concat(childStatement, '..............')"/-->
787 <!--xsl:text>.......................................................................................</xsl:text>
788 </fo:block-->
789 <fo:block text-align="justify" text-align-last="justify">
790 <!-- leader-length="auto"-->
791 <xsl:value-of select="childStatement"/>
792 <xsl:text> </xsl:text>
793 <fo:leader leader-pattern="dots"/>
794 </fo:block>
795
796 </fo:table-cell>
797 <fo:table-cell display-align="after">
798 <fo:block font-style="italic" text-align="justify" text-align-last="justify">
799 <!-- leader-length="auto" text-align="right"-->
800 <fo:leader leader-pattern="dots"/>
801 <xsl:choose>
802 <xsl:when test="links/e[1]/class = 'PolytomousKeyNodeLinkDto'">
803 <xsl:value-of select="links/e[1]/nodeNumber"/>
804 </xsl:when>
805 <xsl:when test="links/e[1]/class = 'TaxonLinkDto'">
806 <xsl:variable name="taxonUuid" select="links/e[1]/uuid"/>
807 <xsl:variable name="genus"
808 select="//Taxon/uuid[.=$taxonUuid]/../name/genusOrUninomial"/>
809 <xsl:choose>
810 <xsl:when test="taxonUuid = $uuidSubgenus">
811 <xsl:variable name="repr"
812 select="//Taxon/uuid[.='71cd0e8d-47eb-4c66-829a-e21c705ee660']/../name/rank/representation_L10n"/>
813 <xsl:value-of select="concat($substring($genus,1,1), '. ', $repr)"/>
814 </xsl:when>
815 <xsl:when test="taxonUuid = $uuidGenus">
816 <fo:block font-weight="bold" text-align="center"
817 text-transform="uppercase">
818 <xsl:apply-templates select="$genus"/>
819 </fo:block>
820 </xsl:when>
821 <xsl:otherwise>
822 <xsl:variable name="specificEpithet"
823 select="//Taxon/uuid[.=$taxonUuid]/../name/specificEpithet"/>
824 <!-- abbreviate the genus for species names -->
825 <xsl:value-of
826 select="concat(substring($genus,1,1), '. ', $specificEpithet)"/>
827 </xsl:otherwise>
828 </xsl:choose>
829 </xsl:when>
830 <xsl:otherwise/>
831 </xsl:choose>
832 </fo:block>
833 </fo:table-cell>
834 </fo:table-row>
835 </xsl:for-each>
836
837 </fo:table-body>
838 </fo:table>
839 <fo:leader leader-pattern="rule" leader-length="100%"/>
840 <xsl:text>&#xA;</xsl:text>
841 </xsl:if>
842 <!-- new line for the end of the section -->
843 <xsl:text>&#xA;</xsl:text>
844 </fo:block>
845 </xsl:template>
846
847
848 <!-- SYNONYMY BLOCK -->
849
850 <xsl:template match="synonymy" name="synonymy">
851 <fo:block margin-bottom="5mm" line-height="{$taxon-name-line-height}"
852 font-size="{$taxon-name-size-font}">
853 <fo:block text-align="justify" text-indent="-{$taxon-name-indentation}"
854 start-indent="{$taxon-name-indentation}">
855 <xsl:apply-templates select="../name"/>
856 <!--xsl:call-template name="citations"/-->
857 <!-- 99b2842f-9aa7-42fa-bd5f-7285311e0101 is Citation -->
858 <xsl:call-template name="citations">
859 <xsl:with-param name="descriptionelements"
860 select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
861 <xsl:with-param name="name-uuid" select="../name/uuid"/>
862 </xsl:call-template>
863 <xsl:text>.**********</xsl:text>
864 <xsl:apply-templates select="homotypicSynonymsByHomotypicGroup"/>
865 <xsl:apply-templates select="../name/typeDesignations"/>
866 </fo:block>
867 <xsl:apply-templates select="heterotypicSynonymyGroups"/>
868 </fo:block>
869 </xsl:template>
870
871 <xsl:template match="homotypicSynonymsByHomotypicGroup">
872 <xsl:for-each select="e">
873 <xsl:text> - </xsl:text>
874 <xsl:apply-templates select="name"/>
875 <xsl:call-template name="citations">
876 <!--LORNA Pass the description elements for the citation 99b2842f-9aa7-42fa-bd5f-7285311e0101 -->
877 <xsl:with-param name="descriptionelements"
878 select="../../../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
879 <xsl:with-param name="name-uuid" select="name/uuid"/>
880 </xsl:call-template>
881 </xsl:for-each>
882
883 <!--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-->
884 </xsl:template>
885
886 <xsl:template match="heterotypicSynonymyGroups">
887 <xsl:for-each select="e">
888 <fo:block text-align="start" text-indent="-{$taxon-name-indentation}"
889 start-indent="{$taxon-name-indentation}">
890 <xsl:for-each select="e">
891 <xsl:apply-templates select="name"/>
892 <xsl:call-template name="citations">
893 <xsl:with-param name="descriptionelements"
894 select="../../../../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
895 <xsl:with-param name="name-uuid" select="name/uuid"/>
896 </xsl:call-template>
897 <xsl:apply-templates select="name/typeDesignations"/>
898 </xsl:for-each>
899 <!--xsl:apply-templates select="e[1]/name/typeDesignations" /-->
900 </fo:block>
901 </xsl:for-each>
902 </xsl:template>
903
904 <xsl:template name="citations">
905 <xsl:param name="name-uuid"/>
906 <xsl:param name="descriptionelements"/>
907 <!--xsl:for-each
908 select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements/descriptionelement"-->
909 <xsl:for-each select="$descriptionelements/descriptionelement">
910 <!-- TODO sorting only works for the first citation, implement correctly -->
911 <xsl:sort select="sources/e[1]/citation/datePublished/start"/>
912 <xsl:for-each select="sources/e">
913 <xsl:if test="nameUsedInSource/uuid=$name-uuid">
914 <xsl:text>; </xsl:text>
915 <fo:inline>
916 <!--xsl:value-of select="citation/authorTeam/titleCache"/-->
917 <xsl:for-each select="citation/authorTeam/teamMembers/e">
918 <xsl:value-of select="lastname"/>
919 <xsl:choose>
920 <xsl:when test="position() != last()">
921 <xsl:text> &amp; </xsl:text>
922 </xsl:when>
923 </xsl:choose>
924 </xsl:for-each>
925
926 <xsl:value-of select="citation/authorTeam/lastname"/>
927 <xsl:text> (</xsl:text>
928 <xsl:value-of select="citation/datePublished/start"/>
929 <xsl:text>: </xsl:text>
930 <xsl:value-of select="citationMicroReference"/>
931 <xsl:text>)</xsl:text>
932 </fo:inline>
933 </xsl:if>
934 </xsl:for-each>
935 </xsl:for-each>
936 </xsl:template>
937
938 <xsl:template match="typeDesignations">
939 <xsl:for-each select="child::*">
940 <fo:inline>
941 <xsl:text> - Type: </xsl:text>
942 <xsl:choose>
943 <xsl:when test="class='SpecimenTypeDesignation'">
944 <xsl:value-of select="typeSpecimen/titleCache"/>
945 </xsl:when>
946 </xsl:choose>
947 </fo:inline>
948 </xsl:for-each>
949 </xsl:template>
950
951
952 </xsl:stylesheet>