Project

General

Profile

« Previous | Next » 

Revision 40061

namespace declaration

View differences:

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

  
89
								<xsl:variable name="resultproject" select="dnet:oafResultProject_Outcome_FromMDStore($resultId, $projectId, 'isProducedBy', $about)"/>
90
								<xsl:variable name="projectresult" select="dnet:oafResultProject_Outcome_FromMDStore($projectId, $resultId, 'produces', $about)"/>
25
						<xsl:output omit-xml-declaration="yes" indent="yes"/>
91 26

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

  
108
								<xsl:variable name="resultDataset" select="dnet:oafResultResult_PublicationDataset_FromMDStore($resultId, $datasetId, 'isRelatedTo', $about)"/>
109
								<xsl:variable name="datasetResult" select="dnet:oafResultResult_PublicationDataset_FromMDStore($datasetId, $resultId, 'isRelatedTo', $about)"/>
30
						<xsl:template match="/*">
31
							<xsl:variable name="about" select="/*[local-name() = 'record']/*[local-name() = 'about']"/>
32
							<xsl:variable name="dateofcollection" select="//dr:dateOfCollection"/>
110 33

  
111
								<ROW key="{$resultId}" columnFamily="resultResult_publicationDataset_isRelatedTo">
112
									<QUALIFIER name="{$datasetId}" type="base64"><xsl:value-of select="$resultDataset"/></QUALIFIER>
113
								</ROW>
114
								<ROW key="{$datasetId}" columnFamily="resultResult_publicationDataset_isRelatedTo">
115
									<QUALIFIER name="{$resultId}" type="base64"><xsl:value-of select="$datasetResult"/></QUALIFIER>
116
								</ROW>
117
							</xsl:if>							
118
						</xsl:for-each>						
119
					
120
						<xsl:for-each select="//*[local-name()='creator']">
121
							
122
							<xsl:if test="string-length(normalize-space(.)) &gt; 0">
123
							
124
								<xsl:variable name="personIdPart">
125
									<xsl:call-template name="personIdTmpl">
126
										<xsl:with-param name="objIdentifier" select="$objIdentifier" />
127
									</xsl:call-template>
128
								</xsl:variable>
129
								<xsl:variable name="position" select="position()" />
130
								
131
								<xsl:variable name="personId" select="dnet:oafId('person', $namespaceprefix, normalize-space($personIdPart))" /> 
132
								<xsl:variable name="person" select="dnet:oafPersonFromMDStore($personId, $about, $collectedfromid, $collectedfromname, $originalid, $dateofcollection, .)" />
133
								<xsl:variable name="personresult" select="dnet:oafPersonResult_Authorship_FromMDStore($personId, $resultId, $position, 'isAuthorOf', $about)" />
134
								<xsl:variable name="resultperson" select="dnet:oafPersonResult_Authorship_FromMDStore($resultId, $personId, $position, 'hasAuthor', $about)" />
135
		
136
								<xsl:if test="string-length($personId) &gt; 0">
137
									<ROW key="{$personId}" columnFamily="person">
138
										<QUALIFIER name="body" type="base64"><xsl:value-of select="$person" /></QUALIFIER>
139
									</ROW>
140
									<ROW key="{$personId}" columnFamily="personResult_authorship_isAuthorOf">
141
										<QUALIFIER name="{$resultId}" type="base64"><xsl:value-of select="$personresult" /></QUALIFIER>
142
									</ROW>
143
									<ROW key="{$resultId}" columnFamily="personResult_authorship_hasAuthor">
144
										<QUALIFIER name="{$personId}" type="base64"><xsl:value-of select="$resultperson" /></QUALIFIER>
145
									</ROW>
146
									<ROW key="{$personId}" columnFamily="result">
147
										<QUALIFIER name="{$resultId}" type="base64"><xsl:value-of select="$result"/></QUALIFIER>
148
									</ROW>										
149
								</xsl:if>
150
								
151
								<!-- COAUTHORS -->
152
								<xsl:if test="$writeCoAuthors = true()">
153
									<xsl:for-each select="../dc:creator">
154
										<xsl:if test="$position != position()">
155
											<xsl:variable name="coauthorIdPart">
156
												<xsl:call-template name="personIdTmpl">
157
													<xsl:with-param name="objIdentifier" select="$objIdentifier" />
158
												</xsl:call-template>
159
											</xsl:variable>
160
											<xsl:variable name="coauthorId" select="dnet:oafId('person', $namespaceprefix, normalize-space($coauthorIdPart))" /> 
161
											<xsl:variable name="personperson" select="dnet:oafPersonPerson_CoAuthorship_FromDMF($personId, $coauthorId, 'isCoAuthorOf', $about)" />
162
											<ROW key="{$personId}" columnFamily="personPerson_coAuthorship_isCoAuthorOf">
163
												<QUALIFIER name="{$coauthorId}" type="base64"><xsl:value-of select="$personperson" /></QUALIFIER>
34
							<xsl:variable name="metadata" select="exslt:node-set(//*[local-name()='metadata']/*)"/>
35
							<xsl:variable name="namespaceprefix">
36
								<xsl:choose>
37

  
38
									<!-- TODO check namespaceprefix length is 12 -->
39
									<xsl:when test="string-length(//oaf:datasourceprefix) &gt; 0">
40
										<xsl:value-of select="//oaf:datasourceprefix"/>
41
									</xsl:when>
42
									<xsl:otherwise>
43
										<xsl:value-of select="unknown_"/>
44
									</xsl:otherwise>
45
								</xsl:choose>
46
							</xsl:variable>
47

  
48
							<xsl:choose>
49
								<!-- 			<xsl:when test="count($metadata) = 0 or string-length($namespaceprefix) = 0"> -->
50
								<xsl:when test="count($metadata) = 0">
51
									<ROWS/>
52
								</xsl:when>
53
								<xsl:otherwise>
54

  
55
									<xsl:variable name="objIdentifier" select="//dri:objIdentifier"/>
56
									<xsl:variable name="resultId" select="dnet:oafSimpleId('result', //dri:objIdentifier)"/>
57

  
58
									<xsl:if test="string-length($resultId) &gt; 0">
59

  
60
										<xsl:variable name="collectedfromid" select="dnet:oafSplitId('datasource', //oaf:collectedFrom/@id)"/>
61
										<xsl:variable name="collectedfromname" select="//oaf:collectedFrom/@name"/>
62

  
63
										<xsl:variable name="hostedbyid" select="dnet:oafSplitId('datasource', //oaf:hostedBy/@id)"/>
64
										<xsl:variable name="hostedbyname" select="//oaf:hostedBy/@name"/>
65

  
66
										<xsl:variable name="originalidTest" select="/record/*[local-name() = 'header']/*[local-name() = 'recordIdentifier']"/>
67
										<xsl:variable name="originalid">
68
											<xsl:choose>
69
												<xsl:when test="contains($originalidTest, '::')">
70
													<xsl:value-of select="substring-after($originalidTest, '::')"/>
71
												</xsl:when>
72
												<xsl:otherwise>
73
													<xsl:value-of select="$originalidTest"/>
74
												</xsl:otherwise>
75
											</xsl:choose>
76
										</xsl:variable>
77

  
78
										<xsl:variable name="result"
79
										              select="dnet:oafResultFromMDStore($resultId, $about, $hostedbyid, $hostedbyname, $collectedfromid, $collectedfromname, $originalid, $dateofcollection, $metadata)"/>
80

  
81
										<ROWS>
82
											<ROW key="{$resultId}" columnFamily="result">
83
												<QUALIFIER name="body" type="base64">
84
													<xsl:value-of select="$result"/>
85
												</QUALIFIER>
164 86
											</ROW>
165
										</xsl:if>
166
									</xsl:for-each>
167
								</xsl:if>
168
								<!-- / COAUTHORS -->
169
							</xsl:if>
170
						</xsl:for-each>
171
					</ROWS>
172
				</xsl:if>
173
			</xsl:otherwise>
174
		</xsl:choose>
175
	</xsl:template>
176
	
177
	<xsl:template name="personIdTmpl">
178
		<xsl:param name="objIdentifier" />
179
		<xsl:choose>
180
			<xsl:when test="$mergeIdForHomonyms = false()">
181
				<xsl:value-of select="concat($objIdentifier, '::', normalize-space(.))" />
182
			</xsl:when>				
183
			<xsl:otherwise>
184
				<xsl:value-of select="normalize-space(.)" />
185
			</xsl:otherwise>
186
		</xsl:choose>
187
	</xsl:template>
188 87

  
189
</xsl:stylesheet>
190
	</CODE>
191
            </SCRIPT>
192
        </CONFIGURATION>
193
		<STATUS />
88
											<xsl:for-each select="//*[local-name()='projectid']">
89

  
90
												<xsl:variable name="projectId" select="dnet:oafSplitId('project', normalize-space(.))"/>
91

  
92
												<xsl:if test="string-length($projectId) &gt; 0">
93

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

  
99
													<ROW key="{$resultId}" columnFamily="resultProject_outcome_isProducedBy">
100
														<QUALIFIER name="{$projectId}" type="base64">
101
															<xsl:value-of select="$resultproject"/>
102
														</QUALIFIER>
103
													</ROW>
104
													<ROW key="{$projectId}" columnFamily="resultProject_outcome_produces">
105
														<QUALIFIER name="{$resultId}" type="base64">
106
															<xsl:value-of select="$projectresult"/>
107
														</QUALIFIER>
108
													</ROW>
109
												</xsl:if>
110
											</xsl:for-each>
111

  
112
											<xsl:for-each select="//*[local-name()='relatedDataset']">
113

  
114
												<!-- relatedDataset ids must be in the openaire format  -->
115
												<xsl:variable name="datasetId" select="dnet:oafSimpleId('result', normalize-space(./@id))"/>
116

  
117
												<xsl:if test="string-length($datasetId) &gt; 0">
118

  
119
													<xsl:variable name="resultDataset"
120
													              select="dnet:oafResultResult_PublicationDataset_FromMDStore($resultId, $datasetId, 'isRelatedTo', $about)"/>
121
													<xsl:variable name="datasetResult"
122
													              select="dnet:oafResultResult_PublicationDataset_FromMDStore($datasetId, $resultId, 'isRelatedTo', $about)"/>
123

  
124
													<ROW key="{$resultId}" columnFamily="resultResult_publicationDataset_isRelatedTo">
125
														<QUALIFIER name="{$datasetId}" type="base64">
126
															<xsl:value-of select="$resultDataset"/>
127
														</QUALIFIER>
128
													</ROW>
129
													<ROW key="{$datasetId}" columnFamily="resultResult_publicationDataset_isRelatedTo">
130
														<QUALIFIER name="{$resultId}" type="base64">
131
															<xsl:value-of select="$datasetResult"/>
132
														</QUALIFIER>
133
													</ROW>
134
												</xsl:if>
135
											</xsl:for-each>
136

  
137
											<xsl:for-each select="//*[local-name()='creator']">
138

  
139
												<xsl:if test="string-length(normalize-space(.)) &gt; 0">
140

  
141
													<xsl:variable name="personIdPart">
142
														<xsl:call-template name="personIdTmpl">
143
															<xsl:with-param name="objIdentifier" select="$objIdentifier"/>
144
														</xsl:call-template>
145
													</xsl:variable>
146
													<xsl:variable name="position" select="position()"/>
147

  
148
													<xsl:variable name="personId"
149
													              select="dnet:oafId('person', $namespaceprefix, normalize-space($personIdPart))"/>
150
													<xsl:variable name="person"
151
													              select="dnet:oafPersonFromMDStore($personId, $about, $collectedfromid, $collectedfromname, $originalid, $dateofcollection, .)"/>
152
													<xsl:variable name="personresult"
153
													              select="dnet:oafPersonResult_Authorship_FromMDStore($personId, $resultId, $position, 'isAuthorOf', $about)"/>
154
													<xsl:variable name="resultperson"
155
													              select="dnet:oafPersonResult_Authorship_FromMDStore($resultId, $personId, $position, 'hasAuthor', $about)"/>
156

  
157
													<xsl:if test="string-length($personId) &gt; 0">
158
														<ROW key="{$personId}" columnFamily="person">
159
															<QUALIFIER name="body" type="base64">
160
																<xsl:value-of select="$person"/>
161
															</QUALIFIER>
162
														</ROW>
163
														<ROW key="{$personId}" columnFamily="personResult_authorship_isAuthorOf">
164
															<QUALIFIER name="{$resultId}" type="base64">
165
																<xsl:value-of select="$personresult"/>
166
															</QUALIFIER>
167
														</ROW>
168
														<ROW key="{$resultId}" columnFamily="personResult_authorship_hasAuthor">
169
															<QUALIFIER name="{$personId}" type="base64">
170
																<xsl:value-of select="$resultperson"/>
171
															</QUALIFIER>
172
														</ROW>
173
														<ROW key="{$personId}" columnFamily="result">
174
															<QUALIFIER name="{$resultId}" type="base64">
175
																<xsl:value-of select="$result"/>
176
															</QUALIFIER>
177
														</ROW>
178
													</xsl:if>
179

  
180
													<!-- COAUTHORS -->
181
													<xsl:if test="$writeCoAuthors = true()">
182
														<xsl:for-each select="../dc:creator">
183
															<xsl:if test="$position != position()">
184
																<xsl:variable name="coauthorIdPart">
185
																	<xsl:call-template name="personIdTmpl">
186
																		<xsl:with-param name="objIdentifier" select="$objIdentifier"/>
187
																	</xsl:call-template>
188
																</xsl:variable>
189
																<xsl:variable name="coauthorId"
190
																              select="dnet:oafId('person', $namespaceprefix, normalize-space($coauthorIdPart))"/>
191
																<xsl:variable name="personperson"
192
																              select="dnet:oafPersonPerson_CoAuthorship_FromDMF($personId, $coauthorId, 'isCoAuthorOf', $about)"/>
193
																<ROW key="{$personId}" columnFamily="personPerson_coAuthorship_isCoAuthorOf">
194
																	<QUALIFIER name="{$coauthorId}" type="base64">
195
																		<xsl:value-of select="$personperson"/>
196
																	</QUALIFIER>
197
																</ROW>
198
															</xsl:if>
199
														</xsl:for-each>
200
													</xsl:if>
201
													<!-- / COAUTHORS -->
202
												</xsl:if>
203
											</xsl:for-each>
204
										</ROWS>
205
									</xsl:if>
206
								</xsl:otherwise>
207
							</xsl:choose>
208
						</xsl:template>
209

  
210
						<xsl:template name="personIdTmpl">
211
							<xsl:param name="objIdentifier"/>
212
							<xsl:choose>
213
								<xsl:when test="$mergeIdForHomonyms = false()">
214
									<xsl:value-of select="concat($objIdentifier, '::', normalize-space(.))"/>
215
								</xsl:when>
216
								<xsl:otherwise>
217
									<xsl:value-of select="normalize-space(.)"/>
218
								</xsl:otherwise>
219
							</xsl:choose>
220
						</xsl:template>
221

  
222
					</xsl:stylesheet>
223
				</CODE>
224
			</SCRIPT>
225
		</CONFIGURATION>
226
		<STATUS/>
194 227
		<SECURITY_PARAMETERS>SECURITY_PARAMETERS</SECURITY_PARAMETERS>
195 228
	</BODY>
196 229
</RESOURCE_PROFILE>

Also available in: Unified diff