-
Notifications
You must be signed in to change notification settings - Fork 0
/
dracor_jinja2.py
101 lines (100 loc) · 3.15 KB
/
dracor_jinja2.py
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
# Jinja2 template
# https://jinja.palletsprojects.com/en/3.1.x/templates/
xml_template = """<?xml version="1.0" encoding="utf-8"?>
<?xml-model href="https://dracor.org/schema.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0" xml:id="{{ data.get('ti_id') }}" xml:lang="nl">
<fileDesc>
<titleStmt>
<title type="main">{{data.get('main_title')}}</title>
{% if data.get('subtitle') %}
<title type="sub">{{ data.get('subtitle') }}</title>
{% endif %}
<author>
<persName>
<forename>{{data.get('voornaam', '')}}</forename>
<surname>{{data.get('achternaam', '')}}</surname>
</persName>
<idno type="wikidata">wikidata identifier</idno>
<idno type="pnd">pnd identifier (optional)</idno>
</author>
</titleStmt>
<publicationStmt>
<publisher xml:id="dracor">DraCor</publisher>
<idno type="URL">https://dracor.org</idno>
<availability>
<licence>
<ab>CC0 1.0</ab>
<ref target="https://creativecommons.org/publicdomain/zero/1.0/">Licence</ref>
</licence>
</availability>
</publicationStmt>
<sourceDesc>
<bibl type="digitalSource">
<name>{{ data.get('signatuur') }}</name>
<idno type="URL">{{ data.get('ur;') }}</idno>
<availability status="free">
<p>In the public domain.</p>
</availability>
<bibl type="originalSource">
<title>{{ data.get('link') }}</title>
</bibl>
</bibl>
</sourceDesc>
</fileDesc>
<profileDesc>
<particDesc>
<listPerson>
{% for speaker in data.get('speakerlist') %}
<person xml:id="{{ speaker[1:] }}" sex="{{ data.get('speakerlist').get(speaker).gender[0]|lower }}">
<persName>{{ data.get('speakerlist').get(speaker).speaker_variant }}</persName>
</person>
{% endfor %}
<listRelation type="type of relation">
<relation name="" active="pers_1" passive="pers_2"/>
</listRelation>
</listPerson>
</particDesc>
<textClass>
<keywords>
<term type="genreTitle">{{ data.get('dracor_genre', '') }}</term>
</keywords>
</textClass>
</profileDesc>
<revisionDesc>
<listChange>
<change when="0000-00-00">who did what</change>
</listChange>
</revisionDesc>
<standOff>
<listEvent>
<event type="print" when="{{ data.get('jaar') }}">
<desc/>
</event>
<event type="premiere" when="">
<desc/>
</event>
<event type="written" when="">
<desc/>
</event>
</listEvent>
<listRelation>
<relation name="wikidata" active="https://dracor.org/entity/" passive="http://www.wikidata.org/entity/"/>
</listRelation>
</standOff>
<text>
<front>
</front>
<body>
{% for block in data.get('readingorder') %}
{% for key, value in block.items() %}
<div type="{{ key }}" n="{{ loop.index }}">
{% for f in value %}
{{ f }}
{% endfor %}
</div>
{% endfor %}
{% endfor %}
</body>
</text>
</TEI>
"""