-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpers2.xsl
204 lines (175 loc) · 12.5 KB
/
pers2.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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:math="http://www.w3.org/2005/xpath-functions/math" exclude-result-prefixes="xs math" xmlns="http://www.tei-c.org/ns/1.0" xpath-default-namespace="http://www.tei-c.org/ns/1.0" version="3.0">
<xsl:output method="xml" encoding="UTF-8" indent="yes" exclude-result-prefixes="#all" xmlns="http://www.tei-c.org/ns/1.0" xpath-default-namespace="http://www.tei-c.org/ns/1.0"/>
<xsl:strip-space elements="*"/>
<xsl:preserve-space elements="persName"/>
<xsl:mode on-no-match="shallow-copy"/>
<xsl:variable name="docs" select="collection('?select=taxroll_*.xml')"/>
<xsl:variable name="refs" select="$docs//persName | $docs//rs[@type='person']"/>
<!-- Create TEI Body -->
<xsl:template match="/">
<xsl:variable name="docList" select="collection('?select=taxroll_*.xml')"/>
<TEI xmlns="http://www.tei-c.org/ns/1.0" xml:id="personography">
<teiHeader>
<fileDesc>
<titleStmt>
<title>Title</title>
</titleStmt>
<publicationStmt>
<p>Publication Information</p>
</publicationStmt>
<sourceDesc>
<p>Born digital</p>
</sourceDesc>
</fileDesc>
</teiHeader>
<text>
<body>
<listPerson>
<xsl:for-each-group select="$refs" group-by="@ref">
<xsl:sort select="@ref"/>
<!--<xsl:sort select=".//forename" lang="fr-FR"/>-->
<xsl:variable name="persRef" select="@ref"/>
<xsl:variable name="auth" select="document('authority.xml')//person[@corresp = $persRef]"/>
<!-- <xsl:for-each-group select="$refs" >-->
<!--<xsl:if test="not(preceding::persName[@ref = $persRef] | preceding::rs[@ref = $persRef])">-->
<person xml:id="{substring(@ref,2)}">
<!-- Names -->
<xsl:copy-of select="$auth/persName"/>
<xsl:for-each select="current-group()">
<xsl:apply-templates select="."/>
</xsl:for-each>
<!-- Authority IDs -->
<xsl:copy-of select="$auth/idno"/>
<!-- Choose Sex -->
<xsl:choose>
<xsl:when test="$auth">
<xsl:copy-of select="$auth/sex"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="current-group()/descendant::nameLink[(text() = 'le')] | current-group()/descendant::nameLink[(text() = 'Le')] | current-group()/roleName[(text() = 'Mestre' or text() = 'mestre')] | current-group()[@type='person'][starts-with(.,'Le ') or starts-with(.,'le ')] | current-group()[@type='person'][starts-with(.,'Son ') or starts-with(.,'son ')]">
<sex value="male"/>
</xsl:when>
<xsl:when test="current-group()/descendant::nameLink[(text() = 'la')] | current-group()/descendant::nameLink[(text() = 'La')] | current-group()/roleName[(text() = 'Dame' or text() = 'dame')] | current-group()[@type='person'][starts-with(.,'La ') or starts-with(.,'la ')] | current-group()[@type='person'][starts-with(.,'Sa ') or starts-with(.,'sa ')]">
<sex value="female"/>
</xsl:when>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
<!-- Birth and Death [authority.xml only atm]-->
<xsl:if test="$auth/birth">
<xsl:copy-of select="$auth/birth"/>
</xsl:if>
<xsl:if test="$auth/death">
<xsl:copy-of select="$auth/death"/>
</xsl:if>
<!-- Record Office -->
<xsl:choose>
<xsl:when test="$auth/state[@type = 'office']">
<xsl:copy-of select="$auth/state[@type = 'office']"/>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="//roleName[@ref = $persRef]">
<xsl:if test="//roleName[@ref = $persRef]/@type = 'office'">
<state type="office">
<label type="style">
<xsl:value-of select="current()/@role"/>
<xsl:if test="descendant::placeName">
<xsl:text> of </xsl:text>
<xsl:value-of select="descendant::placeName"/>
</xsl:if>
</label>
</state>
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
<!-- Record Occupation -->
<xsl:for-each select="$docs//roleName[@ref = $persRef][@type = 'occupation']">
<xsl:variable name="source" select="concat('#', (ancestor::item/@xml:id | ancestor::head/@xml:id))"/>
<xsl:variable name="date" select="//date/@when"/>
<xsl:variable name="role" select="./@role"/>
<occupation source='{$source}' when='{$date}' role='{$role}'>
<desc type='source'>
<xsl:value-of select="normalize-space(.)"/>
</desc>
<xsl:if test="document('relationships.xml')//relation[@source = $source][@type='professional'][@active = $persRef] | document('relationships.xml')//relation[@source = $source][@type='professional'][@passive = $persRef]">
<desc type='reg'>
<xsl:value-of select="$role"/>
<xsl:text> to </xsl:text>
<xsl:variable name="empl" select="document('relationships.xml')//relation[@active = $persRef]/@passive | document('relationships.xml')//relation[@passive = $persRef]/@active"/>
<xsl:element name="persName">
<xsl:attribute name="ref">
<xsl:value-of select="$empl"/>
</xsl:attribute>
<xsl:choose>
<xsl:when test="document('authority.xml')//person[@corresp = $empl]/persName[@type='short']">
<xsl:value-of select="document('authority.xml')//person[@corresp = $empl]/persName[@type='short']/@key"/>
</xsl:when>
<xsl:when test="document('authority.xml')//person[@corresp = $empl]">
<xsl:value-of select="document('authority.xml')//person[@corresp = $empl]/persName/@key"/>
</xsl:when>
<xsl:otherwise>
<!--this is still weird-->
<xsl:value-of select="//persName[@ref = $empl][ancestor::item[@xml:id = $source] | ancestor::head[@xml:id = $source]] | //rs[@ref = $empl]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</desc>
</xsl:if>
</occupation>
</xsl:for-each>
</person>
<xsl:text>

</xsl:text>
<!--</xsl:if>-->
</xsl:for-each-group>
</listPerson>
</body>
</text>
</TEI>
</xsl:template>
<!-- Suppress various tags -->
<xsl:template match="ptr"/>
<xsl:template match="persName/text()"/>
<xsl:template match="lb"/>
<xsl:template match="del"/>
<xsl:template match="ex | unclear | seg">
<xsl:apply-templates select="node()"/>
</xsl:template>
<!-- Create <persName> for <rs> strings -->
<!-- <xsl:template match="rs[descendant::roleName | descendant::persName]"> -->
<xsl:template match="rs[@type = 'person']">
<persName>
<!-- AnonNameKey -->
<xsl:if test=".[@subtype = 'anon_sing']">
<xsl:attribute name="type">anonymous</xsl:attribute>
<xsl:attribute name="key">Unnamed Person (<xsl:value-of select="@ref"/>)</xsl:attribute>
</xsl:if>
<xsl:if test=".[@subtype = 'anon_group']">
<xsl:attribute name="type">anonymous_group</xsl:attribute>
<xsl:attribute name="key">Unnamed Group (<xsl:value-of select="@ref"/>)</xsl:attribute>
</xsl:if>
<xsl:variable name="source" select="(ancestor::item/@xml:id | ancestor::head/@xml:id)"/>
<xsl:variable name="date" select="//date/@when"/>
<xsl:attribute name="source"><xsl:value-of select="concat('#', $source)"/></xsl:attribute>
<xsl:attribute name="when"><xsl:value-of select="$date"/></xsl:attribute>
<xsl:apply-templates select="node()"/>
</persName>
</xsl:template>
<!-- Remove all/particular attributes from certain elements -->
<xsl:template match="roleName/@*"/>
<xsl:template match="persName/@ref"/>
<xsl:template match="persName/@ana"/>
<xsl:template match="rs"/>
<!-- Add @source / @when to <persName> -->
<xsl:template match="persName">
<xsl:copy>
<xsl:variable name="source" select="(ancestor::item/@xml:id | ancestor::head/@xml:id)"/>
<xsl:variable name="date" select="//date/@when"/>
<xsl:attribute name="source"><xsl:value-of select="concat('#', $source)"/></xsl:attribute>
<xsl:attribute name="when"><xsl:value-of select="$date"/></xsl:attribute>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>