Project

General

Profile

Download (40.3 KB) Statistics
| Branch: | Tag: | Revision:
1
<!DOCTYPE xsl:stylesheet [<!ENTITY hyphen "&#45;" > <!ENTITY ndash "&#x2013;" >]>
2
<xsl:stylesheet version="2.0"
3
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:functx="http://www.functx.com"
4
	xmlns:fn="http://www.w3.org/2005/xpath-functions">
5
	<xsl:import href="src/main/resources/stylesheets/mediawiki/functx-1.0-doc-2007-01.xsl" />
6
	<!--xsl:import href="functx-1.0-doc-2007-01.xsl" /-->
7
	<!-- xsl:output method="xml" indent="no"/> -->
8
	<xsl:strip-space elements="text" />
9

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

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

    
15
	<!-- mediawiki prefix -->
16
	<xsl:param name="prefix"></xsl:param>
17
	<xsl:variable name="page-prefix">
18
		<!-- <xsl:text>Internal:</xsl:text> -->
19
		<xsl:value-of select="$prefix"></xsl:value-of>
20
	</xsl:variable>
21
	
22
	<!-- cdm url of source -->
23
	<xsl:param name="cdm-url"></xsl:param>
24
	<xsl:variable name="cdm-credit-text">
25
		<xsl:value-of select="concat('This page was generated automatically from content in ', $cdm-url)"></xsl:value-of>
26
	</xsl:variable>
27

    
28
	<!-- create a timestamp for the whole going -->
29
	<xsl:variable name="timestamp">
30
		<xsl:value-of
31
			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')" />
32
	</xsl:variable>
33

    
34
	<!-- create the username who changed/created the pages -->
35
	<xsl:param name="username"></xsl:param>
36
	<xsl:variable name="u_name">
37
		<xsl:value-of select="$username"></xsl:value-of>
38
	</xsl:variable>
39

    
40
	<xsl:template name="wiki-newline">
41
		<xsl:text>&#xa;</xsl:text>
42
	</xsl:template>
43

    
44
	<xsl:template name="wiki-newline-comment">
45
		<xsl:comment>
46
			<xsl:text>&#xa; </xsl:text>
47
		</xsl:comment>
48
	</xsl:template>
49

    
50
	<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
51

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

    
111
	<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
112

    
113
	<!-- this creates a page and a category for every taxon node. -->
114
	<!-- TODO create a template for page creating and for categorie creating -->
115
	<xsl:template match="TaxonNode" name="TaxonNode">
116
		<!-- as we will need the title more than once, we create a variable -->
117
		<xsl:variable name="title">
118
			<xsl:call-template name="title">
119
				<xsl:with-param name="taxon" select="Taxon" />
120
			</xsl:call-template>
121
		</xsl:variable>
122

    
123
		<!-- we also initialize the parent taxon variable if there is a higher 
124
			taxon assigned: -->
125

    
126
		<xsl:variable name="parent-title">
127
			<xsl:if test="exists(../..) and name(../..)='TaxonNode'">
128

    
129
				<xsl:call-template name="title">
130
					<xsl:with-param name="taxon" select="../../Taxon" />
131
				</xsl:call-template>
132

    
133
			</xsl:if>
134
			<!-- else if no higher taxon could be found -->
135
			<xsl:if test="not(exists(../..)) or not(name(../..)='TaxonNode')">
136

    
137
				<xsl:text>{{EDIT No Parent available}}</xsl:text>
138

    
139
			</xsl:if>
140
		</xsl:variable>
141

    
142
		<!-- create category -->
143
		<xsl:text>
144
            <!-- this creates a newline before the <page> 
145
            if it was not there, the page could not be imported by the mediawiki-->
146
        </xsl:text>
147

    
148
		<page>
149
			<title>
150
				<xsl:text>Category:</xsl:text>
151
				<xsl:value-of select="$title" />
152
			</title>
153
			<revision>
154
				<!-- TODO: create seconds without positions after decimal point! -->
155
				<timestamp>
156
					<xsl:value-of select="$timestamp" />
157
				</timestamp>
158
				<contributor>
159
					<username>
160
						<xsl:value-of select="$u_name" />
161
					</username>
162
				</contributor>
163

    
164
				<text>
165
					<xsl:attribute name="xml:space">preserve</xsl:attribute>
166
					<!-- redirekt to corresponding page -->
167
					<xsl:value-of select="concat('#REDIRECT [[',$page-prefix,$title,']]')" />
168
					<!-- add parent categorie if exists -->
169
					<xsl:if test="exists(../..) and name(../..)='TaxonNode'">
170
						<xsl:call-template name="wiki-newline" />
171
						<xsl:value-of select="concat('[[Category:',$parent-title,']]')" />
172
					</xsl:if>
173
				</text>
174

    
175
			</revision>
176
		</page>
177

    
178
		<!-- create taxon page -->
179
		<page>
180
			<title>
181
				<xsl:value-of select="concat($page-prefix,$title)" />
182
			</title>
183
			<revision>
184
				<!-- MAYDO: create seconds without positions after decimal point! -->
185
				<timestamp>
186
					<xsl:value-of select="$timestamp" />
187
				</timestamp>
188
				<contributor>
189
					<username>
190
						<xsl:value-of select="$username" />
191
					</username>
192
				</contributor>
193

    
194
				<text>
195
					<xsl:attribute name="xml:space">preserve</xsl:attribute>
196
					<!-- add table of contents -->
197
					<xsl:call-template name="TOC" />
198
					<!-- add taxo tree -->
199
					<xsl:value-of
200
						select="concat('{{EDIT_Taxotree| parentTaxon=',$page-prefix,$parent-title,'}}')" />
201
					<xsl:call-template name="wiki-newline" />
202
					<xsl:call-template name="wiki-newline" />
203

    
204
					<!-- add contents of taxon page -->
205
					<xsl:call-template name="credit" />
206
					<xsl:call-template name="wiki-newline" />
207
					<xsl:apply-templates select="Taxon" />
208
					<xsl:call-template name="display-references" />
209
					<xsl:call-template name="wiki-newline" />
210
					<xsl:call-template name="wiki-newline" />
211
					<!-- put page to corresponding tax category -->
212
					<xsl:value-of select="concat('[[Category:',$title, ']]')" />
213

    
214
				</text>
215
			</revision>
216
		</page>
217

    
218
		<!--<xsl:apply-templates select="//childNodes/TaxonNode/Taxon"/> -->
219
	</xsl:template>
220

    
221
	<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
222

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

    
268
	<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
269

    
270
	<!-- these templates create the name of the taxa wheater their kind is -->
271

    
272
	<xsl:template name="get-family-or-genus-title">
273
		<xsl:param name="genusOrUninomial" />
274
		<xsl:value-of select="$genusOrUninomial" />
275
	</xsl:template>
276

    
277
	<xsl:template name="get-species-title">
278
		<xsl:param name="taxon" />
279
		<xsl:value-of
280
			select="concat($taxon/name/genusOrUninomial, ' ', $taxon/name/specificEpithet)" />
281
	</xsl:template>
282

    
283
	<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
284

    
285
	<!-- we run this for the content of the page -->
286
	<xsl:template match="Taxon" name="Taxon">
287
		
288
		<xsl:apply-templates select="synonymy" />
289
		<xsl:apply-templates select="key" />
290
		<xsl:apply-templates select="descriptions" />
291
		<!-- A change to Gallery: uncomment following line: -->
292
		<!-- <xsl:call-template name="gallery"/> -->
293
		<xsl:call-template name="featureGallery" />
294
		<!-- TODO to change to Figure Gallery: call figure gallery in the right 
295
			place what else? -->
296
	</xsl:template>
297

    
298
	<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
299

    
300
	<!-- these templates provide the citations -->
301

    
302
	<xsl:template name="display-references">
303
		<xsl:text>{{EDIT_Reference_Section}}</xsl:text>
304
	</xsl:template>
305

    
306

    
307
	<xsl:template name="citations">
308
		<xsl:param name="name-uuid" />
309
		<xsl:param name="descriptionelements" />
310

    
311
		<!--<ref name="{$name-uuid}"> -->
312
		<!-- iterate through all the description elements for the citation feature -->
313
		<xsl:for-each select="$descriptionelements/descriptionelement">
314

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

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

    
319
			<xsl:for-each select="sources/e">
320
				<xsl:if test="nameUsedInSource/uuid=$name-uuid">
321

    
322
					<!-- call reference template with sources/e/citation -->
323
					<xsl:call-template name="reference">
324
						<xsl:with-param name="reference-node" select="citation" />
325
					</xsl:call-template>
326
					<!-- use the citation-uuid as a unique name for the reference -->
327

    
328
				</xsl:if>
329
			</xsl:for-each>
330
			<!--</ref> -->
331
		</xsl:for-each>
332

    
333
	</xsl:template>
334

    
335
	<!-- an example of mediawiki formtting of references: Mohrig, W.; Menzel, 
336
		F. 1992: Neue Arten europäischer Trauermücken (Diptera, Sciaridae). An International 
337
		Journal of Dipterological Research, 3(1-2), 1–16. Authors Date: title. inReferences 
338
		title in italics, Volume in bold(series), page range -->
339
	<xsl:template name="reference">
340
		<xsl:param name="reference-node" />
341
		<!--TODO Do we need to sort the list of references in WikiMedia or will 
342
			they just appear in numbered order as they occur in the names -->
343
		<!--xsl:sort select="sources/e[1]/citation/datePublished/start"/ -->
344

    
345
		<!-- first of all check if any of the data we show exist: TODO remove this 
346
			test, if we modified CDM services, to export proper data -->
347
		<xsl:if
348
			test="exists($reference-node/authorship/teamMembers/e[1]/familyname) 
349
            or exists($reference-node/authorship/familyname) or exists($reference-node/datePublished/start)
350
            or exists($reference-node/title)">
351

    
352
			<!-- use the citation-uuid as a unique name for the reference -->
353
			<xsl:variable name="citation-uuid" select="$reference-node/uuid" />
354

    
355
			<!-- use the citation-uuid as a unique name for the reference -->
356
			<xsl:value-of
357
				select="concat('{{EDIT_Reference|name=',$citation-uuid,'|content=')" />
358

    
359
			<xsl:choose>
360
				<xsl:when test="exists($reference-node/authorship/teamMembers)">
361
					<xsl:text>{{aut|</xsl:text>
362
					<xsl:for-each select="$reference-node/authorship/teamMembers/e">
363
						<xsl:value-of select="familyname" />
364
						<xsl:choose>
365
							<xsl:when test="position() != last()">
366
								<xsl:text> &amp; </xsl:text>
367
							</xsl:when>
368
						</xsl:choose>
369
					</xsl:for-each>
370
					<xsl:text>}} </xsl:text>
371
				</xsl:when>
372
				<xsl:otherwise>
373
					<xsl:choose>
374
						<xsl:when test="exists($reference-node/authorship/familyname)">
375
							<xsl:text>{{aut|</xsl:text>
376
							<xsl:value-of select="$reference-node/authorship/familyname" />
377
							<xsl:text>}} </xsl:text>
378
						</xsl:when>
379
						<xsl:otherwise>
380
							<xsl:value-of select="$reference-node/titleCache"></xsl:value-of>
381
						</xsl:otherwise>
382
					</xsl:choose>
383

    
384
				</xsl:otherwise>
385

    
386
			</xsl:choose>
387

    
388
			<!-- DEBUGGING display uuid so can check references against those in Tax 
389
				Editor -->
390
			<!--<xsl:if test="$reference-node/datePublished/start != ''"> <xsl:value-of 
391
				select="$reference-node/datePublished/start"/> <xsl:text>: </xsl:text> </xsl:if> -->
392
			<xsl:apply-templates select="$reference-node/title" />
393
			<!-- do we need any other info from inReference node - see flore-afrique-centrale.xsl 
394
				xsl -->
395
			<xsl:variable name="wiki-markup">
396
				''
397
			</xsl:variable>
398

    
399
			<xsl:if test="$reference-node/inReference/node()">
400
				<xsl:value-of
401
					select="concat($wiki-markup, $reference-node/inReference/title, $wiki-markup)" />
402
			</xsl:if>
403
			<xsl:apply-templates select="$reference-node/volume" />
404
			<xsl:apply-templates select="$reference-node/series" />
405
			<xsl:apply-templates select="$reference-node/pages" />
406
			<xsl:apply-templates select="$reference-node/placePublished" />
407
			<xsl:apply-templates select="$reference-node/publisher" />
408

    
409
			<!--xsl:choose> <xsl:when test="$reference-node/inReference/node()"> <xsl:value-of 
410
				select="$reference-node/title"/> <xsl:text>. </xsl:text> <xsl:value-of select="$reference-node/inReference/title"/> 
411
				</xsl:when> <xsl:otherwise> <xsl:value-of select="$reference-node/title"/> 
412
				</xsl:otherwise> </xsl:choose> <xsl:text>.</xsl:text> <xsl:value-of select="$reference-node/pages"/> 
413
				<xsl:text>.</xsl:text> <xsl:if test="$reference-node/type = 'Book' or $reference-node/type 
414
				= 'BookSection'"> <xsl:if test="$reference-node/placePublished != '' or $reference-node/publisher 
415
				!= ''"> <xsl:text> </xsl:text> <xsl:value-of select="$reference-node/placePublished"/> 
416
				<xsl:text>, </xsl:text> <xsl:value-of select="$reference-node/publisher"/> 
417
				<xsl:text>.</xsl:text> </xsl:if> </xsl:if -->
418
			<xsl:text>}}</xsl:text>
419
		</xsl:if>
420
		<!--</ref> -->
421
		<xsl:call-template name="wiki-newline-comment" />
422
	</xsl:template>
423

    
424
	<!-- wild card match for different children of nomenclaturalReference and 
425
		citaion nodes -->
426
	<xsl:template match="*">
427

    
428
		<xsl:choose>
429
			<xsl:when test="name(.) = 'pages'">
430
				<xsl:value-of select="replace(.,'&hyphen;','&ndash;')" />
431
			</xsl:when>
432
			<xsl:otherwise>
433
				<xsl:value-of select="." />
434
			</xsl:otherwise>
435
		</xsl:choose>
436

    
437
		<!--<xsl:text>FOO </xsl:text> -->
438
		<xsl:if
439
			test="name(.) = 'title' or name(.) = 'publisher' or name(.) = 'pages'">
440
			<!-- . if publisher or title - comma if placePublished -->
441
			<xsl:text>. </xsl:text>
442
		</xsl:if>
443

    
444
		<xsl:if test="name(.) = 'volume'">
445
			<xsl:text>: </xsl:text>
446
		</xsl:if>
447
		<xsl:if
448
			test="(../type = 'Book' or ../type = 'BookSection') and name(.) = 'placePublished' and . != ''">
449
			<xsl:text>, </xsl:text>
450
		</xsl:if>
451
	</xsl:template>
452
	<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
453

    
454
	<!-- these templates provide the polytomous key For example: {{Lead | 1=4| 
455
		2= jeunes couverts de cils simples et glanduleux mais jamais de cils denticulés 
456
		ou branchus| result = Erica trimera (Flora of XX) | result text = ''Erica 
457
		trimera''}} -->
458
	<xsl:template match="key" name="key">
459

    
460
		<xsl:param name="uuidFamily">
461
			210a8214-4e69-401a-8e47-c7940d990bdd
462
		</xsl:param>
463
		<xsl:param name="uuidGenus">
464
			1b11c34c-48a8-4efa-98d5-84f7f66ef43a
465
		</xsl:param>
466
		<xsl:param name="uuidSubgenus">
467
			78786e16-2a70-48af-a608-494023b91904
468
		</xsl:param>
469

    
470
		<xsl:if test="HashMap/records/e">
471

    
472
			<xsl:call-template name="chapter">
473
				<xsl:with-param name="title">
474
					Key
475
				</xsl:with-param>
476
			</xsl:call-template>
477

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

    
482

    
483
			<!--xsl:if test="ArrayList/e" -->
484
			<xsl:for-each select="HashMap/records/e">
485

    
486
				<xsl:variable name="node-number" select="nodeNumber" />
487
				<xsl:variable name="child-statement" select="childStatement" />
488

    
489
				<!-- TaxonLinkDto or PolytomousKeyNodeLinkDto -->
490
				<!--xsl:value-of select="concat('{{Decision | id =', $node-number, '| 
491
					lead 1 = ', $child-statement)"/ -->
492
				<xsl:value-of select="concat('{{Lead | 1 =', $node-number)" />
493

    
494
				<xsl:if test="edgeNumber = 2">
495
					<xsl:text>*</xsl:text>
496
				</xsl:if>
497

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

    
500

    
501
				<xsl:choose>
502
					<xsl:when test="links/e[1]/class = 'PolytomousKeyNodeLinkDto'">
503
						<xsl:variable name="link-node-number" select="links/e[1]/nodeNumber" />
504
						<xsl:value-of select="concat('| 3 =', $link-node-number)" />
505
					</xsl:when>
506
					<xsl:when test="links/e[1]/class = 'TaxonLinkDto'">
507

    
508
						<xsl:text>| result  = '' </xsl:text>
509
						<xsl:variable name="taxonUuid" select="links/e[1]/uuid" />
510
						<xsl:variable name="genus"
511
							select="//Taxon/uuid[.=$taxonUuid]/../name/genusOrUninomial" />
512
						<xsl:choose>
513
							<xsl:when test="taxonUuid = $uuidSubgenus">
514
								<xsl:variable name="repr"
515
									select="//Taxon/uuid[.='71cd0e8d-47eb-4c66-829a-e21c705ee660']/../name/rank/representation_L10n" />
516
								<xsl:value-of select="concat($genus, '. ', $repr)" />
517
							</xsl:when>
518
							<xsl:when test="taxonUuid = $uuidGenus">
519
								<xsl:apply-templates select="$genus" />
520
							</xsl:when>
521
							<xsl:otherwise>
522
								<xsl:variable name="specificEpithet"
523
									select="//Taxon/uuid[.=$taxonUuid]/../name/specificEpithet" />
524
								<!-- abbreviate the genus for species names -->
525
								<xsl:value-of select="concat($genus, ' ', $specificEpithet)" />
526
							</xsl:otherwise>
527
						</xsl:choose>
528
						<xsl:text>''</xsl:text>
529
					</xsl:when>
530
					<xsl:otherwise />
531
				</xsl:choose>
532

    
533
				<xsl:text>}}</xsl:text>
534

    
535
			</xsl:for-each>
536

    
537
			<xsl:text>{{Key End}}</xsl:text>
538
			<xsl:call-template name="wiki-newline"></xsl:call-template>
539
		</xsl:if>
540

    
541
	</xsl:template>
542

    
543
	<!-- this template provides the Credit to the source database -->
544
	
545
	<xsl:template name="credit">
546
		<xsl:call-template name="chapter">
547
			<xsl:with-param name="title">
548
				Credits
549
			</xsl:with-param>
550
		</xsl:call-template>
551
			<xsl:apply-templates select="$cdm-credit-text"/><br></br>
552
	</xsl:template>
553

    
554
	<!-- these templates provide the synonomy -->
555

    
556
	<xsl:template match="synonymy" name="synonymy">
557
		<xsl:call-template name="chapter">
558
			<xsl:with-param name="title">
559
				Synonomy
560
			</xsl:with-param>
561
		</xsl:call-template>
562
		<!--<xsl:text>{{EDIT_Taxon|</xsl:text> -->
563
		<xsl:apply-templates select="../name">
564
			<xsl:with-param name="type">
565
				Taxon
566
			</xsl:with-param>
567
		</xsl:apply-templates>
568
		<!--<xsl:text>}}</xsl:text> -->
569
		<xsl:call-template name="wiki-newline" />
570
		<!-- getting nomenclatural refs and citaions for this name -->
571
		<xsl:call-template name="reference">
572
			<xsl:with-param name="reference-node" select="../name/nomenclaturalReference" />
573
		</xsl:call-template>
574
		<xsl:call-template name="citations">
575
			<xsl:with-param name="descriptionelements"
576
				select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements" />
577
			<xsl:with-param name="name-uuid" select="../name/uuid" />
578
		</xsl:call-template>
579
		<xsl:apply-templates select="homotypicSynonymsByHomotypicGroup" />
580
		<xsl:apply-templates select="heterotypicSynonymyGroups" />
581
		<xsl:call-template name="wiki-newline" />
582
		<xsl:call-template name="wiki-newline" />
583
		<!--xsl:call-template name="citations"> <xsl:with-param name="descriptionelements" 
584
			select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/> 
585
			<xsl:with-param name="name-uuid" select="../name/uuid"/> </xsl:call-template -->
586
	</xsl:template>
587

    
588
	<!--............................................. -->
589

    
590
	<xsl:template match="homotypicSynonymsByHomotypicGroup">
591
		<xsl:for-each select="e">
592
			<xsl:text>{{EDIT Homotypic Synonym|1|</xsl:text>
593
			<xsl:apply-templates select="name" />
594
			<xsl:text>}}</xsl:text>
595
			<xsl:call-template name="wiki-newline-comment" />
596
			<!--homotypicSynonymsByHomotypicGroup/e/name/nomenclaturalReference -->
597
			<!--xsl:apply-templates select="name/nomenclaturalReference"/ -->
598
			<xsl:for-each select="name/homotypicalGroup/typifiedNames/e">
599
				<xsl:call-template name="reference">
600
					<xsl:with-param name="reference-node" select="nomenclaturalReference" />
601
				</xsl:call-template>
602
			</xsl:for-each>
603
			<xsl:call-template name="reference">
604
				<xsl:with-param name="reference-node" select="name/nomenclaturalReference" />
605

    
606

    
607
			</xsl:call-template>
608

    
609
			<!--LORNA Pass the description elements for the citation 99b2842f-9aa7-42fa-bd5f-7285311e0101 -->
610
			<xsl:call-template name="citations">
611
				<xsl:with-param name="descriptionelements"
612
					select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements" />
613
				<xsl:with-param name="name-uuid" select="name/uuid" />
614
			</xsl:call-template>
615
		</xsl:for-each>
616
	</xsl:template>
617

    
618
	<!--............................................. -->
619

    
620
	<xsl:template match="heterotypicSynonymyGroups">
621
		<xsl:for-each select="e">
622
			<!-- take the first one to printout as the head of the homotypic group -->
623
			<xsl:variable name="first-element" select="e[1]" />
624
			<xsl:text>{{EDIT Heterotypic Synonym|1|</xsl:text>
625
			<xsl:apply-templates select="$first-element/name" />
626
			<xsl:text>}}</xsl:text>
627

    
628
			<xsl:call-template name="wiki-newline-comment" />
629
			<xsl:call-template name="reference">
630
				<xsl:with-param name="reference-node"
631
					select="$first-element/name/nomenclaturalReference" />
632
			</xsl:call-template>
633

    
634
			<xsl:for-each select="name/homotypicalGroup/typifiedNames/e">
635
				<xsl:call-template name="reference">
636
					<xsl:with-param name="reference-node"
637
						select="$first-element/nomenclaturalReference" />
638
				</xsl:call-template>
639
			</xsl:for-each>
640

    
641
			<!-- take the first one to printout as the head of the homotypic group -->
642
			<!--do foreach for the rest -->
643
			<xsl:for-each select="e[position() &gt; 1]">
644
				<!--xsl:for-each select="e" -->
645
				<xsl:text>{{EDIT Homotypic Synonym|2|</xsl:text>
646
				<xsl:apply-templates select="name" />
647
				<xsl:text>}}</xsl:text>
648
				<xsl:call-template name="wiki-newline-comment" />
649
				<xsl:call-template name="reference">
650
					<xsl:with-param name="reference-node" select="name/nomenclaturalReference" />
651
				</xsl:call-template>
652

    
653
				<xsl:for-each select="name/homotypicalGroup/typifiedNames/e">
654
					<xsl:call-template name="reference">
655
						<xsl:with-param name="reference-node" select="nomenclaturalReference" />
656
					</xsl:call-template>
657
				</xsl:for-each>
658

    
659
				<!--LORNA Pass the description elements for the citation 99b2842f-9aa7-42fa-bd5f-7285311e0101 -->
660
				<xsl:call-template name="citations">
661
					<xsl:with-param name="descriptionelements"
662
						select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements" />
663
					<xsl:with-param name="name-uuid" select="name/uuid" />
664
				</xsl:call-template>
665
			</xsl:for-each>
666
		</xsl:for-each>
667
		<!--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 -->
668
	</xsl:template>
669

    
670
	<!--............................................. -->
671

    
672
	<xsl:template match="name" name="name">
673
		<xsl:param name="type" />
674
		<xsl:apply-templates select="taggedName">
675
			<xsl:with-param name="type" select="$type" />
676
		</xsl:apply-templates>
677
		<!--xsl:apply-templates select="nomenclaturalReference"/ -->
678
	</xsl:template>
679

    
680
	<!--............................................. -->
681

    
682
	<xsl:template match="taggedName">
683
		<xsl:param name="type" />
684
		<xsl:choose>
685
			<xsl:when test="$type!=''">
686
				<xsl:value-of select="concat('{{EDIT_',normalize-space($type),'|')" />
687
				<xsl:for-each select="e">
688
					<xsl:choose>
689
						<xsl:when test="type='name'">
690
							<xsl:apply-templates select="text" />
691
							<xsl:text> </xsl:text>
692
						</xsl:when>
693
						<xsl:when test="type='authors'">
694
							<xsl:text>}}</xsl:text>
695
							<xsl:value-of
696
								select="concat('{{EDIT_',normalize-space($type),'_Author|')" />
697
							<xsl:apply-templates select="text" />
698
							<xsl:text>}}</xsl:text>
699
						</xsl:when>
700
					</xsl:choose>
701
				</xsl:for-each>
702
			</xsl:when>
703
			<xsl:otherwise>
704
				<xsl:for-each select="e">
705
					<xsl:apply-templates select="text" />
706
					<xsl:text> </xsl:text>
707
				</xsl:for-each>
708
			</xsl:otherwise>
709
		</xsl:choose>
710

    
711

    
712

    
713

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

    
718

    
719
		<!--<xsl:text>&#xA;</xsl:text> -->
720
	</xsl:template>
721

    
722
	<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
723

    
724
	<!-- description features -->
725

    
726
	<!-- TODO: for first and second level: check if there is a page that describes 
727
		the feature and use Parameter "Link=pagename" with templates Tax_Feature 
728
		or Second_Level_Feature -->
729

    
730
	<xsl:template match="descriptions" name="descriptions">
731
		<xsl:call-template name="wiki-comment">
732
			<xsl:with-param name="wiki-comment">
733
				FEATURES
734
			</xsl:with-param>
735
		</xsl:call-template>
736
		<xsl:for-each select="features/feature">
737
			<xsl:choose>
738
				<xsl:when test="count(feature)!=0">
739
					<xsl:call-template name="secondLevelDescriptionElements" />
740
				</xsl:when>
741
				<xsl:otherwise>
742
					<!-- everything but Citation -->
743
					<xsl:if test="uuid!='99b2842f-9aa7-42fa-bd5f-7285311e0101'">
744
						<xsl:call-template name="descriptionElements" />
745
					</xsl:if>
746
					<!--xsl:apply-templates select="media/e/representations/e/parts/e/uri"/ -->
747
				</xsl:otherwise>
748
			</xsl:choose>
749
		</xsl:for-each>
750

    
751
	</xsl:template>
752

    
753
	<!--............................................. -->
754

    
755
	<xsl:template name="secondLevelDescriptionElements">
756

    
757
		<xsl:value-of
758
			select="concat('{{EDIT_Highlevel_Feature|',representation_L10n,'}}')" />
759
		<xsl:call-template name="wiki-newline" />
760
		<xsl:for-each select="feature">
761
			<!-- TODO assign TermBase description to parameter description- after 
762
				exporting it from CDM -->
763
			<xsl:if test="uuid!='6dfb4e78-c67e-410c-8989-c1fb1295abf6'">
764
				<xsl:value-of
765
					select="concat('{{EDIT_Nested_Feature|name=',representation_L10n,'|description=',representation_L10n,'|elements=')" />
766
				<xsl:call-template name="wiki-newline" />
767
				<!-- TODO create Elements -->
768
				<xsl:for-each select="descriptionelements/descriptionelement">
769
					<xsl:value-of
770
						select="concat('{{EDIT_Nested_Feature_Element|',multilanguageText_L10n/text, '}}')" />
771
					
772
					<xsl:choose>
773
						<xsl:when test="position() != last()">
774
							<xsl:text>{{EDIT_Delimiter}}</xsl:text>
775
						</xsl:when>
776
					</xsl:choose>
777
					<xsl:if test="position() != last()">
778
						<xsl:call-template name="wiki-newline" />
779
					</xsl:if>
780
				</xsl:for-each>
781
				<xsl:text>}}</xsl:text>
782
				<xsl:call-template name="wiki-newline" />
783
			</xsl:if>
784
		</xsl:for-each>
785
		<xsl:for-each select="feature">
786
			<xsl:if test="uuid='6dfb4e78-c67e-410c-8989-c1fb1295abf6'">
787
				<xsl:call-template name="featureGallery" />
788
			</xsl:if>
789
		</xsl:for-each>
790
		<xsl:call-template name="wiki-newline" />
791

    
792
	</xsl:template>
793
	<!--............................................. -->
794

    
795

    
796
	<xsl:template name="descriptionElements">
797
		<xsl:choose>
798
			<xsl:when test="supportsCommonTaxonName='true'">
799
				<!-- must be Vernacular Name feature -->
800
				<xsl:call-template name="commonTaxonName" />
801
			</xsl:when>
802
			<xsl:otherwise>
803
				<!-- for example Habitat, Material Examined -->
804
				<xsl:call-template name="textData" />
805
			</xsl:otherwise>
806
		</xsl:choose>
807
	</xsl:template>
808

    
809
	<!--............................................. -->
810

    
811
	<xsl:template name="commonTaxonName">
812

    
813
		<xsl:value-of
814
			select="concat('{{EDIT_Feature|name=',representation_L10n,'|elements=')" />
815
		<xsl:call-template name="wiki-newline" />
816
		<xsl:for-each select="descriptionelements/descriptionelement">
817
			<xsl:text />
818
			<xsl:value-of
819
				select="concat('{{EDIT_Common_Name|name=',name,'|language=',language/representation_L10n,'}}')" />
820
			<xsl:choose>
821
				<xsl:when test="position() != last()">
822
					<xsl:text>{{EDIT_Delimiter}}</xsl:text>
823
					<xsl:call-template name="wiki-newline" />
824
				</xsl:when>
825
			</xsl:choose>
826
		</xsl:for-each>
827
		<xsl:text>}}</xsl:text>
828
		<xsl:call-template name="wiki-newline" />
829
		<xsl:call-template name="wiki-newline" />
830
	</xsl:template>
831

    
832
	<!--............................................. -->
833

    
834
	<xsl:template name="textData">
835
		
836
		<xsl:value-of
837
			select="concat('{{EDIT_Feature|name=',representation_L10n, '|elements=')" />
838
		<xsl:call-template name="wiki-newline" />
839
		<xsl:text>{{EDIT_Feature_Text|</xsl:text>
840
		<!-- <xsl:choose> <xsl:when test="uuid!='9fc9d10c-ba50-49ee-b174-ce83fc3f80c6'"> -->
841
		<!-- feature is not "Distribution" -->
842
		<xsl:apply-templates
843
			select="descriptionelements/descriptionelement[1]/multilanguageText_L10n/text" />
844
		<xsl:call-template name="reference">
845
			<xsl:with-param name="reference-node" select="descriptionelements/descriptionelement[1]/sources[1]/e[1]/citation[1]" />
846
		</xsl:call-template>
847
		(
848
		<xsl:apply-templates
849
			select="descriptionelements/descriptionelement[1]/sources[1]/e[1]/citation[1]/titleCache[1]" />
850
		)
851
		
852
		<!-- </xsl:when> </xsl:choose> -->
853
		<xsl:text>}}}}</xsl:text>
854
		<!-- feature is "Figures -->
855
		<!-- A Gallery: uncomment following line -->
856
		<!--<xsl:apply-templates select="descriptionelements/descriptionelement[1]/multilanguageText_L10n/text"/> -->
857
		<!-- A Gallery: comment following line -->
858
		<!--xsl:call-template name="gallery"/ -->
859

    
860
		<xsl:call-template name="wiki-newline" />
861
		<xsl:call-template name="wiki-newline" />
862
		<!-- LORNA TRY IMAGE HERE -->
863
		<!--xsl:apply-templates select="descriptionelements/descriptionelement[1]/media/e/representations/e/parts/e/uri"/ -->
864

    
865

    
866
	</xsl:template>
867

    
868
	<!--............................................. -->
869

    
870

    
871
	<xsl:template match="text">
872
		<xsl:call-template name="replace-tags-others">
873
			<xsl:with-param name="text-string" select="." />
874
		</xsl:call-template>
875
	</xsl:template>
876

    
877
	<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
878
	<!-- image galleries -->
879

    
880
	<xsl:template name="gallery">
881
		<!-- A change to Figure Gallery: delete/comment following line -->
882
		<xsl:text>{{EDIT_Gallery|files=</xsl:text>
883
		<!-- A change to Figure Gallery: uncomment following line -->
884
		<!--<xsl:text>{{EDIT_Figure_Gallery|files=</xsl:text> -->
885
		<xsl:call-template name="wiki-newline" />
886
		<xsl:apply-templates select="../media/e/representations/e/parts/e/uri" />
887

    
888
		<xsl:text>}}</xsl:text>
889
		<xsl:call-template name="wiki-newline" />
890
		<xsl:call-template name="wiki-newline" />
891
	</xsl:template>
892

    
893

    
894
	<xsl:template name="featureGallery">
895

    
896
		<xsl:value-of
897
			select="concat('{{EDIT_Nested_Feature|name=',representation_L10n,'|description=',representation_L10n,'|elements=}}')" />
898
		<xsl:text>{{EDIT_Figure_Gallery|files=</xsl:text>
899
		<xsl:text />
900
		<xsl:call-template name="wiki-newline" />
901
		<xsl:apply-templates select=".//media/e/representations/e/parts/e/uri" />
902

    
903
		<xsl:text>}}</xsl:text>
904
		<xsl:call-template name="wiki-newline" />
905
		<xsl:call-template name="wiki-newline" />
906

    
907
		<xsl:call-template name="gallery_file" />
908

    
909
	</xsl:template>
910

    
911

    
912
	<xsl:template name="gallery_file" />
913

    
914
	<xsl:template match="media/e/representations/e/parts/e/uri">
915

    
916
		<xsl:value-of
917
			select="concat('{{EDIT_Gallery_File|filename=',functx:substring-after-last(.,'/'), '|description=')" />
918
		<!--go back up to the description element and get the text for the Figure 
919
			legend -->
920
		<xsl:apply-templates select="../../../../../../../multilanguageText_L10n/text" />
921
		<xsl:apply-templates select="../../../../../../../name/titleCache" />
922
		<xsl:text>}}</xsl:text>
923
		<xsl:if test="position() != last()">
924
			<xsl:call-template name="wiki-newline" />
925
		</xsl:if>
926
	</xsl:template>
927

    
928

    
929

    
930

    
931
	<!--+++++++++++++++++++++++++++++L A Y O U T ++++++++++++++++++++++++++++++++++++++ -->
932

    
933

    
934
	<!-- change here to change the look of the mediawiki output -->
935
	<!-- please use mediawiki templates -->
936
	<!-- think also of template changes in the mediawiki -->
937

    
938
	<xsl:template name="TOC">
939
		{{EDIT_TOC}}
940
	</xsl:template>
941

    
942
	<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
943
	<xsl:template name="chapter">
944
		<xsl:param name="title" />
945
		<xsl:value-of select="concat('{{EDIT_Section|title=',$title,'}}')" />
946
		<xsl:call-template name="wiki-newline" />
947
		<xsl:call-template name="wiki-newline" />
948
	</xsl:template>
949

    
950
	<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
951

    
952
	<xsl:template name="subchapter">
953
		<xsl:param name="title" />
954
		<xsl:value-of select="concat('{{EDIT_Subsection|title=',$title,'}}')" />
955
		<xsl:call-template name="wiki-newline" />
956
		<xsl:call-template name="wiki-newline" />
957
	</xsl:template>
958

    
959
	<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
960
	<!-- puts in a wiki comment -->
961
	<xsl:template name="wiki-comment">
962
		<xsl:param name="wiki-comment" />
963
		<xsl:comment>
964
			<xsl:value-of select="concat($wiki-comment,'&#xa;')" />
965
		</xsl:comment>
966
	</xsl:template>
967

    
968
	<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
969

    
970
	<!--this template layouts and displays the name of a taxon depending on 
971
		it's "kind" MAYDO: create more useful layouts instead of title sizes -->
972
	<xsl:template name="display-taxon-name">
973
		<xsl:param name="taxon" />
974
		<!-- get the name of the taxon -->
975
		<xsl:variable name="name">
976
			<xsl:call-template name="title">
977
				<xsl:with-param name="taxon" select="$taxon" />
978
			</xsl:call-template>
979
		</xsl:variable>
980
		<!-- format the name of the taxon according to it's kind -->
981
		<xsl:choose>
982
			<!-- family -->
983
			<xsl:when
984
				test="$taxon/name/rank/uuid='af5f2481-3192-403f-ae65-7c957a0f02b6'">
985
				<xsl:value-of select="concat('{{EDIT_Family_Name|', $name, '}}')" />
986
			</xsl:when>
987
			<!-- genus -->
988
			<xsl:when
989
				test="$taxon/name/rank/uuid='1b11c34c-48a8-4efa-98d5-84f7f66ef43a'">
990
				<xsl:value-of select="concat('{{EDIT_Genus Name|', $name, '}}')" />
991
			</xsl:when>
992
			<!--TODO -->
993
			<!-- subgenus -->
994
			<xsl:when
995
				test="$taxon/name/rank/uuid='78786e16-2a70-48af-a608-494023b91904'">
996
				<xsl:value-of select="concat('{{EDIT_Subgenus Name|', $name, '}}')" />
997
			</xsl:when>
998
			<!-- species -->
999
			<xsl:when
1000
				test="$taxon/name/rank/uuid='b301f787-f319-4ccc-a10f-b4ed3b99a86d'">
1001
				<xsl:value-of select="concat('{{EDIT_Species Name|', $name, '}}')" />
1002
			</xsl:when>
1003
			<xsl:otherwise>
1004
				<!-- for debugging -->
1005
				Unformatted title for rank uuid:
1006
				<xsl:value-of select="$taxon/name/rank/uuid" />
1007
				:
1008
				<xsl:value-of select="$taxon/name/titleCache" />
1009
			</xsl:otherwise>
1010
		</xsl:choose>
1011
	</xsl:template>
1012

    
1013

    
1014
	<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
1015

    
1016
	<!--we replace "escaped" html <i> and <b> with mediawiki markup -->
1017
	<!--............................................. -->
1018

    
1019
	<xsl:template name="replace-tags-others">
1020
		<xsl:param name="text-string" />
1021
		<!-- first replace bold tags and put the result in text-string2 -->
1022
		<xsl:variable name="text-string2">
1023
			<xsl:call-template name="add-markup">
1024
				<xsl:with-param name="str" select="$text-string" />
1025
				<xsl:with-param name="wiki-markup">
1026
					'''
1027
				</xsl:with-param>
1028
				<xsl:with-param name="tag-name">
1029
					b
1030
				</xsl:with-param>
1031
			</xsl:call-template>
1032
		</xsl:variable>
1033

    
1034
		<!-- second replace italic tags on text-string2 -->
1035
		<xsl:variable name="text-string3">
1036
			<xsl:call-template name="add-markup">
1037
				<xsl:with-param name="str" select="$text-string2" />
1038
				<xsl:with-param name="wiki-markup">
1039
					''
1040
				</xsl:with-param>
1041
				<xsl:with-param name="tag-name">
1042
					i
1043
				</xsl:with-param>
1044
			</xsl:call-template>
1045
		</xsl:variable>
1046
	
1047

    
1048
	<!-- third wrap = with <nowiki> tag -->
1049
	<xsl:call-template name="wrap-a-sequence-with-tags">
1050
	 <xsl:with-param name="str" select="$text-string3" />
1051
		<xsl:with-param name="pattern">=</xsl:with-param>
1052
		<xsl:with-param name="tag-name">nowiki</xsl:with-param>
1053
	</xsl:call-template>
1054
	</xsl:template>
1055
	<!--............................................. -->
1056

    
1057
	<xsl:template name="add-markup">
1058
		<xsl:param name="str" />
1059
		<xsl:param name="wiki-markup" />
1060
		<xsl:param name="tag-name" />
1061

    
1062
		<xsl:variable name="opening-tag">
1063
			<xsl:value-of select="concat('&lt;', $tag-name, '&gt;')">
1064
			</xsl:value-of>
1065
		</xsl:variable>
1066
		<xsl:variable name="closing-tag">
1067
			<xsl:value-of select="concat('&lt;/', $tag-name, '&gt;')">
1068
			</xsl:value-of>
1069
		</xsl:variable>
1070

    
1071
		<xsl:choose>
1072
			<!-- if the tag occures in the string -->
1073
			<xsl:when
1074
				test="contains($str, $opening-tag) and contains($str, $closing-tag)">
1075

    
1076
				<!-- separate string before, inside and after the tag -->
1077
				<xsl:variable name="before-tag"
1078
					select="substring-before($str, $opening-tag)" />
1079
				<xsl:variable name="inside-tag"
1080
					select="substring-before(substring-after($str,$opening-tag),$closing-tag)" />
1081
				<xsl:variable name="after-tag"
1082
					select="substring-after($str, $closing-tag)" />
1083

    
1084
				<!-- built the new string by putting in the mediawiki template -->
1085
				<xsl:value-of
1086
					select="concat($before-tag, $wiki-markup, $inside-tag, $wiki-markup)" />
1087
				<!-- in the part after the closing tag could be more tag, so we do a 
1088
					recursive call -->
1089
				<xsl:call-template name="add-markup">
1090
					<xsl:with-param name="str" select="$after-tag" />
1091
					<xsl:with-param name="wiki-markup" select="$wiki-markup" />
1092
					<xsl:with-param name="tag-name" select="$tag-name" />
1093
				</xsl:call-template>
1094
			</xsl:when>
1095
			<xsl:otherwise>
1096
				<xsl:value-of select="$str" />
1097
			</xsl:otherwise>
1098
		</xsl:choose>
1099
	</xsl:template>
1100

    
1101
	<!--............................................. -->
1102
	
1103
	<xsl:template name="wrap-a-sequence-with-tags">
1104
		
1105
		<!-- the string we operate on -->
1106
		<xsl:param name="str" />
1107
		<!-- the sequence we want to put tags arround e.g. "=" -->
1108
		<xsl:param name="pattern"/>
1109
		<!-- the tag name e.g. nowiki -->
1110
		<xsl:param name="tag-name" />
1111
		<!--xsl:value-of>###in wrap</xsl:value-of-->
1112
		<xsl:variable name="new-pattern">
1113
			<xsl:value-of select="concat('&lt;',$tag-name,'&gt;',$pattern,'&lt;/',$tag-name,'&gt;')">				
1114
			</xsl:value-of>
1115
		</xsl:variable>
1116
		
1117
		<xsl:value-of select="replace($str,$pattern, $new-pattern)"></xsl:value-of>
1118
	</xsl:template>
1119

    
1120
	<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
1121

    
1122

    
1123

    
1124

    
1125
</xsl:stylesheet>
(2-2/2)