-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtei-author-portrait.xsl
92 lines (86 loc) · 5.56 KB
/
tei-author-portrait.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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dct="http://purl.org/dc/terms/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:wdt="http://www.wikidata.org/prop/direct/"
exclude-result-prefixes="dct xs tei rdf rdfs wdt"
version="2.0">
<dct:contributor>
<rdf:value>http://d-nb.info/gnd/1017477760</rdf:value>
<rdfs:label>Martin de la Iglesia</rdfs:label>
</dct:contributor>
<dct:license rdf:resource="https://creativecommons.org/licenses/by/4.0/"/>
<xsl:template match="/">
<!-- Enter TEI source here: -->
<xsl:variable name="teiurl" select="'http://textgridrep.org/textgrid:jn0f'"/>
<xsl:for-each select="document($teiurl)//tei:author">
<xsl:variable select="./@key" name="key"/>
<xsl:variable name="authorname" select="."/>
<xsl:variable name="gndurl" select="concat('http://d-nb.info/gnd/',substring-after($key, 'pnd:'))"/>
<xsl:choose>
<xsl:when test="contains(unparsed-text($gndurl), 'Nachweis der Quelle')">
<xsl:call-template name="WPtoWD">
<xsl:with-param name="wpurl" select="substring-after(substring-after(substring-before(unparsed-text($gndurl), '" onclick="window.open(this.href); return false;" title="Zugehöriger Artikel in wikipedia.de'),'Nachweis der Quelle'),'href="')"/>
<xsl:with-param name="authorname" select="$authorname"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="WPtoWD">
<xsl:with-param name="wpurl" select="substring-after(substring-after(substring-before(unparsed-text($gndurl), '" onclick="window.open(this.href); return false;" title="Zugehöriger Artikel in wikipedia.de'),'Korrekturanfrage'),'href="')"/>
<xsl:with-param name="authorname" select="$authorname"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template name="WPtoWD">
<xsl:param name="wpurl"/>
<xsl:param name="authorname"/>
<xsl:variable name="wdurl" select="concat('http:',document($wpurl)//li[@id='t-wikibase']/a/@href)"/>
<xsl:variable name="wdid" select="substring-after($wdurl,'//www.wikidata.org/wiki/')"/>
<xsl:variable name="wdrdfurl" select="concat('https://www.wikidata.org/wiki/Special:EntityData/',$wdid,'.rdf')"/>
<xsl:result-document href="dlina-portrait.html" method="html">
<html>
<body>
<xsl:choose>
<xsl:when test="not(count(document($wdrdfurl)/rdf:RDF/rdf:Description/wdt:P18/@rdf:resource) > 0)">
<xsl:call-template name="WDtoHTML">
<xsl:with-param name="authorname" select="$authorname"/>
<xsl:with-param name="wdrdfurl" select="$wdrdfurl"/>
<xsl:with-param name="src" select="'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTC8b6igoqKDW9OdxHOJPS_DX0h_rFNxVVjkKhADdBPetrZJjsH'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="WDtoHTML">
<xsl:with-param name="authorname" select="$authorname"/>
<xsl:with-param name="wdrdfurl" select="$wdrdfurl"/>
<xsl:with-param name="src" select="document($wdrdfurl)/rdf:RDF/rdf:Description/wdt:P18[1]/@rdf:resource"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</body>
</html>
</xsl:result-document>
</xsl:template>
<xsl:template name="WDtoHTML">
<xsl:param name="wdrdfurl"/>
<xsl:param name="authorname"/>
<xsl:param name="src"/>
<img>
<xsl:attribute name="birth" select="substring(document($wdrdfurl)/rdf:RDF/rdf:Description/wdt:P569[1],1,4)"/>
<xsl:attribute name="authorname" select="$authorname"/>
<xsl:attribute name="gender">
<xsl:if test="document($wdrdfurl)/rdf:RDF/rdf:Description/wdt:P21[@rdf:resource='http://www.wikidata.org/entity/Q6581072']">
<xsl:value-of>female</xsl:value-of>
</xsl:if>
<xsl:if test="document($wdrdfurl)/rdf:RDF/rdf:Description/wdt:P21[@rdf:resource='http://www.wikidata.org/entity/Q6581097']">
<xsl:value-of>male</xsl:value-of>
</xsl:if>
</xsl:attribute>
<xsl:attribute name="src" select="$src"/>
</img>
</xsl:template>
</xsl:stylesheet>