Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdmlib / cdmlib-print / src / main / resources / stylesheets / mediawiki / multipages.xsl @ 4647f17a

History | View | Annotate | Download (40.1 KB)

1

    
2
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
    xmlns:functx="http://www.functx.com">
4

    
5
    <xsl:import href="functx-1.0-doc-2007-01.xsl"/>
6
    <!--<xsl:output method="xml" indent="yes"/>-->
7
    <xsl:strip-space elements="text"/>
8

    
9
    <!-- Authors: Sybille & Lorna -->
10
    <!-- Date: March/April 2013 -->
11

    
12
    <!--++++++++++ global vars (and templates used as such) +++++++++++++++++++++++++++ -->
13

    
14
    <!-- mediawiki prefix -->
15
    <xsl:variable name="page-prefix">
16
        <xsl:text>Internal:</xsl:text>
17
    </xsl:variable>
18

    
19
    <!-- create a timestamp for the whole going -->
20
    <xsl:variable name="timestamp">
21
        <xsl:value-of
22
            select="concat(year-from-date(current-date()),'-',month-from-date(current-date()),'-',day-from-date(current-date()),'T',hours-from-time(current-time()),':',minutes-from-time(current-time()),':00Z')"
23
        />
24
    </xsl:variable>
25

    
26
    <!-- create the username who changed/created the pages -->
27
    <xsl:variable name="username">Sybille Test </xsl:variable>
28

    
29
    <xsl:template name="wiki-newline-comment">
30
        <xsl:comment>
31
            <xsl:text>&#xa; </xsl:text>
32
        </xsl:comment>
33
    </xsl:template>
34

    
35
    <xsl:template name="wiki-two-newlines-comment">
36
        <xsl:comment>
37
            <xsl:text>&#xa; </xsl:text>
38
            <xsl:text>&#xa; </xsl:text>
39
        </xsl:comment>
40
    </xsl:template>
41

    
42
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
43

    
44
    <!-- this is the start template 
45
    it creates the mediawiki tag surounding and calls a template to create a page for 
46
    every taxon node TODO: and a category -->
47
    <xsl:template match="root">
48
        <mediawiki xmlns="http://www.mediawiki.org/xml/export-0.7/"
49
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
50
            xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.7.xsd" version="0.7"
51
            xml:lang="en">
52
            <siteinfo>
53
                <sitename>TestWiki</sitename>
54
                <base>http://biowikifarm.net/test/Main_Page</base>
55
                <generator>MediaWiki 1.20.3</generator>
56
                <case>first-letter</case>
57
                <namespaces>
58
                    <namespace key="-2" case="first-letter">Media</namespace>
59
                    <namespace key="-1" case="first-letter">Special</namespace>
60
                    <namespace key="0" case="first-letter"/>
61
                    <namespace key="1" case="first-letter">Talk</namespace>
62
                    <namespace key="2" case="first-letter">User</namespace>
63
                    <namespace key="3" case="first-letter">User talk</namespace>
64
                    <namespace key="4" case="first-letter">TestWiki</namespace>
65
                    <namespace key="5" case="first-letter">TestWiki talk</namespace>
66
                    <namespace key="6" case="first-letter">File</namespace>
67
                    <namespace key="7" case="first-letter">File talk</namespace>
68
                    <namespace key="8" case="first-letter">MediaWiki</namespace>
69
                    <namespace key="9" case="first-letter">MediaWiki talk</namespace>
70
                    <namespace key="10" case="first-letter">Template</namespace>
71
                    <namespace key="11" case="first-letter">Template talk</namespace>
72
                    <namespace key="12" case="first-letter">Help</namespace>
73
                    <namespace key="13" case="first-letter">Help talk</namespace>
74
                    <namespace key="14" case="first-letter">Category</namespace>
75
                    <namespace key="15" case="first-letter">Category talk</namespace>
76
                    <namespace key="102" case="first-letter">Property</namespace>
77
                    <namespace key="103" case="first-letter">Property talk</namespace>
78
                    <namespace key="106" case="first-letter">Form</namespace>
79
                    <namespace key="107" case="first-letter">Form talk</namespace>
80
                    <namespace key="108" case="first-letter">Concept</namespace>
81
                    <namespace key="109" case="first-letter">Concept talk</namespace>
82
                    <namespace key="170" case="first-letter">Filter</namespace>
83
                    <namespace key="171" case="first-letter">Filter talk</namespace>
84
                    <namespace key="198" case="first-letter">Internal</namespace>
85
                    <namespace key="199" case="first-letter">Internal talk</namespace>
86
                    <namespace key="200" case="first-letter">Portal</namespace>
87
                    <namespace key="201" case="first-letter">Portal talk</namespace>
88
                    <namespace key="202" case="first-letter">Bibliography</namespace>
89
                    <namespace key="203" case="first-letter">Bibliography talk</namespace>
90
                    <namespace key="204" case="first-letter">Draft</namespace>
91
                    <namespace key="205" case="first-letter">Draft talk</namespace>
92
                    <namespace key="206" case="first-letter">Submission</namespace>
93
                    <namespace key="207" case="first-letter">Submission talk</namespace>
94
                    <namespace key="208" case="first-letter">Reviewed</namespace>
95
                    <namespace key="209" case="first-letter">Reviewed talk</namespace>
96
                    <namespace key="420" case="first-letter">Layer</namespace>
97
                    <namespace key="421" case="first-letter">Layer talk</namespace>
98
                </namespaces>
99
            </siteinfo>
100
            <xsl:apply-templates select="//TaxonNode"/>
101
        </mediawiki>
102
    </xsl:template>
103

    
104
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
105

    
106
    <!-- this creates a page and a category for 
107
    every taxon node.  -->
108
    <!-- TODO create a template for page creating and for categorie creating -->
109
    <xsl:template match="TaxonNode" name="TaxonNode">
110
        <!-- as we will need the title more than once, we create a variable-->
111
        <xsl:variable name="title">
112
            <xsl:call-template name="title">
113
                <xsl:with-param name="taxon" select="Taxon"/>
114
            </xsl:call-template>
115
        </xsl:variable>
116

    
117
        <!-- we also initialize the parent taxon variable if there is a higher taxon assigned: -->
118

    
119
        <xsl:variable name="parent-title">
120
            <xsl:if test="exists(../..) and name(../..)='TaxonNode'">
121

    
122
                <xsl:call-template name="title">
123
                    <xsl:with-param name="taxon" select="../../Taxon"/>
124
                </xsl:call-template>
125

    
126
            </xsl:if>
127
            <!-- else if no higher taxon could be found -->
128
            <xsl:if test="not(exists(../..)) or not(name(../..)='TaxonNode')">
129

    
130
                <xsl:text>{{EDIT No Parent available}}</xsl:text>
131

    
132
            </xsl:if>
133
        </xsl:variable>
134

    
135
        <!-- create category -->
136
        <xsl:text>
137
            <!-- this creates a newline before the <page> 
138
            if it was not there, the page could not be imported by the mediawiki-->
139
        </xsl:text>
140

    
141
        <page>
142
            <title>
143
                <xsl:text>Category:</xsl:text>
144
                <xsl:value-of select="$title"/>
145
            </title>
146
            <revision>
147
                <!-- TODO: create seconds without positions after decimal point! -->
148
                <timestamp>
149
                    <xsl:value-of select="$timestamp"/>
150
                </timestamp>
151
                <contributor>
152
                    <username>Sybille Test</username>
153
                </contributor>
154

    
155
                <text>
156
                    <xsl:attribute name="xml:space">preserve</xsl:attribute>
157
                    <!-- redirekt to corresponding page -->
158
                    <xsl:value-of select="concat('#REDIRECT [[',$page-prefix,$title,']]')"/>
159
                    <!-- add parent categorie if exists -->
160
                    <xsl:if test="exists(../..) and name(../..)='TaxonNode'">
161
                        <xsl:call-template name="wiki-newline-comment"/>
162
                        <xsl:value-of select="concat('[[Category:',$parent-title,']]')"/>
163
                    </xsl:if>
164
                </text>
165

    
166
            </revision>
167
        </page>
168

    
169
        <!-- create taxon page -->
170
        <page>
171
            <title>
172
                <xsl:value-of select="concat($page-prefix,$title)"/>
173
            </title>
174
            <revision>
175
                <!-- MAYDO: create seconds without positions after decimal point! -->
176
                <timestamp>
177
                    <xsl:value-of select="$timestamp"/>
178
                </timestamp>
179
                <contributor>
180
                    <username>
181
                        <xsl:value-of select="$username"/>
182
                    </username>
183
                </contributor>
184

    
185
                <text>
186
                    <xsl:attribute name="xml:space">preserve</xsl:attribute>
187
                    <!-- add table of contents -->
188
                    <xsl:call-template name="TOC"/>
189

    
190
                    <!-- add taxo tree -->
191
                    <xsl:value-of
192
                        select="concat('{{EDIT_Taxotree| parentTaxon=',$page-prefix,$parent-title, '}}')"/>
193
                    <xsl:call-template name="wiki-two-newlines-comment"/>
194

    
195

    
196
                    <!-- add contents of taxon page -->
197
                    <xsl:apply-templates select="Taxon"/>
198
                    <xsl:call-template name="display-references"/>
199
                    <xsl:call-template name="wiki-newline-comment"/>
200

    
201
                    <!-- put page to corresponding tax category -->
202
                    <xsl:value-of select="concat('[[Category:',$title, ']]')"/>
203

    
204
                </text>
205
            </revision>
206
        </page>
207

    
208
        <!--<xsl:apply-templates select="//childNodes/TaxonNode/Taxon"/>-->
209
    </xsl:template>
210

    
211
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
212

    
213
    <!-- this template provides the correct name of a taxon 
214
    parameter: taxon the taxon we want to get the name from-->
215
    <xsl:template name="title">
216
        <xsl:param name="taxon"/>
217
        <xsl:choose>
218
            <!-- family -->
219
            <xsl:when test="$taxon/name/rank/uuid='af5f2481-3192-403f-ae65-7c957a0f02b6'">
220
                <xsl:call-template name="get-family-or-genus-title">
221
                    <xsl:with-param name="genusOrUninomial" select="$taxon/name/genusOrUninomial"/>
222
                </xsl:call-template>
223
            </xsl:when>
224
            <!-- genus -->
225
            <xsl:when test="$taxon/name/rank/uuid='1b11c34c-48a8-4efa-98d5-84f7f66ef43a'">
226
                <xsl:call-template name="get-family-or-genus-title">
227
                    <xsl:with-param name="genusOrUninomial" select="$taxon/name/genusOrUninomial"/>
228
                </xsl:call-template>
229
            </xsl:when>
230
            <!--TODO-->
231
            <!-- subgenus -->
232
            <xsl:when test="$taxon/name/rank/uuid='78786e16-2a70-48af-a608-494023b91904'">
233
                <xsl:apply-templates select="$taxon/name/rank/representation_L10n"/>
234
                <xsl:text> </xsl:text>
235
                <xsl:apply-templates select="$taxon/name/genusOrUninomial"/>
236
            </xsl:when>
237
            <!-- species -->
238
            <xsl:when test="$taxon/name/rank/uuid='b301f787-f319-4ccc-a10f-b4ed3b99a86d'">
239
                <xsl:call-template name="get-species-title">
240
                    <xsl:with-param name="taxon" select="$taxon"/>
241
                </xsl:call-template>
242
            </xsl:when>
243
            <xsl:otherwise>
244
                <!-- for debugging --> Unformatted title for rank uuid: <xsl:value-of
245
                    select="$taxon/name/rank/uuid"/>: <xsl:value-of select="$taxon/name/titleCache"
246
                />
247
            </xsl:otherwise>
248
        </xsl:choose>
249
    </xsl:template>
250

    
251
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
252

    
253
    <!-- these templates create the name of the taxa wheater their kind is -->
254

    
255
    <xsl:template name="get-family-or-genus-title">
256
        <xsl:param name="genusOrUninomial"/>
257
        <xsl:value-of select="$genusOrUninomial"/>
258
    </xsl:template>
259

    
260
    <xsl:template name="get-species-title">
261
        <xsl:param name="taxon"/>
262
        <xsl:value-of
263
            select="concat($taxon/name/genusOrUninomial, ' ', $taxon/name/specificEpithet)"/>
264
    </xsl:template>
265

    
266
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
267

    
268
    <!-- we run this for the content of the page -->
269
    <xsl:template match="Taxon" name="Taxon">
270
        <xsl:apply-templates select="synonymy"/>
271
        <xsl:apply-templates select="key"/>
272
        <xsl:apply-templates select="descriptions"/>
273
        <xsl:call-template name="gallery"/>
274
    </xsl:template>
275

    
276
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
277

    
278
    <!-- these templates provide the citations -->
279

    
280
    <xsl:template name="display-references">
281
        <xsl:call-template name="chapter">
282
            <xsl:with-param name="title">References</xsl:with-param>
283
        </xsl:call-template>
284
        <xsl:text>{{EDIT_Reference_Section}}</xsl:text>
285
    </xsl:template>
286

    
287

    
288
    <xsl:template name="citations">
289
        <xsl:param name="name-uuid"/>
290
        <xsl:param name="descriptionelements"/>
291

    
292
        <!--<ref name="{$name-uuid}">-->
293
        <!-- iterate through all the description elements for the citation feature -->
294
        <xsl:for-each select="$descriptionelements/descriptionelement">
295

    
296
            <xsl:sort select="sources/e[1]/citation/datePublished/start"/>
297

    
298
            <xsl:variable name="citation-uuid" select="sources/e[1]/citation/uuid"/>
299

    
300
            <xsl:for-each select="sources/e">
301
                <xsl:if test="nameUsedInSource/uuid=$name-uuid">
302

    
303
                    <!-- call reference template with sources/e/citation -->
304
                    <xsl:call-template name="reference">
305
                        <xsl:with-param name="reference-node" select="citation"/>
306
                    </xsl:call-template>
307
                    <!-- use the citation-uuid as a unique name for the reference -->
308

    
309
                </xsl:if>
310
            </xsl:for-each>
311
            <!--</ref>-->
312
        </xsl:for-each>
313

    
314
    </xsl:template>
315

    
316
    <!-- an example of mediawiki formtting of references:
317
        Mohrig, W.; Menzel, F. 1992: Neue Arten europäischer Trauermücken (Diptera, Sciaridae). An International Journal of Dipterological Research, 3(1-2), 1–16.
318
        Authors Date: title. inReferences title in italics, Volume in bold(series), page range -->
319
    <xsl:template name="reference">
320

    
321
        <xsl:param name="reference-node"/>
322
        <!--TODO Do we need to sort the list of references in WikiMedia or will they just appear in numbered order as they occur in the names-->
323
        <!--xsl:sort select="sources/e[1]/citation/datePublished/start"/-->
324

    
325
        <!-- use the citation-uuid as a unique name for the reference -->
326
        <xsl:variable name="citation-uuid" select="$reference-node/uuid"/>
327

    
328
        <!-- use the citation-uuid as a unique name for the reference -->
329
        <xsl:value-of select="concat('{{EDIT_Reference|name=',$citation-uuid,'|content=')"/>
330
        <xsl:call-template name="wiki-newline-comment"/>
331
        <xsl:text>{{aut|</xsl:text>
332
        <xsl:choose>
333
            <xsl:when test="$reference-node/authorTeam/teamMembers/e[1]/lastname != ''">
334
                <xsl:for-each select="$reference-node/authorTeam/teamMembers/e">
335
                    <xsl:value-of select="lastname"/>
336
                    <xsl:choose>
337
                        <xsl:when test="position() != last()">
338
                            <xsl:text> &amp; </xsl:text>
339
                        </xsl:when>
340
                    </xsl:choose>
341
                </xsl:for-each>
342
            </xsl:when>
343
            <xsl:otherwise>
344
                <xsl:value-of select="$reference-node/authorTeam/lastname"/>
345
            </xsl:otherwise>
346

    
347
        </xsl:choose>
348
        <xsl:value-of select="$citation-uuid"/>
349
        <!-- DEBUGGING display uuid so can check references against those in Tax Editor -->
350

    
351
        <xsl:text>}} </xsl:text>
352
        <xsl:if test="$reference-node/datePublished/start != ''">
353
            <xsl:value-of select="$reference-node/datePublished/start"/>
354
            <xsl:text>: </xsl:text>
355
        </xsl:if>
356

    
357
        <xsl:apply-templates select="$reference-node/title"/>
358

    
359
        <!-- do we need any other info from inReference node - see flore-afrique-centrale.xsl xsl -->
360
        <xsl:variable name="wiki-markup">''</xsl:variable>
361

    
362
        <xsl:if test="$reference-node/inReference/node()">
363
            <xsl:value-of
364
                select="concat($wiki-markup, $reference-node/inReference/title, $wiki-markup)"/>
365
        </xsl:if>
366
        <xsl:apply-templates select="$reference-node/volume"/>
367
        <xsl:apply-templates select="$reference-node/series"/>
368
        <xsl:apply-templates select="$reference-node/pages"/>
369
        <xsl:apply-templates select="$reference-node/placePublished"/>
370
        <xsl:apply-templates select="$reference-node/publisher"/>
371

    
372
        <!--xsl:choose>
373
            <xsl:when test="$reference-node/inReference/node()">
374
                <xsl:value-of select="$reference-node/title"/>
375
                <xsl:text>. </xsl:text>
376
                <xsl:value-of select="$reference-node/inReference/title"/>
377
            </xsl:when>
378
            <xsl:otherwise>
379
                <xsl:value-of select="$reference-node/title"/>
380
            </xsl:otherwise>
381
        </xsl:choose>
382
        <xsl:text>.</xsl:text>
383
        <xsl:value-of select="$reference-node/pages"/>
384
        <xsl:text>.</xsl:text>
385

    
386
        <xsl:if test="$reference-node/type = 'Book' or $reference-node/type = 'BookSection'">
387
            <xsl:if test="$reference-node/placePublished != '' or $reference-node/publisher != ''">
388
                <xsl:text> </xsl:text>
389
                <xsl:value-of select="$reference-node/placePublished"/>
390
                <xsl:text>, </xsl:text>
391
                <xsl:value-of select="$reference-node/publisher"/>
392
                <xsl:text>.</xsl:text>
393
            </xsl:if>
394
        </xsl:if-->
395
        <xsl:text>}}</xsl:text>
396
        <!--</ref>-->
397
        <xsl:call-template name="wiki-newline-comment"/>
398
    </xsl:template>
399

    
400
    <!-- wild card match for different children of nomenclaturalReference and citaion nodes -->
401
    <xsl:template match="*">
402
        <xsl:value-of select="."/>
403
        <xsl:if test="name(.) = 'title' or name(.) = 'publisher' or name(.) = 'pages'">
404
            <!-- . if pages or publisher or title - comma if placePublished -->
405
            <xsl:text>. </xsl:text>
406
        </xsl:if>
407
        <xsl:if test="name(.) = 'volume'">
408
            <xsl:text>: </xsl:text>
409
        </xsl:if>
410
        <xsl:if
411
            test="(../type = 'Book' or ../type = 'BookSection') and name(.) = 'placePublished' and . != ''">
412
            <xsl:text>, </xsl:text>
413
        </xsl:if>
414
    </xsl:template>
415
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
416

    
417
    <!-- these templates provide the polytomous key 
418

    
419
    For example:
420
    {{Lead | 1=4| 2= jeunes couverts de cils simples et glanduleux mais jamais de cils denticulés ou branchus| 
421
    result = Erica trimera (Flora of XX) | result text = ''Erica trimera''}}
422
    -->
423
    <xsl:template match="key" name="key">
424

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

    
429
        <xsl:if test="HashMap/records/e">
430

    
431
            <xsl:call-template name="chapter">
432
                <xsl:with-param name="title">Key</xsl:with-param>
433
            </xsl:call-template>
434

    
435
            <xsl:variable name="key-name" select="HashMap/titleCache"/>
436
            <xsl:value-of
437
                select="concat('{{Key Start | id =',$key-name,'|title=',$key-name,'|edited by=L.Morris}}')"/>
438

    
439

    
440
            <!--xsl:if test="ArrayList/e"-->
441
            <xsl:for-each select="HashMap/records/e">
442

    
443
                <xsl:variable name="node-number" select="nodeNumber"/>
444
                <xsl:variable name="child-statement" select="childStatement"/>
445

    
446
                <!-- TaxonLinkDto or PolytomousKeyNodeLinkDto-->
447
                <!--xsl:value-of select="concat('{{Decision | id =', $node-number, '| lead 1 = ', $child-statement)"/-->
448
                <xsl:value-of select="concat('{{Lead | 1 =', $node-number)"/>
449

    
450
                <xsl:if test="edgeNumber = 2">
451
                    <xsl:text>*</xsl:text>
452
                </xsl:if>
453

    
454
                <xsl:value-of select="concat('| 2 =', $child-statement)"/>
455

    
456

    
457
                <xsl:choose>
458
                    <xsl:when test="links/e[1]/class = 'PolytomousKeyNodeLinkDto'">
459
                        <xsl:variable name="link-node-number" select="links/e[1]/nodeNumber"/>
460
                        <xsl:value-of select="concat('| 3 =', $link-node-number)"/>
461
                    </xsl:when>
462
                    <xsl:when test="links/e[1]/class = 'TaxonLinkDto'">
463

    
464
                        <xsl:text>| result  = '' </xsl:text>
465
                        <xsl:variable name="taxonUuid" select="links/e[1]/uuid"/>
466
                        <xsl:variable name="genus"
467
                            select="//Taxon/uuid[.=$taxonUuid]/../name/genusOrUninomial"/>
468
                        <xsl:choose>
469
                            <xsl:when test="taxonUuid = $uuidSubgenus">
470
                                <xsl:variable name="repr"
471
                                    select="//Taxon/uuid[.='71cd0e8d-47eb-4c66-829a-e21c705ee660']/../name/rank/representation_L10n"/>
472
                                <xsl:value-of select="concat($genus, '. ', $repr)"/>
473
                            </xsl:when>
474
                            <xsl:when test="taxonUuid = $uuidGenus">
475
                                <xsl:apply-templates select="$genus"/>
476
                            </xsl:when>
477
                            <xsl:otherwise>
478
                                <xsl:variable name="specificEpithet"
479
                                    select="//Taxon/uuid[.=$taxonUuid]/../name/specificEpithet"/>
480
                                <!-- abbreviate the genus for species names -->
481
                                <xsl:value-of select="concat($genus, ' ', $specificEpithet)"/>
482
                            </xsl:otherwise>
483
                        </xsl:choose>
484
                        <xsl:text>''</xsl:text>
485
                    </xsl:when>
486
                    <xsl:otherwise/>
487
                </xsl:choose>
488

    
489
                <xsl:text>}}</xsl:text>
490

    
491
            </xsl:for-each>
492

    
493
            <xsl:text>{{Key End}}</xsl:text>
494
        </xsl:if>
495

    
496
    </xsl:template>
497

    
498

    
499
    <!-- these templates provide the synonomy -->
500

    
501
    <xsl:template match="synonymy" name="synonymy">
502
        <xsl:call-template name="chapter">
503
            <xsl:with-param name="title">Synonomy</xsl:with-param>
504
        </xsl:call-template>
505
        <xsl:apply-templates select="../name"/>
506

    
507
        <!-- getting nomenclatural refs and citaions for this name-->
508
        <xsl:call-template name="reference">
509
            <xsl:with-param name="reference-node" select="../name/nomenclaturalReference"/>
510
        </xsl:call-template>
511
        <xsl:call-template name="citations">
512
            <xsl:with-param name="descriptionelements"
513
                select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
514
            <xsl:with-param name="name-uuid" select="../name/uuid"/>
515
        </xsl:call-template>
516
        <xsl:call-template name="wiki-two-newlines-comment"/>
517
        <xsl:apply-templates select="homotypicSynonymsByHomotypicGroup"/>
518
        <xsl:apply-templates select="heterotypicSynonymyGroups"/>
519
        <!--xsl:call-template name="citations">
520
            <xsl:with-param name="descriptionelements"
521
                select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
522
            <xsl:with-param name="name-uuid" select="../name/uuid"/>
523
        </xsl:call-template-->
524
    </xsl:template>
525

    
526
    <!--.............................................-->
527

    
528
    <xsl:template match="homotypicSynonymsByHomotypicGroup">
529
        <xsl:for-each select="e">
530
            <xsl:text>{{EDIT Homotypic Synonym|1|</xsl:text>
531
            <xsl:apply-templates select="name"/>
532
            <xsl:text>}}</xsl:text>
533

    
534
            <!--homotypicSynonymsByHomotypicGroup/e/name/nomenclaturalReference-->
535
            <!--xsl:apply-templates select="name/nomenclaturalReference"/-->
536
            <xsl:call-template name="reference">
537
                <xsl:with-param name="reference-node" select="name/nomenclaturalReference"/>
538
            </xsl:call-template>
539

    
540
            <!--LORNA Pass the description elements for the citation 99b2842f-9aa7-42fa-bd5f-7285311e0101 -->
541
            <xsl:call-template name="citations">
542
                <xsl:with-param name="descriptionelements"
543
                    select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
544
                <xsl:with-param name="name-uuid" select="name/uuid"/>
545
            </xsl:call-template>
546
        </xsl:for-each>
547
        <xsl:call-template name="wiki-two-newlines-comment"/>
548
    </xsl:template>
549

    
550
    <!--.............................................-->
551

    
552
    <xsl:template match="heterotypicSynonymyGroups">
553
        <xsl:for-each select="e">
554

    
555
            <!--do foreach for the rest-->
556
            <!--<xsl:text>==***==</xsl:text>-->
557
            <xsl:variable name="first-element" select="e[1]"/>
558
            <xsl:text>{{EDIT Heterotypic Synonym|1|</xsl:text>
559
            <xsl:apply-templates select="$first-element/name"/>
560
            <xsl:text>}}</xsl:text>
561
            <!--<xsl:text>==***==</xsl:text>-->
562

    
563
            <!-- take the first one to printout as the head of the homotypic group -->
564

    
565
            <xsl:for-each select="e[position() &gt; 1]">
566
                <xsl:text>{{EDIT Homotypic Synonym|2|</xsl:text>
567
                <xsl:apply-templates select="name"/>
568
                <xsl:text>}}</xsl:text>
569

    
570
                <xsl:call-template name="reference">
571
                    <xsl:with-param name="reference-node" select="name/nomenclaturalReference"/>
572
                </xsl:call-template>
573

    
574
                <!--LORNA Pass the description elements for the citation 99b2842f-9aa7-42fa-bd5f-7285311e0101 -->
575
                <xsl:call-template name="citations">
576
                    <xsl:with-param name="descriptionelements"
577
                        select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
578
                    <xsl:with-param name="name-uuid" select="name/uuid"/>
579
                </xsl:call-template>
580
                <xsl:call-template name="wiki-two-newlines-comment"/>
581
            </xsl:for-each>        
582
        </xsl:for-each>
583
        <xsl:call-template name="wiki-two-newlines-comment"/>
584
        <!--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-->
585
    </xsl:template>
586

    
587
    <!--.............................................-->
588

    
589
    <xsl:template match="name">
590
        <xsl:apply-templates select="taggedName"/>
591
        <!--xsl:apply-templates select="nomenclaturalReference"/-->
592
    </xsl:template>
593

    
594
    <!--.............................................-->
595

    
596
    <xsl:template match="taggedName">
597
        <xsl:for-each select="e">
598
            <!-- TODO mybe some types don't contain font tags, we don't have to call the tmeplate  -->
599
            <!--        we could just use <xsl:value-of select="text"/>-->
600
            <xsl:choose>
601
                <xsl:when test="type='name'">
602
                    <xsl:apply-templates select="text"/>
603
                    <xsl:text> </xsl:text>
604
                </xsl:when>
605
                <xsl:when test="type='authors'">
606
                    <xsl:apply-templates select="text"/>
607
                </xsl:when>
608
                <xsl:otherwise>
609
                    <xsl:apply-templates select="text"/>
610
                    <xsl:text> </xsl:text>
611
                </xsl:otherwise>
612
            </xsl:choose>
613
        </xsl:for-each>
614
        <xsl:call-template name="wiki-newline-comment"/>
615
        <!--<xsl:text>&#xA;</xsl:text>-->
616
    </xsl:template>
617

    
618
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
619

    
620
    <!-- description features -->
621

    
622
    <!-- TODO: for first and second level: 
623
        check if there is a page that describes the feature 
624
        and use Parameter "Link=pagename" with templates Tax_Feature or 
625
        Second_Level_Feature-->
626

    
627
    <xsl:template match="descriptions" name="descriptions">
628
        <xsl:call-template name="wiki-comment">
629
            <xsl:with-param name="wiki-comment">FEATURES</xsl:with-param>
630
        </xsl:call-template>
631
        <xsl:for-each select="features/feature">
632
            <xsl:choose>
633
                <xsl:when test="count(feature)!=0">
634
                    <xsl:call-template name="secondLevelDescriptionElements"/>
635
                </xsl:when>
636
                <xsl:otherwise>
637
                    <!-- everything but Citation -->
638
                    <xsl:if test="uuid!='99b2842f-9aa7-42fa-bd5f-7285311e0101'">
639
                        <xsl:call-template name="descriptionElements"/>
640
                    </xsl:if>
641
                    <!--xsl:apply-templates select="media/e/representations/e/parts/e/uri"/-->
642
                </xsl:otherwise>
643
            </xsl:choose>
644
        </xsl:for-each>
645
    </xsl:template>
646

    
647
    <!--.............................................-->
648

    
649
    <xsl:template name="secondLevelDescriptionElements">
650

    
651
        <xsl:value-of select="concat('{{EDIT_Highlevel_Feature|',representation_L10n,'}}')"/>
652
        <xsl:call-template name="wiki-newline-comment"></xsl:call-template>
653
        <xsl:for-each select="feature">
654
            <xsl:value-of
655
                select="concat('{{EDIT_Nested_Feature|name=',representation_L10n,'|elements=')"/>
656
            <!-- TODO create Element -->
657
            <xsl:for-each select="descriptionelements/descriptionelement">
658
                <xsl:value-of
659
                    select="concat('{{EDIT_Nested_Feature_Element|',multilanguageText_L10n/text, '}}')"/>
660
                <xsl:choose>
661
                    <xsl:when test="position() != last()">
662
                        <xsl:text>{{EDIT_Delimiter}}</xsl:text>
663
                    </xsl:when>
664
                </xsl:choose>
665
            </xsl:for-each>
666
            <xsl:text>}}</xsl:text>
667
            <xsl:call-template name="wiki-newline-comment"></xsl:call-template>
668
        </xsl:for-each>
669
        <xsl:call-template name="wiki-newline-comment"></xsl:call-template>
670
    </xsl:template>
671
    <!--.............................................-->
672

    
673

    
674
    <xsl:template name="descriptionElements">
675
        <xsl:choose>
676
            <xsl:when test="supportsCommonTaxonName='true'">
677
                <!-- must be Vernacular Name feature -->
678
                <xsl:call-template name="commonTaxonName"/>
679
            </xsl:when>
680
            <xsl:otherwise>
681
                <!-- for example Habitat, Material Examined -->
682
                <xsl:call-template name="textData"/>
683
            </xsl:otherwise>
684
        </xsl:choose>
685
    </xsl:template>
686

    
687
    <!--.............................................-->
688

    
689
    <xsl:template name="commonTaxonName">
690

    
691
        <xsl:value-of select="concat('{{EDIT_Feature|name=',representation_L10n,'|elements=')"/>
692
        <xsl:for-each select="descriptionelements/descriptionelement">
693
            <xsl:text/>
694
            <xsl:value-of
695
                select="concat('{{EDIT_Common_Name|name=',name,'|language=',language/representation_L10n,'}}')"/>
696
            <xsl:choose>
697
                <xsl:when test="position() != last()">
698
                    <xsl:text>{{EDIT_Delimiter}}</xsl:text>
699
                    <xsl:call-template name="wiki-newline-comment"></xsl:call-template>
700
                </xsl:when>
701
            </xsl:choose>
702
        </xsl:for-each>
703
        <xsl:text>}}</xsl:text>
704
        <xsl:call-template name="wiki-two-newlines-comment"></xsl:call-template>
705
    </xsl:template>
706

    
707
    <!--.............................................-->
708

    
709
    <xsl:template name="textData">
710

    
711
        <xsl:value-of
712
            select="concat('{{EDIT_Feature|name=',representation_L10n, '|elements={{EDIT_Feature_Text|' )"/>
713
        <xsl:call-template name="wiki-newline-comment"></xsl:call-template>
714
        <!--
715
        <xsl:choose>
716
            <xsl:when test="uuid!='9fc9d10c-ba50-49ee-b174-ce83fc3f80c6'">-->
717
        <!-- feature is not "Distribution" -->
718

    
719
        <xsl:apply-templates
720
            select="descriptionelements/descriptionelement[1]/multilanguageText_L10n/text"/>
721
        <!--
722
            </xsl:when>
723
        </xsl:choose>
724
        -->
725
        <xsl:text>}}}}</xsl:text>
726
        <xsl:call-template name="wiki-two-newlines-comment"></xsl:call-template>
727

    
728
        <!-- LORNA TRY IMAGE HERE -->
729
        <!--xsl:apply-templates select="descriptionelements/descriptionelement[1]/media/e/representations/e/parts/e/uri"/-->
730

    
731

    
732
    </xsl:template>
733

    
734
    <!--.............................................-->
735

    
736

    
737
    <xsl:template match="text">
738

    
739
        <xsl:call-template name="replace-tags">
740
            <xsl:with-param name="text-string" select="."/>
741
        </xsl:call-template>
742
    </xsl:template>
743

    
744
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
745
    <!-- image gallery -->
746

    
747
    <xsl:template name="gallery">
748
        <xsl:text>{{EDIT_Gallery|files=</xsl:text>
749
        <xsl:call-template name="wiki-newline-comment"></xsl:call-template>
750
        <xsl:apply-templates select=".//media/e/representations/e/parts/e/uri"/>
751

    
752
        <xsl:text>}}</xsl:text>
753
        <xsl:call-template name="wiki-two-newlines-comment"></xsl:call-template>
754
    </xsl:template>
755

    
756

    
757
    <xsl:template name="gallery_file"/>
758

    
759
    <xsl:template match="media/e/representations/e/parts/e/uri">
760

    
761
        <xsl:value-of
762
            select="concat('{{EDIT_Gallery_File|filename=',functx:substring-after-last(.,'/'), '|description=')"/>
763
        <xsl:call-template name="wiki-newline-comment"></xsl:call-template>
764
        <!--go back up to the description element and get the text for the Figure legend -->
765
        <xsl:apply-templates select="../../../../../../../multilanguageText_L10n/text"/>
766
        <xsl:text>}}</xsl:text>
767
        <xsl:call-template name="wiki-newline-comment"></xsl:call-template>
768
    </xsl:template>
769

    
770

    
771

    
772

    
773
    <!--+++++++++++++++++++++++++++++L A Y O U T ++++++++++++++++++++++++++++++++++++++ -->
774

    
775

    
776
    <!-- change here to change the look of the mediawiki output -->
777
    <!-- please use mediawiki templates -->
778
    <!-- think also of template changes in the mediawiki -->
779
    <!-- TODO: wrap TOC layout in a mediawiki template -->
780

    
781
    <xsl:template name="TOC"> {{EDIT_TOC}} <xsl:call-template name="wiki-two-newlines-comment"/>
782
    </xsl:template>
783

    
784
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
785
    <xsl:template name="chapter">
786
        <xsl:param name="title"/>
787
        <xsl:value-of select="concat('{{EDIT_Section|',$title,'}}')"/>
788
        <xsl:call-template name="wiki-two-newlines-comment"/>
789
    </xsl:template>
790

    
791
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
792

    
793
    <xsl:template name="subchapter">
794
        <xsl:param name="title"/>
795
        <xsl:value-of select="concat('{{EDIT_Subsection|',$title,'}}')"/>
796
        <xsl:call-template name="wiki-two-newlines-comment"/>
797
    </xsl:template>
798

    
799
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
800
    <!-- puts in a wiki comment -->
801
    <xsl:template name="wiki-comment">
802
        <xsl:param name="wiki-comment"></xsl:param>
803
        <xsl:comment>
804
            <xsl:value-of select="concat($wiki-comment,'&#xa;')"/>
805
        </xsl:comment>
806
    </xsl:template>
807
    
808
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
809

    
810
    <!--this template layouts and displays the name of a 
811
        taxon depending on it's "kind"
812
        MAYDO: create more useful layouts instead of title sizes-->
813
    <xsl:template name="display-taxon-name">
814
        <xsl:param name="taxon"/>
815
        <!-- get the name of the taxon -->
816
        <xsl:variable name="name">
817
            <xsl:call-template name="title">
818
                <xsl:with-param name="taxon" select="$taxon"/>
819
            </xsl:call-template>
820
        </xsl:variable>
821
        <!-- format the name of the taxon according to it's kind -->
822
        <xsl:choose>
823
            <!-- family -->
824
            <xsl:when test="$taxon/name/rank/uuid='af5f2481-3192-403f-ae65-7c957a0f02b6'">
825
                <xsl:value-of select="concat('{{EDIT_Family_Name|', $name, '}}')"/>
826
            </xsl:when>
827
            <!-- genus -->
828
            <xsl:when test="$taxon/name/rank/uuid='1b11c34c-48a8-4efa-98d5-84f7f66ef43a'">
829
                <xsl:value-of select="concat('{{EDIT_Genus Name|', $name, '}}')"/>
830
            </xsl:when>
831
            <!--TODO-->
832
            <!-- subgenus -->
833
            <xsl:when test="$taxon/name/rank/uuid='78786e16-2a70-48af-a608-494023b91904'">
834
                <xsl:value-of select="concat('{{EDIT_Subgenus Name|', $name, '}}')"/>
835
            </xsl:when>
836
            <!-- species -->
837
            <xsl:when test="$taxon/name/rank/uuid='b301f787-f319-4ccc-a10f-b4ed3b99a86d'">
838
                <xsl:value-of select="concat('{{EDIT_Species Name|', $name, '}}')"/>
839
            </xsl:when>
840
            <xsl:otherwise>
841
                <!-- for debugging --> Unformatted title for rank uuid: <xsl:value-of
842
                    select="$taxon/name/rank/uuid"/>: <xsl:value-of select="$taxon/name/titleCache"
843
                />
844
            </xsl:otherwise>
845
        </xsl:choose>
846
    </xsl:template>
847

    
848

    
849
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
850

    
851
    <!--we replace html <i> and <b> with mediawiki templates-->
852

    
853

    
854
    <!--.............................................-->
855

    
856
    <xsl:template name="replace-tags">
857
        <xsl:param name="text-string"/>
858

    
859
        <!-- first replace bold tags and put the result in text-string2 -->
860
        <xsl:variable name="text-string2">
861
            <xsl:call-template name="add-markup">
862
                <xsl:with-param name="str" select="$text-string"/>
863
                <xsl:with-param name="wiki-markup">'''</xsl:with-param>
864
                <xsl:with-param name="tag-name">b</xsl:with-param>
865
            </xsl:call-template>
866
        </xsl:variable>
867

    
868
        <!-- second replace italic tags on text-string2 -->
869
        <xsl:call-template name="add-markup">
870
            <xsl:with-param name="str" select="$text-string2"/>
871
            <xsl:with-param name="wiki-markup">''</xsl:with-param>
872
            <xsl:with-param name="tag-name">i</xsl:with-param>
873
        </xsl:call-template>
874
    </xsl:template>
875

    
876
    <!--.............................................-->
877

    
878
    <xsl:template name="add-markup">
879
        <xsl:param name="str"/>
880
        <xsl:param name="wiki-markup"/>
881
        <xsl:param name="tag-name"/>
882

    
883
        <xsl:variable name="opening-tag">
884
            <xsl:value-of select="concat('&lt;', $tag-name, '&gt;')"> </xsl:value-of>
885
        </xsl:variable>
886
        <xsl:variable name="closing-tag">
887
            <xsl:value-of select="concat('&lt;/', $tag-name, '&gt;')"> </xsl:value-of>
888
        </xsl:variable>
889

    
890
        <xsl:choose>
891
            <!-- if the tag occures in the string -->
892
            <xsl:when test="contains($str, $opening-tag) and contains($str, $closing-tag)">
893

    
894
                <!-- separate string before, inside and after the tag -->
895
                <xsl:variable name="before-tag" select="substring-before($str, $opening-tag)"/>
896
                <xsl:variable name="inside-tag"
897
                    select="substring-before(substring-after($str,$opening-tag),$closing-tag)"/>
898
                <xsl:variable name="after-tag" select="substring-after($str, $closing-tag)"/>
899

    
900
                <!-- built the new string by putting in the mediawiki template -->
901
                <xsl:value-of select="concat($before-tag, $wiki-markup, $inside-tag, $wiki-markup)"/>
902
                <!-- in the part after the closing tag could be more tag, so we do a recursive call -->
903
                <xsl:call-template name="add-markup">
904
                    <xsl:with-param name="str" select="$after-tag"/>
905
                    <xsl:with-param name="wiki-markup" select="$wiki-markup"/>
906
                    <xsl:with-param name="tag-name" select="$tag-name"/>
907
                </xsl:call-template>
908
            </xsl:when>
909
            <xsl:otherwise>
910
                <xsl:value-of select="$str"/>
911
            </xsl:otherwise>
912
        </xsl:choose>
913
    </xsl:template>
914

    
915
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
916

    
917

    
918

    
919

    
920
</xsl:stylesheet>
Add picture from clipboard (Maximum size: 40 MB)