stash-wrapper 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0b9b2b3b3b61546cb479b5641e250d4494daee32
4
+ data.tar.gz: 88c5ce1cab8a9868b69b0905cb848346b3bebe33
5
+ SHA512:
6
+ metadata.gz: ca3ccf0129d471e5d3c92625784cdc03d4221c9691ea943e75ff73f354773c7082d92425cc16e6545056036165b9d9062376e20dd2044a5f43ae1de3830ab26c
7
+ data.tar.gz: 93c73e6f99e009f811618145daa9b90820d094257b17f39cafac5f5c934584ab81d4efdc5a6c124e41a406c0aa5e41568e2f679d34f7b0154cf8349c9074c18d
data/.gitignore ADDED
@@ -0,0 +1,46 @@
1
+ # Ruby defaults
2
+
3
+ /.bundle/
4
+ /.yardoc
5
+ /Gemfile.lock
6
+ /_yardoc/
7
+ /coverage/
8
+ /doc/
9
+ /pkg/
10
+ /spec/reports/
11
+ /tmp/
12
+ *.bundle
13
+ *.so
14
+ *.o
15
+ *.a
16
+ mkmf.log
17
+
18
+ # Built gem
19
+
20
+ *.gem
21
+
22
+ # Database
23
+
24
+ db/*.sqlite3
25
+
26
+ # Logs
27
+
28
+ /log/
29
+
30
+ # IntellJ
31
+
32
+ *.iml
33
+ *.ipr
34
+ *.iws
35
+ *.ids
36
+ .rakeTasks
37
+
38
+ # Emacs
39
+
40
+ *~
41
+ \#*
42
+ .#*
43
+
44
+ # Mac OS
45
+
46
+ .DS_Store
data/.rubocop.yml ADDED
@@ -0,0 +1,24 @@
1
+ # Disable compact style check for example.rb
2
+ Style/ClassAndModuleChildren:
3
+ Exclude:
4
+ - 'example.rb'
5
+
6
+ # Disable line-length check; it's too easy for the cure to be worse than the disease
7
+ Metrics/LineLength:
8
+ Enabled: False
9
+
10
+ # Disable problematic module documentation check (see https://github.com/bbatsov/rubocop/issues/947)
11
+ Style/Documentation:
12
+ Enabled: false
13
+
14
+ # Allow one line around class body (Style/EmptyLines will still disallow two or more)
15
+ Style/EmptyLinesAroundClassBody:
16
+ Enabled: false
17
+
18
+ # Allow one line around module body (Style/EmptyLines will still disallow two or more)
19
+ Style/EmptyLinesAroundModuleBody:
20
+ Enabled: false
21
+
22
+ # Allow one line around block body (Style/EmptyLines will still disallow two or more)
23
+ Style/EmptyLinesAroundBlockBody:
24
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.3
data/.travis.yml ADDED
@@ -0,0 +1,2 @@
1
+ language: ruby
2
+
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup markdown
data/CHANGES.md ADDED
@@ -0,0 +1,7 @@
1
+ # 0.1.1 (16 March 2016)
2
+
3
+ - Fix gem metadata
4
+
5
+ # 0.1.0 (16 March 2016)
6
+
7
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 The Regents of the University of California
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,230 @@
1
+ # stash-wrapper
2
+
3
+ [![Build Status](https://travis-ci.org/CDLUC3/stash-wrapper.svg?branch=master)](https://travis-ci.org/CDLUC3/stash-wrapper)
4
+ [![Code Climate](https://codeclimate.com/github/CDLUC3/stash-wrapper.svg)](https://codeclimate.com/github/CDLUC3/stash-wrapper)
5
+ [![Inline docs](http://inch-ci.org/github/CDLUC3/stash-wrapper.svg)](http://inch-ci.org/github/CDLUC3/stash-wrapper)
6
+ [![Gem Version](https://img.shields.io/gem/v/stash-wrapper.svg)](https://github.com/CDLUC3/stash-wrapper/releases)
7
+
8
+ Gem for working with the [Stash](https://github.com/CDLUC3/stash)
9
+ [XML wrapper format](https://dash.cdlib.org/stash_wrapper/stash_wrapper.xsd).
10
+
11
+ The `StashWrapper` object graph mostly mirrors the `stash_wrapper` schema, though some
12
+ simpler elements have been collapsed into object attributes. Also, some classes and
13
+ attributes have slightly different names from the corresponding XML attributes in order
14
+ to avoid colliding with Ruby keywords (e.g. `end` ⇒ `end_date`) or standard types
15
+ (e.g. `file` ⇒ `StashFile`).
16
+
17
+ | Schema element | Corresponding class or field | Attribute type |
18
+ | -------------- | ------------------- | ---- |
19
+ | `<st:stash_wrapper>` | `StashWrapper` | |
20
+ | `<st:identifier>` | `Identifier` | |
21
+ | `<st:stash_administrative>` | `StashAdministrative` | |
22
+ | `<st:version>` | `Version` | |
23
+ | `<st:version_number>` | `Version.version_number` | `Integer` |
24
+ | `<st:date>` | `Version.date` | `Date` | |
25
+ | `<st:license>` | `License` | |
26
+ | `<st:name>` | `License.name` | `String` |
27
+ | `<st:uri>` | `License.uri` | `URI` |
28
+ | `<st:embargo>` | `Embargo` | |
29
+ | `<st:type>` | `Embargo.type` | `EmbargoType` |
30
+ | `<st:period>` | `Embargo.period` | `String` |
31
+ | `<st:start>` | `Embargo.start_date` | `Date` |
32
+ | `<st:end>` | `Embargo.end_date` | `Date` |
33
+ | `<st:inventory>` | `Inventory` | |
34
+ | `<st:file>` | `StashFile` | |
35
+ | `<st:pathname>` | `StashFile.pathname` | `String` |
36
+ | `<st:size>` | `Size` | |
37
+ | `<st:mime_type>` | `StashFile.mime_type` | `MIME::Type` |
38
+ | `<st:stash_descriptive>` | `StashWrapper.descriptive_elements` | `Array<REXML::Element>` |
39
+
40
+ Note that [TypesafeEnum](https://github.com/dmolesUC3/typesafe_enum) classes are provided
41
+ for embargo type (`EmbargoType`), identifier type (`IdentifierType`), and size unit
42
+ (`SizeUnit`).
43
+
44
+ ## Usage
45
+
46
+ The `Stash::Wrapper::StashWrapper` class represents a single Stash wrapper document.
47
+ It accepts a payload of one or more XML metadata documents in the form of the
48
+ `descriptive_elements` attribute, an array of `REXML::Element` objects. On calling
49
+ `save_to_xml` on the `StashWrapper` instance, these elements will be embedded in the
50
+ wrapper's `<st:stash_descriptive>` element.
51
+
52
+ ### Full example
53
+
54
+ ```ruby
55
+ require 'stash/wrapper'
56
+
57
+ ST = Stash::Wrapper
58
+
59
+ identifier = ST::Identifier.new(
60
+ type: ST::IdentifierType::DOI,
61
+ value: '10.14749/1407399498'
62
+ )
63
+
64
+ version = ST::Version.new(
65
+ number: 1,
66
+ date: Date.new(2013, 8, 18),
67
+ note: 'Sample wrapped Datacite document'
68
+ )
69
+
70
+ license = ST::License::CC_BY
71
+
72
+ embargo = ST::Embargo.new(
73
+ type: ST::EmbargoType::DOWNLOAD,
74
+ period: '1 year',
75
+ start_date: Date.new(2013, 8, 18),
76
+ end_date: Date.new(2014, 8, 18)
77
+ )
78
+
79
+ inventory = ST::Inventory.new(
80
+ files: [
81
+ ST::StashFile.new(
82
+ pathname: 'HSRC_MasterSampleII.dat', size_bytes: 12_345, mime_type: 'text/plain'
83
+ ),
84
+ ST::StashFile.new(
85
+ pathname: 'HSRC_MasterSampleII.csv', size_bytes: 67_890, mime_type: 'text/csv'
86
+ ),
87
+ ST::StashFile.new(
88
+ pathname: 'HSRC_MasterSampleII.sas7bdat', size_bytes: 123_456, mime_type: 'application/x-sas-data'
89
+ ),
90
+ ])
91
+
92
+ datacite_file = 'spec/data/wrapper/wrapper-2-payload.xml'
93
+ datacite_root = REXML::Document.new(File.read(datacite_file)).root
94
+
95
+ wrapper = ST::StashWrapper.new(
96
+ identifier: identifier,
97
+ version: version,
98
+ license: license,
99
+ embargo: embargo,
100
+ inventory: inventory,
101
+ descriptive_elements: [datacite_root]
102
+ )
103
+
104
+ wrapper_xml = wrapper.save_to_xml
105
+
106
+ formatter = REXML::Formatters::Pretty.new
107
+ formatter.compact = true
108
+ puts formatter.write(wrapper_xml, '')
109
+ ```
110
+
111
+ ## Generating sample data
112
+
113
+ The script `bin/gen_stash_wrapper_sample` will generate sample wrapper files with embedded
114
+ datacite metadata and [lorem ipsum](https://en.wikipedia.org/wiki/Lorem_ipsum)-style
115
+ placeholder content. With no arguments, it will generate one file and write it to standard
116
+ output; with a numeric argument, it will generate that number of files and write them to the
117
+ current working directory.
118
+
119
+ When generating multiple files, the script pulls from a relatively small pool of randomly
120
+ generated authors (1000), publishers (100), and resource types (20), so that files generated
121
+ in the same session will share some metadata field values. The MIME types of the `<file/>`
122
+ entries in a single session will also be pulled from a small subset (20) of real MIME types,
123
+ and the file extensions should match, but the MIME types, being randomly selected, are likely
124
+ to be nonsensical.
125
+
126
+ ### Single file to standard output
127
+ ```
128
+ % gen_stash_wrapper_sample
129
+ <st:stash_wrapper xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://dash.cdlib.org/stash_wrapper/ http://dash.cdlib.org/stash_wrapper/stash_wrapper.xsd' xmlns:st='http://dash.cdlib.org/stash_wrapper/'>
130
+ <st:identifier type='DOI'>10.21585/def1000001</st:identifier>
131
+ <st:stash_administrative>
132
+ <st:version>
133
+ <st:version_number>1</st:version_number>
134
+ <st:date>2014-03-16Z</st:date>
135
+ <st:note>Mecum noctem illam superiorem; iam intellege</st:note>
136
+ </st:version>
137
+ <st:license>
138
+ <st:name>Creative Commons Attribution 4.0 International (CC-BY)</st:name>
139
+ <st:uri>https://creativecommons.org/licenses/by/4.0/legalcode</st:uri>
140
+ </st:license>
141
+ <st:embargo>
142
+ <st:type>none</st:type>
143
+ <st:period>none</st:period>
144
+ <st:start>2014-03-16Z</st:start>
145
+ <st:end>2014-03-16Z</st:end>
146
+ </st:embargo>
147
+ <st:inventory num_files='4'>
148
+ <st:file>
149
+ <st:pathname>nocte.mng</st:pathname>
150
+ <st:size unit='B'>2244</st:size>
151
+ <st:mime_type>video/x-mng</st:mime_type>
152
+ </st:file>
153
+ <st:file>
154
+ <st:pathname>constrictam.htc</st:pathname>
155
+ <st:size unit='B'>2228</st:size>
156
+ <st:mime_type>text/x-component</st:mime_type>
157
+ </st:file>
158
+ <st:file>
159
+ <st:pathname>teneri.plt</st:pathname>
160
+ <st:size unit='B'>55719</st:size>
161
+ <st:mime_type>application/vnd.hp-HPGL</st:mime_type>
162
+ </st:file>
163
+ <st:file>
164
+ <st:pathname>oculis.uvg</st:pathname>
165
+ <st:size unit='B'>8080</st:size>
166
+ <st:mime_type>image/vnd.dece.graphic</st:mime_type>
167
+ </st:file>
168
+ </st:inventory>
169
+ </st:stash_administrative>
170
+ <st:stash_descriptive>
171
+ <dcs:resource xmlns:dcs='http://datacite.org/schema/kernel-3' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://datacite.org/schema/kernel-3
172
+ http://schema.datacite.org/meta/kernel-3/metadata.xsd'>
173
+ <dcs:identifier identifierType='DOI'>10.21585/def1000001</dcs:identifier>
174
+ <dcs:creators>
175
+ <dcs:creator>
176
+ <dcs:creatorName>Interficiere Statum</dcs:creatorName>
177
+ <dcs:creatorName>Armis Speculabuntur</dcs:creatorName>
178
+ <dcs:creatorName>Iste Relinqueres Opimius</dcs:creatorName>
179
+ <dcs:creatorName>Ordinis Vivis</dcs:creatorName>
180
+ </dcs:creator>
181
+ </dcs:creators>
182
+ <dcs:titles>
183
+ <dcs:title>Admirandum, dies</dcs:title>
184
+ </dcs:titles>
185
+ <dcs:publisher>Furorem Nostro Multis Mores Nocturnum Ahala Tam</dcs:publisher>
186
+ <dcs:publicationYear>2014</dcs:publicationYear>
187
+ <dcs:subjects>
188
+ <dcs:subject>convenit</dcs:subject>
189
+ <dcs:subject>domus</dcs:subject>
190
+ <dcs:subject>neque</dcs:subject>
191
+ <dcs:subject>ora</dcs:subject>
192
+ <dcs:subject>paulo</dcs:subject>
193
+ <dcs:subject>perniciosum</dcs:subject>
194
+ <dcs:subject>poena</dcs:subject>
195
+ <dcs:subject>res</dcs:subject>
196
+ <dcs:subject>scientia</dcs:subject>
197
+ <dcs:subject>tuorum</dcs:subject>
198
+ </dcs:subjects>
199
+ <dcs:resourceType resourceTypeGeneral='Dataset'>te</dcs:resourceType>
200
+ <dcs:descriptions>
201
+ <dcs:description descriptionType='Abstract'>
202
+ Pridem oportebat, in te conferri pestem, quam tu in nos omnes iam diu
203
+ machinaris. an vero vir amplissumus, scipio, pontifex maximus,
204
+ gracchum mediocriter labefactantem statum rei publicae privatus
205
+ interfecit; catilinam orbem terrae caede atque incendiis vastare
206
+ cupientem nos consules perferemus? nam illa nimis antiqua praetereo,
207
+ quod servilius ahala maelium novis rebus studentem manu sua occidit.
208
+ fuit, fuit ista quondam in hac re publica virtus, ut viri.
209
+ </dcs:description>
210
+ </dcs:descriptions>
211
+ </dcs:resource>
212
+ </st:stash_descriptive>
213
+ </st:stash_wrapper>
214
+ ```
215
+
216
+ ### Multiple files
217
+ ```
218
+ % cd /tmp
219
+ % gen_stash_wrapper_sample 10
220
+ /tmp/stash_wrapper-01.xml
221
+ /tmp/stash_wrapper-02.xml
222
+ /tmp/stash_wrapper-03.xml
223
+ /tmp/stash_wrapper-04.xml
224
+ /tmp/stash_wrapper-05.xml
225
+ /tmp/stash_wrapper-06.xml
226
+ /tmp/stash_wrapper-07.xml
227
+ /tmp/stash_wrapper-08.xml
228
+ /tmp/stash_wrapper-09.xml
229
+ /tmp/stash_wrapper-10.xml
230
+ ```
data/Rakefile ADDED
@@ -0,0 +1,47 @@
1
+ # ------------------------------------------------------------
2
+ # RSpec
3
+
4
+ require 'rspec/core'
5
+ require 'rspec/core/rake_task'
6
+
7
+ namespace :spec do
8
+
9
+ desc 'Run all unit tests'
10
+ RSpec::Core::RakeTask.new(:unit) do |task|
11
+ task.rspec_opts = %w(--color --format documentation --order default)
12
+ task.pattern = 'unit/**/*_spec.rb'
13
+ end
14
+
15
+ task all: [:unit]
16
+ end
17
+
18
+ desc 'Run all tests'
19
+ task spec: 'spec:all'
20
+
21
+ # ------------------------------------------------------------
22
+ # Coverage
23
+
24
+ desc 'Run all unit tests with coverage'
25
+ task :coverage do
26
+ ENV['COVERAGE'] = 'true'
27
+ Rake::Task['spec:unit'].execute
28
+ end
29
+
30
+ # ------------------------------------------------------------
31
+ # RuboCop
32
+
33
+ require 'rubocop/rake_task'
34
+ RuboCop::RakeTask.new
35
+
36
+ # ------------------------------------------------------------
37
+ # Miscellaneous
38
+
39
+ task :debug_load_path do
40
+ puts $LOAD_PATH
41
+ end
42
+
43
+ # ------------------------------------------------------------
44
+ # Defaults
45
+
46
+ desc 'Run unit tests, check test coverage, check code style'
47
+ task default: [:coverage, :rubocop]
@@ -0,0 +1,220 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <xsl:stylesheet
3
+ version="2.0"
4
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6
+ xmlns:datacite="http://datacite.org/schema/kernel-3"
7
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
8
+ xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
9
+ exclude-result-prefixes="datacite">
10
+
11
+ <xsl:output method="xml" omit-xml-declaration="yes" indent="yes" encoding="UTF-8" />
12
+
13
+ <xsl:strip-space elements="*"/>
14
+
15
+ <xsl:template match="datacite:identifier">
16
+ <dc:identifier>
17
+ <xsl:choose>
18
+ <xsl:when test="string-length(@identifierType) &gt; 0">
19
+ <xsl:value-of select="lower-case(@identifierType)"/>
20
+ <xsl:text>:</xsl:text>
21
+ </xsl:when>
22
+ </xsl:choose>
23
+ <xsl:value-of select="."/>
24
+ </dc:identifier>
25
+ </xsl:template>
26
+
27
+ <xsl:template match="datacite:creators">
28
+ <xsl:for-each select="datacite:creator">
29
+ <xsl:element name="dc:creator">
30
+ <xsl:value-of select="./datacite:creatorName"/>
31
+ </xsl:element>
32
+ </xsl:for-each>
33
+ </xsl:template>
34
+
35
+ <xsl:template match="datacite:titles">
36
+ <xsl:for-each select="datacite:title">
37
+ <xsl:element name="dc:title">
38
+ <xsl:if test="@xml:lang">
39
+ <xsl:attribute name="xml:lang"><xsl:value-of select="@xml:lang"/></xsl:attribute>
40
+ </xsl:if>
41
+ <xsl:value-of select="."/>
42
+ </xsl:element>
43
+ </xsl:for-each>
44
+ </xsl:template>
45
+
46
+ <xsl:template match="datacite:publisher">
47
+ <xsl:for-each select=".">
48
+ <xsl:element name="dc:publisher">
49
+ <xsl:value-of select="."/>
50
+ </xsl:element>
51
+ </xsl:for-each>
52
+ </xsl:template>
53
+
54
+ <xsl:template match="datacite:publicationYear">
55
+ <xsl:element name="dc:date">
56
+ <xsl:value-of select="."/>
57
+ </xsl:element>
58
+ </xsl:template>
59
+
60
+ <xsl:template match="datacite:subjects">
61
+ <xsl:for-each select="datacite:subject">
62
+ <xsl:element name="dc:subject">
63
+ <xsl:if test="@xml:lang">
64
+ <xsl:attribute name="xml:lang"><xsl:value-of select="@xml:lang"/></xsl:attribute>
65
+ </xsl:if>
66
+ <xsl:value-of select="."/>
67
+ </xsl:element>
68
+ </xsl:for-each>
69
+ </xsl:template>
70
+
71
+ <xsl:template match="datacite:contributors">
72
+ <xsl:for-each select="datacite:contributor">
73
+ <xsl:element name="dc:contributor">
74
+ <xsl:value-of select="./datacite:contributorName"/>
75
+ </xsl:element>
76
+ </xsl:for-each>
77
+ </xsl:template>
78
+
79
+ <xsl:template match="datacite:dates">
80
+
81
+ <xsl:for-each select="datacite:date">
82
+ <xsl:element name="dc:date">
83
+ <xsl:if test="@dateType">
84
+ <xsl:value-of select="@dateType"/><xsl:text>: </xsl:text>
85
+ </xsl:if>
86
+ <xsl:value-of select="."/>
87
+ </xsl:element>
88
+ </xsl:for-each>
89
+ </xsl:template>
90
+
91
+ <xsl:template match="datacite:language">
92
+ <xsl:element name="dc:language">
93
+ <xsl:value-of select="."/>
94
+ </xsl:element>
95
+ </xsl:template>
96
+
97
+ <xsl:template match="datacite:resourceType">
98
+ <xsl:for-each select=".">
99
+ <xsl:if test="normalize-space(@resourceTypeGeneral)">
100
+ <xsl:element name="dc:type">
101
+ <xsl:value-of select="@resourceTypeGeneral"/>
102
+ </xsl:element>
103
+ </xsl:if>
104
+ <xsl:if test="normalize-space(.)">
105
+ <xsl:element name="dc:type">
106
+ <xsl:value-of select="."/>
107
+ </xsl:element>
108
+ </xsl:if>
109
+ </xsl:for-each>
110
+ </xsl:template>
111
+
112
+ <xsl:template match="datacite:alternateIdentifiers">
113
+ <xsl:for-each select="datacite:alternateIdentifier">
114
+ <xsl:element name="dc:identifier">
115
+ <xsl:choose>
116
+ <xsl:when test="string-length(@alternateIdentifierType) &gt; 0">
117
+ <xsl:value-of select="lower-case(@alternateIdentifierType)"/>
118
+ <xsl:text>:</xsl:text>
119
+ </xsl:when>
120
+ </xsl:choose>
121
+ <xsl:value-of select="."/>
122
+ </xsl:element>
123
+ </xsl:for-each>
124
+ </xsl:template>
125
+
126
+ <xsl:template match="datacite:relatedIdentifiers">
127
+ <xsl:for-each select="datacite:relatedIdentifier">
128
+ <xsl:element name="dc:relation">
129
+ <xsl:choose>
130
+ <xsl:when test="string-length(@relatedIdentifierType) &gt; 0">
131
+ <xsl:value-of select="lower-case(@relatedIdentifierType)"/>
132
+ <xsl:text>:</xsl:text>
133
+ </xsl:when>
134
+ </xsl:choose>
135
+ <xsl:value-of select="."/>
136
+ </xsl:element>
137
+ </xsl:for-each>
138
+ </xsl:template>
139
+
140
+ <xsl:template match="datacite:sizes">
141
+ <xsl:for-each select="datacite:size">
142
+ <xsl:element name="dc:format">
143
+ <xsl:value-of select="."/>
144
+ </xsl:element>
145
+ </xsl:for-each>
146
+ </xsl:template>
147
+
148
+ <xsl:template match="datacite:formats">
149
+ <xsl:for-each select="datacite:format">
150
+ <xsl:element name="dc:format">
151
+ <xsl:value-of select="."/>
152
+ </xsl:element>
153
+ </xsl:for-each>
154
+ </xsl:template>
155
+
156
+ <xsl:template match="datacite:rightsList">
157
+ <xsl:for-each select="datacite:rights">
158
+ <xsl:element name="dc:rights">
159
+ <xsl:value-of select="."/>
160
+ </xsl:element>
161
+ <xsl:if test="@rightsURI">
162
+ <xsl:element name="dc:rights">
163
+ <xsl:value-of select="@rightsURI"/>
164
+ </xsl:element>
165
+ </xsl:if>
166
+ </xsl:for-each>
167
+ </xsl:template>
168
+
169
+ <xsl:template match="datacite:geoLocations">
170
+ <xsl:for-each select="datacite:geoLocation">
171
+ <xsl:for-each select="child::node()">
172
+ <xsl:element name="dc:coverage">
173
+ <xsl:value-of select="string(.)"/>
174
+ </xsl:element>
175
+ </xsl:for-each>
176
+ </xsl:for-each>
177
+ </xsl:template>
178
+
179
+ <xsl:template match="datacite:descriptions">
180
+ <xsl:for-each select="datacite:description">
181
+ <xsl:if test="normalize-space(@descriptionType)">
182
+ <xsl:element name="dc:description">
183
+ <xsl:value-of select="@descriptionType"/>
184
+ </xsl:element>
185
+ </xsl:if>
186
+ <xsl:if test="normalize-space(.)">
187
+ <xsl:element name="dc:description">
188
+ <xsl:if test="@xml:lang">
189
+ <xsl:attribute name="xml:lang"><xsl:value-of select="@xml:lang" /></xsl:attribute>
190
+ </xsl:if>
191
+ <xsl:value-of select="."/>
192
+ </xsl:element>
193
+ </xsl:if>
194
+ </xsl:for-each>
195
+ </xsl:template>
196
+
197
+ <xsl:template match="datacite:resource">
198
+ <xsl:element name="oai_dc:dc">
199
+ <xsl:attribute name="xsi:schemaLocation">http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd</xsl:attribute>
200
+ <xsl:namespace name="dc">http://purl.org/dc/elements/1.1/</xsl:namespace>
201
+ <xsl:apply-templates select="datacite:titles"/>
202
+ <xsl:apply-templates select="datacite:creators"/>
203
+ <xsl:apply-templates select="datacite:publisher"/>
204
+ <xsl:apply-templates select="datacite:publicationYear"/>
205
+ <xsl:apply-templates select="datacite:dates"/>
206
+ <xsl:apply-templates select="datacite:identifier"/>
207
+ <xsl:apply-templates select="datacite:alternateIdentifiers"/>
208
+ <xsl:apply-templates select="datacite:relatedIdentifiers"/>
209
+ <xsl:apply-templates select="datacite:subjects"/>
210
+ <xsl:apply-templates select="datacite:descriptions"/>
211
+ <xsl:apply-templates select="datacite:contributors"/>
212
+ <xsl:apply-templates select="datacite:language"/>
213
+ <xsl:apply-templates select="datacite:resourceType"/>
214
+ <xsl:apply-templates select="datacite:sizes"/>
215
+ <xsl:apply-templates select="datacite:formats"/>
216
+ <xsl:apply-templates select="datacite:rightsList"/>
217
+ <xsl:apply-templates select="datacite:geoLocations"/>
218
+ </xsl:element>
219
+ </xsl:template>
220
+ </xsl:stylesheet>