-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconvert_tei-to-zotero-rdf_functions.xsl
718 lines (700 loc) · 36.9 KB
/
convert_tei-to-zotero-rdf_functions.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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:z="http://www.zotero.org/namespaces/export#"
xmlns:bib="http://purl.org/net/biblio#"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:vcard="http://nwalsh.com/rdf/vCard#"
xmlns:tss="http://www.thirdstreetsoftware.com/SenteXML-1.0"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:prism="http://prismstandard.org/namespaces/1.2/basic/"
xmlns:link="http://purl.org/rss/1.0/modules/link/"
xmlns:oape="https://openarabicpe.github.io/ns"
exclude-result-prefixes="tei tss"
version="3.0">
<xsl:output method="xml" indent="yes" omit-xml-declaration="no" encoding="UTF-8"/>
<xsl:include href="functions.xsl"/>
<!-- this stylesheet translates <tei:biblStruct> to Zotero RDF -->
<!-- to do:
- improve short titles: add eclipse
- add full-text notes
-->
<xsl:param name="p_length-short-title" select="5"/>
<xsl:param name="p_full-text-note" select="false()"/>
<xsl:variable name="v_new-line" select="'
'"/>
<xsl:variable name="v_separator-key-value" select="': '"/>
<xsl:variable name="v_cite-key-whitespace-replacement" select="'+'"/>
<xsl:function name="oape:bibliography-tei-to-zotero-rdf">
<xsl:param name="tei_biblstruct"/>
<xsl:param name="p_lang"/>
<!-- check reference type, since the first child after the root depends on it -->
<!-- this can be based on the structure of the biblStruct -->
<!-- <xsl:variable name="v_reference-type-zotero" select="'journalArticle'"/>-->
<xsl:variable name="v_reference-type-zotero">
<xsl:choose>
<!-- test if input is an entire work or a part of it -->
<xsl:when test="$tei_biblstruct/tei:analytic">
<!-- test what type of work it is part of -->
<xsl:choose>
<!-- a periodical article -->
<xsl:when test="$tei_biblstruct/tei:monogr/tei:title/@level = 'j'">
<!-- With reference to OpenArabicPE this should be mapped to -->
<xsl:text>magazineArticle</xsl:text>
</xsl:when>
<!-- a book chapter -->
<xsl:when test="$tei_biblstruct/tei:monogr/tei:title/@level = 'm'">
<xsl:text>bookSection</xsl:text>
</xsl:when>
<!-- fallback -->
<xsl:otherwise>
<xsl:message terminate="yes">
<xsl:text>Could not establish the Zotero reference type from the input structure.</xsl:text>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- fallback:book -->
<xsl:otherwise>
<xsl:text>book</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="v_reference-type-bib" select="$v_reference-types/descendant::tei:nym[tei:form[@n = 'zotero'][. = $v_reference-type-zotero]][1]/tei:form[@n = 'bib']"/>
<xsl:variable name="v_reference-is-section" select="if($tei_biblstruct/tei:analytic) then(true()) else(false())"/>
<!-- <xsl:variable name="v_reference-is-part-of-series" select="if($tss_reference/descendant::tss:characteristic[@name = 'Series'] != '') then(true()) else(false())"/>-->
<!--<xsl:variable name="v_series">
<dcterms:isPartOf>
<bib:Series>
<xsl:apply-templates select="$tss_reference/descendant::tss:characteristic[@name = 'Series']" mode="m_tei-to-zotero-rdf"/>
<xsl:apply-templates select="$tss_reference/descendant::tss:characteristic[@name = 'Series number']" mode="m_tei-to-zotero-rdf"/>
</bib:Series>
</dcterms:isPartOf>
</xsl:variable>-->
<!-- output -->
<xsl:element name="bib:{$v_reference-type-bib}">
<!-- add an ID -->
<xsl:variable name="v_rdf-about">
<xsl:choose>
<xsl:when test="$tei_biblstruct/tei:analytic/tei:idno[@type = 'BibTeX']">
<xsl:value-of select="$tei_biblstruct/tei:analytic/tei:idno[@type = 'BibTeX'][1]"/>
</xsl:when>
<xsl:when test="$tei_biblstruct/tei:monogr/tei:idno[@type = 'BibTeX']">
<xsl:value-of select="$tei_biblstruct/tei:monogr/tei:idno[@type = 'BibTeX'][1]"/>
</xsl:when>
<!-- construct an ID from availabele idno and biblScope -->
<xsl:when test="$tei_biblstruct/tei:monogr/tei:idno[@type = 'OCLC']">
<xsl:variable name="v_oclc" select="concat('oclc_', $tei_biblstruct/tei:monogr/tei:idno[@type = 'OCLC'][1])"/>
<xsl:variable name="v_volume">
<xsl:if test="$tei_biblstruct/tei:monogr/tei:biblScope[@unit = 'volume']">
<xsl:value-of select="concat('-v_',$tei_biblstruct/tei:monogr/tei:biblScope[@unit = 'volume']/@from )"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="v_issue">
<xsl:if test="$tei_biblstruct/tei:monogr/tei:biblScope[@unit = 'issue']">
<xsl:value-of select="concat('-i_',$tei_biblstruct/tei:monogr/tei:biblScope[@unit = 'issue']/@from )"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="v_article">
<xsl:choose>
<xsl:when test="$tei_biblstruct/tei:analytic/tei:idno[@type != 'url']">
<xsl:value-of select="concat('-', $tei_biblstruct/tei:analytic/tei:idno[@type != 'url']/@type,'_', $tei_biblstruct/tei:analytic/tei:idno[@type != 'url'][1])"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('-a_', generate-id($tei_biblstruct))"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="concat($v_oclc, $v_volume, $v_issue, $v_article)"/>
</xsl:when>
<xsl:when test="$tei_biblstruct/@xml:id">
<xsl:value-of select="$tei_biblstruct/@xml:id"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="generate-id($tei_biblstruct)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:attribute name="rdf:about" select="concat('#',$v_rdf-about)"/>
<!-- itemType -->
<z:itemType>
<xsl:value-of select="$v_reference-type-zotero"/>
</z:itemType>
<!-- titles -->
<xsl:variable name="v_title-monogr">
<xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:title[@xml:lang = $p_lang][not(@type = 'sub')]" mode="m_tei-to-zotero-rdf">
<xsl:with-param name="p_lang" select="$p_lang"/>
</xsl:apply-templates>
</xsl:variable>
<xsl:choose>
<!-- check if the reference is part of a larger work (i.e. a chapter, article) -->
<xsl:when test="$v_reference-is-section = true()">
<dcterms:isPartOf>
<xsl:choose>
<!-- book chapters -->
<xsl:when test="$v_reference-type-bib = 'BookSection'">
<bib:Book>
<xsl:copy-of select="$v_title-monogr"/>
</bib:Book>
</xsl:when>
<!-- periodical articles -->
<xsl:when test="$v_reference-type-bib = 'Article'">
<bib:Periodical>
<xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:biblScope[@unit = 'volume']" mode="m_tei-to-zotero-rdf"/>
<xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:biblScope[@unit = 'issue']" mode="m_tei-to-zotero-rdf"/>
<xsl:copy-of select="$v_title-monogr"/>
</bib:Periodical>
</xsl:when>
<!-- maps: it seems that the articleTitle should be mapped to Series -->
<xsl:when test="$v_reference-type-zotero = 'map'"/>
<!-- fallback: book -->
<xsl:otherwise>
<bib:Book>
<xsl:copy-of select="$v_title-monogr"/>
</bib:Book>
</xsl:otherwise>
</xsl:choose>
</dcterms:isPartOf>
<!-- check if an item is part of a series -->
<xsl:apply-templates select="$tei_biblstruct/tei:analytic/tei:title[@level = 'a'][@xml:lang = $p_lang]" mode="m_tei-to-zotero-rdf"/>
</xsl:when>
<xsl:otherwise>
<!-- <xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:title[@xml:lang = $p_lang]" mode="m_tei-to-zotero-rdf"/>-->
<xsl:copy-of select="$v_title-monogr"/>
</xsl:otherwise>
</xsl:choose>
<!-- short titles -->
<xsl:variable name="v_title-temp">
<xsl:choose>
<xsl:when test="$v_reference-is-section = true()">
<xsl:value-of select="$tei_biblstruct/tei:analytic/tei:title[@level = 'a'][@xml:lang = $p_lang]"/>
</xsl:when>
<xsl:when test="$v_reference-is-section = false()">
<xsl:value-of select="$tei_biblstruct/tei:monogr/tei:title[@xml:lang = $p_lang][not(@type = 'sub')]"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="v_title-short">
<xsl:analyze-string select="normalize-space($v_title-temp)" regex="^(.+?)([:|\.|\?])(.+)$">
<xsl:matching-substring>
<xsl:value-of select="normalize-space(regex-group(1))"/>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:for-each select="tokenize(normalize-space($v_title-temp),'\s+')">
<xsl:if test="position() <= $p_length-short-title">
<xsl:if test="position() gt 1">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:value-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:variable>
<z:shortTitle><xsl:value-of select="$v_title-short"/></z:shortTitle>
<!-- contributors: authors, editors etc. -->
<xsl:if test="$tei_biblstruct/descendant::tei:author">
<bib:authors>
<rdf:Seq>
<xsl:apply-templates select="$tei_biblstruct/descendant::tei:author/node()[@xml:lang = $p_lang]" mode="m_tei-to-zotero-rdf"/>
</rdf:Seq>
</bib:authors>
</xsl:if>
<xsl:if test="$tei_biblstruct/descendant::tei:editor">
<bib:editors>
<rdf:Seq>
<xsl:apply-templates select="$tei_biblstruct/descendant::tei:editor/node()[@xml:lang = $p_lang]" mode="m_tei-to-zotero-rdf"/>
</rdf:Seq>
</bib:editors>
</xsl:if>
<xsl:if test="$tei_biblstruct/descendant::tei:respStmt">
<bib:contributors>
<rdf:Seq>
<xsl:apply-templates select="$tei_biblstruct/descendant::tei:respStmt/node()[not(self::tei:resp)][@xml:lang = $p_lang]" mode="m_tei-to-zotero-rdf"/>
</rdf:Seq>
</bib:contributors>
</xsl:if>
<!-- <xsl:apply-templates select="$tss_reference/descendant::tss:characteristic[@name = 'Recipient']" mode="m_tei-to-zotero-rdf"/>-->
<!-- publisher: name, location -->
<dc:publisher>
<foaf:Organization>
<vcard:adr>
<vcard:Address>
<vcard:locality><xsl:value-of select="$tei_biblstruct/tei:monogr/tei:imprint/tei:pubPlace/tei:placeName[@xml:lang = $p_lang]"/></vcard:locality>
</vcard:Address>
</vcard:adr>
<foaf:name><xsl:value-of select="$tei_biblstruct/tei:monogr/tei:imprint/tei:publisher/node()[@xml:lang = $p_lang]"/></foaf:name>
</foaf:Organization>
</dc:publisher>
<!-- links to notes -->
<xsl:if test="$p_full-text-note = true()">
<dcterms:isReferencedBy rdf:resource="{concat('#',$tei_biblstruct/descendant::tei:idno[@type = 'BibTeX'],'-text')}"/>
</xsl:if>
<!-- IDs / URLs -->
<xsl:choose>
<xsl:when test="$tei_biblstruct/tei:analytic/tei:idno[@type = 'url']">
<xsl:apply-templates select="$tei_biblstruct/tei:analytic/tei:idno[@type = 'url']" mode="m_tei-to-zotero-rdf"/>
</xsl:when>
<xsl:when test="$tei_biblstruct/tei:monogr/tei:idno[@type = 'url']">
<xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:idno[@type = 'url']" mode="m_tei-to-zotero-rdf"/>
</xsl:when>
</xsl:choose>
<!-- Identitifiers -->
<!-- edition -->
<!-- <xsl:apply-templates select="$tss_reference/descendant::tss:characteristic[@name = 'Edition']" mode="m_tei-to-zotero-rdf"/>-->
<!-- volume, issue: depends on work not being a chapter or article -->
<xsl:if test="$v_reference-is-section = false()">
<xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:biblScope[@unit = 'volume']" mode="m_tei-to-zotero-rdf"/>
<xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:biblScope[@unit = 'issue']" mode="m_tei-to-zotero-rdf"/>
</xsl:if>
<xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:biblScope[@unit = 'page']" mode="m_tei-to-zotero-rdf"/>
<!-- dates -->
<xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:imprint/tei:date" mode="m_tei-to-zotero-rdf"/>
<!-- extra field: map all sorts of custom fields -->
<dc:description>
<xsl:apply-templates select="$tei_biblstruct/tei:analytic/tei:idno[@type = 'BibTeX']" mode="m_extra-field"/>
<xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:idno[@type = 'BibTeX']" mode="m_extra-field"/>
<xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:imprint/tei:date[@datingMethod = '#cal_ottomanfiscal']" mode="m_extra-field"/>
<xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:imprint/tei:date[@datingMethod = '#cal_islamic']" mode="m_extra-field"/>
<xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:imprint/tei:date[@datingMethod = '#cal_julian']" mode="m_extra-field"/>
<xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:idno[@type = 'DOI']" mode="m_extra-field"/>
<xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:idno[@type = 'ISBN']" mode="m_extra-field"/>
<!-- do not replicate all OCLC IDs -->
<xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:idno[@type = 'OCLC'][1]" mode="m_extra-field"/>
<xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:idno[@type = 'zenodo']" mode="m_extra-field"/>
<!-- support for multiple languages? -->
<!--<xsl:apply-templates select="$tss_reference/descendant::tss:characteristic[@name = 'Original publication year']" mode="m_extra-field"/>
<xsl:apply-templates select="$tss_reference/descendant::tss:characteristic[@name = 'Orig.Title']" mode="m_extra-field"/>
<xsl:apply-templates select="$tss_reference/descendant::tss:characteristic[@name = 'Translated title']" mode="m_extra-field"/>-->
<!-- <xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:biblScope[@unit = 'issue']" mode="m_extra-field"/>-->
<!-- make this dependent on the reference type: letter etc. -->
<xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:imprint/tei:pubPlace/tei:placeName[@xml:lang = $p_lang]" mode="m_extra-field"/>
<xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:imprint/tei:publisher/node()[@xml:lang = $p_lang]" mode="m_extra-field"/>
<!-- <xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:biblScope[@unit = 'volume']" mode="m_extra-field"/>-->
</dc:description>
<!-- language -->
<xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:textLang" mode="m_tei-to-zotero-rdf"/>
<!-- ISBN, ISSN etc. -->
<xsl:apply-templates select="$tei_biblstruct/tei:monogr/tei:idno[@type = 'ISBN']" mode="m_tei-to-zotero-rdf"/>
</xsl:element>
<!-- notes -->
<xsl:if test="$p_full-text-note = true()">
<xsl:copy-of select="oape:bibliography-full-text-to-note($tei_biblstruct)"/>
</xsl:if>
</xsl:function>
<!-- extra field -->
<!-- if used with Better BibTeX, one can set the citation key in the extra field -->
<xsl:template match="tei:idno[@type = 'BibTeX']" mode="m_extra-field">
<xsl:if test=".!=''">
<xsl:value-of select="concat('Citation Key', $v_separator-key-value, .,$v_new-line)"/>
<!-- as the Citation Key line is dropped upon dragging and dropping references between Zotero libraries or groups, we replicate the content in an additional line -->
<xsl:value-of select="concat('BibTeX Cite Key', $v_separator-key-value, .,$v_new-line)"/>
</xsl:if>
</xsl:template>
<xsl:template match="tei:idno[@type = 'DOI']" mode="m_extra-field">
<xsl:if test=".!=''">
<xsl:value-of select="concat('doi', $v_separator-key-value,.,$v_new-line)"/>
</xsl:if>
</xsl:template>
<xsl:template match="tei:idno[@type = 'ISBN']" mode="m_extra-field">
<xsl:if test=".!=''">
<xsl:value-of select="concat('isbn', $v_separator-key-value,.,$v_new-line)"/>
</xsl:if>
</xsl:template>
<xsl:template match="tei:idno[@type = 'ISBN']" mode="m_tei-to-zotero-rdf">
<dc:identifier><xsl:value-of select="concat('ISBN ', .)"/></dc:identifier>
</xsl:template>
<xsl:template match="tei:idno[@type = 'OCLC']" mode="m_extra-field">
<xsl:if test=".!=''">
<xsl:value-of select="concat('oclc', $v_separator-key-value,.,$v_new-line)"/>
</xsl:if>
</xsl:template>
<xsl:template match="tei:idno[@type = 'zenodo']" mode="m_extra-field">
<xsl:if test=".!=''">
<xsl:value-of select="concat('zenodo', $v_separator-key-value,.,$v_new-line)"/>
</xsl:if>
</xsl:template>
<xsl:template match="tei:date" mode="m_extra-field">
<!-- try to establish the calendar -->
<!-- content -->
<xsl:text>date_</xsl:text>
<xsl:choose>
<xsl:when test="@datingMethod = '#cal_julian'">
<xsl:text>rumi</xsl:text>
</xsl:when>
<xsl:when test="@datingMethod = '#cal_ottomanfiscal'">
<xsl:text>mali</xsl:text>
</xsl:when>
<xsl:when test="@datingMethod = '#cal_islamic'">
<xsl:text>hijri</xsl:text>
</xsl:when>
</xsl:choose>
<xsl:value-of select="concat($v_separator-key-value, @when-custom, $v_new-line)"/>
</xsl:template>
<xsl:template match="tei:biblScope" mode="m_extra-field">
<xsl:variable name="v_value">
<xsl:choose>
<xsl:when test="@from = @to">
<xsl:value-of select="@from"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat(@from, '-', @to)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="concat(@unit, $v_separator-key-value, $v_value, $v_new-line)"/>
</xsl:template>
<xsl:template match="tei:placeName" mode="m_extra-field">
<xsl:if test=".!=''">
<xsl:value-of select="concat('place', $v_separator-key-value,.,$v_new-line)"/>
</xsl:if>
</xsl:template>
<xsl:template match="tei:publisher/node()" mode="m_extra-field">
<xsl:if test=".!=''">
<xsl:value-of select="concat('publisher', $v_separator-key-value,.,$v_new-line)"/>
</xsl:if>
</xsl:template>
<!-- contributors -->
<xsl:template match="tei:persName" mode="m_tei-to-zotero-rdf">
<rdf:li>
<foaf:Person>
<!-- Zotero has a problem with non-Western name schemes -->
<xsl:choose>
<xsl:when test="tei:surname and tei:forename">
<xsl:apply-templates select="tei:surname" mode="m_tei-to-zotero-rdf"/>
<xsl:apply-templates select="tei:forename" mode="m_tei-to-zotero-rdf"/>
</xsl:when>
<xsl:when test="tei:surname">
<xsl:apply-templates select="tei:surname" mode="m_tei-to-zotero-rdf"/>
<foaf:givenName><xsl:apply-templates select="child::node()[not(self::tei:surname | self::tei:roleName)]" mode="m_plain-text"/></foaf:givenName>
</xsl:when>
<xsl:otherwise>
<foaf:surname><!--<xsl:apply-templates select="." mode="m_plain-text"/>-->
<xsl:value-of select="normalize-space(.)"/>
</foaf:surname>
</xsl:otherwise>
</xsl:choose>
</foaf:Person>
</rdf:li>
</xsl:template>
<xsl:template match="tei:surname" mode="m_tei-to-zotero-rdf">
<xsl:variable name="v_temp">
<xsl:apply-templates mode="m_plain-text"/>
</xsl:variable>
<foaf:surname><xsl:value-of select="normalize-space($v_temp)"/></foaf:surname>
</xsl:template>
<xsl:template match="tei:forename" mode="m_tei-to-zotero-rdf">
<xsl:variable name="v_temp">
<xsl:apply-templates mode="m_plain-text"/>
</xsl:variable>
<foaf:givenName><xsl:value-of select="normalize-space($v_temp)"/></foaf:givenName>
</xsl:template>
<!-- titles -->
<xsl:template match="tei:title" mode="m_tei-to-zotero-rdf">
<xsl:param name="p_lang"/>
<xsl:choose>
<!-- for cases when author names contain periodical titles -->
<xsl:when test="parent::tei:author">
<foaf:surname><xsl:apply-templates mode="m_plain-text"/></foaf:surname>
</xsl:when>
<xsl:otherwise>
<dc:title>
<xsl:apply-templates mode="m_plain-text"/>
<xsl:if test="parent::node()/tei:title[@type = 'sub'][@xml:lang = $p_lang]">
<xsl:text>: </xsl:text>
<xsl:apply-templates select="parent::node()/tei:title[@type = 'sub'][@xml:lang = $p_lang][1]" mode="m_plain-text"/>
</xsl:if>
</dc:title>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- transform dates -->
<xsl:template match="tei:date" mode="m_tei-to-zotero-rdf">
<xsl:variable name="v_date">
<xsl:choose>
<xsl:when test="@when">
<xsl:value-of select="@when"/>
</xsl:when>
<!-- date ranges -->
<xsl:when test="@from">
<xsl:value-of select="@from"/>
</xsl:when>
<xsl:when test="@notBefore">
<xsl:value-of select="@notBefore"/>
</xsl:when>
<xsl:otherwise>
<xsl:message>
<xsl:text>Date note has no @when, @from or @notBefore attributes</xsl:text>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<dc:date><xsl:value-of select="$v_date"/></dc:date>
</xsl:template>
<xsl:template match="tei:idno[@type = 'url']" mode="m_tei-to-zotero-rdf">
<dc:identifier>
<dcterms:URI>
<rdf:value><xsl:value-of select="."/></rdf:value>
</dcterms:URI>
</dc:identifier>
</xsl:template>
<!--<xsl:template match="tss:characteristic[@name = 'Edition']" mode="m_tei-to-zotero-rdf">
<prism:edition><xsl:value-of select="."/></prism:edition>
</xsl:template>-->
<!--<xsl:template match="tss:characteristic[@name = 'Number of volumes']" mode="m_tei-to-zotero-rdf">
<z:numberOfVolumes><xsl:value-of select="."/></z:numberOfVolumes>
</xsl:template>-->
<xsl:template match="tei:biblScope" mode="m_tei-to-zotero-rdf">
<xsl:variable name="v_value">
<xsl:choose>
<xsl:when test="@from = @to">
<xsl:value-of select="@from"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat(@from, '-', @to)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="@unit = 'volume'">
<prism:volume><xsl:value-of select="$v_value"/></prism:volume>
</xsl:when>
<xsl:when test="@unit = 'issue'">
<prism:number><xsl:value-of select="$v_value"/></prism:number>
</xsl:when>
<xsl:when test="@unit = 'page'">
<bib:pages><xsl:value-of select="$v_value"/></bib:pages>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="tei:textLang" mode="m_tei-to-zotero-rdf">
<z:language><xsl:value-of select="@mainLang"/></z:language>
</xsl:template>
<!-- call-numbers -->
<!-- full-text notes -->
<xsl:function name="oape:bibliography-full-text-to-note">
<xsl:param name="tei_biblstruct"/>
<!-- notes -->
<bib:Memo rdf:about="{concat('#',$tei_biblstruct/descendant::tei:idno[@type = 'BibTeX'],'-text')}">
<rdf:value>
<!-- full-text that needs to be pulled out of the biblStruct or pulled from the URL of the article -->
</rdf:value>
</bib:Memo>
</xsl:function>
<!-- map reference types -->
<xsl:variable name="v_reference-types">
<tei:listNym>
<tei:nym>
<tei:form n="tss">Archival Book Chapter</tei:form>
<tei:form n="zotero">bookSection</tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib">BookSection</tei:form>
<tei:form n="biblatex"></tei:form>
<tei:form n="csl"></tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Archival File</tei:form>
<tei:form n="zotero">manuscript</tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib">Manuscript</tei:form>
<tei:form n="biblatex"></tei:form>
<tei:form n="csl">manuscript</tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Archival Journal Entry</tei:form>
<tei:form n="zotero"></tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib"></tei:form>
<tei:form n="biblatex"></tei:form>
<tei:form n="csl"></tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Archival Letter</tei:form>
<tei:form n="zotero">letter</tei:form>
<tei:form n="marcgt">letter</tei:form>
<tei:form n="bib">Letter</tei:form>
<tei:form n="biblatex"></tei:form>
<tei:form n="csl">personal_communication</tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Archival Material</tei:form>
<tei:form n="zotero">manuscript</tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib">Manuscript</tei:form>
<tei:form n="biblatex"></tei:form>
<tei:form n="csl">manuscript</tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Archival Periodical</tei:form>
<tei:form n="zotero">newspaperArticle</tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib">Article</tei:form>
<tei:form n="biblatex">article</tei:form>
<tei:form n="csl">article-newspaper</tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Archival Periodical Article</tei:form>
<tei:form n="zotero">magazineArticle</tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib">Article</tei:form>
<tei:form n="biblatex">article</tei:form>
<tei:form n="csl">article-magazine</tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Bill</tei:form>
<tei:form n="zotero">bill</tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib">Legislation</tei:form>
<tei:form n="biblatex"></tei:form>
<tei:form n="csl">bill</tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Book</tei:form>
<tei:form n="zotero">book</tei:form>
<tei:form n="marcgt">book</tei:form>
<tei:form n="bib">Book</tei:form>
<tei:form n="biblatex">mvbook</tei:form>
<tei:form n="csl">book</tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Book Chapter</tei:form>
<tei:form n="zotero">bookSection</tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib">BookSection</tei:form>
<tei:form n="biblatex"></tei:form>
<tei:form n="csl">chapter</tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">CD/DVD</tei:form>
<tei:form n="zotero">computerProgram</tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib">Data</tei:form>
<tei:form n="biblatex"></tei:form>
<tei:form n="csl"></tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Computer Software</tei:form>
<tei:form n="zotero">computerProgram</tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib">Data</tei:form>
<tei:form n="biblatex"></tei:form>
<tei:form n="csl"></tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Conference Proceedings</tei:form>
<tei:form n="zotero">book</tei:form>
<tei:form n="marcgt">book</tei:form>
<tei:form n="bib">Book</tei:form>
<tei:form n="biblatex">mvbook</tei:form>
<tei:form n="csl">book</tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Edited Book</tei:form>
<tei:form n="zotero">book</tei:form>
<tei:form n="marcgt">book</tei:form>
<tei:form n="bib">Book</tei:form>
<tei:form n="biblatex">mvbook</tei:form>
<tei:form n="csl">book</tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Electronic Citation</tei:form>
<tei:form n="zotero"></tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib"></tei:form>
<tei:form n="biblatex"></tei:form>
<tei:form n="csl"></tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Journal Article</tei:form>
<tei:form n="zotero">journalArticle</tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib">Article</tei:form>
<tei:form n="biblatex">article</tei:form>
<tei:form n="csl">article-journal</tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Magazine Article</tei:form>
<tei:form n="zotero">magazineArticle</tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib">Article</tei:form>
<tei:form n="biblatex">article</tei:form>
<tei:form n="csl">article-magazine</tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Manuscript</tei:form>
<tei:form n="zotero">manuscript</tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib">Manuscript</tei:form>
<tei:form n="biblatex"></tei:form>
<tei:form n="csl">manuscript</tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Maps</tei:form>
<tei:form n="zotero">map</tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib">Image</tei:form>
<tei:form n="biblatex"></tei:form>
<tei:form n="csl">map</tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Motion Picture</tei:form>
<tei:form n="zotero"></tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib"></tei:form>
<tei:form n="biblatex"></tei:form>
<tei:form n="csl"></tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Newspaper article</tei:form>
<tei:form n="zotero">newspaperArticle</tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib">Article</tei:form>
<tei:form n="biblatex">article</tei:form>
<tei:form n="csl">article-newspaper</tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Other</tei:form>
<tei:form n="zotero"></tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib"></tei:form>
<tei:form n="biblatex"></tei:form>
<tei:form n="csl"></tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Photograph</tei:form>
<tei:form n="zotero">artwork</tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib"></tei:form>
<tei:form n="biblatex"></tei:form>
<tei:form n="csl"></tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Presentation</tei:form>
<tei:form n="zotero">presentation</tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib">ConferenceProceedings</tei:form>
<tei:form n="biblatex"></tei:form>
<tei:form n="csl"></tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Thesis type</tei:form>
<tei:form n="zotero">thesis</tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib">Thesis</tei:form>
<tei:form n="biblatex"></tei:form>
<tei:form n="csl">thesis</tei:form>
</tei:nym>
<tei:nym>
<tei:form n="tss">Web Page</tei:form>
<tei:form n="zotero">webpage</tei:form>
<tei:form n="marcgt"></tei:form>
<tei:form n="bib">Document</tei:form>
<tei:form n="biblatex"></tei:form>
<tei:form n="csl">webpage</tei:form>
</tei:nym>
</tei:listNym>
</xsl:variable>
</xsl:stylesheet>