Project

General

Profile

Revision 4647f17a

ID4647f17ad61e8e005691dc7dc41fd94dede451d7
Parent 5ab46f86
Child fe4e29da

Added by Sybille Bürs over 8 years ago

xsl transformation now outputs a human readable mediawiki code

View differences:

cdmlib-print/src/main/resources/stylesheets/mediawiki/multipages.xsl
4 4

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

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

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

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

  
18 19
    <!-- create a timestamp for the whole going -->
19 20
    <xsl:variable name="timestamp">
20 21
        <xsl:value-of
......
24 25

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

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

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

  
......
129 137
            <!-- this creates a newline before the <page> 
130 138
            if it was not there, the page could not be imported by the mediawiki-->
131 139
        </xsl:text>
132
        
140

  
133 141
        <page>
134 142
            <title>
135 143
                <xsl:text>Category:</xsl:text>
......
143 151
                <contributor>
144 152
                    <username>Sybille Test</username>
145 153
                </contributor>
146
                <text xml:space="default">
154

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

  
155 166
            </revision>
156 167
        </page>
157 168

  
......
161 172
                <xsl:value-of select="concat($page-prefix,$title)"/>
162 173
            </title>
163 174
            <revision>
164
                <!-- TODO: create seconds without positions after decimal point! -->
175
                <!-- MAYDO: create seconds without positions after decimal point! -->
165 176
                <timestamp>
166 177
                    <xsl:value-of select="$timestamp"/>
167 178
                </timestamp>
......
170 181
                        <xsl:value-of select="$username"/>
171 182
                    </username>
172 183
                </contributor>
173
                <text xml:space="default" >
174
 <!-- add table of contents -->
184

  
185
                <text>
186
                    <xsl:attribute name="xml:space">preserve</xsl:attribute>
187
                    <!-- add table of contents -->
175 188
                    <xsl:call-template name="TOC"/>
176
                   <!-- add taxo tree -->
177
                     <xsl:value-of select="concat('{{EDIT_Taxotree| parentTaxon=',$page-prefix,$parent-title, '}}')"/> 
178
                   
179
                   <!-- add contents of taxon page -->                   
180 189

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

  
195

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

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

  
......
250 267

  
251 268
    <!-- we run this for the content of the page -->
252 269
    <xsl:template match="Taxon" name="Taxon">
253
        <!--
254
        -->
255 270
        <xsl:apply-templates select="synonymy"/>
256 271
        <xsl:apply-templates select="key"/>
257 272
        <xsl:apply-templates select="descriptions"/>
258 273
        <xsl:call-template name="gallery"/>
259

  
260

  
261 274
    </xsl:template>
262 275

  
263 276
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
......
272 285
    </xsl:template>
273 286

  
274 287

  
275
    <xsl:template name="citationsold">
276

  
277
        <xsl:param name="name-uuid"/>
278
        <xsl:param name="descriptionelements"/>
279

  
280
        <!--only calling this for ag salcifolia what about the other uuids???-->
281
        <xsl:value-of select="concat('{{EDIT_Reference|name=',$name-uuid,'|content=')"/>
282
        <!--<ref name="{$name-uuid}">-->
283
        <!-- iterate through all the description elements fo the citation feature -->
284
        <xsl:for-each select="$descriptionelements/descriptionelement">
285
            <!-- TODO sorting only works for the first citation, implement correctly -->
286
            <xsl:sort select="sources/e[1]/citation/datePublished/start"/>
287

  
288
            <xsl:for-each select="sources/e">
289
                <xsl:if test="nameUsedInSource/uuid=$name-uuid">
290

  
291
                    <!-- call reference template with sources/e/citation -->
292
                    <xsl:call-template name="reference">
293
                        <xsl:with-param name="reference-node" select="citation"/>
294
                    </xsl:call-template>
295
                    <!-- use the citation-uuid as a unique name for the reference -->
296

  
297

  
298
                </xsl:if>
299
            </xsl:for-each>
300
            <!--</ref>-->
301
        </xsl:for-each>
302
    </xsl:template>
303

  
304 288
    <xsl:template name="citations">
305 289
        <xsl:param name="name-uuid"/>
306 290
        <xsl:param name="descriptionelements"/>
......
326 310
            </xsl:for-each>
327 311
            <!--</ref>-->
328 312
        </xsl:for-each>
313

  
329 314
    </xsl:template>
330 315

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

  
343 328
        <!-- use the citation-uuid as a unique name for the reference -->
344 329
        <xsl:value-of select="concat('{{EDIT_Reference|name=',$citation-uuid,'|content=')"/>
330
        <xsl:call-template name="wiki-newline-comment"/>
345 331
        <xsl:text>{{aut|</xsl:text>
346

  
347 332
        <xsl:choose>
348 333
            <xsl:when test="$reference-node/authorTeam/teamMembers/e[1]/lastname != ''">
349 334
                <xsl:for-each select="$reference-node/authorTeam/teamMembers/e">
......
358 343
            <xsl:otherwise>
359 344
                <xsl:value-of select="$reference-node/authorTeam/lastname"/>
360 345
            </xsl:otherwise>
361
                      
346

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

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

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

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

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

  
385 372
        <!--xsl:choose>
386 373
            <xsl:when test="$reference-node/inReference/node()">
387 374
                <xsl:value-of select="$reference-node/title"/>
......
407 394
        </xsl:if-->
408 395
        <xsl:text>}}</xsl:text>
409 396
        <!--</ref>-->
410

  
397
        <xsl:call-template name="wiki-newline-comment"/>
411 398
    </xsl:template>
412 399

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

  
......
511 499
    <!-- these templates provide the synonomy -->
512 500

  
513 501
    <xsl:template match="synonymy" name="synonymy">
514
        <!--<xsl:text>&#xA;'''Synonymy'''&#xA;&#xA;</xsl:text>
515
    --><xsl:call-template name="chapter">
502
        <xsl:call-template name="chapter">
516 503
            <xsl:with-param name="title">Synonomy</xsl:with-param>
517 504
        </xsl:call-template>
518 505
        <xsl:apply-templates select="../name"/>
......
526 513
                select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
527 514
            <xsl:with-param name="name-uuid" select="../name/uuid"/>
528 515
        </xsl:call-template>
529

  
516
        <xsl:call-template name="wiki-two-newlines-comment"/>
530 517
        <xsl:apply-templates select="homotypicSynonymsByHomotypicGroup"/>
531 518
        <xsl:apply-templates select="heterotypicSynonymyGroups"/>
532 519
        <!--xsl:call-template name="citations">
......
556 543
                    select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
557 544
                <xsl:with-param name="name-uuid" select="name/uuid"/>
558 545
            </xsl:call-template>
559

  
560 546
        </xsl:for-each>
547
        <xsl:call-template name="wiki-two-newlines-comment"/>
561 548
    </xsl:template>
562 549

  
563 550
    <!--.............................................-->
......
579 566
                <xsl:text>{{EDIT Homotypic Synonym|2|</xsl:text>
580 567
                <xsl:apply-templates select="name"/>
581 568
                <xsl:text>}}</xsl:text>
582
                
569

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

  
587 574
                <!--LORNA Pass the description elements for the citation 99b2842f-9aa7-42fa-bd5f-7285311e0101 -->
588 575
                <xsl:call-template name="citations">
589 576
                    <xsl:with-param name="descriptionelements"
590 577
                        select="../descriptions/features/feature[uuid='99b2842f-9aa7-42fa-bd5f-7285311e0101']/descriptionelements"/>
591 578
                    <xsl:with-param name="name-uuid" select="name/uuid"/>
592 579
                </xsl:call-template>
593
            </xsl:for-each>
580
                <xsl:call-template name="wiki-two-newlines-comment"/>
581
            </xsl:for-each>        
594 582
        </xsl:for-each>
595

  
583
        <xsl:call-template name="wiki-two-newlines-comment"/>
596 584
        <!--xsl:apply-templates select="e[1]/name[1]/homotypicalGroup[1]/typifiedNames[1]/e/taxonBases[1]/e/descriptions[1]/e/elements[1]/e[1]/media[1]/e/representations[1]/e/parts[1]/e/uri"></xsl:apply-templates-->
597 585
    </xsl:template>
598 586

  
......
603 591
        <!--xsl:apply-templates select="nomenclaturalReference"/-->
604 592
    </xsl:template>
605 593

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

  
606 596
    <xsl:template match="taggedName">
607 597
        <xsl:for-each select="e">
608 598
            <!-- TODO mybe some types don't contain font tags, we don't have to call the tmeplate  -->
......
621 611
                </xsl:otherwise>
622 612
            </xsl:choose>
623 613
        </xsl:for-each>
624
        <xsl:text>&#xA;</xsl:text>
614
        <xsl:call-template name="wiki-newline-comment"/>
615
        <!--<xsl:text>&#xA;</xsl:text>-->
625 616
    </xsl:template>
626 617

  
627 618
    <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
......
634 625
        Second_Level_Feature-->
635 626

  
636 627
    <xsl:template match="descriptions" name="descriptions">
628
        <xsl:call-template name="wiki-comment">
629
            <xsl:with-param name="wiki-comment">FEATURES</xsl:with-param>
630
        </xsl:call-template>
637 631
        <xsl:for-each select="features/feature">
638 632
            <xsl:choose>
639 633
                <xsl:when test="count(feature)!=0">
......
654 648

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

  
657
        <xsl:value-of select="concat('{{Highlevel_Feature|',representation_L10n,'}}')"/>
658

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

  
669
        <xsl:call-template name="wiki-newline-comment"></xsl:call-template>
676 670
    </xsl:template>
677 671
    <!--.............................................-->
678 672

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

  
712 707
    <!--.............................................-->
......
715 710

  
716 711
        <xsl:value-of
717 712
            select="concat('{{EDIT_Feature|name=',representation_L10n, '|elements={{EDIT_Feature_Text|' )"/>
713
        <xsl:call-template name="wiki-newline-comment"></xsl:call-template>
718 714
        <!--
719 715
        <xsl:choose>
720 716
            <xsl:when test="uuid!='9fc9d10c-ba50-49ee-b174-ce83fc3f80c6'">-->
......
727 723
        </xsl:choose>
728 724
        -->
729 725
        <xsl:text>}}}}</xsl:text>
730

  
726
        <xsl:call-template name="wiki-two-newlines-comment"></xsl:call-template>
731 727

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

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

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

  
758 756

  
......
762 760

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

  
771 770

  
......
779 778
    <!-- think also of template changes in the mediawiki -->
780 779
    <!-- TODO: wrap TOC layout in a mediawiki template -->
781 780

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

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

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

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

  
799 810
    <!--this template layouts and displays the name of a 
800 811
        taxon depending on it's "kind"
......
891 902
                <!-- in the part after the closing tag could be more tag, so we do a recursive call -->
892 903
                <xsl:call-template name="add-markup">
893 904
                    <xsl:with-param name="str" select="$after-tag"/>
894
                    <xsl:with-param name="wiki-markup"
895
                        select="$wiki-markup"/>
905
                    <xsl:with-param name="wiki-markup" select="$wiki-markup"/>
896 906
                    <xsl:with-param name="tag-name" select="$tag-name"/>
897 907
                </xsl:call-template>
898 908
            </xsl:when>

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)