Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdmlib / cdmlib-print / src / main / resources / stylesheets / mediawiki / multipages.xsl @ 3ae8866d

History | View | Annotate | Download (42.3 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">
30
        <xsl:text>&#xa;</xsl:text>
31
    </xsl:template>
32

    
33
    <xsl:template name="wiki-newline-comment">
34
        <xsl:comment>
35
            <xsl:text>&#xa; </xsl:text>
36
        </xsl:comment>
37
    </xsl:template>
38

    
39
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
40

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

    
101
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
102

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

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

    
116
        <xsl:variable name="parent-title">
117
            <xsl:if test="exists(../..) and name(../..)='TaxonNode'">
118

    
119
                <xsl:call-template name="title">
120
                    <xsl:with-param name="taxon" select="../../Taxon"/>
121
                </xsl:call-template>
122

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

    
127
                <xsl:text>{{EDIT No Parent available}}</xsl:text>
128

    
129
            </xsl:if>
130
        </xsl:variable>
131

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

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

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

    
163
            </revision>
164
        </page>
165

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

    
182
                <text>
183
                    <xsl:attribute name="xml:space">preserve</xsl:attribute>
184
                    <!-- add table of contents -->
185
                    <xsl:call-template name="TOC"/>
186
                    <!-- add taxo tree -->
187
                    <xsl:value-of
188
                        select="concat('{{EDIT_Taxotree| parentTaxon=',$page-prefix,$parent-title,'}}')"/>
189
                    <xsl:call-template name="wiki-newline"/>
190
                    <xsl:call-template name="wiki-newline"/>
191

    
192
                    <!-- add contents of taxon page -->
193
                    <xsl:apply-templates select="Taxon"/>
194
                    <xsl:call-template name="display-references"/>
195
                    <xsl:call-template name="wiki-newline"/>
196
                    <xsl:call-template name="wiki-newline"/>
197
                    <!-- put page to corresponding tax category -->
198
                    <xsl:value-of select="concat('[[Category:',$title, ']]')"/>
199

    
200
                </text>
201
            </revision>
202
        </page>
203

    
204
        <!--<xsl:apply-templates select="//childNodes/TaxonNode/Taxon"/>-->
205
    </xsl:template>
206

    
207
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
208

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

    
248
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
249

    
250
    <!-- these templates create the name of the taxa wheater their kind is -->
251

    
252
    <xsl:template name="get-family-or-genus-title">
253
        <xsl:param name="genusOrUninomial"/>
254
        <xsl:value-of select="$genusOrUninomial"/>
255
    </xsl:template>
256

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

    
263
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
264

    
265
    <!-- we run this for the content of the page -->
266
    <xsl:template match="Taxon" name="Taxon">
267
        <xsl:apply-templates select="synonymy"/>
268
        <xsl:apply-templates select="key"/>
269
        <xsl:apply-templates select="descriptions"/>
270
        <!-- A change to Figure Gallery: comment following line: -->
271
        <xsl:call-template name="gallery"/>
272
        <!-- TODO to change to Figure Gallery: call figure gallery in the right place
273
        what else?-->
274
    </xsl:template>
275

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

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

    
280
    <xsl:template name="display-references">
281
        <xsl:text>{{EDIT_Reference_Section}}</xsl:text>
282
    </xsl:template>
283

    
284

    
285
    <xsl:template name="citations">
286
        <xsl:param name="name-uuid"/>
287
        <xsl:param name="descriptionelements"/>
288

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

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

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

    
297
            <xsl:for-each select="sources/e">
298
                <xsl:if test="nameUsedInSource/uuid=$name-uuid">
299

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

    
306
                </xsl:if>
307
            </xsl:for-each>
308
            <!--</ref>-->
309
        </xsl:for-each>
310

    
311
    </xsl:template>
312

    
313
    <!-- an example of mediawiki formtting of references:
314
        Mohrig, W.; Menzel, F. 1992: Neue Arten europäischer Trauermücken (Diptera, Sciaridae). An International Journal of Dipterological Research, 3(1-2), 1–16.
315
        Authors Date: title. inReferences title in italics, Volume in bold(series), page range -->
316
    <xsl:template name="reference">
317
        <xsl:param name="reference-node"/>
318
        <!--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-->
319
        <!--xsl:sort select="sources/e[1]/citation/datePublished/start"/-->
320

    
321
        <!-- first of all check if any of the data we show exist: TODO remove this test, 
322
            if we modified CDM services, to export proper data -->
323
        <xsl:if
324
            test="exists($reference-node/authorTeam/teamMembers/e[1]/lastname) 
325
            or exists($reference-node/authorTeam/lastname) or exists($reference-node/datePublished/start)
326
            or exists($reference-node/title)">
327

    
328
            <!-- use the citation-uuid as a unique name for the reference -->
329
            <xsl:variable name="citation-uuid" select="$reference-node/uuid"/>
330

    
331
            <!-- use the citation-uuid as a unique name for the reference -->
332
            <xsl:value-of select="concat('{{EDIT_Reference|name=',$citation-uuid,'|content=')"/>
333
            <xsl:text>{{aut|</xsl:text>
334
            <xsl:choose>
335
                <xsl:when test="exists($reference-node/authorTeam/teamMembers)">
336
                    <xsl:for-each select="$reference-node/authorTeam/teamMembers/e">
337
                        <xsl:value-of select="lastname"/>
338
                        <xsl:choose>
339
                            <xsl:when test="position() != last()">
340
                                <xsl:text> &amp; </xsl:text>
341
                            </xsl:when>
342
                        </xsl:choose>
343
                    </xsl:for-each>
344
                </xsl:when>
345
                <xsl:otherwise>
346
                    <xsl:value-of select="$reference-node/authorTeam/lastname"/>
347
                </xsl:otherwise>
348
            </xsl:choose>
349
            <!-- DEBUGGING display uuid so can check references against those in Tax Editor -->
350
            <xsl:text>}} </xsl:text>
351
            <xsl:if test="$reference-node/datePublished/start != ''">
352
                <xsl:value-of select="$reference-node/datePublished/start"/>
353
                <xsl:text>: </xsl:text>
354
            </xsl:if>
355
            <xsl:apply-templates select="$reference-node/title"/>
356
            <!-- do we need any other info from inReference node - see flore-afrique-centrale.xsl xsl -->
357
            <xsl:variable name="wiki-markup">''</xsl:variable>
358

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

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

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

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

    
415
    <!-- these templates provide the polytomous key 
416

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

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

    
427
        <xsl:if test="HashMap/records/e">
428

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

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

    
437

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

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

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

    
448
                <xsl:if test="edgeNumber = 2">
449
                    <xsl:text>*</xsl:text>
450
                </xsl:if>
451

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

    
454

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

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

    
487
                <xsl:text>}}</xsl:text>
488

    
489
            </xsl:for-each>
490

    
491
            <xsl:text>{{Key End}}</xsl:text>
492
        </xsl:if>
493

    
494
    </xsl:template>
495

    
496

    
497
    <!-- these templates provide the synonomy -->
498

    
499
    <xsl:template match="synonymy" name="synonymy">
500
        <xsl:call-template name="chapter">
501
            <xsl:with-param name="title">Synonomy</xsl:with-param>
502
        </xsl:call-template>
503
        <!--<xsl:text>{{EDIT_Taxon|</xsl:text>-->
504
        <xsl:apply-templates select="../name">
505
            <xsl:with-param name="type">Taxon</xsl:with-param>
506
        </xsl:apply-templates>
507
        <!--<xsl:text>}}</xsl:text>-->
508
        <xsl:call-template name="wiki-newline"/>
509
        <!-- getting nomenclatural refs and citaions for this name-->
510
        <xsl:call-template name="reference">
511
            <xsl:with-param name="reference-node" select="../name/nomenclaturalReference"/>
512
        </xsl:call-template>
513
        <xsl:call-template name="citations">
514
            <xsl:with-param name="descriptionelements"
515
                select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
516
            <xsl:with-param name="name-uuid" select="../name/uuid"/>
517
        </xsl:call-template>
518
        <xsl:apply-templates select="homotypicSynonymsByHomotypicGroup"/>
519
        <xsl:apply-templates select="heterotypicSynonymyGroups"/>
520
        <xsl:call-template name="wiki-newline"/>
521
        <xsl:call-template name="wiki-newline"/>
522
        <!--xsl:call-template name="citations">
523
            <xsl:with-param name="descriptionelements"
524
                select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
525
            <xsl:with-param name="name-uuid" select="../name/uuid"/>
526
        </xsl:call-template-->
527
    </xsl:template>
528

    
529
    <!--.............................................-->
530

    
531
    <xsl:template match="homotypicSynonymsByHomotypicGroup">
532
        <xsl:for-each select="e">
533
            <xsl:text>{{EDIT Homotypic Synonym|1|</xsl:text>
534
            <xsl:apply-templates select="name"/>
535
            <xsl:text>}}</xsl:text>
536
            <xsl:call-template name="wiki-newline-comment"/>
537
            <!--homotypicSynonymsByHomotypicGroup/e/name/nomenclaturalReference-->
538
            <!--xsl:apply-templates select="name/nomenclaturalReference"/-->
539
            <xsl:call-template name="reference">
540
                <xsl:with-param name="reference-node" select="name/nomenclaturalReference"/>
541
            </xsl:call-template>
542

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

    
552
    <!--.............................................-->
553

    
554
    <xsl:template match="heterotypicSynonymyGroups">
555
        <xsl:for-each select="e">
556
            <!-- take the first one to printout as the head of the homotypic group -->
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
            <!-- take the first one to printout as the head of the homotypic group -->
562
            <!--do foreach for the rest-->
563
            <xsl:for-each select="e[position() &gt; 1]">
564
                <xsl:text>{{EDIT Homotypic Synonym|2|</xsl:text>
565
                <xsl:apply-templates select="name"/>
566
                <xsl:text>}}</xsl:text>
567
                <xsl:call-template name="wiki-newline-comment"/>
568
                <xsl:call-template name="reference">
569
                    <xsl:with-param name="reference-node" select="name/nomenclaturalReference"/>
570
                </xsl:call-template>
571

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

    
583
    <!--.............................................-->
584

    
585
    <xsl:template match="name" name="name">
586
        <xsl:param name="type"/>
587
        <xsl:apply-templates select="taggedName">
588
            <xsl:with-param name="type" select="$type"/>
589
        </xsl:apply-templates>
590
        <!--xsl:apply-templates select="nomenclaturalReference"/-->
591
    </xsl:template>
592

    
593
    <!--.............................................-->
594

    
595
    <xsl:template match="taggedName">
596
        <xsl:param name="type"/>
597
        <xsl:choose>
598
            <xsl:when test="$type!=''">
599
                <xsl:value-of select="concat('{{EDIT_',$type,'|')"/>
600
                <xsl:for-each select="e">
601
                    <xsl:choose>
602
                        <xsl:when test="type='name'">
603
                            <xsl:apply-templates select="text"/>
604
                            <xsl:text> </xsl:text>
605
                        </xsl:when>
606
                        <xsl:when test="type='authors'">
607
                            <xsl:text>}}</xsl:text>
608
                            <xsl:value-of select="concat('{{EDIT_',$type,'_Author|')"/>
609
                            <xsl:apply-templates select="text"/>
610
                            <xsl:text>}}</xsl:text>
611
                        </xsl:when>
612
                    </xsl:choose>
613
                </xsl:for-each>
614
            </xsl:when>
615
            <xsl:otherwise>
616
                <xsl:for-each select="e">
617
                    <xsl:apply-templates select="text"/>
618
                    <xsl:text> </xsl:text>
619
                </xsl:for-each>
620
            </xsl:otherwise>
621
        </xsl:choose>
622

    
623

    
624

    
625

    
626
        <!-- TODO mybe some types don't contain font tags, we don't have to call the tmeplate  -->
627
        <!--        we could just use <xsl:value-of select="text"/>-->
628

    
629

    
630
        <!--<xsl:text>&#xA;</xsl:text>-->
631
    </xsl:template>
632

    
633
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
634

    
635
    <!-- description features -->
636

    
637
    <!-- TODO: for first and second level: 
638
        check if there is a page that describes the feature 
639
        and use Parameter "Link=pagename" with templates Tax_Feature or 
640
        Second_Level_Feature-->
641

    
642
    <xsl:template match="descriptions" name="descriptions">
643
        <xsl:call-template name="wiki-comment">
644
            <xsl:with-param name="wiki-comment">FEATURES</xsl:with-param>
645
        </xsl:call-template>
646
        <xsl:for-each select="features/feature">
647
            <xsl:choose>
648
                <xsl:when test="count(feature)!=0">
649
                    <xsl:call-template name="secondLevelDescriptionElements"/>
650
                </xsl:when>
651
                <xsl:otherwise>
652
                    <!-- everything but Citation -->
653
                    <xsl:if test="uuid!='99b2842f-9aa7-42fa-bd5f-7285311e0101'">
654
                        <xsl:call-template name="descriptionElements"/>
655
                    </xsl:if>
656
                    <!--xsl:apply-templates select="media/e/representations/e/parts/e/uri"/-->
657
                </xsl:otherwise>
658
            </xsl:choose>
659
        </xsl:for-each>
660
    </xsl:template>
661

    
662
    <!--.............................................-->
663

    
664
    <xsl:template name="secondLevelDescriptionElements">
665

    
666
        <xsl:value-of select="concat('{{EDIT_Highlevel_Feature|',representation_L10n,'}}')"/>
667
        <xsl:call-template name="wiki-newline"/>
668
        <xsl:for-each select="feature">
669
            <!-- TODO change mouseover to TermBase description - after exporting it from CDM -->
670
            <xsl:value-of
671
                select="concat('{{EDIT_Nested_Feature|name=',representation_L10n,'|mouseover=',representation_L10n,'|elements=')"/>
672
            <xsl:call-template name="wiki-newline"/>
673
            <!-- TODO create Elements -->
674
            <xsl:for-each select="descriptionelements/descriptionelement">
675
                <xsl:value-of
676
                    select="concat('{{EDIT_Nested_Feature_Element|',multilanguageText_L10n/text, '}}')"/>
677
                <xsl:choose>
678
                    <xsl:when test="position() != last()">
679
                        <xsl:text>{{EDIT_Delimiter}}</xsl:text>
680
                    </xsl:when>
681
                </xsl:choose>
682
                <xsl:if test="position() != last()">
683
                    <xsl:call-template name="wiki-newline"/>
684
                </xsl:if>
685
            </xsl:for-each>
686
            <xsl:text>}}</xsl:text>
687
            <xsl:call-template name="wiki-newline"/>
688
        </xsl:for-each>
689
        <xsl:call-template name="wiki-newline"/>
690

    
691
    </xsl:template>
692
    <!--.............................................-->
693

    
694

    
695
    <xsl:template name="descriptionElements">
696
        <xsl:choose>
697
            <xsl:when test="supportsCommonTaxonName='true'">
698
                <!-- must be Vernacular Name feature -->
699
                <xsl:call-template name="commonTaxonName"/>
700
            </xsl:when>
701
            <xsl:otherwise>
702
                <!-- for example Habitat, Material Examined -->
703
                <xsl:call-template name="textData"/>
704
            </xsl:otherwise>
705
        </xsl:choose>
706
    </xsl:template>
707

    
708
    <!--.............................................-->
709

    
710
    <xsl:template name="commonTaxonName">
711

    
712
        <xsl:value-of select="concat('{{EDIT_Feature|name=',representation_L10n,'|elements=')"/>
713
        <xsl:call-template name="wiki-newline"/>
714
        <xsl:for-each select="descriptionelements/descriptionelement">
715
            <xsl:text/>
716
            <xsl:value-of
717
                select="concat('{{EDIT_Common_Name|name=',name,'|language=',language/representation_L10n,'}}')"/>
718
            <xsl:choose>
719
                <xsl:when test="position() != last()">
720
                    <xsl:text>{{EDIT_Delimiter}}</xsl:text>
721
                    <xsl:call-template name="wiki-newline"/>
722
                </xsl:when>
723
            </xsl:choose>
724
        </xsl:for-each>
725
        <xsl:text>}}</xsl:text>
726
        <xsl:call-template name="wiki-newline"/>
727
        <xsl:call-template name="wiki-newline"/>
728
    </xsl:template>
729

    
730
    <!--.............................................-->
731

    
732
    <xsl:template name="textData">
733
        <xsl:value-of select="concat('{{EDIT_Feature|name=',representation_L10n, '|elements=')"/>
734
        <xsl:call-template name="wiki-newline"/>
735
        <xsl:text>{{EDIT_Feature_Text|</xsl:text>
736
        <!--
737
        <xsl:choose>
738
            <xsl:when test="uuid!='9fc9d10c-ba50-49ee-b174-ce83fc3f80c6'">-->
739
        <!-- feature is not "Distribution" -->
740

    
741
        <xsl:apply-templates
742
            select="descriptionelements/descriptionelement[1]/multilanguageText_L10n/text"/>
743
        <!--
744
            </xsl:when>
745
        </xsl:choose>
746
        -->
747
        <xsl:text>}}}}</xsl:text>
748
        <xsl:choose>
749
            <xsl:when test="uuid='6dfb4e78-c67e-410c-8989-c1fb1295abf6'">--> <!-- feature is "Figures -->
750
                <!-- A Gallery: uncomment following line -->
751
                <!--<xsl:apply-templates
752
                    select="descriptionelements/descriptionelement[1]/multilanguageText_L10n/text"/>-->
753
                <!-- A Gallery: comment following line -->
754
                <xsl:call-template name="gallery"/>
755
            </xsl:when>
756
        </xsl:choose>
757
        <xsl:call-template name="wiki-newline"/>
758
        <xsl:call-template name="wiki-newline"/>
759
        <!-- LORNA TRY IMAGE HERE -->
760
        <!--xsl:apply-templates select="descriptionelements/descriptionelement[1]/media/e/representations/e/parts/e/uri"/-->
761

    
762

    
763
    </xsl:template>
764

    
765
    <!--.............................................-->
766

    
767

    
768
    <xsl:template match="text">
769

    
770
        <xsl:call-template name="replace-tags">
771
            <xsl:with-param name="text-string" select="."/>
772
        </xsl:call-template>
773
    </xsl:template>
774

    
775
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
776
    <!-- image gallery -->
777

    
778
    <xsl:template name="gallery">
779
        <!-- A change to Figure Gallery: delete/comment following line-->
780
        <xsl:text>{{EDIT_Gallery|files=</xsl:text>
781
        <!-- A change to Figure Gallery: uncomment following line -->
782
        <!--<xsl:text>{{EDIT_Figure_Gallery|files=</xsl:text>-->
783
        <xsl:call-template name="wiki-newline"/>
784
        <xsl:apply-templates select=".//media/e/representations/e/parts/e/uri"/>
785

    
786
        <xsl:text>}}</xsl:text>
787
        <xsl:call-template name="wiki-newline"/>
788
        <xsl:call-template name="wiki-newline"/>
789
    </xsl:template>
790

    
791

    
792
    <xsl:template name="gallery_file"/>
793

    
794
    <xsl:template match="media/e/representations/e/parts/e/uri">
795

    
796
        <xsl:value-of
797
            select="concat('{{EDIT_Gallery_File|filename=',functx:substring-after-last(.,'/'), '|description=')"/>
798
        <!--go back up to the description element and get the text for the Figure legend -->
799
        <xsl:apply-templates select="../../../../../../../multilanguageText_L10n/text"/>
800
        <xsl:text>}}</xsl:text>
801
        <xsl:if test="position() != last()">
802
            <xsl:call-template name="wiki-newline"/>
803
        </xsl:if>
804
    </xsl:template>
805

    
806

    
807

    
808

    
809
    <!--+++++++++++++++++++++++++++++L A Y O U T ++++++++++++++++++++++++++++++++++++++ -->
810

    
811

    
812
    <!-- change here to change the look of the mediawiki output -->
813
    <!-- please use mediawiki templates -->
814
    <!-- think also of template changes in the mediawiki -->
815

    
816
    <xsl:template name="TOC">{{EDIT_TOC}}</xsl:template>
817

    
818
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
819
    <xsl:template name="chapter">
820
        <xsl:param name="title"/>
821
        <xsl:value-of select="concat('{{EDIT_Section|title=',$title,'}}')"/>
822
        <xsl:call-template name="wiki-newline"/>
823
        <xsl:call-template name="wiki-newline"/>
824
    </xsl:template>
825

    
826
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
827

    
828
    <xsl:template name="subchapter">
829
        <xsl:param name="title"/>
830
        <xsl:value-of select="concat('{{EDIT_Subsection|title=',$title,'}}')"/>
831
        <xsl:call-template name="wiki-newline"/>
832
        <xsl:call-template name="wiki-newline"/>
833
    </xsl:template>
834

    
835
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
836
    <!-- puts in a wiki comment -->
837
    <xsl:template name="wiki-comment">
838
        <xsl:param name="wiki-comment"/>
839
        <xsl:comment>
840
            <xsl:value-of select="concat($wiki-comment,'&#xa;')"/>
841
        </xsl:comment>
842
    </xsl:template>
843

    
844
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
845

    
846
    <!--this template layouts and displays the name of a 
847
        taxon depending on it's "kind"
848
        MAYDO: create more useful layouts instead of title sizes-->
849
    <xsl:template name="display-taxon-name">
850
        <xsl:param name="taxon"/>
851
        <!-- get the name of the taxon -->
852
        <xsl:variable name="name">
853
            <xsl:call-template name="title">
854
                <xsl:with-param name="taxon" select="$taxon"/>
855
            </xsl:call-template>
856
        </xsl:variable>
857
        <!-- format the name of the taxon according to it's kind -->
858
        <xsl:choose>
859
            <!-- family -->
860
            <xsl:when test="$taxon/name/rank/uuid='af5f2481-3192-403f-ae65-7c957a0f02b6'">
861
                <xsl:value-of select="concat('{{EDIT_Family_Name|', $name, '}}')"/>
862
            </xsl:when>
863
            <!-- genus -->
864
            <xsl:when test="$taxon/name/rank/uuid='1b11c34c-48a8-4efa-98d5-84f7f66ef43a'">
865
                <xsl:value-of select="concat('{{EDIT_Genus Name|', $name, '}}')"/>
866
            </xsl:when>
867
            <!--TODO-->
868
            <!-- subgenus -->
869
            <xsl:when test="$taxon/name/rank/uuid='78786e16-2a70-48af-a608-494023b91904'">
870
                <xsl:value-of select="concat('{{EDIT_Subgenus Name|', $name, '}}')"/>
871
            </xsl:when>
872
            <!-- species -->
873
            <xsl:when test="$taxon/name/rank/uuid='b301f787-f319-4ccc-a10f-b4ed3b99a86d'">
874
                <xsl:value-of select="concat('{{EDIT_Species Name|', $name, '}}')"/>
875
            </xsl:when>
876
            <xsl:otherwise>
877
                <!-- for debugging --> Unformatted title for rank uuid: <xsl:value-of
878
                    select="$taxon/name/rank/uuid"/>: <xsl:value-of select="$taxon/name/titleCache"
879
                />
880
            </xsl:otherwise>
881
        </xsl:choose>
882
    </xsl:template>
883

    
884

    
885
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
886

    
887
    <!--we replace "escaped" html <i> and <b> with mediawiki markup-->
888
    <!--.............................................-->
889

    
890
    <xsl:template name="replace-tags">
891
        <xsl:param name="text-string"/>
892

    
893
        <!-- first replace bold tags and put the result in text-string2 -->
894
        <xsl:variable name="text-string2">
895
            <xsl:call-template name="add-markup">
896
                <xsl:with-param name="str" select="$text-string"/>
897
                <xsl:with-param name="wiki-markup">'''</xsl:with-param>
898
                <xsl:with-param name="tag-name">b</xsl:with-param>
899
            </xsl:call-template>
900
        </xsl:variable>
901

    
902
        <!-- second replace italic tags on text-string2 -->
903
        <xsl:call-template name="add-markup">
904
            <xsl:with-param name="str" select="$text-string2"/>
905
            <xsl:with-param name="wiki-markup">''</xsl:with-param>
906
            <xsl:with-param name="tag-name">i</xsl:with-param>
907
        </xsl:call-template>
908
    </xsl:template>
909

    
910
    <!--.............................................-->
911

    
912
    <xsl:template name="add-markup">
913
        <xsl:param name="str"/>
914
        <xsl:param name="wiki-markup"/>
915
        <xsl:param name="tag-name"/>
916

    
917
        <xsl:variable name="opening-tag">
918
            <xsl:value-of select="concat('&lt;', $tag-name, '&gt;')"> </xsl:value-of>
919
        </xsl:variable>
920
        <xsl:variable name="closing-tag">
921
            <xsl:value-of select="concat('&lt;/', $tag-name, '&gt;')"> </xsl:value-of>
922
        </xsl:variable>
923

    
924
        <xsl:choose>
925
            <!-- if the tag occures in the string -->
926
            <xsl:when test="contains($str, $opening-tag) and contains($str, $closing-tag)">
927

    
928
                <!-- separate string before, inside and after the tag -->
929
                <xsl:variable name="before-tag" select="substring-before($str, $opening-tag)"/>
930
                <xsl:variable name="inside-tag"
931
                    select="substring-before(substring-after($str,$opening-tag),$closing-tag)"/>
932
                <xsl:variable name="after-tag" select="substring-after($str, $closing-tag)"/>
933

    
934
                <!-- built the new string by putting in the mediawiki template -->
935
                <xsl:value-of select="concat($before-tag, $wiki-markup, $inside-tag, $wiki-markup)"/>
936
                <!-- in the part after the closing tag could be more tag, so we do a recursive call -->
937
                <xsl:call-template name="add-markup">
938
                    <xsl:with-param name="str" select="$after-tag"/>
939
                    <xsl:with-param name="wiki-markup" select="$wiki-markup"/>
940
                    <xsl:with-param name="tag-name" select="$tag-name"/>
941
                </xsl:call-template>
942
            </xsl:when>
943
            <xsl:otherwise>
944
                <xsl:value-of select="$str"/>
945
            </xsl:otherwise>
946
        </xsl:choose>
947
    </xsl:template>
948

    
949
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
950

    
951

    
952

    
953

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