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"/>
242 <xsl:call-template name="gallery"/>
247 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
249 <!-- these templates provide the citations -->
251 <xsl:template name="display-references">
252 <xsl:call-template name="chapter">
253 <xsl:with-param name="title">References</xsl:with-param>
255 <xsl:text>{{Show_References}}</xsl:text>
259 <xsl:template name="citations">
260 <xsl:param name="name-uuid"/>
261 <xsl:param name="descriptionelements" />
263 <!--only calling this for ag salcifolia what about the other uuids???-->
264 <xsl:value-of select="concat('{{ViBRANT_Reference|Name=',$name-uuid,'|Content=')"></xsl:value-of>
265 <!--<ref name="{$name-uuid}">-->
266 <!-- iterate through all the description elements fo the citation feature -->
267 <xsl:for-each select="$descriptionelements/descriptionelement">
268 <!-- TODO sorting only works for the first citation, implement correctly -->
269 <xsl:sort select="sources/e[1]/citation/datePublished/start"/>
271 <xsl:for-each select="sources/e">
272 <xsl:if test="nameUsedInSource/uuid=$name-uuid">
273 <!--xsl:text>; </xsl:text-->
274 <xsl:text>{{aut|</xsl:text>
275 <!--xsl:value-of select="citation/authorTeam/titleCache"/-->
276 <xsl:for-each select="citation/authorTeam/teamMembers/e">
277 <xsl:value-of select="lastname"/>
279 <xsl:when test="position() != last()"><xsl:text> & </xsl:text></xsl:when>
282 <xsl:text>}} </xsl:text>
283 <xsl:value-of select="citation/datePublished/start"/>
284 <xsl:text>: </xsl:text>
285 <xsl:value-of select="citation/title"/>
286 <!--xsl:value-of select="citation/authorTeam/lastname"/>
287 <xsl:text> (</xsl:text>
288 <xsl:value-of select="citation/datePublished/start"/>
289 <xsl:text>: </xsl:text>
290 <xsl:value-of select="citationMicroReference"/>
291 <xsl:text>)</xsl:text-->
297 <xsl:text>}}</xsl:text>
299 <!--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-->
301 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
303 <!-- these templates provide the synonomy -->
305 <xsl:template match="synonymy" name="synonymy">
306 <!--<xsl:text>
'''Synonymy'''

</xsl:text>-->
307 <xsl:call-template name="chapter">
308 <xsl:with-param name="title">Synonomy</xsl:with-param>
310 <xsl:apply-templates select="../name"/>
311 <xsl:apply-templates select="homotypicSynonymsByHomotypicGroup"/>
312 <xsl:apply-templates select="heterotypicSynonymyGroups"/>
313 <xsl:call-template name="citations">
314 <xsl:with-param name="descriptionelements" select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
315 <xsl:with-param name="name-uuid" select="../name/uuid"/>
319 <!--.............................................-->
321 <xsl:template match="homotypicSynonymsByHomotypicGroup">
322 <xsl:for-each select="e">
323 <xsl:text>{{Homotypic Synonym|1|</xsl:text>
325 <xsl:apply-templates select="name"/>
326 <xsl:text>}}</xsl:text>
330 <!--.............................................-->
332 <xsl:template match="heterotypicSynonymyGroups">
333 <xsl:for-each select="e">
335 <!--do foreach for the rest-->
336 <!--<xsl:text>==***==</xsl:text>-->
337 <xsl:variable name="first-element" select="e[1]"/>
338 <xsl:text>{{Heterotypic Synonym|1|</xsl:text>
339 <xsl:apply-templates select="$first-element/name"/>
340 <xsl:text>}}</xsl:text>
341 <!--<xsl:text>==***==</xsl:text>-->
343 <!-- take the first one to printout as the head of the homotypic group -->
345 <xsl:for-each select="e[position() > 1]">
346 <xsl:text>{{Homotypic Synonym|2|</xsl:text>
347 <xsl:apply-templates select="name"/>
348 <xsl:text>}}</xsl:text>
349 <!--xsl:call-template name="citations">
350 <LORNA Pass the description elements for the citation 99b2842f-9aa7-42fa-bd5f-7285311e0101>
351 <xsl:with-param name="descriptionelements" select="../../../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
352 <xsl:with-param name="name-uuid" select="name/uuid"/>
353 </xsl:call-template-->
357 <!--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-->
360 <!--.............................................-->
362 <xsl:template match="name">
363 <xsl:apply-templates select="taggedName"/>
364 <!--xsl:apply-templates select="nomenclaturalReference"/-->
367 <xsl:template match="taggedName">
368 <xsl:for-each select="e">
369 <!-- TODO mybe some types don't contain font tags, we don't have to call the tmeplate -->
370 <!-- we could just use <xsl:value-of select="text"/>-->
372 <xsl:when test="type='name'">
373 <xsl:apply-templates select="text"/>
374 <xsl:text> </xsl:text>
376 <xsl:when test="type='authors'">
377 <xsl:apply-templates select="text"/>
380 <xsl:apply-templates select="text"/>
381 <xsl:text> </xsl:text>
385 <xsl:text>
</xsl:text>
388 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
390 <!-- description features -->
392 <!-- TODO: for first and second level:
393 check if there is a page that describes the feature
394 and use Parameter "Link=pagename" with templates Tax_Feature or
395 Second_Level_Feature-->
397 <xsl:template match="descriptions" name="descriptions">
398 <xsl:for-each select="features/feature">
400 <xsl:when test="count(feature)!=0">
401 <xsl:call-template name="secondLevelDescriptionElements"/>
404 <!-- everything but Citation -->
405 <xsl:if test="uuid!='99b2842f-9aa7-42fa-bd5f-7285311e0101'">
406 <xsl:call-template name="descriptionElements"/>
408 <!--xsl:apply-templates select="media/e/representations/e/parts/e/uri"/-->
414 <!--.............................................-->
416 <xsl:template name="secondLevelDescriptionElements">
418 <xsl:value-of select="concat('{{Two_Leveled_Features_Title|',representation_L10n,'}}')"/>
420 <xsl:for-each select="feature">
422 select="concat('{{Second_Level_Feature|Name=',representation_L10n,'|Elements=')"/>
423 <!-- TODO create Element -->
424 <xsl:for-each select="descriptionelements/descriptionelement">
426 select="concat('{{Second_Level_Feature_DescrElement|',multilanguageText_L10n/text, '}}')"
429 <xsl:text>}}</xsl:text>
433 <!--.............................................-->
436 <xsl:template name="descriptionElements">
438 <xsl:when test="supportsCommonTaxonName='true'">
439 <!-- must be Vernacular Name feature -->
440 <xsl:call-template name="commonTaxonName"/>
443 <!-- for example Habitat, Material Examined -->
444 <xsl:call-template name="textData"/>
449 <!--.............................................-->
451 <xsl:template name="commonTaxonName">
453 <xsl:value-of select="concat('{{Tax_Feature|Name=',representation_L10n,'|Elements=')"/>
454 <xsl:for-each select="descriptionelements/descriptionelement">
457 select="concat('{{Common_Name_Feature_Element|Name=',name,'|Language=',language/representation_L10n,'}}')"
460 <xsl:text>}}</xsl:text>
463 <!--.............................................-->
465 <xsl:template name="textData">
468 select="concat('{{Tax_Feature|Name=',representation_L10n, '|Elements={{Feature_Text|' )"/>
470 <xsl:when test="uuid!='9fc9d10c-ba50-49ee-b174-ce83fc3f80c6'">
471 <!-- feature is not "Distribution" -->
473 select="descriptionelements/descriptionelement[1]/multilanguageText_L10n/text"/>
477 <xsl:text>}}}}</xsl:text>
480 <!-- LORNA TRY IMAGE HERE -->
481 <!--xsl:apply-templates select="descriptionelements/descriptionelement[1]/media/e/representations/e/parts/e/uri"/-->
486 <!--.............................................-->
489 <xsl:template match="text">
492 <xsl:when test="contains(.,"<b>")">
493 <xsl:call-template name="add-markup">
494 <xsl:with-param name="str" select="."/>
495 <!--xsl:with-param name="tag-name" select="b"/-->
496 <xsl:with-param name="tag-name">b</xsl:with-param>
500 <xsl:call-template name="add-markup">
501 <xsl:with-param name="str" select="."/>
502 <xsl:with-param name="tag-name">i</xsl:with-param>
510 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
511 <!-- image gallery -->
513 <xsl:template name="gallery">
514 <!--<xsl:text>{{ViBRANT_Gallery|Files=</xsl:text>--> {{chapter|Images}} <xsl:value-of
515 select="concat('===',./name/titleCache,'===')"/>
516 <xsl:apply-templates select="//media/e/representations/e/parts/e/uri"/>
517 <!--<xsl:text>}}</xsl:text>-->
520 <xsl:template match="uri">
521 <xsl:text>FOO</xsl:text>
522 <xsl:value-of select="."/>
523 <!--go back up to the description element and get the text for the Figure legend -->
524 <!--<xsl:apply-templates select="../../../../../../../multilanguageText_L10n/text"/>-->
528 <!--+++++++++++++++++++++++++++++L A Y O U T ++++++++++++++++++++++++++++++++++++++ -->
531 <!-- change here to change the look of the mediawiki output -->
532 <!-- please use mediawiki templates -->
533 <!-- think also of template changes in the mediawiki -->
534 <!-- TODO: wrap TOC layout in a mediawiki template -->
536 <xsl:template name="TOC"> {{ViBRANT_TOC}} </xsl:template>
538 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
540 <xsl:template name="chapter">
541 <xsl:param name="title"/>
542 <xsl:value-of select="concat('{{Chapter|',$title,'}}')"/>
545 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
547 <xsl:template name="subchapter">
548 <xsl:param name="title"/>
549 <xsl:value-of select="concat('{{Subchapter|',$title,'}}')"/>
552 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
554 <!--this template layouts and displays the name of a
555 taxon depending on it's "kind"
556 MAYDO: create more useful layouts instead of title sizes-->
557 <xsl:template name="display-taxon-name">
558 <xsl:param name="taxon"/>
559 <!-- get the name of the taxon -->
560 <xsl:variable name="name">
561 <xsl:call-template name="title">
562 <xsl:with-param name="taxon" select="$taxon"/>
565 <!-- format the name of the taxon according to it's kind -->
568 <xsl:when test="$taxon/name/rank/uuid='af5f2481-3192-403f-ae65-7c957a0f02b6'">
569 <xsl:value-of select="concat('{{Family name|', $name, '}}')"/>
572 <xsl:when test="$taxon/name/rank/uuid='1b11c34c-48a8-4efa-98d5-84f7f66ef43a'">
573 <xsl:value-of select="concat('{{Genus name|', $name, '}}')"/>
577 <xsl:when test="$taxon/name/rank/uuid='78786e16-2a70-48af-a608-494023b91904'">
578 <xsl:value-of select="concat('{{Subgenus name|', $name, '}}')"/>
581 <xsl:when test="$taxon/name/rank/uuid='b301f787-f319-4ccc-a10f-b4ed3b99a86d'">
582 <xsl:value-of select="concat('{{Species name|', $name, '}}')"/>
585 <!-- for debugging --> Unformatted title for rank uuid: <xsl:value-of
586 select="$taxon/name/rank/uuid"/>: <xsl:value-of select="$taxon/name/titleCache"
593 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
595 <!--we replace html i> with mediawiki templates-->
596 <xsl:template match="text" name="replace_html_tags">
597 <xsl:call-template name="replace-tags">
598 <xsl:with-param name="text-string" select="."/>
603 <!--.............................................-->
605 <xsl:template name="replace-tags">
606 <xsl:param name="text-string"/>
608 <xsl:when test="contains($text-string,';<b>')">
609 <xsl:call-template name="add-markup">
610 <xsl:with-param name="str" select="$text-string"/>
611 <!--xsl:with-param name="tag-name" select="b"/-->
612 <xsl:with-param name="wiki-template">Bold</xsl:with-param>
613 <xsl:with-param name="tag-name">b</xsl:with-param>
617 <xsl:call-template name="add-markup">
618 <xsl:with-param name="str" select="$text-string"/>
619 <xsl:with-param name="wiki-template">Italic</xsl:with-param>
620 <xsl:with-param name="tag-name">i</xsl:with-param>
627 <!--.............................................-->
629 <xsl:template name="add-markup">
630 <xsl:param name="str"/>
631 <xsl:param name="wiki-template"/>
632 <xsl:param name="tag-name"/>
634 <xsl:variable name="opening-tag">
635 <xsl:value-of select="concat('<', $tag-name, '>')"> </xsl:value-of>
637 <xsl:variable name="closing-tag">
638 <xsl:value-of select="concat('</', $tag-name, '>')"> </xsl:value-of>
643 <xsl:when test="contains($str, $opening-tag) and contains($str, $closing-tag)">
644 <xsl:variable name="before-tag" select="substring-before($str, $opening-tag)"/>
645 <xsl:variable name="inside-tag"
646 select="substring-before(substring-after($str,$opening-tag),$closing-tag)"/>
647 <xsl:variable name="after-tag" select="substring-after($str, $closing-tag)"/>
648 <xsl:value-of select="concat($before-tag,'{{',$wiki-template,'|',$inside-tag,'}}')"/>
649 <xsl:call-template name="replace-tags">
650 <xsl:with-param name="text-string" select="$after-tag"/>
654 <xsl:value-of select="$str"/>
659 <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->