-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path2_use_zenodo_vocab.xsl
71 lines (64 loc) · 2.9 KB
/
2_use_zenodo_vocab.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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns="http://www.tei-c.org/ns/1.0"
xpath-default-namespace="http://www.tei-c.org/ns/1.0"
exclude-result-prefixes="tei xsl #default"
version="2.0">
<xsl:output method="xml"/>
<!-- <xsl:strip-space elements="p div head titlePart hi damage unclear"/>-->
<xsl:strip-space elements="tei:choice tei:abbr tei:expan tei:orig tei:reg tei:sic tei:corr tei:g tei:damage tei:unclear"/>
<!-- for the root node, insert xml scheme processing instructions -->
<xsl:template match="/"><xsl:text>
</xsl:text>
<xsl:processing-instruction name="xml-model">
href="http://files.salamanca.school/saltei.rng"
type="application/xml"
schematypens="http://relaxng.org/ns/structure/1.0"</xsl:processing-instruction><xsl:text>
</xsl:text>
<xsl:apply-templates select="*"/>
</xsl:template>
<!-- IdentityTransform -->
<xsl:template match="@xml:base" />
<xsl:template mode="#all" match="@* | node()">
<xsl:copy copy-namespaces="no">
<xsl:apply-templates select="@* | node()" mode="#current"/>
</xsl:copy>
</xsl:template>
<!-- Use zenodo vocabulary for contributor roles (#scholarly, #technical, #additional) -->
<xsl:template match="/TEI/teiHeader/fileDesc/titleStmt/editor/@role">
<xsl:variable name="FirstRole">
<xsl:value-of select="tokenize(string(.), ' ')[1]"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="$FirstRole = '#scholarly'">
<xsl:attribute name="role">Editor</xsl:attribute>
</xsl:when>
<xsl:when test="$FirstRole = '#technical'">
<xsl:attribute name="role">DataManager</xsl:attribute>
</xsl:when>
<!-- <xsl:when test="$FirstRole ='#additional'">-->
<xsl:otherwise>
<xsl:attribute name="role">Other</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Use zenodo vocabulary for contributor roles (for project leaders) -->
<xsl:template match="/TEI/teiHeader/fileDesc/seriesStmt/editor">
<xsl:element name="editor">
<xsl:if test="@xml:id = ('TD', 'MLB')">
<xsl:attribute name="role">ProjectLeader</xsl:attribute>
<xsl:apply-templates select="@* | node()"/>
</xsl:if>
</xsl:element>
</xsl:template>
<!-- Use zenodo vocabulary for licence types -->
<xsl:template match="//publicationStmt/availability/licence"> <!-- n="cc-by" -->
<xsl:element name="licence">
<xsl:attribute name="n">cc-by</xsl:attribute>
<xsl:apply-templates select="@* | node()" mode="#current"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>