-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcbs2easydb-personenliste.xsl
More file actions
127 lines (122 loc) · 6.91 KB
/
cbs2easydb-personenliste.xsl
File metadata and controls
127 lines (122 loc) · 6.91 KB
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
<?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:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:gndo="http://d-nb.info/standards/elementset/gnd#"
exclude-result-prefixes="xs"
version="2.0">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="record[../name()='dataExportXML']">
<xsl:variable name="ppn" select="tag[@id='003@']/sbf[@id='0']"/>
<xsl:for-each select="tag[starts-with(@id,'028')]|tag[starts-with(@id,'029')]">
<xsl:call-template name="feld"> <!-- PPN -->
<xsl:with-param name="wert" select="$ppn"/>
</xsl:call-template>
<xsl:variable name="gndid" select="sbf[@id='0']"/>
<xsl:variable name="gndfile" select="concat('gnd/gnd-',$gndid,'.xml')"/>
<xsl:variable name="gnddata">
<xsl:if test="(string-length($gndid) ge 1) and doc-available($gndfile)">
<xsl:copy-of
select="document($gndfile)/rdf:RDF/*"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="gndname">
<xsl:choose>
<xsl:when test="string-length($gndid) lt 1"/>
<xsl:when test="($gnddata/*/*:type/@*:resource='https://d-nb.info/standards/elementset/gnd#DifferentiatedPerson') or
(name($gnddata/*)='gndo:DifferentiatedPerson')">
<xsl:value-of select="$gnddata/*/(*:preferredNameForThePerson|*:preferredName)"/>
</xsl:when>
<xsl:when test="($gnddata/*/*:type/@*:resource='https://d-nb.info/standards/elementset/gnd#CorporateBody') or
(name($gnddata/*)='gndo:CorporateBody')">
<xsl:value-of select="$gnddata/*/(*:preferredNameForTheCorporateBody|*:preferredName)"/>
</xsl:when>
<xsl:when test="($gnddata/*/*:type/@*:resource='https://d-nb.info/standards/elementset/gnd#MusicalCorporateBody') or
(name($gnddata/*)='gndo:MusicalCorporateBody')">
<xsl:value-of select="$gnddata/*/(*:preferredNameForTheCorporateBody|*:preferredName)"/>
</xsl:when>
<xsl:otherwise><xsl:message>Warnung: Unbekannter GND-Typ</xsl:message></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="gndvolltext">
<xsl:for-each select="$gnddata//(*:oldAuthorityNumber|*:label|*:variantName)[not(contains(.,'http'))]">
<xsl:sort/>
<xsl:value-of select="normalize-space(.)"/><xsl:text> </xsl:text>
</xsl:for-each>
</xsl:variable>
<xsl:if test="($gndname='') and (string-length($gndid) ge 1)"><xsl:message>Daten fehlen: <xsl:value-of select="$gndid"/></xsl:message></xsl:if>
<xsl:variable name="gndjson">
<xsl:if test="not($gndname='')">
<xsl:text>{"frontendLanguage":"de","_fulltext":{"text":"</xsl:text>
<xsl:value-of select="$gndvolltext"/>
<xsl:text>"},</xsl:text>
<xsl:text>"conceptURI":"https://d-nb.info/</xsl:text>
<xsl:value-of select="$gndid"/>
<xsl:text>","_standard":{"text":"</xsl:text>
<xsl:value-of select="$gndname"/>
<xsl:text>"},"conceptName":"</xsl:text>
<xsl:value-of select="$gndname"/>
<xsl:text>"}</xsl:text>
</xsl:if>
</xsl:variable>
<xsl:message><xsl:value-of select="$gndid"/><xsl:text> - </xsl:text><xsl:value-of select="$gndjson"/></xsl:message>
<xsl:call-template name="feld"> <!-- GND-ID -->
<xsl:with-param name="wert" select="$gndid"/>
</xsl:call-template>
<xsl:call-template name="feld"> <!-- GND-Name -->
<xsl:with-param name="wert" select="$gndname"/>
</xsl:call-template>
<xsl:call-template name="feld"> <!-- GND-JSON -->
<xsl:with-param name="wert" select="$gndjson"/>
</xsl:call-template>
<xsl:call-template name="feld"> <!-- Kategorie -->
<xsl:with-param name="wert" select="@id"/>
</xsl:call-template>
<xsl:call-template name="feld"> <!-- Rolle -->
<xsl:with-param name="wert" select="if (sbf[@id='4']) then (concat('$4:',sbf[@id='4'][1])) else (concat('$B:',sbf[@id='B'][1]))"/>
</xsl:call-template>
<xsl:call-template name="feld"> <!-- Name -->
<xsl:with-param name="wert" select="concat(if (sbf[@id='a']) then string-join((sbf[@id='c'],string-join((sbf[@id='a'],sbf[@id='d']),', ')),' ') else (sbf[@id='P']),
if (sbf[@id='l']) then concat(' <',sbf[@id='l'],'>') else ())"/>
</xsl:call-template>
<xsl:call-template name="feld"> <!-- Bemerkung -->
<xsl:with-param name="wert" select="sbf[@id='L']"/>
</xsl:call-template>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
<xsl:template match="/">
<xsl:call-template name="feld">
<xsl:with-param name="wert">PPN</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="feld">
<xsl:with-param name="wert" select="'GND-ID'"/>
</xsl:call-template>
<xsl:call-template name="feld">
<xsl:with-param name="wert" select="'GND-Name'"/>
</xsl:call-template>
<xsl:call-template name="feld">
<xsl:with-param name="wert" select="'GND-JSON'"/>
</xsl:call-template>
<xsl:call-template name="feld">
<xsl:with-param name="wert" select="'Kategorie'"/>
</xsl:call-template>
<xsl:call-template name="feld">
<xsl:with-param name="wert" select="'Rolle'"/>
</xsl:call-template>
<xsl:call-template name="feld">
<xsl:with-param name="wert" select="'Name'"/>
</xsl:call-template>
<xsl:call-template name="feld">
<xsl:with-param name="wert" select="'Bemerkung'"/>
</xsl:call-template>
<xsl:text> </xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template name="feld">
<xsl:param name="wert"/>
<xsl:value-of select="normalize-unicode($wert,'NFC')"/><xsl:text>	</xsl:text>
</xsl:template>
<xsl:template match="*/text()"/>
</xsl:stylesheet>