Project

General

Profile

1
<RESOURCE_PROFILE>
2
	<HEADER>
3
		<RESOURCE_IDENTIFIER value="c460e550-01dc-414d-9eb3-7f5c02e2ab03_VHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZXMvVHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZVR5cGU=" />
4
		<RESOURCE_TYPE value="TransformationRuleDSResourceType" />
5
		<RESOURCE_KIND value="TransformationRuleDSResources" />
6
		<RESOURCE_URI value="" />
7
		<DATE_OF_CREATION value="2015-02-27T17:15:30+00:00"/>
8
	</HEADER>
9
	<BODY>
10
        <CONFIGURATION>
11
			<SOURCE_METADATA_FORMAT name="oaf" layout="store" interpretation="cleaned" />
12
			<SINK_METADATA_FORMAT name="oaf_hbase" />  
13
            <IMPORTED/>
14
            <SCRIPT>          
15
                <TITLE>xslt_mapping_oaf2hbase_unpack_authors</TITLE>
16
                <CODE>
17
<xsl:stylesheet version="1.0"
18
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dc="http://purl.org/dc/elements/1.1/"
19
	xmlns:dr="http://www.driver-repository.eu/namespace/dr" xmlns:dri="http://www.driver-repository.eu/namespace/dri" 
20
	xmlns:oaa="http://namespace.openaire.eu/oaa" xmlns:oaf="http://namespace.openaire.eu/oaf"
21
	xmlns:dnet="eu.dnetlib.data.transform.xml.DNetMdStoreToHbaseXsltFunctions"
22
    xmlns:exslt="http://exslt.org/common" extension-element-prefixes="exslt" 
23
    exclude-result-prefixes="xsl dc dr dri oaa oaf dnet exslt">
24
    
25
    <xsl:output omit-xml-declaration="yes" indent="yes"/>
26
    
27
    <xsl:param name="mergeIdForHomonyms" select="false()" />
28
    <xsl:param name="mergeIdForHomonymsMap" />
29
    
30
    <xsl:param name="writeCoAuthors" select="false()" />
31
    
32
	<xsl:template match="/*">
33
		<xsl:variable name="dataInfo" select="/*[local-name() = 'record']/*[local-name() = 'about']/*[local-name() = 'datainfo']"/>
34
		<xsl:variable name="dateofcollection" select="//dr:dateOfCollection"/>
35
		
36
		<xsl:variable name="metadata" select="exslt:node-set(//*[local-name()='metadata']/*)" />
37
		<xsl:variable name="namespaceprefix">
38
			<xsl:choose>
39
			
40
				<!-- TODO check namespaceprefix length is 12 -->
41
				<xsl:when test="string-length(//oaf:datasourceprefix) &gt; 0">
42
					<xsl:value-of select="//oaf:datasourceprefix" />
43
				</xsl:when>
44
				<xsl:otherwise>
45
					<xsl:value-of select="unknown_" />
46
				</xsl:otherwise>
47
			</xsl:choose>
48
		</xsl:variable>
49
	
50
		<xsl:choose>
51
<!-- 			<xsl:when test="count($metadata) = 0 or string-length($namespaceprefix) = 0"> -->
52
			<xsl:when test="count($metadata) = 0">
53
				<ROWS/>
54
			</xsl:when>
55
			<xsl:otherwise>
56
			
57
				<xsl:variable name="objIdentifier" select="//dri:objIdentifier" />
58
				<xsl:variable name="resultId" select="dnet:oafSimpleId('result', //dri:objIdentifier)" />
59
				
60
				<xsl:if test="string-length($resultId) &gt; 0">
61
				
62
					<xsl:variable name="collectedfromid" select="dnet:oafSplitId('datasource', //oaf:collectedFrom/@id)" />
63
					<xsl:variable name="collectedfromname" select="//oaf:collectedFrom/@name" />
64
				
65
					<xsl:variable name="hostedbyid" select="dnet:oafSplitId('datasource', //oaf:hostedBy/@id)" />
66
					<xsl:variable name="hostedbyname" select="//oaf:hostedBy/@name" />
67
					
68
					<xsl:variable name="originalidTest" select="/record/*[local-name() = 'header']/*[local-name() = 'recordIdentifier']" />
69
					<xsl:variable name="originalid">
70
						<xsl:choose>
71
							<xsl:when test="contains($originalidTest, '::')">
72
								<xsl:value-of select="substring-after($originalidTest, '::')" />
73
							</xsl:when>
74
							<xsl:otherwise>
75
								<xsl:value-of select="$originalidTest" />
76
							</xsl:otherwise>
77
						</xsl:choose>
78
					</xsl:variable>
79
				
80
					<xsl:variable name="result" select="dnet:oafResultFromMDStore($resultId, $dataInfo, $hostedbyid, $hostedbyname, $collectedfromid, $collectedfromname, $originalid, $dateofcollection, $metadata)"/>
81
					
82
					<ROWS>
83
						<ROW key="{$resultId}" columnFamily="result">
84
							<QUALIFIER name="body" type="base64"><xsl:value-of select="$result" /></QUALIFIER>
85
						</ROW>
86
						
87
						<xsl:for-each select="//*[local-name()='projectid']">
88
	
89
							<xsl:variable name="projectId" select="dnet:oafSplitId('project', normalize-space(.))"/>
90
							
91
							<xsl:if test="string-length($projectId) &gt; 0">
92

    
93
								<xsl:variable name="resultproject" select="dnet:oafResultProject_Outcome_FromMDStore($resultId, $projectId, 'isProducedBy', $dataInfo)"/>
94
								<xsl:variable name="projectresult" select="dnet:oafResultProject_Outcome_FromMDStore($projectId, $resultId, 'produces', $dataInfo)"/>
95

    
96
								<ROW key="{$resultId}" columnFamily="resultProject_outcome_isProducedBy">
97
									<QUALIFIER name="{$projectId}" type="base64"><xsl:value-of select="$resultproject"/></QUALIFIER>
98
								</ROW>
99
								<ROW key="{$projectId}" columnFamily="resultProject_outcome_produces">
100
									<QUALIFIER name="{$resultId}" type="base64"><xsl:value-of select="$projectresult"/></QUALIFIER>
101
								</ROW>
102
							</xsl:if>							
103
						</xsl:for-each>
104
						
105
						<xsl:for-each select="//*[local-name()='relatedDataset']">
106
	
107
							<!-- relatedDataset ids must be in the openaire format  -->
108
							<xsl:variable name="datasetId" select="dnet:oafSimpleId('result', normalize-space(./@id))"/>
109
							
110
							<xsl:if test="string-length($datasetId) &gt; 0">
111

    
112
								<xsl:variable name="resultDataset" select="dnet:oafResultResult_PublicationDataset_FromMDStore($resultId, $datasetId, 'isRelatedTo', $dataInfo)"/>
113
								<xsl:variable name="datasetResult" select="dnet:oafResultResult_PublicationDataset_FromMDStore($datasetId, $resultId, 'isRelatedTo', $dataInfo)"/>
114

    
115
								<ROW key="{$resultId}" columnFamily="resultResult_publicationDataset_isRelatedTo">
116
									<QUALIFIER name="{$datasetId}" type="base64"><xsl:value-of select="$resultDataset"/></QUALIFIER>
117
								</ROW>
118
								<ROW key="{$datasetId}" columnFamily="resultResult_publicationDataset_isRelatedTo">
119
									<QUALIFIER name="{$resultId}" type="base64"><xsl:value-of select="$datasetResult"/></QUALIFIER>
120
								</ROW>
121
							</xsl:if>				
122
						</xsl:for-each>						
123
					
124
						<xsl:for-each select="//*[local-name()='creator']">
125
							
126
							<xsl:if test="string-length(normalize-space(.)) &gt; 0">
127
							
128
								<xsl:variable name="personIdPart">
129
									<xsl:call-template name="personIdTmpl">
130
										<xsl:with-param name="objIdentifier" select="$objIdentifier" />
131
										<xsl:with-param name="namespaceprefix" select="$namespaceprefix" />
132
										<xsl:with-param name="mergeIdForHomonymsMap" select="$mergeIdForHomonymsMap" />
133
									</xsl:call-template>
134
								</xsl:variable>
135
								<xsl:variable name="position" select="position()" />
136
								
137
								<xsl:variable name="personId" select="dnet:oafId('person', $namespaceprefix, normalize-space($personIdPart))" /> 
138
								<xsl:variable name="person" select="dnet:oafPersonFromMDStore($personId, $dataInfo, $collectedfromid, $collectedfromname, $originalid, $dateofcollection, .)" />
139
								<xsl:variable name="personresult" select="dnet:oafPersonResult_Authorship_FromMDStore($personId, $resultId, $position, 'isAuthorOf', $dataInfo)" />
140
								<xsl:variable name="resultperson" select="dnet:oafPersonResult_Authorship_FromMDStore($resultId, $personId, $position, 'hasAuthor', $dataInfo)" />
141
		
142
								<xsl:if test="string-length($personId) &gt; 0">
143
									<ROW key="{$personId}" columnFamily="person">
144
										<QUALIFIER name="body" type="base64"><xsl:value-of select="$person" /></QUALIFIER>
145
									</ROW>
146
									<ROW key="{$personId}" columnFamily="personResult_authorship_isAuthorOf">
147
										<QUALIFIER name="{$resultId}" type="base64"><xsl:value-of select="$personresult" /></QUALIFIER>
148
									</ROW>
149
									<ROW key="{$resultId}" columnFamily="personResult_authorship_hasAuthor">
150
										<QUALIFIER name="{$personId}" type="base64"><xsl:value-of select="$resultperson" /></QUALIFIER>
151
									</ROW>
152
									<ROW key="{$personId}" columnFamily="result">
153
										<QUALIFIER name="{$resultId}" type="base64"><xsl:value-of select="$result"/></QUALIFIER>
154
									</ROW>										
155
								</xsl:if>
156
								
157
								<!-- COAUTHORS -->
158
								<xsl:if test="$writeCoAuthors = true()">
159
									<xsl:for-each select="../dc:creator">
160
										<xsl:if test="$position != position()">
161
											<xsl:variable name="coauthorIdPart">
162
												<xsl:call-template name="personIdTmpl">
163
													<xsl:with-param name="objIdentifier" select="$objIdentifier" />
164
												</xsl:call-template>
165
											</xsl:variable>
166
											<xsl:variable name="coauthorId" select="dnet:oafId('person', $namespaceprefix, normalize-space($coauthorIdPart))" /> 
167
											<xsl:variable name="personperson" select="dnet:oafPersonPerson_CoAuthorship_FromDMF($personId, $coauthorId, 'isCoAuthorOf', $dataInfo)" />
168
											<ROW key="{$personId}" columnFamily="personPerson_coAuthorship_isCoAuthorOf">
169
												<QUALIFIER name="{$coauthorId}" type="base64"><xsl:value-of select="$personperson" /></QUALIFIER>
170
											</ROW>
171
										</xsl:if>
172
									</xsl:for-each>
173
								</xsl:if>
174
								<!-- / COAUTHORS -->
175
							</xsl:if>
176
						</xsl:for-each>
177
					</ROWS>
178
				</xsl:if>
179
			</xsl:otherwise>
180
		</xsl:choose>
181
	</xsl:template>
182
	
183
	<xsl:template name="personIdTmpl">
184
		
185
		<xsl:param name="objIdentifier" />
186
		<xsl:param name="namespaceprefix" />
187
		<xsl:param name="mergeIdForHomonymsMap" />
188
		<xsl:variable name="mergeIdForHomonyms" select="dnet:lookupValue($mergeIdForHomonymsMap, $namespaceprefix)" />
189
		<xsl:choose>
190
			<xsl:when test="$mergeIdForHomonyms = false()">
191
				<xsl:value-of select="concat($objIdentifier, '::', normalize-space(.))" />
192
			</xsl:when>				
193
			<xsl:otherwise>
194
				<xsl:value-of select="normalize-space(.)" />
195
			</xsl:otherwise>
196
		</xsl:choose>
197
	</xsl:template>
198

    
199
</xsl:stylesheet>
200
	</CODE>
201
            </SCRIPT>
202
        </CONFIGURATION>
203
		<STATUS />
204
		<SECURITY_PARAMETERS>SECURITY_PARAMETERS</SECURITY_PARAMETERS>
205
	</BODY>
206
</RESOURCE_PROFILE>
(44-44/52)