Project

General

Profile

Download (18.9 KB) Statistics
| Branch: | Tag: | Revision:
1
<?xml version="1.0" encoding="UTF-8"?>
2

    
3
<!--
4
  
5
  CDM XSL Transformation
6
  Target Format: Flora Malesiana
7
  
8
  -->
9
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10
  xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
11

    
12
  <!-- ############### Constants and definitions ################### -->
13

    
14
  <!-- **********************************
15
    ** global definitions 
16
    *********************************** -->
17
  <xsl:param name="global-family-font">Times</xsl:param>
18
  <xsl:param name="global-size-font">12pt</xsl:param>
19
  <xsl:param name="global-line-height">1.2em</xsl:param>
20

    
21
  <xsl:param name="global-height-page">297mm</xsl:param>
22
  <xsl:param name="global-width-page">210mm</xsl:param>
23

    
24
  <xsl:param name="global-indentation">8mm</xsl:param>
25

    
26
  <!-- **********************************   
27
    ** definitions for taxon pages
28
    *********************************** -->
29
  <xsl:param name="taxon-page-top-margin">0mm</xsl:param>
30
  <xsl:param name="taxon-page-right-margin">32mm</xsl:param>
31
  <xsl:param name="taxon-page-bottom-margin">0mm</xsl:param>
32
  <xsl:param name="taxon-page-left-margin">32mm</xsl:param>
33

    
34
  <xsl:param name="taxon-region-body-top-margin">26mm</xsl:param>
35
  <xsl:param name="taxon-region-body-bottom-margin">28mm</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="taxon-header-family-font">Times</xsl:param>
41
  <xsl:param name="taxon-header-before-bg-color">white</xsl:param>
42
  <xsl:param name="content-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">9pt</xsl:param>
45
  <xsl:param name="taxon-header-style-font">italic</xsl:param>
46
  <xsl:param name="taxon-header-page-number-size-font">8pt</xsl:param>
47
  <xsl:param name="taxon-header-page-number-align-text">end</xsl:param>
48

    
49
  <xsl:param name="taxon-page-number-initial">1</xsl:param>
50

    
51
  <xsl:param name="uuidFamily">210a8214-4e69-401a-8e47-c7940d990bdd</xsl:param>
52
  <xsl:param name="uuidGenus">1b11c34c-48a8-4efa-98d5-84f7f66ef43a</xsl:param>
53
  <xsl:param name="uuidSubgenus">78786e16-2a70-48af-a608-494023b91904</xsl:param>
54

    
55
  <!-- **********************************   
56
    ** html support
57
    *********************************** -->
58

    
59
  <!-- format html i tags in text as italic -->
60
  <xsl:template match="i">
61
    <fo:inline font-style="italic">
62
      <xsl:value-of select="."/>
63
    </fo:inline>
64
  </xsl:template>
65

    
66
  <!-- format html b tags in text as bold -->
67
  <xsl:template match="b">
68
    <fo:inline font-weight="bold">
69
      <xsl:apply-templates/>
70
    </fo:inline>
71
  </xsl:template>
72

    
73
  <!-- ########################################################################## -->
74

    
75

    
76
  <!-- start xsl output -->
77
  <xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="no"/>
78
  <xsl:param name="versionParam" select="'1.0'"/>
79

    
80
  <!-- root element: root -->
81
  <xsl:template match="root">
82
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
83

    
84
      <!-- defines page layout -->
85
      <fo:layout-master-set>
86

    
87
        <!-- layout for odd taxon pages -->
88
        <fo:simple-page-master master-name="taxon_page_odd" page-height="{$global-height-page}"
89
          page-width="{$global-width-page}" margin-top="{$taxon-page-top-margin}"
90
          margin-bottom="{$taxon-page-bottom-margin}" margin-left="{$taxon-page-left-margin}"
91
          margin-right="{$taxon-page-right-margin}">
92
          <fo:region-body margin-top="{$taxon-region-body-top-margin}"
93
            margin-bottom="{$taxon-region-body-bottom-margin}"/>
94
          <fo:region-before extent="{$taxon-region-before-extent}" region-name="odd-before"/>
95
          <fo:region-after extent="{$taxon-region-after-extent}" region-name="odd-after"/>
96
        </fo:simple-page-master>
97

    
98
        <!-- layout for even taxon pages -->
99
        <fo:simple-page-master master-name="taxon_page_even" page-height="{$global-height-page}"
100
          page-width="{$global-width-page}" margin-top="{$taxon-page-top-margin}"
101
          margin-bottom="{$taxon-page-bottom-margin}" margin-left="{$taxon-page-left-margin}"
102
          margin-right="{$taxon-page-right-margin}">
103
          <fo:region-body margin-top="{$taxon-region-body-top-margin}"
104
            margin-bottom="{$taxon-region-body-bottom-margin}"/>
105
          <fo:region-before extent="{$taxon-region-before-extent}" region-name="even-before"/>
106
          <fo:region-after extent="{$taxon-region-after-extent}" region-name="even-after"/>
107
        </fo:simple-page-master>
108

    
109

    
110

    
111
        <!-- defines repeatable page-sequence for layout of taxa -->
112
        <fo:page-sequence-master master-name="taxon_page">
113
          <fo:repeatable-page-master-alternatives>
114
            <fo:conditional-page-master-reference master-reference="taxon_page_odd"
115
              page-position="first"/>
116
            <fo:conditional-page-master-reference master-reference="taxon_page_odd"
117
              page-position="rest" odd-or-even="even"/>
118
            <fo:conditional-page-master-reference master-reference="taxon_page_even"
119
              page-position="rest" odd-or-even="odd"/>
120
            <!--            <fo:conditional-page-master-reference master-reference="mclBoook_taxon_page_even"
121
              page-position="last"/>-->
122
          </fo:repeatable-page-master-alternatives>
123
        </fo:page-sequence-master>
124
      </fo:layout-master-set>
125
      <!-- end: defines page layout -->
126

    
127
      <!-- page sequence for taxon view -->
128
      <fo:page-sequence master-reference="taxon_page"
129
        initial-page-number="{$taxon-page-number-initial}" force-page-count="no-force">
130

    
131
        <fo:static-content flow-name="odd-before">
132
          <xsl:call-template name="odd-before-header"/>
133
        </fo:static-content>
134

    
135
        <fo:static-content flow-name="even-before">
136
          <xsl:call-template name="even-before-header"/>
137
        </fo:static-content>
138

    
139
        <fo:static-content flow-name="odd-after">
140
          <xsl:call-template name="odd-after-header"/>
141
        </fo:static-content>
142

    
143
        <fo:static-content flow-name="even-after">
144
          <xsl:call-template name="even-after-header"/>
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
      </fo:page-sequence>
158
    </fo:root>
159
  </xsl:template>
160

    
161
  <!-- HEADER -->
162

    
163
  <xsl:template name="odd-before-header">
164

    
165
    <fo:block font-family="{$taxon-header-family-font}" font-style="{$taxon-header-style-font}"
166
      font-size="{$taxon-header-size-font}">
167
      <!-- No pagination at the moment
168
      <fo:block font-size="{$taxon-header-page-number-size-font}"
169
        text-align="{$taxon-header-page-number-align-text}"> &#x2014; <fo:page-number/> &#x2014; </fo:block>
170
        <fo:block color="white">-</fo:block> -->
171
      <fo:block>
172
        <fo:retrieve-marker retrieve-class-name="pageTitleMarker"
173
          retrieve-position="first-starting-within-page" retrieve-boundary="document"/>
174
        <xsl:text> </xsl:text>
175
        <fo:retrieve-marker retrieve-class-name="pageTitleSectionMarker"
176
          retrieve-position="first-starting-within-page" retrieve-boundary="document"/>
177
      </fo:block>
178
    </fo:block>
179

    
180
  </xsl:template>
181

    
182
  <xsl:template name="odd-before-header-endnote">
183
    <fo:block font-family="{$taxon-header-family-font}" font-style="{$taxon-header-style-font}"
184
      font-size="{$taxon-header-size-font}">
185
      <!-- No pagination at the moment
186
      <fo:block font-size="{$taxon-header-page-number-size-font}"
187
        text-align="{$taxon-header-page-number-align-text}"> &#x2014; <fo:page-number/> &#x2014;
188
        </fo:block> -->
189
    </fo:block>
190
  </xsl:template>
191

    
192
  <xsl:template name="odd-after-header">
193
    <fo:block font-family="{$taxon-header-family-font}" font-style="{$taxon-header-style-font}"
194
      font-size="{$taxon-header-size-font}">
195
      <fo:block>
196
        <fo:inline>
197
          <fo:retrieve-marker retrieve-class-name="pageTitleMarker"
198
            retrieve-position="last-starting-within-page" retrieve-boundary="document"/>
199
          <fo:retrieve-marker retrieve-class-name="pageTitleSectionMarker"
200
            retrieve-position="last-starting-within-page" retrieve-boundary="document"/>
201
        </fo:inline>
202
      </fo:block>
203
    </fo:block>
204
  </xsl:template>
205

    
206

    
207
  <xsl:template name="even-before-header">
208
    <fo:block font-family="{$taxon-header-family-font}" font-style="{$taxon-header-style-font}"
209
      font-size="{$taxon-header-size-font}">
210
      <!--
211
      No pagination at the moment  
212
      <fo:block color="white" font-size="{$taxon-header-page-number-size-font}">-</fo:block>
213
      <fo:block color="white">-</fo:block>-->
214
      <fo:block>
215
        <fo:inline>
216
          <fo:retrieve-marker retrieve-class-name="pageTitleMarker"
217
            retrieve-position="first-starting-within-page" retrieve-boundary="document"/>
218
          <fo:retrieve-marker retrieve-class-name="pageTitleSectionMarker"
219
            retrieve-position="first-starting-within-page" retrieve-boundary="document"/>
220
        </fo:inline>
221
      </fo:block>
222
    </fo:block>
223

    
224
  </xsl:template>
225

    
226
  <xsl:template name="even-after-header">
227
    <fo:block font-family="{$taxon-header-family-font}" font-style="{$taxon-header-style-font}"
228
      font-size="{$taxon-header-size-font}">
229
      <fo:block>
230
        <fo:inline>
231
          <fo:retrieve-marker retrieve-class-name="pageTitleMarker"
232
            retrieve-position="last-starting-within-page" retrieve-boundary="document"/>
233
          <fo:retrieve-marker retrieve-class-name="pageTitleSectionMarker"
234
            retrieve-position="last-starting-within-page" retrieve-boundary="document"/>
235
        </fo:inline>
236
      </fo:block>
237
      <!-- No pagination at the moment
238
      <fo:block color="white">-</fo:block>
239
      <fo:block font-size="{$taxon-header-page-number-size-font}"
240
        text-align="{$taxon-header-page-number-align-text}"> &#x2014; <fo:page-number/> &#x2014;
241
        </fo:block> -->
242
    </fo:block>
243
  </xsl:template>
244

    
245
  <!-- GENERAL -->
246

    
247
  <xsl:template match="TaxonNode" name="TaxonNode">
248
    <xsl:apply-templates select="Taxon"/>
249
  </xsl:template>
250

    
251
  <xsl:template match="Taxon" name="Taxon">
252
    <xsl:call-template name="title"/>
253
    <xsl:apply-templates select="synonymy"/>
254
    <xsl:apply-templates select="descriptions"/>
255
  </xsl:template>
256

    
257

    
258
  <xsl:template name="title">
259
    <fo:block margin-bottom="5mm">
260
      <!-- we need to find a way to store the uuid in a variable xsl:parameter did not work or i was using it wrong -->
261
      <xsl:choose>
262
        <!-- family -->
263
        <xsl:when test="name/rank/uuid='af5f2481-3192-403f-ae65-7c957a0f02b6'">
264
          <fo:block text-align="center" text-transform="uppercase">
265
            <xsl:apply-templates select="name/genusOrUninomial"/>
266
          </fo:block>
267
        </xsl:when>
268
        <!-- genus -->
269
        <xsl:when test="name/rank/uuid='1b11c34c-48a8-4efa-98d5-84f7f66ef43a'">
270
          <fo:block font-weight="bold" text-align="center" text-transform="uppercase">
271
            <xsl:apply-templates select="name/genusOrUninomial"/>
272
          </fo:block>
273
        </xsl:when>
274
        <!-- subgenus -->
275
        <xsl:when test="name/rank/uuid='78786e16-2a70-48af-a608-494023b91904'">
276
          <fo:block font-weight="bold" text-align="center">
277
            <xsl:apply-templates select="name/rank/representation_L10n"/>
278
            <xsl:text> </xsl:text>
279
            <xsl:apply-templates select="name/genusOrUninomial"/>
280
          </fo:block>
281
        </xsl:when>
282
        <!-- species -->
283
        <xsl:when test="name/rank/uuid='b301f787-f319-4ccc-a10f-b4ed3b99a86d'"/>
284
        <xsl:otherwise>
285
          <!-- for debugging --> <!-- Unformatted title for rank uuid: <xsl:value-of
286
            select="name/rank/uuid"/>: <xsl:value-of select="name/titleCache"/>-->
287
        </xsl:otherwise>
288
      </xsl:choose>
289
    </fo:block>
290
  </xsl:template>
291

    
292
  <!-- NAME -->
293

    
294
  <xsl:template match="name">
295
    <xsl:apply-templates select="taggedName"/>
296
    <xsl:apply-templates select="nomenclaturalReference"/>
297
  </xsl:template>
298

    
299
  <xsl:template match="taggedName">
300
    <xsl:for-each select="e">
301
      <xsl:choose>
302
        <xsl:when test="type='name'">
303
          <xsl:choose>
304
            <xsl:when
305
              test="../../rank/uuid='b301f787-f319-4ccc-a10f-b4ed3b99a86d' and name(../../..)='Taxon'">
306
              <fo:inline font-weight="bold">
307
                <xsl:value-of select="text"/>
308
              </fo:inline>
309
            </xsl:when>
310
            <xsl:otherwise>
311
              <fo:inline font-style="italic">
312
                <xsl:value-of select="text"/>
313
              </fo:inline>
314
            </xsl:otherwise>
315
          </xsl:choose>
316
          <xsl:text> </xsl:text>
317
        </xsl:when>
318
        <xsl:when test="type='authors'">
319
          <xsl:value-of select="text"/>
320
        </xsl:when>
321
        <xsl:otherwise>
322
          <xsl:value-of select="text"/>
323
          <xsl:text> </xsl:text>
324
        </xsl:otherwise>
325
      </xsl:choose>
326

    
327
    </xsl:for-each>
328
  </xsl:template>
329

    
330
  <xsl:template match="nomenclaturalReference">
331
    <fo:inline>
332
      <xsl:value-of
333
        select="substring-before(substring-after(titleCache, authorTeam/titleCache), datePublished/start)"/>
334
      <xsl:value-of select="concat('(', datePublished/start, ')')"/>
335
    </fo:inline>
336
    <xsl:text> </xsl:text>
337
    <fo:inline>
338
      <xsl:value-of select="../nomenclaturalMicroReference"/>
339
    </fo:inline>
340
  </xsl:template>
341

    
342
  <!-- DESCRIPTIONS -->
343

    
344
  <xsl:template match="descriptions" name="descriptions">
345
    <fo:block margin-bottom="5mm">
346
      <xsl:for-each select="features/feature">
347
        <fo:block text-indent="{$global-indentation}" text-align="justify">
348
          <xsl:choose>
349
            <xsl:when test="count(feature)!=0">
350
              <xsl:call-template name="secondLevelDescriptionElements"/>
351
            </xsl:when>
352
            <xsl:otherwise>
353
              <!-- everything except Citation -->
354
              <xsl:if test="uuid!='99b2842f-9aa7-42fa-bd5f-7285311e0101'">
355
                <xsl:value-of select="representation_L10n"/> - <xsl:call-template
356
                  name="descriptionElements"/>
357
              </xsl:if>
358
            </xsl:otherwise>
359
          </xsl:choose>
360
        </fo:block>
361
      </xsl:for-each>
362
    </fo:block>
363
  </xsl:template>
364

    
365
  <xsl:template name="descriptionElements">
366
    <!--xsl:choose>
367
      <xsl:when test="supportsDistribution='true'">
368
        <xsl:call-template name="distribution"/>
369
      </xsl:when>
370
      <xsl:when test="supportsCommonTaxonName='true'">
371
        <xsl:call-template name="commonTaxonName"/>
372
      </xsl:when>
373
      <xsl:otherwise-->
374
    <xsl:call-template name="textData"/>
375
    <!--/xsl:otherwise>
376
    </xsl:choose-->
377
  </xsl:template>
378

    
379
  <xsl:template name="secondLevelDescriptionElements">
380
    <xsl:for-each select="feature">
381
      <fo:inline>
382
        <xsl:choose>
383
          <!-- Lifeform -->
384
          <!-- should not show the feature name -->
385
          <xsl:when test="uuid='db9228d3-8bbf-4460-abfe-0b1326c82f8e'">
386
            <xsl:for-each select="descriptionelements/descriptionelement">
387
              <fo:inline>
388
                <xsl:value-of select="multilanguageText_L10n/text"/>
389
              </fo:inline>
390
            </xsl:for-each>
391
          </xsl:when>
392
          <xsl:otherwise>
393
            <fo:inline font-style="italic">
394
              <xsl:value-of select="representation_L10n"/>
395
            </fo:inline>
396
            <xsl:for-each select="descriptionelements/descriptionelement">
397
              <fo:inline>
398
                <xsl:value-of
399
                  select="substring-after(multilanguageText_L10n/text, ../../representation_L10n)"/>
400
              </fo:inline>
401
            </xsl:for-each>
402
          </xsl:otherwise>
403
        </xsl:choose>
404
      </fo:inline>
405
    </xsl:for-each>
406
  </xsl:template>
407

    
408
  <xsl:template name="commonTaxonName">
409
    <xsl:for-each select="descriptionelements/descriptionelement">
410
      <fo:inline>
411
        <xsl:value-of select="language/representation_L10n"/> (<xsl:value-of
412
          select="area/representation_L10n"/>), </fo:inline>
413
    </xsl:for-each>
414
  </xsl:template>
415

    
416
  <xsl:template name="distribution">
417
    <xsl:for-each select="descriptionelements/descriptionelement">
418
      <fo:inline>
419
        <xsl:value-of select="area/representation_L10n"/> (<xsl:value-of
420
          select="status/representation_L10n"/>), </fo:inline>
421
    </xsl:for-each>
422
  </xsl:template>
423

    
424
  <xsl:template name="textData">
425
    <xsl:for-each select="descriptionelements/descriptionelement">
426
      <fo:inline>
427
        <xsl:apply-templates select="multilanguageText_L10n/text"/>
428
      </fo:inline>
429
    </xsl:for-each>
430
  </xsl:template>
431

    
432

    
433
  <!-- SYNONYMY BLOCK -->
434

    
435
  <xsl:template match="synonymy" name="synonymy">
436
    <fo:block margin-bottom="5mm">
437
      <fo:block line-height="{$global-line-height}" text-align="justify"
438
        text-indent="-{$global-indentation}" start-indent="{$global-indentation}">
439
        <xsl:apply-templates select="../name"/>
440
        <xsl:call-template name="citations"/>
441
        <xsl:apply-templates select="homotypicSynonymsByHomotypicGroup"/>
442
        <xsl:apply-templates select="../name/typeDesignations"/>
443
      </fo:block>
444
      <xsl:apply-templates select="heterotypicSynonymyGroups"/>
445
    </fo:block>
446
  </xsl:template>
447

    
448
  <xsl:template match="homotypicSynonymsByHomotypicGroup">
449
    <xsl:for-each select="e">
450
      <xsl:text> - </xsl:text>
451
      <xsl:apply-templates select="name"/>
452
    </xsl:for-each>
453
  </xsl:template>
454

    
455
  <xsl:template match="heterotypicSynonymyGroups">
456
    <xsl:for-each select="e">
457
      <fo:block line-height="{$global-line-height}" text-align="start"
458
        text-indent="-{$global-indentation}" start-indent="{$global-indentation}">
459
        <xsl:for-each select="e">
460
          <xsl:apply-templates select="name"/>
461
        </xsl:for-each>
462
        <xsl:apply-templates select="e[1]/name/typeDesignations" />
463
      </fo:block>
464
    </xsl:for-each>
465
  </xsl:template>
466

    
467
  <xsl:template name="citations">
468
    <xsl:for-each
469
      select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements/descriptionelement">
470
      <!-- TODO sorting only works for the first citation, implement correctly -->
471
      <xsl:sort select="sources/e[1]/citation/datePublished/start"/>
472
      <xsl:for-each select="sources/e">
473
        <xsl:text>; </xsl:text>
474
        <fo:inline>
475
          <xsl:value-of select="substring-before(citation/titleCache, citation/datePublished/start)"/>
476
          <xsl:value-of select="concat('(', citation/datePublished/start, ')')"/>
477
          <xsl:text> </xsl:text>
478
          <xsl:value-of select="citationMicroReference"/>
479
        </fo:inline>
480
      </xsl:for-each>
481
    </xsl:for-each>
482
  </xsl:template>
483

    
484
  <xsl:template match="typeDesignations">
485
    <xsl:for-each select="child::*">
486
      <fo:inline>
487
        <xsl:text> - Type: </xsl:text>
488
        <xsl:choose>
489
          <xsl:when test="class='SpecimenTypeDesignation'">
490
            <xsl:value-of select="typeSpecimen/titleCache"/>
491
          </xsl:when>
492
        </xsl:choose>
493
      </fo:inline>
494
    </xsl:for-each>
495
  </xsl:template>
496

    
497
</xsl:stylesheet>
(1-1/2)