-
Notifications
You must be signed in to change notification settings - Fork 1
/
ACMCitSeq.XSL
3153 lines (2836 loc) · 143 KB
/
ACMCitSeq.XSL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<!--
Stylesheet for Microsoft Word 2007 Bibliography formatting.
Author(s): Yves Dhondt ([email protected])
Copyright: Copyright (c) 2008 Yves Dhondt
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
-->
<xsl:stylesheet version="1.0" xmlns:b="http://schemas.openxmlformats.org/officeDocument/2006/bibliography" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<!-- Variable containing all necessary data for a certain style of bibliography. -->
<xsl:variable name="data">
<general>
<stylename>ACM - Citation Sequence</stylename>
<version>2009.05.23</version>
<description>An implementation of the ACM reference style.</description>
<URL></URL>
<author>Yves Dhondt ([email protected])</author>
<comments></comments>
<display_errors>yes</display_errors>
<citation_as_link>yes</citation_as_link>
</general>
<importantfields>
<source type="ArticleInAPeriodical">
<b:ImportantField>b:Author/b:Author/b:NameList</b:ImportantField>
<b:ImportantField>b:Title</b:ImportantField>
<b:ImportantField>b:PeriodicalTitle</b:ImportantField>
<b:ImportantField>b:Volume</b:ImportantField>
<b:ImportantField>b:Issue</b:ImportantField>
<b:ImportantField>b:Month</b:ImportantField>
<b:ImportantField>b:Year</b:ImportantField>
<b:ImportantField>b:Pages</b:ImportantField>
</source>
<source type="Book">
<b:ImportantField>b:Author/b:Author/b:NameList</b:ImportantField>
<b:ImportantField>b:Author/b:Editor/b:NameList</b:ImportantField>
<b:ImportantField>b:Title</b:ImportantField>
<b:ImportantField>b:Year</b:ImportantField>
<b:ImportantField>b:City</b:ImportantField>
<b:ImportantField>b:Publisher</b:ImportantField>
</source>
<source type="BookSection">
<b:ImportantField>b:Author/b:Author/b:NameList</b:ImportantField>
<b:ImportantField>b:Author/b:Editor/b:NameList</b:ImportantField>
<b:ImportantField>b:Title</b:ImportantField>
<b:ImportantField>b:BookTitle</b:ImportantField>
<b:ImportantField>b:Year</b:ImportantField>
<b:ImportantField>b:City</b:ImportantField>
<b:ImportantField>b:Publisher</b:ImportantField>
</source>
<source type="ConferenceProceedings">
<b:ImportantField>b:Author/b:Author/b:NameList</b:ImportantField>
<b:ImportantField>b:Title</b:ImportantField>
<b:ImportantField>b:Year</b:ImportantField>
<b:ImportantField>b:City</b:ImportantField>
<b:ImportantField>b:Publisher</b:ImportantField>
</source>
<source type="JournalArticle">
<b:ImportantField>b:Author/b:Author/b:NameList</b:ImportantField>
<b:ImportantField>b:Title</b:ImportantField>
<b:ImportantField>b:JournalName</b:ImportantField>
<b:ImportantField>b:Volume</b:ImportantField>
<b:ImportantField>b:Issue</b:ImportantField>
<b:ImportantField>b:Month</b:ImportantField>
<b:ImportantField>b:Year</b:ImportantField>
<b:ImportantField>b:Pages</b:ImportantField>
</source>
<source type="Misc">
<b:ImportantField>b:Author/b:Author/b:NameList</b:ImportantField>
<b:ImportantField>b:Title</b:ImportantField>
<b:ImportantField>b:Year</b:ImportantField>
<b:ImportantField>b:City</b:ImportantField>
<b:ImportantField>b:Publisher</b:ImportantField>
</source>
<source type="Report">
<b:ImportantField>b:Author/b:Author/b:NameList</b:ImportantField>
<b:ImportantField>b:Title</b:ImportantField>
<b:ImportantField>b:ThesisType</b:ImportantField>
<b:ImportantField>b:Year</b:ImportantField>
<b:ImportantField>b:City</b:ImportantField>
<b:ImportantField>b:Institution</b:ImportantField>
</source>
</importantfields>
<citation>
<openbracket>[</openbracket>
<closebracket>]</closebracket>
<separator>,</separator>
<source type="Placeholder">
<format>{%CitationPrefix%}%RefOrder%{%CitationSuffix%}</format>
</source>
<source type="ArticleInAPeriodical">
<format>{%CitationPrefix%}%RefOrder%{%CitationSuffix%}</format>
</source>
<source type="Book">
<format>{%CitationPrefix%}%RefOrder%{%CitationSuffix%}</format>
</source>
<source type="BookSection">
<format>{%CitationPrefix%}%RefOrder%{%CitationSuffix%}</format>
</source>
<source type="ConferenceProceedings">
<format>{%CitationPrefix%}%RefOrder%{%CitationSuffix%}</format>
</source>
<source type="JournalArticle">
<format>{%CitationPrefix%}%RefOrder%{%CitationSuffix%}</format>
</source>
<source type="Misc">
<format>{%CitationPrefix%}%RefOrder%{%CitationSuffix%}</format>
</source>
<source type="Report">
<format>{%CitationPrefix%}%RefOrder%{%CitationSuffix%}</format>
</source>
<source type="Thesis">
<format>{%CitationPrefix%}%RefOrder%{%CitationSuffix%}</format>
</source>
</citation>
<bibliography>
<columns>2</columns>
<source type="Placeholder">
<column id="1">
<halign>left</halign>
<valign>top</valign>
<format>%RefOrder%.</format>
</column>
<column id="2">
<halign>left</halign>
<valign>top</valign>
<format>{%Tag%}</format>
</column>
</source>
<source type="ArticleInAPeriodical">
<column id="1">
<halign>left</halign>
<valign>top</valign>
<format>%RefOrder%</format>
</column>
<column id="2">
<halign>left</halign>
<valign>top</valign>
<format>{%Author:1%.}{ %Title|ShortTitle%}{. <i>%PeriodicalTitle%</i>{, %Volume%}{, %Issue%}}{ ({%Month:s% {%Day%, }}%Year%)}{, %Pages::%}.{ %Comments%.}</format>
</column>
</source>
<source type="Book">
<column id="1">
<halign>left</halign>
<valign>top</valign>
<format>%RefOrder%</format>
</column>
<column id="2">
<halign>left</halign>
<valign>top</valign>
<format>{%Author:1|Editor:2%.}{ <i>%Title|ShortTitle%</i>.}{ %Publisher%{, %City%}{, %Year%}}{ %City%{, %Year%}}{ %Year%}.{ %Comments%.}</format>
</column>
</source>
<source type="BookSection">
<column id="1">
<halign>left</halign>
<valign>top</valign>
<format>%RefOrder%</format>
</column>
<column id="2">
<halign>left</halign>
<valign>top</valign>
<format>{%Author:1%.}{ %Title%.}{ In {%Editor:2%, }<i>%BookTitle|ShortTitle%</i>.}{ %Publisher%{, %City%}{, %Year%}}{ %City%{, %Year%}}{ %Year%}.{ %Comments%.}</format>
</column>
</source>
<source type="ConferenceProceedings">
<column id="1">
<halign>left</halign>
<valign>top</valign>
<format>%RefOrder%</format>
</column>
<column id="2">
<halign>left</halign>
<valign>top</valign>
<format>{%Author:1%.}{ %Title|ShortTitle%.}{ In <i>%ConferenceName%</i>} ({%CountryRegion%{, %City%}}{%City%}{ {%Month:s% {%Day%, }}%Year%}){, %Publisher%}{, %Pages::%}.{ %Comments%.}</format>
</column>
</source>
<source type="JournalArticle">
<column id="1">
<halign>left</halign>
<valign>top</valign>
<format>%RefOrder%</format>
</column>
<column id="2">
<halign>left</halign>
<valign>top</valign>
<format>{%Author:1%.}{ %Title|ShortTitle%}{. <i>%JournalName%</i>{, %Volume%}{, %Issue%}}{ ({%Month:s% {%Day%, }}%Year%)}{, %Pages::%}.{ %Comments%.}</format>
</column>
</source>
<source type="Misc">
<column id="1">
<halign>left</halign>
<valign>top</valign>
<format>%RefOrder%</format>
</column>
<column id="2">
<halign>left</halign>
<valign>top</valign>
<format>{%Author:1%.}{ <i>%Title|ShortTitle%</i>}{. %Publisher%{, %City%{, %Year%}}}{. %City%{, %Year%}}{. %Year%}.{ %Comments%.}</format>
</column>
</source>
<source type="Report">
<column id="1">
<halign>left</halign>
<valign>top</valign>
<format>%RefOrder%</format>
</column>
<column id="2">
<halign>left</halign>
<valign>top</valign>
<format>{%Author:1%.}{ <i>%Title|ShortTitle%</i>}{. {%ThesisType% }%StandardNumber%{, %Institution%}{, %City%}{, %Year%}}{. %Institution%{, %City%}{, %Year%}}{. %City%{, %Year%}}{. %Year%}.{ %Comments%.}</format>
</column>
</source>
<source type="Thesis">
<column id="1">
<halign>left</halign>
<valign>top</valign>
<format>%RefOrder%</format>
</column>
<column id="2">
<halign>left</halign>
<valign>top</valign>
<format>{%Author:1%.}{ <i>%Title|ShortTitle%</i>}{. %ThesisType%{, %Institution%}{, %City%}{, %Year%}}{. %Institution%{, %City%}{, %Year%}}{. %City%{, %Year%}}{. %Year%}.{ %Comments%.}</format>
</column>
</source>
</bibliography>
<namelists>
<list name="author" id="1">
<single_prefix></single_prefix>
<multi_prefix></multi_prefix>
<corporate>{%Corporate:u%}</corporate>
<first_person>{%Last|First%{, %First:d%}{ %Middle:d%}}</first_person>
<other_persons>{%Last|First%{, %First:d%}{ %Middle:d%}}</other_persons>
<separator_between_if_two> and </separator_between_if_two>
<separator_between_if_more_than_two>, </separator_between_if_more_than_two>
<separator_before_last>, and </separator_before_last>
<max_number_of_persons_to_display>7</max_number_of_persons_to_display>
<number_of_persons_to_display_if_more_than_max>3</number_of_persons_to_display_if_more_than_max>
<overflow> et al.</overflow>
<single_suffix></single_suffix>
<multi_suffix></multi_suffix>
</list>
<list name="editor" id="2">
<single_prefix></single_prefix>
<multi_prefix></multi_prefix>
<corporate>{%Corporate:u%}</corporate>
<first_person>{%Last|First%{, %First:d%}{ %Middle:d%}}</first_person>
<other_persons>{%Last|First%{, %First:d%}{ %Middle:d%}}</other_persons>
<separator_between_if_two> and </separator_between_if_two>
<separator_between_if_more_than_two>, </separator_between_if_more_than_two>
<separator_before_last>, and </separator_before_last>
<max_number_of_persons_to_display>2</max_number_of_persons_to_display>
<number_of_persons_to_display_if_more_than_max>1</number_of_persons_to_display_if_more_than_max>
<overflow> et al.</overflow>
<single_suffix>, ed.</single_suffix>
<multi_suffix>, eds.</multi_suffix>
</list>
</namelists>
<strings>
<months>
<month number="1">Jan.</month>
<month number="2">Feb.</month>
<month number="3">Mar.</month>
<month number="4">Apr.</month>
<month number="5">May</month>
<month number="6">June</month>
<month number="7">July</month>
<month number="8">Aug.</month>
<month number="9">Sep.</month>
<month number="10">Oct.</month>
<month number="11">Nov.</month>
<month number="12">Dec.</month>
</months>
</strings>
</xsl:variable>
<!-- Indicates that all output will be in the HTML format. -->
<xsl:output method="html" encoding="utf-8"></xsl:output>
<!-- Handle the different types of input documents. -->
<xsl:template match="/">
<xsl:choose>
<!-- Gets the name of the style as it will be displayed in Word 2007. -->
<xsl:when test="b:StyleName">
<xsl:value-of select="msxsl:node-set($data)/general/stylename"></xsl:value-of>
</xsl:when>
<!-- Gets the version information for the style. -->
<xsl:when test="b:Version">
<xsl:value-of select="msxsl:node-set($data)/general/version"></xsl:value-of>
</xsl:when>
<!-- Gets a description of the style. (Word 2008 or later) -->
<xsl:when test="b:Description">
<xsl:value-of select="msxsl:node-set($data)/general/description"></xsl:value-of>
</xsl:when>
<!-- Gets the URL for updates. (Word 2008 or later) -->
<xsl:when test="b:UpdateURL">
<xsl:value-of select="msxsl:node-set($data)/general/URL"></xsl:value-of>
</xsl:when>
<!-- Retrieve the most important fields for a certain type of citation. -->
<xsl:when test="b:GetImportantFields">
<xsl:variable name="type" select="b:GetImportantFields/b:SourceType"></xsl:variable>
<b:ImportantFields>
<xsl:copy-of select="msxsl:node-set($data)/importantfields/source[@type = $type]/*"></xsl:copy-of>
</b:ImportantFields>
</xsl:when>
<!-- Formats a citation for display. -->
<xsl:when test="b:Citation">
<xsl:choose>
<xsl:when test="msxsl:node-set($data)/citation">
<xsl:call-template name="format-citation"></xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- Fallback method. -->
<xsl:call-template name="format-footnote-citation"></xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- Formats a footnote citation for display (Word 2008 or later). -->
<xsl:when test="b:FootnoteCitation">
<xsl:choose>
<xsl:when test="msxsl:node-set($data)/footnotecitation">
<xsl:call-template name="format-footnote-citation"></xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- Fallback method. -->
<xsl:call-template name="format-citation"></xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- Formats a bibliography for display. -->
<xsl:when test="b:Bibliography">
<xsl:call-template name="format-bibliography"></xsl:call-template>
</xsl:when>
<!-- Add a b:BibOrder element to b:Source elements (not used by Word, BibWord specific!). -->
<xsl:when test="b:BibWord">
<xsl:call-template name="bibword-extensions"></xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- Formats the citation. -->
<xsl:template name="format-citation">
<!-- Generate an XML node-set from the formatting data. -->
<xsl:variable name="params" select="msxsl:node-set($data)"></xsl:variable>
<html xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
</head>
<body>
<p>
<!-- Display the open bracket if this is the first citation. -->
<xsl:if test="/b:Citation/b:FirstAuthor">
<xsl:value-of select="$params/citation/openbracket" disable-output-escaping="yes"></xsl:value-of>
</xsl:if>
<!-- Not handled: MinAuthors, SameAuthors, RepeatedAuthor. -->
<xsl:variable name="citation">
<!-- Get the format string. -->
<xsl:variable name="format">
<xsl:variable name="type" select="/b:Citation/b:Source/b:Type"></xsl:variable>
<xsl:variable name="sourcetype" select="/b:Citation/b:Source/b:SourceType"></xsl:variable>
<xsl:choose>
<!-- If there is no source type, its a placeholder. -->
<xsl:when test="string-length($sourcetype) = 0 and string-length(msxsl:node-set($data)/citation/source[@type = 'Placeholder']/format) > 0">
<xsl:value-of select="msxsl:node-set($data)/citation/source[@type = 'Placeholder']/format"></xsl:value-of>
</xsl:when>
<!-- Go for the type element if available. -->
<xsl:when test="string-length($type) > 0 and string-length(msxsl:node-set($data)/citation/source[@type = $type]/format) > 0 ">
<xsl:value-of select="msxsl:node-set($data)/citation/source[@type = $type]/format"></xsl:value-of>
</xsl:when>
<!-- Else go for the source type element if available. -->
<xsl:when test="string-length(msxsl:node-set($data)/citation/source[@type = $sourcetype]/format) > 0 ">
<xsl:value-of select="msxsl:node-set($data)/citation/source[@type = $sourcetype]/format"></xsl:value-of>
</xsl:when>
<!-- Else display error message. -->
<xsl:otherwise>
<xsl:if test="msxsl:node-set($data)/general/display_errors = 'yes'">
<xsl:text><b>Unsupported </xsl:text>
<xsl:if test="string-length($type) > 0">
<xsl:text>type (</xsl:text>
<xsl:value-of select="$type"></xsl:value-of>
<xsl:text>) and </xsl:text>
</xsl:if>
<xsl:text>source type (</xsl:text>
<xsl:value-of select="$sourcetype"></xsl:value-of>
<xsl:text>) for source </xsl:text>
<xsl:value-of select="/b:Citation/b:Source/b:Tag"></xsl:value-of>
<xsl:text>.</b></xsl:text>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Extend the source. -->
<xsl:variable name="extendedSource">
<b:Source>
<xsl:copy-of select="/b:Citation/b:Source/*"></xsl:copy-of>
<!-- For processing the \f parameter. -->
<b:CitationPrefix>
<xsl:value-of select="/b:Citation/b:PagePrefix"></xsl:value-of>
</b:CitationPrefix>
<!-- For processing the \s parameter. -->
<b:CitationSuffix>
<xsl:value-of select="/b:Citation/b:PageSuffix"></xsl:value-of>
</b:CitationSuffix>
<!-- For processing the \p parameter. -->
<b:CitationPages>
<xsl:value-of select="/b:Citation/b:Pages"></xsl:value-of>
</b:CitationPages>
<!-- For processing the \v parameter. -->
<b:CitationVolume>
<xsl:value-of select="/b:Citation/b:Volume"></xsl:value-of>
</b:CitationVolume>
</b:Source>
</xsl:variable>
<xsl:call-template name="format-source">
<xsl:with-param name="format" select="$format"></xsl:with-param>
<xsl:with-param name="source" select="msxsl:node-set($extendedSource)/b:Source"></xsl:with-param>
<xsl:with-param name="disallowed">
<!-- Do not display the authors of the work. -->
<xsl:if test="/b:Citation/b:NoAuthor">
<xsl:value-of select="msxsl:node-set($data)/citation/noauthor"></xsl:value-of>
</xsl:if>
<!-- Do not display the title of the work. -->
<xsl:if test="/b:Citation/b:NoTitle">
<xsl:value-of select="msxsl:node-set($data)/citation/notitle"></xsl:value-of>
</xsl:if>
<!-- Do not display the year the work was written or accessed in. -->
<xsl:if test="/b:Citation/b:NoYear">
<xsl:value-of select="msxsl:node-set($data)/citation/noyear"></xsl:value-of>
</xsl:if>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="$params/general/citation_as_link = 'yes'">
<a href="#{/b:Citation/b:Source/b:Tag}">
<xsl:value-of select="$citation" disable-output-escaping="yes"></xsl:value-of>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$citation" disable-output-escaping="yes"></xsl:value-of>
</xsl:otherwise>
</xsl:choose>
<!-- end citation -->
<!-- Display the group separator if this is not the last citation. -->
<xsl:if test="not(/b:Citation/b:LastAuthor)">
<xsl:value-of select="$params/citation/separator" disable-output-escaping="yes"></xsl:value-of>
</xsl:if>
<!-- Display the close bracket if this is the last citation. -->
<xsl:if test="/b:Citation/b:LastAuthor">
<xsl:value-of select="$params/citation/closebracket" disable-output-escaping="yes"></xsl:value-of>
</xsl:if>
</p>
</body>
</html>
</xsl:template>
<!-- Formats the footnote citation. -->
<xsl:template name="format-footnote-citation">
<!-- Generate an XML node-set from the formatting data. -->
<xsl:variable name="params" select="msxsl:node-set($data)"></xsl:variable>
<html xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
</head>
<body>
<p class="MsoBibliography">
<!-- Display the open bracket if this is the first citation. -->
<xsl:if test="/b:FootnoteCitation/b:FirstAuthor">
<xsl:value-of select="$params/footnotecitation/openbracket" disable-output-escaping="yes"></xsl:value-of>
</xsl:if>
<!-- Not handled: MinAuthors, SameAuthors, RepeatedAuthor. -->
<xsl:variable name="citation">
<!-- Get the format string. -->
<xsl:variable name="format">
<xsl:variable name="type" select="/b:FootnoteCitation/b:Source/b:Type"></xsl:variable>
<xsl:variable name="sourcetype" select="/b:FootnoteCitation/b:Source/b:SourceType"></xsl:variable>
<xsl:choose>
<!-- If there is no source type, its a placeholder. -->
<xsl:when test="string-length($sourcetype) = 0 and string-length(msxsl:node-set($data)/footnotecitation/source[@type = 'Placeholder']/format) > 0">
<xsl:value-of select="msxsl:node-set($data)/footnotecitation/source[@type = 'Placeholder']/format"></xsl:value-of>
</xsl:when>
<!-- Go for the type element if available. -->
<xsl:when test="string-length($type) > 0 and string-length(msxsl:node-set($data)/footnotecitation/source[@type = $type]/format) > 0 ">
<xsl:value-of select="msxsl:node-set($data)/footnotecitation/source[@type = $type]/format"></xsl:value-of>
</xsl:when>
<!-- Else go for the source type element if available. -->
<xsl:when test="string-length(msxsl:node-set($data)/footnotecitation/source[@type = $sourcetype]/format) > 0 ">
<xsl:value-of select="msxsl:node-set($data)/footnotecitation/source[@type = $sourcetype]/format"></xsl:value-of>
</xsl:when>
<!-- Else display error message. -->
<xsl:otherwise>
<xsl:if test="msxsl:node-set($data)/general/display_errors = 'yes'">
<xsl:text><b>Unsupported </xsl:text>
<xsl:if test="string-length($type) > 0">
<xsl:text>type (</xsl:text>
<xsl:value-of select="$type"></xsl:value-of>
<xsl:text>) and </xsl:text>
</xsl:if>
<xsl:text>source type (</xsl:text>
<xsl:value-of select="$sourcetype"></xsl:value-of>
<xsl:text>) for source </xsl:text>
<xsl:value-of select="/b:FootnoteCitation/b:Source/b:Tag"></xsl:value-of>
<xsl:text>.</b></xsl:text>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Extend the source. -->
<xsl:variable name="extendedSource">
<b:Source>
<xsl:copy-of select="/b:FootnoteCitation/b:Source/*"></xsl:copy-of>
<!-- For processing the \f parameter. -->
<b:FootnoteCitationPrefix>
<xsl:value-of select="/b:FootnoteCitation/b:PagePrefix"></xsl:value-of>
</b:FootnoteCitationPrefix>
<!-- For processing the \s parameter. -->
<b:FootnoteCitationSuffix>
<xsl:value-of select="/b:FootnoteCitation/b:PageSuffix"></xsl:value-of>
</b:FootnoteCitationSuffix>
<!-- For processing the \p parameter. -->
<b:FootnoteCitationPages>
<xsl:value-of select="/b:FootnoteCitation/b:Pages"></xsl:value-of>
</b:FootnoteCitationPages>
<!-- For processing the \v parameter. -->
<b:FootnoteCitationVolume>
<xsl:value-of select="/b:FootnoteCitation/b:Volume"></xsl:value-of>
</b:FootnoteCitationVolume>
</b:Source>
</xsl:variable>
<xsl:call-template name="format-source">
<xsl:with-param name="format" select="$format"></xsl:with-param>
<xsl:with-param name="source" select="msxsl:node-set($extendedSource)/b:Source"></xsl:with-param>
<xsl:with-param name="disallowed">
<!-- Do not display the authors of the work. -->
<xsl:if test="/b:FootnoteCitation/b:NoAuthor">
<xsl:value-of select="msxsl:node-set($data)/citation/noauthor"></xsl:value-of>
</xsl:if>
<!-- Do not display the title of the work. -->
<xsl:if test="/b:FootnoteCitation/b:NoTitle">
<xsl:value-of select="msxsl:node-set($data)/citation/notitle"></xsl:value-of>
</xsl:if>
<!-- Do not display the year the work was written or accessed in. -->
<xsl:if test="/b:FootnoteCitation/b:NoYear">
<xsl:value-of select="msxsl:node-set($data)/citation/noyear"></xsl:value-of>
</xsl:if>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$citation" disable-output-escaping="yes"></xsl:value-of>
<!-- end citation -->
<!-- Display the group separator if this is not the last citation. -->
<xsl:if test="not(/b:FootnoteCitation/b:LastAuthor)">
<xsl:value-of select="$params/citation/separator" disable-output-escaping="yes"></xsl:value-of>
</xsl:if>
<!-- Display the close bracket if this is the last citation. -->
<xsl:if test="/b:FootnoteCitation/b:LastAuthor">
<xsl:value-of select="$params/citation/closebracket" disable-output-escaping="yes"></xsl:value-of>
</xsl:if>
</p>
</body>
</html>
</xsl:template>
<!-- Formats the bibliography. -->
<xsl:template name="format-bibliography">
<!-- Extends the b:Source elements of the b:Bibliography element with a b:SortKey. -->
<xsl:variable name="extendedBib">
<!-- Create a b:Bibliography element. -->
<b:Bibliography>
<!-- Extend all the b:Source elements with a sortkey. -->
<xsl:for-each select="/b:Bibliography/b:Source">
<b:Source>
<!-- Copy the content of the b:Source. -->
<xsl:copy-of select="./*"></xsl:copy-of>
<!-- Add a sorting key. -->
<b:SortKey>
<xsl:variable name="skey">
<xsl:variable name="type">
<xsl:variable name="temp" select="./b:Type"></xsl:variable>
<xsl:choose>
<xsl:when test="string-length($temp) > 0 and string-length(msxsl:node-set($data)/bibliography/source[@type = $temp]/sortkey) > 0 ">
<xsl:value-of select="$temp"></xsl:value-of>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="./b:SourceType"></xsl:value-of>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="upper-case">
<xsl:with-param name="string">
<xsl:call-template name="format-source">
<xsl:with-param name="format" select="msxsl:node-set($data)/bibliography/source[@type = $type]/sortkey"></xsl:with-param>
<xsl:with-param name="source" select="."></xsl:with-param>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<!-- If the formatted key is not empty, use that for sorting ... -->
<xsl:when test="string-length($skey) > 0">
<xsl:value-of select="$skey" disable-output-escaping="yes"></xsl:value-of>
</xsl:when>
<!-- Otherwise, use the reference order ... -->
<xsl:otherwise>
<xsl:value-of select="substring(concat('00000', ./b:RefOrder), string-length(./b:RefOrder) + 1, 5)"></xsl:value-of>
</xsl:otherwise>
</xsl:choose>
</b:SortKey>
</b:Source>
</xsl:for-each>
<!-- With the exception of the b:Source elements, copy all elements (not really used by the stylesheets). -->
<!--<xsl:for-each select="/b:Bibliography/*">
<xsl:if test="local-name() != 'Source'">
<xsl:element name="{name()}" namespace="{namespace-uri()}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:if>
</xsl:for-each>-->
</b:Bibliography>
</xsl:variable>
<html xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<style>
p.MsoBibliography
</style>
</head>
<body>
<xsl:choose>
<!-- If there is more than one column, use a table layout. -->
<xsl:when test="msxsl:node-set($data)/bibliography/columns > 1">
<xsl:call-template name="format-bibliography-as-table">
<xsl:with-param name="bibNodeSet" select="msxsl:node-set($extendedBib)"></xsl:with-param>
</xsl:call-template>
</xsl:when>
<!-- Otherwise use a paragraph layout. -->
<xsl:otherwise>
<xsl:call-template name="format-bibliography-as-paragraphs">
<xsl:with-param name="bibNodeSet" select="msxsl:node-set($extendedBib)"></xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</body>
</html>
</xsl:template>
<!-- Formats a bibliography as a series of paragraphs. -->
<xsl:template name="format-bibliography-as-paragraphs">
<xsl:param name="bibNodeSet"></xsl:param>
<xsl:for-each select="$bibNodeSet/b:Bibliography/b:Source">
<xsl:sort select="b:SortKey" data-type="text"></xsl:sort>
<p class="MsoBibliography">
<!-- Get the format string. -->
<xsl:variable name="format">
<xsl:variable name="type" select="./b:Type"></xsl:variable>
<xsl:variable name="sourcetype" select="./b:SourceType"></xsl:variable>
<xsl:choose>
<!-- If there is no source type, its a placeholder. -->
<xsl:when test="string-length($sourcetype) = 0 and string-length(msxsl:node-set($data)/bibliography/source[@type = 'Placeholder']/column[@id = '1']/format) > 0">
<xsl:value-of select="msxsl:node-set($data)/bibliography/source[@type = 'Placeholder']/column[@id = '1']/format"></xsl:value-of>
</xsl:when>
<!-- Go for the type element if available. -->
<xsl:when test="string-length($type) > 0 and string-length(msxsl:node-set($data)/bibliography/source[@type = $type]/column[@id = '1']/format) > 0 ">
<xsl:value-of select="msxsl:node-set($data)/bibliography/source[@type = $type]/column[@id = '1']/format"></xsl:value-of>
</xsl:when>
<!-- Else go for the source type element if available. -->
<xsl:when test="string-length(msxsl:node-set($data)/bibliography/source[@type = $sourcetype]/column[@id = '1']/format) > 0 ">
<xsl:value-of select="msxsl:node-set($data)/bibliography/source[@type = $sourcetype]/column[@id = '1']/format"></xsl:value-of>
</xsl:when>
<!-- Else display error message. -->
<xsl:otherwise>
<xsl:if test="msxsl:node-set($data)/general/display_errors = 'yes'">
<xsl:text><b>Unsupported </xsl:text>
<xsl:if test="string-length($type) > 0">
<xsl:text>type (</xsl:text>
<xsl:value-of select="$type"></xsl:value-of>
<xsl:text>) and </xsl:text>
</xsl:if>
<xsl:text>source type (</xsl:text>
<xsl:value-of select="$sourcetype"></xsl:value-of>
<xsl:text>) for source </xsl:text>
<xsl:value-of select="./b:Tag"></xsl:value-of>
<xsl:text>.</b></xsl:text>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Format the source. -->
<xsl:variable name="paragraphX">
<xsl:call-template name="format-source">
<xsl:with-param name="format" select="$format"></xsl:with-param>
<xsl:with-param name="source" select="."></xsl:with-param>
</xsl:call-template>
</xsl:variable>
<!-- Convert the formatted source to html. -->
<xsl:choose>
<xsl:when test="msxsl:node-set($data)/general/citation_as_link = 'yes'">
<a name="{./b:Tag}">
<xsl:value-of select="$paragraphX" disable-output-escaping="yes"></xsl:value-of>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$paragraphX" disable-output-escaping="yes"></xsl:value-of>
</xsl:otherwise>
</xsl:choose>
</p>
</xsl:for-each>
</xsl:template>
<!-- Formats a bibliography as a table. -->
<xsl:template name="format-bibliography-as-table">
<xsl:param name="bibNodeSet"></xsl:param>
<!-- Empty paragraph hack for table. -->
<p class="MsoBibliography" style="display:none;">x</p>
<table width="100%">
<xsl:for-each select="$bibNodeSet/b:Bibliography/b:Source">
<xsl:sort select="b:SortKey" data-type="text"></xsl:sort>
<tr>
<xsl:call-template name="format-bibliography-table-column">
<xsl:with-param name="columnId" select="1"></xsl:with-param>
<xsl:with-param name="source" select="."></xsl:with-param>
</xsl:call-template>
</tr>
</xsl:for-each>
</table>
<!-- Empty paragraph hack for table. -->
<p class="MsoBibliography" style="display:none;">x</p>
</xsl:template>
<!-- Formats a single column in a bibliography. -->
<xsl:template name="format-bibliography-table-column">
<!-- Source to format. -->
<xsl:param name="source"></xsl:param>
<!-- Id of the column to format. -->
<xsl:param name="columnId"></xsl:param>
<!-- Generate an XML node-set from the formatting data. -->
<xsl:variable name="params" select="msxsl:node-set($data)"></xsl:variable>
<!-- Get the format string. -->
<xsl:variable name="format">
<xsl:variable name="type" select="./b:Type"></xsl:variable>
<xsl:variable name="sourcetype" select="./b:SourceType"></xsl:variable>
<xsl:choose>
<!-- If there is no source type, its a placeholder. -->
<xsl:when test="string-length($sourcetype) = 0 and string-length(msxsl:node-set($data)/bibliography/source[@type = 'Placeholder']/column[@id = $columnId]/format) > 0">
<xsl:value-of select="msxsl:node-set($data)/bibliography/source[@type = 'Placeholder']/column[@id = $columnId]/format"></xsl:value-of>
</xsl:when>
<!-- Go for the type element if available. -->
<xsl:when test="string-length($type) > 0 and string-length(msxsl:node-set($data)/bibliography/source[@type = $type]/column[@id = $columnId]/format) > 0 ">
<xsl:value-of select="msxsl:node-set($data)/bibliography/source[@type = $type]/column[@id = $columnId]/format"></xsl:value-of>
</xsl:when>
<!-- Else go for the source type element if available. -->
<xsl:when test="string-length(msxsl:node-set($data)/bibliography/source[@type = $sourcetype]/column[@id = $columnId]/format) > 0 ">
<xsl:value-of select="msxsl:node-set($data)/bibliography/source[@type = $sourcetype]/column[@id = $columnId]/format"></xsl:value-of>
</xsl:when>
<!-- Else display error message. -->
<xsl:otherwise>
<xsl:if test="msxsl:node-set($data)/general/display_errors = 'yes'">
<xsl:text><b>Unsupported </xsl:text>
<xsl:if test="string-length($type) > 0">
<xsl:text>type (</xsl:text>
<xsl:value-of select="$type"></xsl:value-of>
<xsl:text>) and </xsl:text>
</xsl:if>
<xsl:text>source type (</xsl:text>
<xsl:value-of select="$sourcetype"></xsl:value-of>
<xsl:text>) for source </xsl:text>
<xsl:value-of select="./b:Tag"></xsl:value-of>
<xsl:text>.</b></xsl:text>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Not really efficient at the moment, but it does the trick so errors can be displayed. -->
<xsl:variable name="type">
<xsl:variable name="temp" select="$source/b:Type"></xsl:variable>
<xsl:variable name="temp2" select="$source/b:SourceType"></xsl:variable>
<xsl:choose>
<xsl:when test="string-length($temp2) = 0 and string-length(msxsl:node-set($data)/bibliography/source[@type = $temp2]/column[@id = $columnId]/format) > 0 ">
<xsl:value-of select="'Placeholder'"></xsl:value-of>
</xsl:when>
<xsl:when test="string-length($temp) > 0 and string-length(msxsl:node-set($data)/bibliography/source[@type = $temp]/column[@id = $columnId]/format) > 0 ">
<xsl:value-of select="$temp"></xsl:value-of>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$source/b:SourceType"></xsl:value-of>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<td align="{$params/bibliography/source[@type = $type]/column[@id = $columnId]/halign}" valign="{$params/bibliography/source[@type = $type]/column[@id = $columnId]/valign}">
<p class="MsoBibliography">
<xsl:variable name="columnX">
<xsl:call-template name="format-source">
<xsl:with-param name="format" select="$format"></xsl:with-param>
<xsl:with-param name="source" select="$source"></xsl:with-param>
</xsl:call-template>
</xsl:variable>
<!-- Convert the formatted source to html. -->
<xsl:choose>
<xsl:when test="msxsl:node-set($data)/general/citation_as_link = 'yes' and $columnId = 1">
<a name="{$source/b:Tag}">
<xsl:value-of select="$columnX" disable-output-escaping="yes"></xsl:value-of>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$columnX" disable-output-escaping="yes"></xsl:value-of>
</xsl:otherwise>
</xsl:choose>
</p>
</td>
<!-- Process remaining columns recursively. -->
<xsl:if test="$params/bibliography/columns > $columnId">
<xsl:call-template name="format-bibliography-table-column">
<xsl:with-param name="source" select="$source"></xsl:with-param>
<xsl:with-param name="columnId" select="$columnId + 1"></xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- Preprocesses a format string by adding level information to every marker.
'{' and '}' change into '{level}' and '%' changes into '%level%' where
level is the depth in the format string.
This will allow for faster processing by the formatting templates. -->
<xsl:template name="preprocess-format-string">
<!-- String to process. -->
<xsl:param name="string"></xsl:param>
<!-- Adds balanced brackets around the entire string to help others. -->
<xsl:text>{0}</xsl:text>
<xsl:call-template name="preprocess-format-string-part-2">
<xsl:with-param name="string" select="$string"></xsl:with-param>
</xsl:call-template>
<!-- Adds balanced brackets around the entire string to help others. -->
<xsl:text>{0}</xsl:text>
</xsl:template>
<!-- Recursively called helper function for the preprocess-format-string template. -->
<xsl:template name="preprocess-format-string-part-2">
<!-- Remaining string. -->
<xsl:param name="string"></xsl:param>
<!-- Current level. -->
<xsl:param name="level" select="0"></xsl:param>
<xsl:if test="string-length($string) > 0">
<!-- Get the first character of the remaining string. -->
<xsl:variable name="firstChar" select="substring($string, 1, 1)"></xsl:variable>
<xsl:choose>
<!-- A new level is reached. -->
<xsl:when test="$firstChar = '{'">
<!-- Calculate the next level. -->
<xsl:variable name="nextLevel" select="$level + 1"></xsl:variable>
<!-- Display a conditional processing marker. -->
<xsl:text>{</xsl:text>
<xsl:value-of select="$nextLevel"></xsl:value-of>
<xsl:text>}</xsl:text>
<!-- Recursively process the rest of the string. -->
<xsl:call-template name="preprocess-format-string-part-2">
<xsl:with-param name="string" select="substring($string, 2)"></xsl:with-param>
<xsl:with-param name="level" select="$nextLevel"></xsl:with-param>
</xsl:call-template>
</xsl:when>
<!-- The current level is finished. -->
<xsl:when test="$firstChar = '}'">
<!-- Display a conditional processing marker. -->
<xsl:text>{</xsl:text>
<xsl:value-of select="$level"></xsl:value-of>
<xsl:text>}</xsl:text>
<!-- Recursively process the rest of the string. -->
<xsl:call-template name="preprocess-format-string-part-2">
<xsl:with-param name="string" select="substring($string, 2)"></xsl:with-param>
<xsl:with-param name="level" select="$level - 1"></xsl:with-param>
</xsl:call-template>
</xsl:when>
<!-- A variable at the current level starts. -->
<xsl:when test="$firstChar = '%'">
<!-- Display a variable processing marker (start of variable). -->
<xsl:text>%</xsl:text>
<xsl:value-of select="$level"></xsl:value-of>
<xsl:text>%</xsl:text>
<!-- Display the variable (no use in parsing character by character).-->
<xsl:value-of select="substring-before(substring($string, 2), '%')"></xsl:value-of>
<!-- Display a variable processing marker (end of variable). -->
<xsl:text>%</xsl:text>
<xsl:value-of select="$level"></xsl:value-of>
<xsl:text>%</xsl:text>
<!-- Recursively process the rest of the string. -->
<xsl:call-template name="preprocess-format-string-part-2">
<xsl:with-param name="string" select="substring-after(substring($string, 2), '%')"></xsl:with-param>
<xsl:with-param name="level" select="$level"></xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- Display the first character -->
<xsl:value-of select="$firstChar"></xsl:value-of>
<!-- Recursively process the rest of the string. -->
<xsl:call-template name="preprocess-format-string-part-2">
<xsl:with-param name="string" select="substring($string, 2)"></xsl:with-param>