Project

General

Profile

1
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2
                xmlns:dnet="eu.dnetlib.wds.utils.WDSUtils"
3
                xmlns:dri="http://www.driver-repository.eu/namespace/dri"
4
                xmlns:oaf="http://namespace.dnet.eu/oaf" version="2.0" exclude-result-prefixes="xsl dnet">
5
    <xsl:output indent="yes"/>
6
    <xsl:template match="/">
7
        <xsl:choose>
8
            <xsl:when test="count(//*[local-name()='metadata'] ) = 0 ">
9
                <record/>
10
            </xsl:when>
11
            <xsl:otherwise>
12
                <xsl:call-template name="createRecord"/>
13
            </xsl:otherwise>
14
        </xsl:choose>
15

    
16
    </xsl:template>
17

    
18
    <xsl:template name="createRecord">
19

    
20
        <oai:record xmlns:oai="http://www.openarchives.org/OAI/2.0/"
21
                    xmlns:dri="http://www.driver-repository.eu/namespace/dri"
22
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
23
            <oai:header>
24
                <xsl:copy-of copy-namespaces="no" select="//*[local-name() = 'header']/*"/>
25

    
26
            </oai:header>
27
            <oai:metadata>
28
                <resource xmlns="http://datacite.org/schema/kernel-3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://datacite.org/schema/kernel-3 http://schema.datacite.org/meta/kernel-3/metadata.xsd">
29
                    <xsl:variable name="identifier" select="//Issue_Identification"/>
30
                     <xsl:for-each select="$identifier">
31
                         <xsl:variable name="pid" select="dnet:getDOI(.)"/>
32
                         <xsl:if test="$pid">
33
                             <identifier identifierType="DOI">
34
                         <xsl:value-of select="$pid"/>
35
                     </identifier>
36
                         </xsl:if>
37
                     </xsl:for-each>
38

    
39

    
40
                    <xsl:variable name="creators" select="tokenize(//Dataset_Creator,';')"/>
41
                    <xsl:if test="$creators[1]">
42
                        <creators>
43
                            <xsl:for-each select="$creators">
44
                                <creator>
45
                                    <creatorName>
46
                                        <xsl:value-of select="."/>
47
                                    </creatorName>
48
                                </creator>
49
                            </xsl:for-each>
50
                        </creators>
51
                    </xsl:if>
52

    
53
                    <xsl:variable name="titles" select="//Dataset_Title"/>
54
                    <xsl:if test="$titles">
55
                        <titles>
56
                            <xsl:for-each select="$titles">
57
                                <title>
58
                                    <xsl:value-of select="."/>
59
                                </title>
60
                            </xsl:for-each>
61
                        </titles>
62
                    </xsl:if>
63
                    <xsl:variable name="publisher" select="//Dataset_Publisher"/>
64
                    <xsl:if test="$publisher">
65
                        <publisher><xsl:value-of select="$publisher"/></publisher>
66
                    </xsl:if>
67
                    <xsl:variable name ="date" select="//Dataset_Release_Date"/>
68
                    <xsl:if test="$date">
69
                        <dates>
70
                            <date dateType='available'>
71
                                <xsl:value-of select="$date"/>
72
                            </date>
73
                        </dates>
74
                    </xsl:if>
75
                    <xsl:variable name="subjects" select="tokenize(//ISO_Topic_Category,'/')"/>
76
                    <xsl:if test="$subjects[1]">
77
                        <subjects>
78
                            <xsl:for-each select="$subjects">
79
                                <subject>
80
                                    <xsl:value-of select="."/>
81
                                </subject>
82
                            </xsl:for-each>
83
                        </subjects>
84
                    </xsl:if>
85

    
86
                    <xsl:variable name="descriptions" select="//Summary"/>
87
                    <xsl:if test="$descriptions">
88
                        <descriptions>
89
                            <xsl:for-each select="$descriptions">
90
                                <description>
91
                                    <xsl:value-of select="."/>
92
                                </description>
93
                            </xsl:for-each>
94
                        </descriptions>
95
                    </xsl:if>
96

    
97
                    <xsl:variable name="geoLocations" select="//Spatial_Coverage"/>
98
                    <xsl:if test="$geoLocations">
99
                        <geoLocations>
100
                            <xsl:for-each select="$geoLocations">
101
                                <geoLocation>
102
                                    <geoLocationBox>
103
                                        <xsl:value-of select="concat(Westernmost_Longitude,' ', Southernmost_Latitude,' ',Easternmost_Longitude,' ', Northernmost_Latitude )"/>
104
                                    </geoLocationBox>
105
                                </geoLocation>
106

    
107

    
108
                            </xsl:for-each>
109
                        </geoLocations>
110
                    </xsl:if>
111
                    <resourceType resourceTypeGeneral="dataset"/>
112
                </resource>
113
            </oai:metadata>
114
            <xsl:call-template name="about"/>
115
        </oai:record>
116
    </xsl:template>
117

    
118
    <xsl:template name="about">
119
        <oaf:about>
120

    
121
            <xsl:variable name="dsPrefix" select="//*[local-name()='datasourceprefix']"/>
122

    
123
            <oaf:datainfo>
124
                <oaf:collectedFrom>
125
                         <xsl:attribute name="id"><xsl:value-of select="dnet:getIdFromDataSourcePrefix($dsPrefix)"/></xsl:attribute>
126
                         <xsl:attribute name="name"><xsl:value-of select="dnet:getNameFromDataSourcePrefix($dsPrefix)"/></xsl:attribute>
127

    
128
                </oaf:collectedFrom>
129
            </oaf:datainfo>
130
        </oaf:about>
131
    </xsl:template>
132

    
133
</xsl:stylesheet>
(6-6/6)