2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
3 <xsl:output method="xml" indent="yes"/>
4 <!-- Authors: Sybille & Lorna -->
5 <!-- Date: March/April 2013 -->
7 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
9 <!-- create a timestamp for the whole going -->
10 <xsl:variable name="timestamp">
12 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')"
16 <!-- create the username who changed/created the pages -->
17 <xsl:variable name="username">Sybille Test </xsl:variable>
19 <!-- this is the start template
20 it creates the mediawiki tag surounding and calls a template to create a page for
21 every taxon node TODO: and a category -->
22 <xsl:template match="root">
23 <mediawiki xmlns="http://www.mediawiki.org/xml/export-0.7/"
24 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
25 xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.7.xsd" version="0.7"
28 <sitename>TestWiki</sitename>
29 <base>http://biowikifarm.net/test/Main_Page</base>
30 <generator>MediaWiki 1.20.3</generator>
31 <case>first-letter</case>
33 <namespace key="-2" case="first-letter">Media</namespace>
34 <namespace key="-1" case="first-letter">Special</namespace>
35 <namespace key="0" case="first-letter"/>
36 <namespace key="1" case="first-letter">Talk</namespace>
37 <namespace key="2" case="first-letter">User</namespace>
38 <namespace key="3" case="first-letter">User talk</namespace>
39 <namespace key="4" case="first-letter">TestWiki</namespace>
40 <namespace key="5" case="first-letter">TestWiki talk</namespace>
41 <namespace key="6" case="first-letter">File</namespace>
42 <namespace key="7" case="first-letter">File talk</namespace>
43 <namespace key="8" case="first-letter">MediaWiki</namespace>
44 <namespace key="9" case="first-letter">MediaWiki talk</namespace>
45 <namespace key="10" case="first-letter">Template</namespace>
46 <namespace key="11" case="first-letter">Template talk</namespace>
47 <namespace key="12" case="first-letter">Help</namespace>
48 <namespace key="13" case="first-letter">Help talk</namespace>
49 <namespace key="14" case="first-letter">Category</namespace>
50 <namespace key="15" case="first-letter">Category talk</namespace>
51 <namespace key="102" case="first-letter">Property</namespace>
52 <namespace key="103" case="first-letter">Property talk</namespace>
53 <namespace key="106" case="first-letter">Form</namespace>
54 <namespace key="107" case="first-letter">Form talk</namespace>
55 <namespace key="108" case="first-letter">Concept</namespace>
56 <namespace key="109" case="first-letter">Concept talk</namespace>
57 <namespace key="170" case="first-letter">Filter</namespace>
58 <namespace key="171" case="first-letter">Filter talk</namespace>
59 <namespace key="198" case="first-letter">Internal</namespace>
60 <namespace key="199" case="first-letter">Internal talk</namespace>
61 <namespace key="200" case="first-letter">Portal</namespace>
62 <namespace key="201" case="first-letter">Portal talk</namespace>
63 <namespace key="202" case="first-letter">Bibliography</namespace>
64 <namespace key="203" case="first-letter">Bibliography talk</namespace>
65 <namespace key="204" case="first-letter">Draft</namespace>
66 <namespace key="205" case="first-letter">Draft talk</namespace>
67 <namespace key="206" case="first-letter">Submission</namespace>
68 <namespace key="207" case="first-letter">Submission talk</namespace>
69 <namespace key="208" case="first-letter">Reviewed</namespace>
70 <namespace key="209" case="first-letter">Reviewed talk</namespace>
71 <namespace key="420" case="first-letter">Layer</namespace>
72 <namespace key="421" case="first-letter">Layer talk</namespace>
76 <xsl:apply-templates select="//TaxonNode"/>
77 <!-- TODO we cannot just call every node, we have to parse the tree
78 to gather tree structure for the categories tree-->
82 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
84 <!-- this creates a page and a category for
86 <!-- TODO create a template for page creating and for categorie creating -->
87 <xsl:template match="TaxonNode" name="TaxonNode">
89 <!-- as we will need the title more than once, we create a variable-->
90 <xsl:variable name="title">
91 <xsl:call-template name="title">
92 <xsl:with-param name="taxon" select="Taxon"/>
96 <!-- we also initialize the parent taxon variable if there is a higher taxon assigned: -->
98 <xsl:variable name="parent-title">
99 <xsl:if test="exists(../..) and name(../..)='TaxonNode'">
101 <xsl:call-template name="title">
102 <xsl:with-param name="taxon" select="../../Taxon"/>
106 <!-- else if no higher taxon could be found -->
107 <xsl:if test="not(exists(../..)) or not(name(../..)='TaxonNode')">
109 <xsl:text>{{No Parent}}</xsl:text>
114 <!-- create category -->
117 <xsl:text>Category:</xsl:text>
118 <xsl:value-of select="$title"/>
121 <!-- TODO: create seconds without positions after decimal point! -->
123 <xsl:value-of select="$timestamp"/>
126 <username>Sybille Test</username>
128 <text xml:space="preserve">
130 <!-- redirekt to corresponding page -->
131 <xsl:value-of select="concat('#REDIRECT [[',$title,']]')"/>
133 <!-- add parent categorie if exists -->
134 <xsl:if test="exists(../..) and name(../..)='TaxonNode'">
135 <xsl:value-of select="concat('[[Category:',$parent-title,']]')"/>
142 <!-- create taxon page -->
145 <xsl:value-of select="$title"/>
148 <!-- TODO: create seconds without positions after decimal point! -->
150 <xsl:value-of select="$timestamp"/>
154 <xsl:value-of select="$username"/>
157 <text xml:space="preserve">
158 <!-- add table of contents -->
159 <xsl:call-template name="TOC"/>
160 <!-- add taxo tree -->
161 <xsl:value-of select="concat('{{Taxo Tree|',$parent-title, '}}')"/>
163 <!-- add contents of taxon page -->
165 <xsl:apply-templates select="Taxon"/>
166 <xsl:call-template name="display-references"/>
168 <!-- put page to corresponding tax category -->
169 <xsl:value-of select="concat('[[Category:',$title, ']]')"/>
175 <!--<xsl:apply-templates select="//childNodes/TaxonNode/Taxon"/>-->
178 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
180 <!-- this template provides the correct name of a taxon
181 parameter: taxon the taxon we want to get the name from-->
182 <xsl:template name="title">
183 <xsl:param name="taxon"/>
186 <xsl:when test="$taxon/name/rank/uuid='af5f2481-3192-403f-ae65-7c957a0f02b6'">
187 <xsl:call-template name="get-family-or-genus-title">
188 <xsl:with-param name="genusOrUninomial" select="$taxon/name/genusOrUninomial"/>
192 <xsl:when test="$taxon/name/rank/uuid='1b11c34c-48a8-4efa-98d5-84f7f66ef43a'">
193 <xsl:call-template name="get-family-or-genus-title">
194 <xsl:with-param name="genusOrUninomial" select="$taxon/name/genusOrUninomial"/>
199 <xsl:when test="$taxon/name/rank/uuid='78786e16-2a70-48af-a608-494023b91904'">
200 <xsl:apply-templates select="$taxon/name/rank/representation_L10n"/>
201 <xsl:text> </xsl:text>
202 <xsl:apply-templates select="$taxon/name/genusOrUninomial"/>
205 <xsl:when test="$taxon/name/rank/uuid='b301f787-f319-4ccc-a10f-b4ed3b99a86d'">
206 <xsl:call-template name="get-species-title">
207 <xsl:with-param name="taxon" select="$taxon"/>
211 <!-- for debugging --> Unformatted title for rank uuid: <xsl:value-of
212 select="$taxon/name/rank/uuid"/>: <xsl:value-of select="$taxon/name/titleCache"
218 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
220 <!-- these templates create the name of the taxa wheater their kind is -->
222 <xsl:template name="get-family-or-genus-title">
223 <xsl:param name="genusOrUninomial"/>
224 <xsl:value-of select="$genusOrUninomial"/>
227 <xsl:template name="get-species-title">
228 <xsl:param name="taxon"/>
230 select="concat($taxon/name/genusOrUninomial, ' ', $taxon/name/specificEpithet)"/>
233 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
238 <!-- we run this for the content of the page -->
239 <xsl:template match="Taxon" name="Taxon">
240 <xsl:apply-templates select="synonymy"/>
241 <xsl:apply-templates select="descriptions"/>
246 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
248 <!-- these templates provide the citations -->
250 <xsl:template name="display-references">
251 <xsl:call-template name="chapter">
252 <xsl:with-param name="title">References</xsl:with-param>
258 <xsl:template name="citations">
259 <xsl:param name="name-uuid"/>
260 <xsl:param name="descriptionelements" />
262 <!--only calling this for ag salcifolia what about the other uuids???-->
263 <ref name="{$name-uuid}">
264 <!-- iterate through all the description elements fo the citation feature -->
265 <xsl:for-each select="$descriptionelements/descriptionelement">
266 <!-- TODO sorting only works for the first citation, implement correctly -->
267 <xsl:sort select="sources/e[1]/citation/datePublished/start"/>
269 <xsl:for-each select="sources/e">
270 <xsl:if test="nameUsedInSource/uuid=$name-uuid">
271 <!--xsl:text>; </xsl:text-->
272 <xsl:text>{{aut|</xsl:text>
273 <!--xsl:value-of select="citation/authorTeam/titleCache"/-->
274 <xsl:for-each select="citation/authorTeam/teamMembers/e">
275 <xsl:value-of select="lastname"/>
277 <xsl:when test="position() != last()"><xsl:text> & </xsl:text></xsl:when>
280 <xsl:text>}} </xsl:text>
281 <xsl:value-of select="citation/datePublished/start"/>
282 <xsl:text>: </xsl:text>
283 <xsl:value-of select="citation/title"/>
284 <!--xsl:value-of select="citation/authorTeam/lastname"/>
285 <xsl:text> (</xsl:text>
286 <xsl:value-of select="citation/datePublished/start"/>
287 <xsl:text>: </xsl:text>
288 <xsl:value-of select="citationMicroReference"/>
289 <xsl:text>)</xsl:text-->
296 <!--ref name="SC078">{{aut|Mohrig, W.; Menzel, F.}} 1992: Neue Arten europäischer Trauermücken (Diptera, Sciaridae). ''An International Journal of Dipterological Research'', '''3'''(1-2), 1–16.</ref-->
298 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
300 <!-- these templates provide the synonomy -->
302 <xsl:template match="synonymy" name="synonymy">
303 <!--<xsl:text>
'''Synonymy'''

</xsl:text>-->
304 <xsl:call-template name="chapter">
305 <xsl:with-param name="title">Synonomy</xsl:with-param>
307 <xsl:apply-templates select="../name"/>
308 <xsl:apply-templates select="homotypicSynonymsByHomotypicGroup"/>
309 <xsl:apply-templates select="heterotypicSynonymyGroups"/>
310 <xsl:call-template name="citations">
311 <xsl:with-param name="descriptionelements" select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
312 <xsl:with-param name="name-uuid" select="../name/uuid"/>
316 <!--.............................................-->
318 <xsl:template match="homotypicSynonymsByHomotypicGroup">
319 <xsl:for-each select="e">
320 <xsl:text>{{Homotypic Synonym|1|</xsl:text>
322 <xsl:apply-templates select="name"/>
323 <xsl:text>}}</xsl:text>
327 <!--.............................................-->
329 <xsl:template match="heterotypicSynonymyGroups">
330 <xsl:for-each select="e">
332 <!--do foreach for the rest-->
333 <!--<xsl:text>==***==</xsl:text>-->
334 <xsl:variable name="first-element" select="e[1]"/>
335 <xsl:text>{{Heterotypic Synonym|1|</xsl:text>
336 <xsl:apply-templates select="$first-element/name"/>
337 <xsl:text>}}</xsl:text>
338 <!--<xsl:text>==***==</xsl:text>-->
340 <!-- take the first one to printout as the head of the homotypic group -->
342 <xsl:for-each select="e[position() > 1]">
343 <xsl:text>{{Homotypic Synonym|2|</xsl:text>
344 <xsl:apply-templates select="name"/>
345 <xsl:text>}}</xsl:text>
346 <!--xsl:call-template name="citations">
347 <LORNA Pass the description elements for the citation 99b2842f-9aa7-42fa-bd5f-7285311e0101>
348 <xsl:with-param name="descriptionelements" select="../../../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
349 <xsl:with-param name="name-uuid" select="name/uuid"/>
350 </xsl:call-template-->
354 <!--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-->
357 <!--.............................................-->
359 <xsl:template match="name">
360 <xsl:apply-templates select="taggedName"/>
361 <!--xsl:apply-templates select="nomenclaturalReference"/-->
364 <xsl:template match="taggedName">
365 <xsl:for-each select="e">
366 <!-- TODO mybe some types don't contain font tags, we don't have to call the tmeplate -->
367 <!-- we could just use <xsl:value-of select="text"/>-->
369 <xsl:when test="type='name'">
370 <xsl:apply-templates select="text"/>
371 <xsl:text> </xsl:text>
373 <xsl:when test="type='authors'">
374 <xsl:apply-templates select="text"/>
377 <xsl:apply-templates select="text"/>
378 <xsl:text> </xsl:text>
382 <xsl:text>
</xsl:text>
385 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
387 <!-- description features -->
389 <xsl:template match="descriptions" name="descriptions">
390 <xsl:for-each select="features/feature">
392 <xsl:when test="count(feature)!=0">
393 <xsl:call-template name="secondLevelDescriptionElements"/>
396 <!-- everything but Citation -->
397 <xsl:if test="uuid!='99b2842f-9aa7-42fa-bd5f-7285311e0101'">
398 <xsl:call-template name="descriptionElements"/>
400 <!--xsl:apply-templates select="media/e/representations/e/parts/e/uri"/-->
406 <!--.............................................-->
408 <xsl:template name="secondLevelDescriptionElements">
410 <xsl:value-of select="concat('{{Two_Leveled_Features_Title|',representation_L10n,'}}')"></xsl:value-of>
412 <xsl:for-each select="feature">
413 <xsl:value-of select="concat('{{Second_Level_Feature|Name=',representation_L10n,'|Elements=')"></xsl:value-of>
414 <!-- TODO create Element -->
415 <xsl:for-each select="descriptionelements/descriptionelement">
416 <xsl:value-of select="concat('{{Second_Level_Feature_DescrElement|',multilanguageText_L10n/text, '}}')"></xsl:value-of>
418 <xsl:text>}}</xsl:text>
422 <!--.............................................-->
425 <xsl:template name="descriptionElements">
427 <xsl:when test="supportsCommonTaxonName='true'">
428 <!-- must be Vernacular Name feature -->
429 <xsl:call-template name="commonTaxonName"/>
432 <!-- for example Habitat, Material Examined -->
433 <xsl:call-template name="textData"/>
438 <!--.............................................-->
440 <xsl:template name="commonTaxonName">
442 <xsl:value-of select="concat('{{Tax_Feature|Name=',representation_L10n,'|Elements=')"/>
443 <xsl:for-each select="descriptionelements/descriptionelement">
446 select="concat('{{Common_Name_Feature_Element|Name=',name,'|Language=',language/representation_L10n,'}}')"
449 <xsl:text>}}</xsl:text>
452 <!--.............................................-->
454 <xsl:template name="textData">
457 select="concat('{{Tax_Feature|Name=',representation_L10n, '|Elements={{Feature_Text|' )"/>
459 <xsl:when test="uuid!='9fc9d10c-ba50-49ee-b174-ce83fc3f80c6'"> <!-- feature is not "Distribution" -->
461 select="descriptionelements/descriptionelement[1]/multilanguageText_L10n/text"/>
465 <xsl:text>}}}}</xsl:text>
468 <!-- LORNA TRY IMAGE HERE -->
469 <!--xsl:apply-templates select="descriptionelements/descriptionelement[1]/media/e/representations/e/parts/e/uri"/-->
474 <!--.............................................-->
477 <xsl:template match="text">
480 <xsl:when test="contains(.,"<b>")">
481 <xsl:call-template name="add-markup">
482 <xsl:with-param name="str" select="."/>
483 <!--xsl:with-param name="tag-name" select="b"/-->
484 <xsl:with-param name="tag-name">b</xsl:with-param>
488 <xsl:call-template name="add-markup">
489 <xsl:with-param name="str" select="."/>
490 <xsl:with-param name="tag-name">i</xsl:with-param>
499 <!--+++++++++++++++++++++++++++++L A Y O U T ++++++++++++++++++++++++++++++++++++++ -->
502 <!-- change here to change the look of the mediawiki output -->
503 <!-- please use mediawiki templates -->
504 <!-- think also of template changes in the mediawiki -->
505 <!-- TODO: wrap TOC layout in a mediawiki template -->
507 <xsl:template name="TOC"> {{ViBRANT_TOC}} </xsl:template>
509 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
511 <xsl:template name="chapter">
512 <xsl:param name="title"/>
513 <xsl:value-of select="concat('{{Chapter|',$title,'}}')"/>
516 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
518 <xsl:template name="subchapter">
519 <xsl:param name="title"/>
520 <xsl:value-of select="concat('{{Subchapter|',$title,'}}')"/>
523 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
525 <!--this template layouts and displays the name of a
526 taxon depending on it's "kind"
527 MAYDO: create more useful layouts instead of title sizes-->
528 <xsl:template name="display-taxon-name">
529 <xsl:param name="taxon"/>
530 <!-- get the name of the taxon -->
531 <xsl:variable name="name">
532 <xsl:call-template name="title">
533 <xsl:with-param name="taxon" select="$taxon"/>
536 <!-- format the name of the taxon according to it's kind -->
539 <xsl:when test="$taxon/name/rank/uuid='af5f2481-3192-403f-ae65-7c957a0f02b6'">
540 <xsl:value-of select="concat('{{Family name|', $name, '}}')"/>
543 <xsl:when test="$taxon/name/rank/uuid='1b11c34c-48a8-4efa-98d5-84f7f66ef43a'">
544 <xsl:value-of select="concat('{{Genus name|', $name, '}}')"/>
548 <xsl:when test="$taxon/name/rank/uuid='78786e16-2a70-48af-a608-494023b91904'">
549 <xsl:value-of select="concat('{{Subgenus name|', $name, '}}')"/>
552 <xsl:when test="$taxon/name/rank/uuid='b301f787-f319-4ccc-a10f-b4ed3b99a86d'">
553 <xsl:value-of select="concat('{{Species name|', $name, '}}')"/>
556 <!-- for debugging --> Unformatted title for rank uuid: <xsl:value-of
557 select="$taxon/name/rank/uuid"/>: <xsl:value-of select="$taxon/name/titleCache"
564 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
566 <!--we replace html i> with mediawiki templates-->
567 <xsl:template match="text" name="replace_html_tags">
568 <xsl:call-template name="replace-tags">
569 <xsl:with-param name="text-string" select="."/>
574 <!--.............................................-->
576 <xsl:template name="replace-tags">
577 <xsl:param name="text-string"/>
579 <xsl:when test="contains($text-string,';<b>')">
580 <xsl:call-template name="add-markup">
581 <xsl:with-param name="str" select="$text-string"/>
582 <!--xsl:with-param name="tag-name" select="b"/-->
583 <xsl:with-param name="wiki-template">Bold</xsl:with-param>
584 <xsl:with-param name="tag-name">b</xsl:with-param>
588 <xsl:call-template name="add-markup">
589 <xsl:with-param name="str" select="$text-string"/>
590 <xsl:with-param name="wiki-template">Italic</xsl:with-param>
591 <xsl:with-param name="tag-name">i</xsl:with-param>
598 <!--.............................................-->
600 <xsl:template name="add-markup">
601 <xsl:param name="str"/>
602 <xsl:param name="wiki-template"/>
603 <xsl:param name="tag-name"/>
605 <xsl:variable name="opening-tag">
606 <xsl:value-of select="concat('<', $tag-name, '>')"> </xsl:value-of>
608 <xsl:variable name="closing-tag">
609 <xsl:value-of select="concat('</', $tag-name, '>')"> </xsl:value-of>
614 <xsl:when test="contains($str, $opening-tag) and contains($str, $closing-tag)">
615 <xsl:variable name="before-tag" select="substring-before($str, $opening-tag)"/>
616 <xsl:variable name="inside-tag"
617 select="substring-before(substring-after($str,$opening-tag),$closing-tag)"/>
618 <xsl:variable name="after-tag" select="substring-after($str, $closing-tag)"/>
619 <xsl:value-of select="concat($before-tag,'{{',$wiki-template,'|',$inside-tag,'}}')"/>
620 <xsl:call-template name="replace-tags">
621 <xsl:with-param name="text-string" select="$after-tag"/>
625 <xsl:value-of select="$str"/>
630 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->