-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTEI2ID-test.xsl
110 lines (108 loc) · 5.58 KB
/
TEI2ID-test.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
<?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:t="http://www.tei-c.org/ns/1.0"
exclude-result-prefixes="xs" version="2.0">
<!--
ToDo: IDs von Nachgeschobenen Dateien müssen gegen die schon in der DB vorhandenen IDs getestet werden:
<xsl:if test="unparsed-text-available(concat('http://..../my-collection/',$id)">
</xsl:if>
Beispiel für Generierung von eindeutigen IDs aus der Wordliste:
* $ids: Variable über alle Zeilen mit ID-Wert aus Datumsangabe und Archivort incl. Sonderzeichennormalisierung
für's Debugging werden auch die Datumss- und Archivspalte mit in die Variable aufgenommen
* Dublettenkontrolle: Vor der Ausgabe eine Kontrolle, ob die ID mehrfach vorkommt, ggf. Erweiterung um "-Zahl"
-->
<xsl:output method="html" indent="yes"/>
<xsl:variable name="ids">
<xsl:for-each select="//t:row[position() gt 1]">
<xsl:variable name="archivort">
<xsl:choose>
<xsl:when test="not(.//t:hi[@rend='Archivort'] and t:cell[6]/normalize-space()='')">
<xsl:value-of select="t:cell[6]/replace(., '^([^\s].*?),.*?$', '$1')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select=".//t:hi[@rend='Archivort'][1]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<row n="{position()}">
<id>
<xsl:value-of
select="t:cell[1]/(text()[1]|t:p[1])/replace(.,'^([0123456789\-––]*)[^0123456789\-––][\s\S]*?$','$1')"/>
<xsl:variable name="totransform"><xsl:text>äöüßÄÖÜňřáàéèóòôúùâšíł ,.;:()[]+*#{}/–§$%&"!?' ’</xsl:text></xsl:variable>
<xsl:choose>
<!-- <xsl:when test="not(t:cell[6]//@rend = 'Archivort') and t:cell[6]/normalize-space()!=''">
<xsl:text>_</xsl:text><xsl:value-of select="t:cell[6]/replace(., '^([^\s].*?),.*?$', '$1')"/>
</xsl:when>-->
<xsl:when test="t:cell[6]/normalize-space()=''"/>
<xsl:otherwise>
<xsl:text>_</xsl:text><xsl:value-of select="$archivort/translate(normalize-space(replace(replace(replace(replace(replace(.,'ä','ae','i'),'Ö','Oe'),'ö','oe'),'ü','ue','i'),'ß','ss')),$totransform,'aousAOUnraaeeooouuasil-')"/>
</xsl:otherwise>
</xsl:choose>
<!--
1162_Klosterneuburg Klosterneuburg
1359-01-01_ aber Archivangabe Warwickshire Record Office (erworben 1984) vorhanden
1363-03-27 Brüssel (Bruxelles), => 1363-03-27_Brussel Bruxelles : Warum?
Alternativer Weg, Unicode-Codepoints als Kriterium zu verwenden, braucht auch eine Normalisierungstabelle und fällt deshalb wohl aus
Wunsch: äöü durch ae, oe, ue ersetzen (siehe die Variable archivort oben, die nicht funktioniert -->
</id>
<date>
<xsl:value-of select="t:cell[1]"/>
</date>
<archiv>
<xsl:value-of select="t:cell[6]"/>
</archiv>
</row>
</xsl:for-each>
</xsl:variable>
<xsl:template match="/">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>IDs</title>
</head>
<body>
<table>
<thead>
<tr><th>Zeilenr.</th>
<th>ID</th>
<th>Anzahl Vorkommen der Kombination Datum-Ort</th>
<th>In der Hauptsammlung schon vorhanden</th>
<th>Datumsspalte</th>
<th>Archivspalte</th>
</tr>
</thead>
<tbody><xsl:apply-templates select="$ids/row"/></tbody>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="row">
<tr>
<td><xsl:value-of select="position()"/></td>
<td>
<xsl:value-of select="id"/>
<!-- Dublettenkontrolle -->
<xsl:if test="count($ids/row/id[.=current()/id]) gt 1">
<xsl:text>_</xsl:text><xsl:value-of select="(count(preceding::id[.=current()/id]) + 1)"></xsl:value-of>
</xsl:if>
</td>
<xsl:variable name="online" select="concat('http://www.monasterium.net/mom/IlluminierteUrkunden/',current()/id,'/charter')"/>
<xsl:variable name="test" select="unparsed-text-available($online)"/>
<td>
<a href="{$online}"><xsl:value-of select="$online"/></a>
<xsl:text> | </xsl:text>
<span>
<xsl:if test="$test"><xsl:attribute name="style">font-weight: bold; font-color:red</xsl:attribute></xsl:if><xsl:value-of select="$test"/></span>
</td>
<td>
<xsl:value-of select="count($ids/row/id[.=current()/id])"/>
</td>
<td>
<xsl:value-of select="date"/>
</td>
<td>
<xsl:value-of select="archiv"/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>