-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert_provenance.xsl
480 lines (434 loc) · 27.3 KB
/
insert_provenance.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
<?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:gsx="http://schemas.google.com/spreadsheets/2006/extended"
xmlns:atom="http://www.w3.org/2005/Atom" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns:org="http://www.w3.org/ns/org#"
xmlns:nmo="http://nomisma.org/ontology#" xmlns:osgeo="http://data.ordnancesurvey.co.uk/ontology/geometry/" xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:un="http://www.owl-ontologies.com/Ontology1181490123.owl#" xmlns:nm="http://nomisma.org/id/" xmlns:prov="http://www.w3.org/ns/prov#"
xmlns:bio="http://purl.org/vocab/bio/0.1/" xmlns:rdac="http://www.rdaregistry.info/Elements/c/" xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:crm="http://www.cidoc-crm.org/cidoc-crm/" exclude-result-prefixes="#all" version="2.0">
<xsl:strip-space elements="*"/>
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:variable name="type" select="rdf:RDF/*[1]/name()"/>
<xsl:variable name="uri" select="rdf:RDF/*[1]/@rdf:about"/>
<xsl:variable name="id" select="tokenize($uri, '/')[last()]"/>
<xsl:variable name="fon" select="data(rdf:RDF/*[1]/dcterms:isPartOf/@rdf:resource)"/>
<!-- see spreadsheet of Nomisma spreadsheets for list of associated Github commit dates :
https://docs.google.com/spreadsheets/d/e/2PACX-1vSzEJwjXIPApTOTCCjGTU9F2_r2QL7qZB-2iv3WIW8_8jDGsyqKNskQzLQ5bfjsTf7J1xoKcneEXngE/pubhtml -->
<!-- Atom feed of spreadsheet -->
<xsl:variable name="spreadsheets" as="document-node()">
<xsl:copy-of select="document('spreadsheets.xml')"/>
<!--<xsl:copy-of select="document('https://spreadsheets.google.com/feeds/list/1ke1Vi8sy9j_D7mnAUA0jgE1po3__RUCQuD2cTW7U8ZQ/od6/public/full')"/>-->
</xsl:variable>
<!-- create a sequence of commit dates from the spreadsheet -->
<xsl:variable name="dates" select="data($spreadsheets//gsx:commitdate)"/>
<xsl:template match="@* | node()">
<xsl:choose>
<!-- normalize space of all text elements -->
<xsl:when test="self::text()">
<xsl:value-of select="normalize-space(.)"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="rdf:RDF">
<xsl:variable name="isDeprecated" select="count(*[1]/dcterms:isReplacedBy) = 1"/>
<xsl:element name="rdf:RDF">
<xsl:namespace name="rdf">http://www.w3.org/1999/02/22-rdf-syntax-ns#</xsl:namespace>
<xsl:namespace name="bio">http://purl.org/vocab/bio/0.1/</xsl:namespace>
<xsl:namespace name="crm">http://www.cidoc-crm.org/cidoc-crm/</xsl:namespace>
<xsl:namespace name="dcterms">http://purl.org/dc/terms/</xsl:namespace>
<xsl:namespace name="foaf">http://xmlns.com/foaf/0.1/</xsl:namespace>
<xsl:namespace name="geo">http://www.w3.org/2003/01/geo/wgs84_pos#</xsl:namespace>
<xsl:namespace name="nm">http://nomisma.org/id/</xsl:namespace>
<xsl:namespace name="nmo">http://nomisma.org/ontology#</xsl:namespace>
<xsl:namespace name="org">http://www.w3.org/ns/org#</xsl:namespace>
<xsl:namespace name="osgeo">http://data.ordnancesurvey.co.uk/ontology/geometry/</xsl:namespace>
<xsl:namespace name="prov">http://www.w3.org/ns/prov#</xsl:namespace>
<xsl:namespace name="rdac">http://www.rdaregistry.info/Elements/c/</xsl:namespace>
<xsl:namespace name="rdfs">http://www.w3.org/2000/01/rdf-schema#</xsl:namespace>
<xsl:namespace name="skos">http://www.w3.org/2004/02/skos/core#</xsl:namespace>
<xsl:namespace name="un">http://www.owl-ontologies.com/Ontology1181490123.owl#</xsl:namespace>
<xsl:namespace name="xsd">http://www.w3.org/2001/XMLSchema#</xsl:namespace>
<xsl:apply-templates/>
<!-- insert provenance events -->
<dcterms:ProvenanceStatement rdf:about="{concat($uri, '#provenance')}">
<foaf:topic rdf:resource="{$uri}"/>
<xsl:variable name="history" as="element()*">
<history>
<xsl:for-each select="document('xhtml-modifications.xml')//file[@id = $id]/date">
<xsl:sort order="ascending"/>
<xsl:copy-of select="self::node()"/>
</xsl:for-each>
<xsl:for-each select="document('rdf-modifications.xml')//file[@id = $id]/date">
<xsl:sort order="ascending"/>
<!-- ignore specific changes -->
<xsl:choose>
<xsl:when test="@desc = 'replaced xsd:float with xsd:decimal'">
<!-- 2015-02-12 -->
<!-- replaced xsd:float with xsd:decimal -->
</xsl:when>
<xsl:when test="@desc = 'added skos:Concept type into a few foaf:Person records that slipped through the cracks'">
<!-- 2015-03-06 -->
<!-- added skos:Concept type into a few foaf:Person records that slipped through the cracks-->
</xsl:when>
<xsl:when test="@desc = 'replaced relatedMatch and exactMatch with closeMatch in mints'">
<!-- 2015-07-16 -->
<!-- replaced relatedMatch and exactMatch with closeMatch in mints -->
</xsl:when>
<xsl:when test="@desc = 'added prov namespace into RDF files'">
<!-- added prov namespace into RDF files -->
<!-- note: Islamic mints also added on 2015-07-28 -->
</xsl:when>
<xsl:when
test="@desc = 'fixed date glitch' or @desc = 'added skos:Concept into dynasty ids' or @desc = 'added FoN islamic_numismatics' or @desc = 'fixed structure'">
<!-- note: minor fixes after creation of Islamic orgs and dynasties: applies to all but one ID -->
<xsl:if test="$id = 'oman_med_governors'">
<xsl:copy-of select="self::node()"/>
</xsl:if>
</xsl:when>
<xsl:when test="@desc = 'migrated CIDOC-CRM to canonical URI from Erlangen'">
<!-- 2016-04-13 -->
<!-- migrated CIDOC-CRM to canonical URI from Erlangen -->
</xsl:when>
<xsl:when test="@desc = 'replaced http with https in wikidata URIs'">
<!-- 2016-06-13-->
<!-- replaced http with https in wikidata URIs -->
</xsl:when>
<xsl:when test="@desc = 'purged false wikidata entities (-1)'">
<!-- 2017-10-18 -->
</xsl:when>
<xsl:when test="@desc = 'changed the class of Epirote and Achaean Leagues'">
<!-- 2018-04-11 -->
</xsl:when>
<xsl:when test="contains(., '2018-08-28')">
<!-- updated permissions -->
</xsl:when>
<xsl:when test="@desc = 'stripped out empty namespace'">
<!-- 2018-09-05 -->
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="self::node()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</history>
</xsl:variable>
<!--<xsl:copy-of select="$history"/>-->
<xsl:variable name="creation" select="substring-before($history/date[1], 'T')"/>
<xsl:choose>
<xsl:when test="index-of($dates, $creation) > 0">
<!-- call a manual modification event for certain combinations of type and date -->
<xsl:choose>
<xsl:when test="$creation = '2015-07-31' and not($type = 'foaf:Person')">
<xsl:apply-templates select="$history/date[1]" mode="manual">
<xsl:with-param name="mode">Create</xsl:with-param>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="$creation = '2015-07-01' and not($type = 'foaf:Person')">
<xsl:apply-templates select="$history/date[1]" mode="manual">
<xsl:with-param name="mode">Create</xsl:with-param>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="$creation = '2018-04-20' and $type = 'nmo:Collection'">
<xsl:apply-templates select="$history/date[1]" mode="manual">
<xsl:with-param name="mode">Create</xsl:with-param>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="$history/date[1]" mode="spreadsheet">
<xsl:with-param name="mode">Create</xsl:with-param>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="$history/date[1]" mode="manual">
<xsl:with-param name="mode">Create</xsl:with-param>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
<!-- process deprecations before inserting modifications -->
<xsl:choose>
<xsl:when test="$isDeprecated = true()">
<xsl:choose>
<xsl:when test="$history/date[@desc='committing igch deprecation']">
<!-- IGCH deprecation to coinhoards.org -->
<prov:wasInvalidatedBy>
<prov:Activity>
<rdf:type rdf:resource="http://www.w3.org/ns/prov#Replace"/>
<prov:atTime rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">
<xsl:value-of select="$history/date[@desc='committing igch deprecation']"/>
</prov:atTime>
<prov:wasAssociatedWith rdf:resource="http://nomisma.org/editor/egruber"/>
<dcterms:type>manual</dcterms:type>
</prov:Activity>
</prov:wasInvalidatedBy>
</xsl:when>
<xsl:when test="$history/date[contains(., '2015-02-03')] and (contains($id, 'rrc-') or contains($id, 'ric.2'))">
<!-- RRC deprecation to CRRO, RIC to OCRE -->
<prov:wasInvalidatedBy>
<prov:Activity>
<rdf:type rdf:resource="http://www.w3.org/ns/prov#Replace"/>
<prov:atTime rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">
<xsl:value-of select="$history/date[contains(., '2015-02-03')][last()]"/>
</prov:atTime>
<prov:wasAssociatedWith rdf:resource="http://nomisma.org/editor/egruber"/>
<dcterms:type>manual</dcterms:type>
</prov:Activity>
</prov:wasInvalidatedBy>
</xsl:when>
<xsl:otherwise>
<prov:wasInvalidatedBy>
<prov:Activity>
<rdf:type rdf:resource="http://www.w3.org/ns/prov#Replace"/>
<prov:atTime rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">
<xsl:value-of select="$history/date[last()]"/>
</prov:atTime>
<prov:wasAssociatedWith rdf:resource="http://nomisma.org/editor/egruber"/>
<dcterms:type>manual</dcterms:type>
</prov:Activity>
</prov:wasInvalidatedBy>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:if test="count($history/date) > 1">
<!-- insert modification events for any spreadsheet -->
<xsl:apply-templates select="$history/date[index-of($dates, substring-before(., 'T')) > 0]" mode="spreadsheet">
<xsl:with-param name="mode">Modify</xsl:with-param>
<xsl:with-param name="creation" select="$creation"/>
</xsl:apply-templates>
<!-- call template on the final commit, but only evaluate whether it should exist within the template -->
<xsl:apply-templates select="$history/date[last()]" mode="manual">
<xsl:with-param name="mode">Modify</xsl:with-param>
</xsl:apply-templates>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</dcterms:ProvenanceStatement>
</xsl:element>
</xsl:template>
<xsl:template match="date" mode="manual">
<xsl:param name="mode"/>
<xsl:variable name="date" select="substring-before(., 'T')"/>
<xsl:choose>
<xsl:when test="$mode = 'Create'">
<prov:wasGeneratedBy>
<prov:Activity>
<rdf:type rdf:resource="http://www.w3.org/ns/prov#{$mode}"/>
<prov:atTime rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">
<xsl:value-of select="."/>
</prov:atTime>
<!-- attempt to evaluate the prov:wasAssociatedWith by date, field of numismatics, or other parameters -->
<xsl:choose>
<xsl:when test="$date = '2012-10-28'">
<prov:wasAssociatedWith rdf:resource="http://nomisma.org/editor/ameadows"/>
<prov:wasAssociatedWith rdf:resource="http://nomisma.org/editor/sfsheath"/>
<dcterms:description xml:lang="en">
<xsl:text>This is among the original Nomisma XHTML+RDFa fragments, most likely created between 2010-2012 by Sebastian Heath and/or Andy Meadows.</xsl:text>
</dcterms:description>
</xsl:when>
<xsl:when
test="($type = 'nmo:Mint' or $type = 'foaf:Person' or $type = 'nmo:Denomination') and (index-of($fon, 'http://nomisma.org/id/modern_german_numismatics') or index-of($fon, 'http://nomisma.org/id/medieval_european_numismatics'))">
<!-- assign Medieval, Modern German, and Merovingian mint or person IDs to Karsten -->
<xsl:if test="not(index-of($fon, 'http://nomisma.org/id/roman_numismatics'))">
<!--ignore any IDs already in Roman numismatics -->
<prov:wasAssociatedWith rdf:resource="http://nomisma.org/editor/kdahmen"/>
<prov:wasAssociatedWith rdf:resource="http://nomisma.org/editor/wbloom"/>
</xsl:if>
</xsl:when>
<xsl:when test="$type = 'foaf:Person' and index-of($fon, 'http://nomisma.org/id/byzantine_numismatics')">
<!-- Byzantine people created by Dennis Mathie -->
<prov:wasAssociatedWith rdf:resource="http://nomisma.org/editor/dmathie"/>
</xsl:when>
<xsl:when test="contains($id, '_pir')">
<prov:wasAssociatedWith rdf:resource="http://nomisma.org/editor/kdahmen"/>
</xsl:when>
</xsl:choose>
<dcterms:type>manual</dcterms:type>
</prov:Activity>
</prov:wasGeneratedBy>
</xsl:when>
<xsl:when test="$mode = 'Modify'">
<!-- insert an event if the date isn't in a spreadsheet -->
<xsl:if test="count(index-of($dates, $date)) = 0">
<prov:activity>
<prov:Activity>
<rdf:type rdf:resource="http://www.w3.org/ns/prov#{$mode}"/>
<prov:atTime rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">
<xsl:value-of select="."/>
</prov:atTime>
<!-- agents of manual modification are nearly impossible to ascertain -->
<dcterms:type>manual</dcterms:type>
</prov:Activity>
</prov:activity>
</xsl:if>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="date" mode="spreadsheet">
<xsl:param name="mode"/>
<xsl:param name="creation"/>
<xsl:variable name="date" select="substring-before(., 'T')"/>
<!-- ignore certain dates when the ID doesn't match a specific parameter -->
<xsl:choose>
<xsl:when test="($date = $creation) and $mode = 'Modify'">
<!-- ignore events that are already determined to be creation dates -->
</xsl:when>
<xsl:otherwise>
<!-- differentiate between new or modified activities -->
<xsl:choose>
<xsl:when test="$mode = 'Modify'">
<prov:activity>
<xsl:call-template name="activity">
<xsl:with-param name="mode" select="$mode"/>
</xsl:call-template>
</prov:activity>
</xsl:when>
<xsl:when test="$mode = 'Create'">
<prov:wasGeneratedBy>
<xsl:call-template name="activity">
<xsl:with-param name="mode" select="$mode"/>
</xsl:call-template>
</prov:wasGeneratedBy>
</xsl:when>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="activity">
<xsl:param name="mode"/>
<xsl:variable name="date" select="substring-before(., 'T')"/>
<xsl:variable name="creator" select="$spreadsheets//atom:entry[gsx:commitdate = $date][1]/gsx:creator"/>
<prov:Activity>
<rdf:type rdf:resource="http://www.w3.org/ns/prov#{$mode}"/>
<prov:atTime rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">
<xsl:value-of select="."/>
</prov:atTime>
<!-- evaluate spreadsheets to determine the uploader -->
<xsl:call-template name="uploader">
<xsl:with-param name="creator" select="$creator"/>
</xsl:call-template>
<!-- evaluate spreadsheet URL based on commit date -->
<xsl:call-template name="generate-spreadsheet">
<xsl:with-param name="date" select="$date"/>
</xsl:call-template>
<dcterms:type>spreadsheet</dcterms:type>
<!-- insert a note that all spreadsheets uploaded before or on 2015-06-12 (Non-Islamic corporate entities and dynasties) were converted to IDs through manual one-off scripts -->
<xsl:if test="xs:date($date) <= xs:date('2015-06-12')">
<dcterms:description xml:lang="en">
<xsl:text>This ID was generated by processing a spreadsheet through a one-off PHP script, predating the Nomisma spreadsheet import feature.</xsl:text>
</dcterms:description>
</xsl:if>
</prov:Activity>
</xsl:template>
<!-- use the spreadsheet of spreadsheets to extract the key -->
<xsl:template name="generate-spreadsheet">
<xsl:param name="date"/>
<!-- evaluate spreadsheets with multiple dates -->
<xsl:variable name="key">
<xsl:choose>
<xsl:when test="$date = '2017-12-16'">
<xsl:choose>
<xsl:when test="$type = 'foaf:Person'">
<xsl:text>1vi_FA60ybtzebLrqzb78ZS5YGk0elvCRp4EsVgoVIEs</xsl:text>
</xsl:when>
<xsl:when test="$type = 'foaf:Organization'">
<xsl:text>1ohAgCJ3nRIoA8PKFaM65YcHkMrChwHrDK37yuScK_IY</xsl:text>
</xsl:when>
<xsl:when test="$type = 'nmo:Mint'">
<xsl:text>1qUZ8k6Nd0kaEeGdOqpVDgP3gcBCaLqtls_0HHS18Cus</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="$date = '2018-04-11'">
<xsl:choose>
<xsl:when test="@desc = 'added remaining Seleucids'">
<xsl:text>1vi_FA60ybtzebLrqzb78ZS5YGk0elvCRp4EsVgoVIEs</xsl:text>
</xsl:when>
<xsl:when test="@desc = 'added new Hellenistic kingdoms'">
<xsl:text>1IbLGN9SsiR89MmD_4GSs3qHgydj0g8gT174Lgf6xjio</xsl:text>
</xsl:when>
<xsl:when test="@desc = 'added new Greek dynasties'">
<xsl:text>1KNnrbtxrc2vtSLKjcp3zNdYcKq6x7okR00H-3CXvNiI</xsl:text>
</xsl:when>
<xsl:when test="@desc = 'added Hellenistic rulers to fill gaps in IGCH'">
<xsl:text>1gXcM0SRWqSZ4RJiDg21i5PI91EVyfMr1ogVgnH9zhIE</xsl:text>
</xsl:when>
<xsl:when test="@desc = 'began adding Ptolemies'">
<xsl:text>13vtnvFZVvRCxdgc9K4a8_EAdBEfcr1wW9gb0wmynLuE</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$spreadsheets//atom:entry[gsx:commitdate = $date]/gsx:spreadsheetkey"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<prov:used rdf:resource="{concat('https://docs.google.com/spreadsheets/d/', $key, '/pubhtml')}"/>
</xsl:template>
<xsl:template name="uploader">
<xsl:param name="creator"/>
<xsl:choose>
<xsl:when test="$creator = 'http://nomisma.org/editor/upeter'">
<prov:wasAssociatedWith rdf:resource="http://nomisma.org/editor/upeter"/>
</xsl:when>
<xsl:when test="$creator = 'http://nomisma.org/editor/ameadows' or $creator = 'http://nomisma.org/editor/kdahmen'">
<prov:wasAssociatedWith rdf:resource="http://nomisma.org/editor/ameadows"/>
</xsl:when>
<xsl:otherwise>
<prov:wasAssociatedWith rdf:resource="http://nomisma.org/editor/egruber"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="*[rdf:type/@rdf:resource = 'http://www.w3.org/2004/02/skos/core#Concept']">
<xsl:element name="{name()}">
<xsl:attribute name="rdf:about" select="@rdf:about"/>
<xsl:variable name="uri" select="@rdf:about"/>
<xsl:apply-templates/>
<skos:inScheme rdf:resource="http://nomisma.org/id/"/>
<skos:changeNote rdf:resource="{concat($uri, '#provenance')}"/>
</xsl:element>
</xsl:template>
<!-- reprocess matches: mints link to skos:closeMatch. All else link to skos:exactMatch. Canonical URIs for Wikidata are http:, Pleiades are https: -->
<xsl:template match="skos:closeMatch|skos:relatedMatch|skos:exactMatch">
<!-- only process if the URI isn't already in -->
<xsl:variable name="uri" select="@rdf:resource"/>
<xsl:if test="not(preceding-sibling::*[ends-with(local-name(), 'Match')]/@rdf:resource = $uri)">
<xsl:choose>
<xsl:when test="$type = 'nmo:Mint'">
<skos:closeMatch>
<xsl:call-template name="process-uri">
<xsl:with-param name="uri" select="$uri"/>
</xsl:call-template>
</skos:closeMatch>
</xsl:when>
<xsl:otherwise>
<skos:exactMatch>
<xsl:call-template name="process-uri">
<xsl:with-param name="uri" select="$uri"/>
</xsl:call-template>
</skos:exactMatch>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<xsl:template name="process-uri">
<xsl:param name="uri"/>
<xsl:choose>
<xsl:when test="contains($uri, 'wikidata.org')">
<xsl:attribute name="rdf:resource" select="replace($uri, 'https', 'http')"/>
</xsl:when>
<xsl:when test="contains($uri, 'pleiades.stoa.org')">
<xsl:attribute name="rdf:resource" select="replace($uri, 'http', 'https')"/>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="rdf:resource" select="$uri"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>