datacite_mds 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +32 -14
- data/data/xsd/datacite-metadata-v3.1.xsd +380 -0
- data/data/xsd/include/datacite-contributorType-v3.1.xsd +35 -0
- data/data/xsd/include/datacite-dateType-v3.xsd +21 -0
- data/data/xsd/include/datacite-descriptionType-v3.xsd +17 -0
- data/data/xsd/include/datacite-relatedIdentifierType-v3.1.xsd +30 -0
- data/data/xsd/include/datacite-relationType-v3.1.xsd +38 -0
- data/data/xsd/include/datacite-resourceType-v3.xsd +26 -0
- data/data/xsd/include/datacite-titleType-v3.xsd +12 -0
- data/datacite_mds.gemspec +2 -2
- data/lib/datacite_mds/version.rb +1 -1
- data/lib/datacite_mds.rb +49 -21
- metadata +16 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02e1d63ca5b160f0348908ee88ed9b47ac6a0381
|
4
|
+
data.tar.gz: 96d04b6132ac7c718050342cbbe57b3c2725da1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e66855a306a357f5626528786c9e9fcdb6031479c35e2f3bbae3bca4fc279fef1c9507d937bb4b337fde65e316f4593addc311316922d400be3c6252c38bdaaa
|
7
|
+
data.tar.gz: ba7cf77180f5efabf2bb1a23baf971f53aea633b97eddbf9fe811bd94509e5daf2a448259e1f7fcc740bfe220de1b4f4d9c832b90c88205587d3a22ab1d85911
|
data/README.md
CHANGED
@@ -33,6 +33,8 @@ Require the gem
|
|
33
33
|
|
34
34
|
require 'datacite_mds'
|
35
35
|
|
36
|
+
### Object creation
|
37
|
+
|
36
38
|
create an Mds object (explicit authorization)
|
37
39
|
|
38
40
|
mds = Datacite::Mds.new authorize: {usr: "joe bloggs", pwd: "password"}
|
@@ -45,31 +47,52 @@ create an Mds object for testing (implicit authorization)
|
|
45
47
|
|
46
48
|
mds = Datacite::Mds.new testing: true
|
47
49
|
|
48
|
-
|
49
|
-
|
50
|
-
res = mds.resolve '10.5072/existing-doi'
|
51
|
-
p res # => <Net::HTTPOK 200 OK readbody=true
|
50
|
+
### Metadata operations
|
52
51
|
|
53
52
|
upload metadata
|
54
53
|
|
55
|
-
|
56
|
-
|
54
|
+
res = mds.upload_metadata File.read('metadata.xml')
|
55
|
+
p res # => <Net::HTTPCreated 201 Created readbody=true>
|
57
56
|
|
58
57
|
delete metadata
|
59
58
|
|
60
59
|
res = mds.delete_metadata '10.5072/existing-doi'
|
61
|
-
p res # => <Net::HTTPOK 200 OK readbody=true
|
60
|
+
p res # => <Net::HTTPOK 200 OK readbody=true>
|
61
|
+
|
62
|
+
get metadata for existing DOI
|
63
|
+
|
64
|
+
res = mds.get_metadata '10.5072/existing-doi'
|
65
|
+
if res.instance_of? Net::HTTPOK
|
66
|
+
p res.body # shows the xml metadata
|
67
|
+
end
|
68
|
+
|
69
|
+
check if metadata is valid XML for for Datacite Schema (http://schema.datacite.org/meta/kernel-3.1/metadata.xsd)
|
70
|
+
|
71
|
+
unless Datacite::Mds.metadata_valid?(INVALID_METADATA)
|
72
|
+
Datacite::Mds.validation_errors.each do |error|
|
73
|
+
p "Validation error: #{error}"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
### DOI operations
|
79
|
+
|
80
|
+
resolve a DOI
|
81
|
+
|
82
|
+
res = mds.resolve '10.5072/existing-doi'
|
83
|
+
p res # => <Net::HTTPOK 200 OK readbody=true
|
62
84
|
|
63
85
|
get all DOIs for datacentre
|
64
86
|
|
65
87
|
res = mds.get_all_dois
|
66
88
|
if res.instance_of? Net::HTTPOK
|
67
|
-
p res.
|
89
|
+
p res.body.split # show all DOIs
|
68
90
|
end
|
69
91
|
|
70
|
-
|
71
92
|
mint a DOI
|
72
93
|
|
94
|
+
*Note*: before minting a DOI, ensure you have uploaded metadata for that DOI, by using the *#upload_metadata* method.
|
95
|
+
|
73
96
|
res = mds.mint '10.5072/non-existing-doi', 'http://ora.ox.ac.uk/objects/uuid:<an-existing-uuid>'
|
74
97
|
p res # => <Net::HTTPCreated 201 Created readbody=true>
|
75
98
|
|
@@ -79,12 +102,7 @@ update dataset for existing DOI
|
|
79
102
|
res = mds.mint '10.5072/existing-doi', 'http://ora.ox.ac.uk/objects/uuid:<new-uuid>'
|
80
103
|
p res # => <Net::HTTPCreated 201 Created readbody=true>
|
81
104
|
|
82
|
-
get metadata for existing DOI
|
83
105
|
|
84
|
-
res = mds.get_metadata '10.5072/existing-doi'
|
85
|
-
if res.instance_of? Net::HTTPOK
|
86
|
-
p res.body # shows the xml metadata
|
87
|
-
end
|
88
106
|
|
89
107
|
## Tests
|
90
108
|
|
@@ -0,0 +1,380 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!-- Revision history
|
3
|
+
2010-08-26 Complete revision according to new common specification by the metadata work group after review. AJH, DTIC
|
4
|
+
2010-11-17 Revised to current state of kernel review, FZ, TIB
|
5
|
+
2011-01-17 Complete revsion after community review. FZ, TIB
|
6
|
+
2011-03-17 Release of v2.1: added a namespace; mandatory properties got minLength; changes in the definitions of relationTypes
|
7
|
+
IsDocumentedBy/Documents and isCompiledBy/Compiles; changes type of property "Date" from xs:date to xs:string. FZ, TIB
|
8
|
+
2011-06-27 v2.2: namespace: kernel-2.2, additions to controlled lists "resourceType", "contributorType", "relatedIdentifierType", and "descriptionType". Removal of intermediate include-files.
|
9
|
+
2013-05 v3.0: namespace: kernel-3.0; delete LastMetadataUpdate & MetadateVersionNumber; additions to controlled lists "contributorType", "dateType", "descriptionType", "relationType", "relatedIdentifierType" & "resourceType"; deletion of "StartDate" & "EndDate" from list "dateType" and "Film" from "resourceType"; allow arbitrary order of elements; allow optional wrapper elements to be empty; include xml:lang attribute for title, subject & description; include attribute schemeURI for nameIdentifier of creator, contributor & subject; added new attributes "relatedMetadataScheme", "schemeURI" & "schemeType" to relatedIdentifier; included new property "geoLocation"
|
10
|
+
2014-08-20 v3.1: additions to controlled lists "relationType", contributorType" and "relatedIdentifierType"; introduction of new child element "affiliation" to "creator" and "contributor"-->
|
11
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified" xml:lang="EN">
|
12
|
+
<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2009/01/xml.xsd"/>
|
13
|
+
<xs:include schemaLocation="include/datacite-titleType-v3.xsd"/>
|
14
|
+
<xs:include schemaLocation="include/datacite-contributorType-v3.1.xsd"/>
|
15
|
+
<xs:include schemaLocation="include/datacite-dateType-v3.xsd"/>
|
16
|
+
<xs:include schemaLocation="include/datacite-resourceType-v3.xsd"/>
|
17
|
+
<xs:include schemaLocation="include/datacite-relationType-v3.1.xsd"/>
|
18
|
+
<xs:include schemaLocation="include/datacite-relatedIdentifierType-v3.1.xsd"/>
|
19
|
+
<xs:include schemaLocation="include/datacite-descriptionType-v3.xsd"/>
|
20
|
+
<xs:element name="resource">
|
21
|
+
<xs:annotation>
|
22
|
+
<xs:documentation>
|
23
|
+
Root element of a single record. This wrapper element is for XML implementation only and is not defined in the DataCite DOI standard.
|
24
|
+
Note: This is the case for all wrapper elements within this schema!</xs:documentation>
|
25
|
+
<xs:documentation>No content in this wrapper element.</xs:documentation>
|
26
|
+
</xs:annotation>
|
27
|
+
<xs:complexType>
|
28
|
+
<xs:all>
|
29
|
+
<!--REQUIRED FIELDS-->
|
30
|
+
<xs:element name="identifier">
|
31
|
+
<xs:annotation>
|
32
|
+
<xs:documentation>A persistent identifier that identifies a resource.</xs:documentation>
|
33
|
+
<xs:documentation>Currently, only DOI is allowed.</xs:documentation>
|
34
|
+
</xs:annotation>
|
35
|
+
<xs:complexType>
|
36
|
+
<xs:simpleContent>
|
37
|
+
<xs:extension base="doiType">
|
38
|
+
<xs:attribute name="identifierType" use="required" fixed="DOI"/>
|
39
|
+
</xs:extension>
|
40
|
+
</xs:simpleContent>
|
41
|
+
</xs:complexType>
|
42
|
+
</xs:element>
|
43
|
+
<xs:element name="creators">
|
44
|
+
<xs:complexType>
|
45
|
+
<xs:sequence>
|
46
|
+
<xs:element name="creator" maxOccurs="unbounded">
|
47
|
+
<xs:annotation>
|
48
|
+
<xs:documentation>The main researchers involved working on the data, or the authors of the publication in priority order. May be a corporate/institutional or personal name.</xs:documentation>
|
49
|
+
<xs:documentation>Format: Family, Given.</xs:documentation>
|
50
|
+
</xs:annotation>
|
51
|
+
<xs:complexType>
|
52
|
+
<xs:sequence>
|
53
|
+
<xs:element name="creatorName">
|
54
|
+
<xs:simpleType>
|
55
|
+
<xs:restriction base="nonemptycontentStringType"/>
|
56
|
+
</xs:simpleType>
|
57
|
+
</xs:element>
|
58
|
+
<xs:element name="nameIdentifier" minOccurs="0">
|
59
|
+
<xs:complexType>
|
60
|
+
<xs:simpleContent>
|
61
|
+
<xs:extension base="nonemptycontentStringType">
|
62
|
+
<xs:attribute name="nameIdentifierScheme" use="required"/>
|
63
|
+
<xs:attribute name="schemeURI" type="xs:anyURI" use="optional"/>
|
64
|
+
</xs:extension>
|
65
|
+
</xs:simpleContent>
|
66
|
+
</xs:complexType>
|
67
|
+
</xs:element>
|
68
|
+
<xs:element name="affiliation" minOccurs="0" maxOccurs="unbounded"/>
|
69
|
+
</xs:sequence>
|
70
|
+
</xs:complexType>
|
71
|
+
</xs:element>
|
72
|
+
</xs:sequence>
|
73
|
+
</xs:complexType>
|
74
|
+
</xs:element>
|
75
|
+
<xs:element name="titles">
|
76
|
+
<xs:complexType>
|
77
|
+
<xs:sequence>
|
78
|
+
<xs:element name="title" maxOccurs="unbounded">
|
79
|
+
<xs:annotation>
|
80
|
+
<xs:documentation>A name or title by which a resource is known.</xs:documentation>
|
81
|
+
</xs:annotation>
|
82
|
+
<xs:complexType>
|
83
|
+
<xs:simpleContent>
|
84
|
+
<xs:extension base="nonemptycontentStringType">
|
85
|
+
<xs:attribute name="titleType" type="titleType" use="optional"/>
|
86
|
+
<xs:attribute ref="xml:lang"/>
|
87
|
+
</xs:extension>
|
88
|
+
</xs:simpleContent>
|
89
|
+
</xs:complexType>
|
90
|
+
</xs:element>
|
91
|
+
</xs:sequence>
|
92
|
+
</xs:complexType>
|
93
|
+
</xs:element>
|
94
|
+
<xs:element name="publisher">
|
95
|
+
<xs:annotation>
|
96
|
+
<xs:documentation>The name of the entity that holds, archives, publishes prints, distributes, releases, issues, or produces the resource. This property will be used to formulate the citation, so consider the prominence of the role.</xs:documentation>
|
97
|
+
<xs:documentation>In the case of datasets, "publish" is understood to mean making the data available to the community of researchers.</xs:documentation>
|
98
|
+
</xs:annotation>
|
99
|
+
<xs:simpleType>
|
100
|
+
<xs:restriction base="nonemptycontentStringType"/>
|
101
|
+
</xs:simpleType>
|
102
|
+
</xs:element>
|
103
|
+
<xs:element name="publicationYear">
|
104
|
+
<xs:annotation>
|
105
|
+
<xs:documentation>Year when the data is made publicly available. If an embargo period has been in effect, use the date when the embargo period ends.</xs:documentation>
|
106
|
+
<xs:documentation>In the case of datasets, "publish" is understood to mean making the data available on a specific date to the community of researchers. If there is no standard publication year value, use the date that would be preferred from a citation perspective.</xs:documentation>
|
107
|
+
<xs:documentation>YYYY</xs:documentation>
|
108
|
+
</xs:annotation>
|
109
|
+
<xs:simpleType>
|
110
|
+
<xs:restriction base="yearType"/>
|
111
|
+
</xs:simpleType>
|
112
|
+
</xs:element>
|
113
|
+
<!--OPTIONAL FIELDS-->
|
114
|
+
<xs:element name="subjects" minOccurs="0">
|
115
|
+
<xs:complexType>
|
116
|
+
<xs:sequence>
|
117
|
+
<xs:element name="subject" minOccurs="0" maxOccurs="unbounded">
|
118
|
+
<xs:annotation>
|
119
|
+
<xs:documentation>Subject, keywords, classification codes, or key phrases describing the resource.</xs:documentation>
|
120
|
+
</xs:annotation>
|
121
|
+
<xs:complexType>
|
122
|
+
<xs:simpleContent>
|
123
|
+
<xs:extension base="xs:string">
|
124
|
+
<xs:attribute name="subjectScheme" use="optional"/>
|
125
|
+
<xs:attribute name="schemeURI" type="xs:anyURI" use="optional"/>
|
126
|
+
<xs:attribute ref="xml:lang"/>
|
127
|
+
</xs:extension>
|
128
|
+
</xs:simpleContent>
|
129
|
+
</xs:complexType>
|
130
|
+
</xs:element>
|
131
|
+
</xs:sequence>
|
132
|
+
</xs:complexType>
|
133
|
+
</xs:element>
|
134
|
+
<xs:element name="contributors" minOccurs="0">
|
135
|
+
<xs:complexType>
|
136
|
+
<xs:sequence>
|
137
|
+
<xs:element name="contributor" minOccurs="0" maxOccurs="unbounded">
|
138
|
+
<xs:annotation>
|
139
|
+
<xs:documentation>The institution or person responsible for collecting, creating, or otherwise contributing to the developement of the dataset.</xs:documentation>
|
140
|
+
<xs:documentation>The personal name format should be: Family, Given.</xs:documentation>
|
141
|
+
</xs:annotation>
|
142
|
+
<xs:complexType>
|
143
|
+
<xs:sequence>
|
144
|
+
<xs:element name="contributorName">
|
145
|
+
<xs:simpleType>
|
146
|
+
<xs:restriction base="xs:string">
|
147
|
+
<xs:minLength value="1"/>
|
148
|
+
</xs:restriction>
|
149
|
+
</xs:simpleType>
|
150
|
+
</xs:element>
|
151
|
+
<xs:element name="nameIdentifier" minOccurs="0">
|
152
|
+
<xs:complexType>
|
153
|
+
<xs:simpleContent>
|
154
|
+
<xs:extension base="xs:string">
|
155
|
+
<xs:attribute name="nameIdentifierScheme" use="required"/>
|
156
|
+
<xs:attribute name="schemeURI" type="xs:anyURI" use="optional"/>
|
157
|
+
</xs:extension>
|
158
|
+
</xs:simpleContent>
|
159
|
+
</xs:complexType>
|
160
|
+
</xs:element>
|
161
|
+
<xs:element name="affiliation" minOccurs="0" maxOccurs="unbounded"/>
|
162
|
+
</xs:sequence>
|
163
|
+
<xs:attribute name="contributorType" type="contributorType" use="required"/>
|
164
|
+
</xs:complexType>
|
165
|
+
</xs:element>
|
166
|
+
</xs:sequence>
|
167
|
+
</xs:complexType>
|
168
|
+
</xs:element>
|
169
|
+
<xs:element name="dates" minOccurs="0">
|
170
|
+
<xs:complexType>
|
171
|
+
<xs:sequence>
|
172
|
+
<xs:element name="date" minOccurs="0" maxOccurs="unbounded">
|
173
|
+
<xs:annotation>
|
174
|
+
<xs:documentation>Different dates relevant to the work.</xs:documentation>
|
175
|
+
<xs:documentation>YYYY,YYYY-MM-DD, YYYY-MM-DDThh:mm:ssTZD or any other format or level of granularity described in W3CDTF. Use RKMS-ISO8601 standard for depicting date ranges.</xs:documentation>
|
176
|
+
</xs:annotation>
|
177
|
+
<xs:complexType>
|
178
|
+
<xs:simpleContent>
|
179
|
+
<xs:extension base="xs:string">
|
180
|
+
<xs:attribute name="dateType" type="dateType" use="required"/>
|
181
|
+
</xs:extension>
|
182
|
+
</xs:simpleContent>
|
183
|
+
</xs:complexType>
|
184
|
+
</xs:element>
|
185
|
+
</xs:sequence>
|
186
|
+
</xs:complexType>
|
187
|
+
</xs:element>
|
188
|
+
<xs:element name="language" type="xs:language" minOccurs="0">
|
189
|
+
<xs:annotation>
|
190
|
+
<xs:documentation>Primary language of the resource. Allowed values are taken from IETF BCP 47, ISO 639-1 language codes.</xs:documentation>
|
191
|
+
</xs:annotation>
|
192
|
+
</xs:element>
|
193
|
+
<xs:element name="resourceType" minOccurs="0">
|
194
|
+
<xs:annotation>
|
195
|
+
<xs:documentation>The type of a resource. You may enter an additional free text description.</xs:documentation>
|
196
|
+
<xs:documentation>The format is open, but the preferred format is a single term of some detail so that a pair can be formed with the sub-property.</xs:documentation>
|
197
|
+
</xs:annotation>
|
198
|
+
<xs:complexType>
|
199
|
+
<xs:simpleContent>
|
200
|
+
<xs:extension base="xs:string">
|
201
|
+
<xs:attribute name="resourceTypeGeneral" type="resourceType" use="required"/>
|
202
|
+
</xs:extension>
|
203
|
+
</xs:simpleContent>
|
204
|
+
</xs:complexType>
|
205
|
+
</xs:element>
|
206
|
+
<xs:element name="alternateIdentifiers" minOccurs="0">
|
207
|
+
<xs:complexType>
|
208
|
+
<xs:sequence>
|
209
|
+
<xs:element name="alternateIdentifier" minOccurs="0" maxOccurs="unbounded">
|
210
|
+
<xs:annotation>
|
211
|
+
<xs:documentation>An identifier or identifiers other than the primary Identifier applied to the resource being registered. This may be any alphanumeric string which is unique within its domain of issue. May be used for local identifiers. AlternateIdentifier should be used for another identifier of the same instance (same location, same file).</xs:documentation>
|
212
|
+
</xs:annotation>
|
213
|
+
<xs:complexType>
|
214
|
+
<xs:simpleContent>
|
215
|
+
<xs:extension base="xs:string">
|
216
|
+
<xs:attribute name="alternateIdentifierType" use="required"/>
|
217
|
+
</xs:extension>
|
218
|
+
</xs:simpleContent>
|
219
|
+
</xs:complexType>
|
220
|
+
</xs:element>
|
221
|
+
</xs:sequence>
|
222
|
+
</xs:complexType>
|
223
|
+
</xs:element>
|
224
|
+
<xs:element name="relatedIdentifiers" minOccurs="0">
|
225
|
+
<xs:complexType>
|
226
|
+
<xs:sequence>
|
227
|
+
<xs:element name="relatedIdentifier" minOccurs="0" maxOccurs="unbounded">
|
228
|
+
<xs:annotation>
|
229
|
+
<xs:documentation>Identifiers of related resources. Use this property to indicate subsets of properties, as appropriate.</xs:documentation>
|
230
|
+
</xs:annotation>
|
231
|
+
<xs:complexType>
|
232
|
+
<xs:simpleContent>
|
233
|
+
<xs:extension base="xs:string">
|
234
|
+
<xs:attribute name="relatedIdentifierType" type="relatedIdentifierType" use="required"/>
|
235
|
+
<xs:attribute name="relationType" type="relationType" use="required"/>
|
236
|
+
<xs:attribute name="relatedMetadataScheme" use="optional"/>
|
237
|
+
<xs:attribute name="schemeURI" type="xs:anyURI" use="optional"/>
|
238
|
+
<xs:attribute name="schemeType" use="optional"/>
|
239
|
+
</xs:extension>
|
240
|
+
</xs:simpleContent>
|
241
|
+
</xs:complexType>
|
242
|
+
</xs:element>
|
243
|
+
</xs:sequence>
|
244
|
+
</xs:complexType>
|
245
|
+
</xs:element>
|
246
|
+
<xs:element name="sizes" minOccurs="0">
|
247
|
+
<xs:complexType>
|
248
|
+
<xs:sequence>
|
249
|
+
<xs:element name="size" type="xs:string" minOccurs="0" maxOccurs="unbounded">
|
250
|
+
<xs:annotation>
|
251
|
+
<xs:documentation>Unstructures size information about the resource.</xs:documentation>
|
252
|
+
</xs:annotation>
|
253
|
+
</xs:element>
|
254
|
+
</xs:sequence>
|
255
|
+
</xs:complexType>
|
256
|
+
</xs:element>
|
257
|
+
<xs:element name="formats" minOccurs="0">
|
258
|
+
<xs:complexType>
|
259
|
+
<xs:sequence>
|
260
|
+
<xs:element name="format" type="xs:string" minOccurs="0" maxOccurs="unbounded">
|
261
|
+
<xs:annotation>
|
262
|
+
<xs:documentation>Technical format of the resource.</xs:documentation>
|
263
|
+
<xs:documentation>Use file extension or MIME type where possible.</xs:documentation>
|
264
|
+
</xs:annotation>
|
265
|
+
</xs:element>
|
266
|
+
</xs:sequence>
|
267
|
+
</xs:complexType>
|
268
|
+
</xs:element>
|
269
|
+
<xs:element name="version" type="xs:string" minOccurs="0">
|
270
|
+
<xs:annotation>
|
271
|
+
<xs:documentation>Version number of the resource. If the primary resource has changed the version number increases.</xs:documentation>
|
272
|
+
<xs:documentation>Register a new identifier for a major version change. Individual stewards need to determine which are major vs. minor versions. May be used in conjunction with properties 11 and 12 (AlternateIdentifier and RelatedIdentifier) to indicate various information updates. May be used in conjunction with property 17 (Description) to indicate the nature and file/record range of version.</xs:documentation>
|
273
|
+
</xs:annotation>
|
274
|
+
</xs:element>
|
275
|
+
<xs:element name="rightsList" minOccurs="0">
|
276
|
+
<xs:complexType>
|
277
|
+
<xs:sequence>
|
278
|
+
<xs:element name="rights" minOccurs="0" maxOccurs="unbounded">
|
279
|
+
<xs:annotation>
|
280
|
+
<xs:documentation>Any rights information for this resource. Provide a rights management statement for the resource or reference a service providing such information. Include embargo information if applicable.
|
281
|
+
Use the complete title of a license and include version information if applicable.</xs:documentation>
|
282
|
+
</xs:annotation>
|
283
|
+
<xs:complexType>
|
284
|
+
<xs:simpleContent>
|
285
|
+
<xs:extension base="xs:string">
|
286
|
+
<xs:attribute name="rightsURI" type="xs:anyURI" use="optional"/>
|
287
|
+
</xs:extension>
|
288
|
+
</xs:simpleContent>
|
289
|
+
</xs:complexType>
|
290
|
+
</xs:element>
|
291
|
+
</xs:sequence>
|
292
|
+
</xs:complexType>
|
293
|
+
</xs:element>
|
294
|
+
<xs:element name="descriptions" minOccurs="0">
|
295
|
+
<xs:complexType>
|
296
|
+
<xs:sequence>
|
297
|
+
<xs:element name="description" minOccurs="0" maxOccurs="unbounded">
|
298
|
+
<xs:annotation>
|
299
|
+
<xs:documentation>All additional information that does not fit in any of the other categories. May be used for technical information. It is a best practice to supply a description.</xs:documentation>
|
300
|
+
</xs:annotation>
|
301
|
+
<xs:complexType mixed="true">
|
302
|
+
<xs:choice>
|
303
|
+
<xs:element name="br" minOccurs="0" maxOccurs="unbounded">
|
304
|
+
<xs:simpleType>
|
305
|
+
<xs:restriction base="xs:string">
|
306
|
+
<xs:length value="0"/>
|
307
|
+
</xs:restriction>
|
308
|
+
</xs:simpleType>
|
309
|
+
</xs:element>
|
310
|
+
</xs:choice>
|
311
|
+
<xs:attribute name="descriptionType" type="descriptionType" use="required"/>
|
312
|
+
<xs:attribute ref="xml:lang"/>
|
313
|
+
</xs:complexType>
|
314
|
+
</xs:element>
|
315
|
+
</xs:sequence>
|
316
|
+
</xs:complexType>
|
317
|
+
</xs:element>
|
318
|
+
<xs:element name="geoLocations" minOccurs="0">
|
319
|
+
<xs:complexType>
|
320
|
+
<xs:sequence>
|
321
|
+
<xs:element name="geoLocation" minOccurs="0" maxOccurs="unbounded">
|
322
|
+
<xs:annotation>
|
323
|
+
<xs:documentation>Spatial region or named place where the data was gathered or about which the data is focused.</xs:documentation>
|
324
|
+
<xs:documentation>A point contains a single latitude-longitude pair, separated by whitespace.</xs:documentation>
|
325
|
+
<xs:documentation>A box contains two white space separated latitude-longitude pairs, with each pair separated by whitespace. The first pair is the lower corner, the second is the upper corner.</xs:documentation>
|
326
|
+
</xs:annotation>
|
327
|
+
<xs:complexType>
|
328
|
+
<xs:sequence>
|
329
|
+
<xs:element name="geoLocationPoint" type="point" minOccurs="0"/>
|
330
|
+
<xs:element name="geoLocationBox" type="box" minOccurs="0"/>
|
331
|
+
<xs:element name="geoLocationPlace" minOccurs="0"/>
|
332
|
+
</xs:sequence>
|
333
|
+
</xs:complexType>
|
334
|
+
</xs:element>
|
335
|
+
</xs:sequence>
|
336
|
+
</xs:complexType>
|
337
|
+
</xs:element>
|
338
|
+
</xs:all>
|
339
|
+
</xs:complexType>
|
340
|
+
</xs:element>
|
341
|
+
<!-- TYPE DECLARATIONS -->
|
342
|
+
<!-- defines the value for a DOI: DOI must start with "10." -->
|
343
|
+
<xs:simpleType name="doiType">
|
344
|
+
<xs:restriction base="xs:token">
|
345
|
+
<xs:pattern value="10\..+/.+"/>
|
346
|
+
</xs:restriction>
|
347
|
+
</xs:simpleType>
|
348
|
+
<!-- defines value for mandatory fields -->
|
349
|
+
<xs:simpleType name="nonemptycontentStringType">
|
350
|
+
<xs:restriction base="xs:string">
|
351
|
+
<xs:minLength value="1"/>
|
352
|
+
</xs:restriction>
|
353
|
+
</xs:simpleType>
|
354
|
+
<xs:attributeGroup name="nameId">
|
355
|
+
<xs:attribute name="nameIdentifier" type="xs:string" use="optional"/>
|
356
|
+
<xs:attribute name="nameIdentifierScheme" type="xs:string" use="optional"/>
|
357
|
+
</xs:attributeGroup>
|
358
|
+
<!-- defines the value for a year -->
|
359
|
+
<xs:simpleType name="yearType">
|
360
|
+
<xs:restriction base="xs:token">
|
361
|
+
<xs:pattern value="[\d]{4}"/>
|
362
|
+
</xs:restriction>
|
363
|
+
<!-- definitions for geoLocation -->
|
364
|
+
</xs:simpleType>
|
365
|
+
<xs:simpleType name="point">
|
366
|
+
<xs:restriction base="listOfDoubles">
|
367
|
+
<xs:minLength value="2"/>
|
368
|
+
<xs:maxLength value="2"/>
|
369
|
+
</xs:restriction>
|
370
|
+
</xs:simpleType>
|
371
|
+
<xs:simpleType name="box">
|
372
|
+
<xs:restriction base="listOfDoubles">
|
373
|
+
<xs:minLength value="4"/>
|
374
|
+
<xs:maxLength value="4"/>
|
375
|
+
</xs:restriction>
|
376
|
+
</xs:simpleType>
|
377
|
+
<xs:simpleType name="listOfDoubles">
|
378
|
+
<xs:list itemType="xs:double"/>
|
379
|
+
</xs:simpleType>
|
380
|
+
</xs:schema>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany
|
3
|
+
2013-05 v3.0: Addition of ID to simpleType element, added values "ResearchGroup" & "Other"
|
4
|
+
2014-08-20 v3.1: Addition of value "DataCurator"-->
|
5
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified">
|
6
|
+
<xs:simpleType name="contributorType" id="contributorType">
|
7
|
+
<xs:annotation>
|
8
|
+
<xs:documentation>The type of contributor of the resource.</xs:documentation>
|
9
|
+
</xs:annotation>
|
10
|
+
<xs:restriction base="xs:string">
|
11
|
+
<xs:enumeration value="ContactPerson"/>
|
12
|
+
<xs:enumeration value="DataCollector"/>
|
13
|
+
<xs:enumeration value="DataCurator"/>
|
14
|
+
<xs:enumeration value="DataManager"/>
|
15
|
+
<xs:enumeration value="Distributor"/>
|
16
|
+
<xs:enumeration value="Editor"/>
|
17
|
+
<xs:enumeration value="Funder"/>
|
18
|
+
<xs:enumeration value="HostingInstitution"/>
|
19
|
+
<xs:enumeration value="Other"/>
|
20
|
+
<xs:enumeration value="Producer"/>
|
21
|
+
<xs:enumeration value="ProjectLeader"/>
|
22
|
+
<xs:enumeration value="ProjectManager"/>
|
23
|
+
<xs:enumeration value="ProjectMember"/>
|
24
|
+
<xs:enumeration value="RegistrationAgency"/>
|
25
|
+
<xs:enumeration value="RegistrationAuthority"/>
|
26
|
+
<xs:enumeration value="RelatedPerson"/>
|
27
|
+
<xs:enumeration value="ResearchGroup"/>
|
28
|
+
<xs:enumeration value="RightsHolder"/>
|
29
|
+
<xs:enumeration value="Researcher"/>
|
30
|
+
<xs:enumeration value="Sponsor"/>
|
31
|
+
<xs:enumeration value="Supervisor"/>
|
32
|
+
<xs:enumeration value="WorkPackageLeader"/>
|
33
|
+
</xs:restriction>
|
34
|
+
</xs:simpleType>
|
35
|
+
</xs:schema>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany
|
3
|
+
2013-05 v3.0: Addition of ID to simpleType element; addition of value "Collected"; deleted "StartDate" & "EndDate"-->
|
4
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified">
|
5
|
+
<xs:simpleType name="dateType" id="dateType">
|
6
|
+
<xs:annotation>
|
7
|
+
<xs:documentation>The type of date. Use RKMS‐ISO8601 standard for depicting date ranges.To indicate the end of an embargo period, use Available. To indicate the start of an embargo period, use Submitted or Accepted, as appropriate.</xs:documentation>
|
8
|
+
</xs:annotation>
|
9
|
+
<xs:restriction base="xs:string">
|
10
|
+
<xs:enumeration value="Accepted"/>
|
11
|
+
<xs:enumeration value="Available"/>
|
12
|
+
<xs:enumeration value="Collected"/>
|
13
|
+
<xs:enumeration value="Copyrighted"/>
|
14
|
+
<xs:enumeration value="Created"/>
|
15
|
+
<xs:enumeration value="Issued"/>
|
16
|
+
<xs:enumeration value="Submitted"/>
|
17
|
+
<xs:enumeration value="Updated"/>
|
18
|
+
<xs:enumeration value="Valid"/>
|
19
|
+
</xs:restriction>
|
20
|
+
</xs:simpleType>
|
21
|
+
</xs:schema>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany
|
3
|
+
2013-05 v3.0: Addition of ID to simpleType element, addition of value "Methods"-->
|
4
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified">
|
5
|
+
<xs:simpleType name="descriptionType" id="descriptionType">
|
6
|
+
<xs:annotation>
|
7
|
+
<xs:documentation>The type of the description.</xs:documentation>
|
8
|
+
</xs:annotation>
|
9
|
+
<xs:restriction base="xs:string">
|
10
|
+
<xs:enumeration value="Abstract"/>
|
11
|
+
<xs:enumeration value="Methods"/>
|
12
|
+
<xs:enumeration value="SeriesInformation"/>
|
13
|
+
<xs:enumeration value="TableOfContents"/>
|
14
|
+
<xs:enumeration value="Other"/>
|
15
|
+
</xs:restriction>
|
16
|
+
</xs:simpleType>
|
17
|
+
</xs:schema>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany
|
3
|
+
2013-05 v3.0: Addition of ID to simpleType element; addition of value "PMID"
|
4
|
+
2014-08-20 v3.1: Addition of values "arxiv" and "bibcode"-->
|
5
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified">
|
6
|
+
<xs:simpleType name="relatedIdentifierType" id="relatedIdentifierType">
|
7
|
+
<xs:annotation>
|
8
|
+
<xs:documentation>The type of the RelatedIdentifier.</xs:documentation>
|
9
|
+
</xs:annotation>
|
10
|
+
<xs:restriction base="xs:string">
|
11
|
+
<xs:enumeration value="ARK"/>
|
12
|
+
<xs:enumeration value="arXiv"/>
|
13
|
+
<xs:enumeration value="bibcode"/>
|
14
|
+
<xs:enumeration value="DOI"/>
|
15
|
+
<xs:enumeration value="EAN13"/>
|
16
|
+
<xs:enumeration value="EISSN"/>
|
17
|
+
<xs:enumeration value="Handle"/>
|
18
|
+
<xs:enumeration value="ISBN"/>
|
19
|
+
<xs:enumeration value="ISSN"/>
|
20
|
+
<xs:enumeration value="ISTC"/>
|
21
|
+
<xs:enumeration value="LISSN"/>
|
22
|
+
<xs:enumeration value="LSID"/>
|
23
|
+
<xs:enumeration value="PMID"/>
|
24
|
+
<xs:enumeration value="PURL"/>
|
25
|
+
<xs:enumeration value="UPC"/>
|
26
|
+
<xs:enumeration value="URL"/>
|
27
|
+
<xs:enumeration value="URN"/>
|
28
|
+
</xs:restriction>
|
29
|
+
</xs:simpleType>
|
30
|
+
</xs:schema>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany
|
3
|
+
2013-05 v3.0: Addition of ID to simpleType element, addition of values "IsIdenticalTo", "HasMetadata" & "IsMetadataFor"
|
4
|
+
2014-08-20 v3.1: Addition of values "Reviews" & "IsReviewedBy" and "IsDerivedFrom" & "IsSourceOf"-->
|
5
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified">
|
6
|
+
<xs:simpleType name="relationType" id="relationType">
|
7
|
+
<xs:annotation>
|
8
|
+
<xs:documentation>Description of the relationship of the resource being registered (A) and the related resource (B).</xs:documentation>
|
9
|
+
</xs:annotation>
|
10
|
+
<xs:restriction base="xs:string">
|
11
|
+
<xs:enumeration value="IsCitedBy"/>
|
12
|
+
<xs:enumeration value="Cites"/>
|
13
|
+
<xs:enumeration value="IsSupplementTo"/>
|
14
|
+
<xs:enumeration value="IsSupplementedBy"/>
|
15
|
+
<xs:enumeration value="IsContinuedBy"/>
|
16
|
+
<xs:enumeration value="Continues"/>
|
17
|
+
<xs:enumeration value="IsNewVersionOf"/>
|
18
|
+
<xs:enumeration value="IsPreviousVersionOf"/>
|
19
|
+
<xs:enumeration value="IsPartOf"/>
|
20
|
+
<xs:enumeration value="HasPart"/>
|
21
|
+
<xs:enumeration value="IsReferencedBy"/>
|
22
|
+
<xs:enumeration value="References"/>
|
23
|
+
<xs:enumeration value="IsDocumentedBy"/>
|
24
|
+
<xs:enumeration value="Documents"/>
|
25
|
+
<xs:enumeration value="IsCompiledBy"/>
|
26
|
+
<xs:enumeration value="Compiles"/>
|
27
|
+
<xs:enumeration value="IsVariantFormOf"/>
|
28
|
+
<xs:enumeration value="IsOriginalFormOf"/>
|
29
|
+
<xs:enumeration value="IsIdenticalTo"/>
|
30
|
+
<xs:enumeration value="HasMetadata"/>
|
31
|
+
<xs:enumeration value="IsMetadataFor"/>
|
32
|
+
<xs:enumeration value="Reviews"/>
|
33
|
+
<xs:enumeration value="IsReviewedBy"/>
|
34
|
+
<xs:enumeration value="IsDerivedFrom"/>
|
35
|
+
<xs:enumeration value="IsSourceOf"/>
|
36
|
+
</xs:restriction>
|
37
|
+
</xs:simpleType>
|
38
|
+
</xs:schema>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany
|
3
|
+
2013-05 v3.0: Addition of ID to simpleType element; added values "Audiovisual", "Workflow" & "Other"; deleted value "Film" -->
|
4
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified">
|
5
|
+
<xs:simpleType name="resourceType" id="resourceType">
|
6
|
+
<xs:annotation>
|
7
|
+
<xs:documentation>The general type of a resource.</xs:documentation>
|
8
|
+
</xs:annotation>
|
9
|
+
<xs:restriction base="xs:string">
|
10
|
+
<xs:enumeration value="Audiovisual"/>
|
11
|
+
<xs:enumeration value="Collection"/>
|
12
|
+
<xs:enumeration value="Dataset"/>
|
13
|
+
<xs:enumeration value="Event"/>
|
14
|
+
<xs:enumeration value="Image"/>
|
15
|
+
<xs:enumeration value="InteractiveResource"/>
|
16
|
+
<xs:enumeration value="Model"/>
|
17
|
+
<xs:enumeration value="PhysicalObject"/>
|
18
|
+
<xs:enumeration value="Service"/>
|
19
|
+
<xs:enumeration value="Software"/>
|
20
|
+
<xs:enumeration value="Sound"/>
|
21
|
+
<xs:enumeration value="Text"/>
|
22
|
+
<xs:enumeration value="Workflow"/>
|
23
|
+
<xs:enumeration value="Other"/>
|
24
|
+
</xs:restriction>
|
25
|
+
</xs:simpleType>
|
26
|
+
</xs:schema>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany
|
3
|
+
2013-05 v3.0: Addition of ID to simpleType element-->
|
4
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified">
|
5
|
+
<xs:simpleType name="titleType" id="titleType">
|
6
|
+
<xs:restriction base="xs:string">
|
7
|
+
<xs:enumeration value="AlternativeTitle"/>
|
8
|
+
<xs:enumeration value="Subtitle"/>
|
9
|
+
<xs:enumeration value="TranslatedTitle"/>
|
10
|
+
</xs:restriction>
|
11
|
+
</xs:simpleType>
|
12
|
+
</xs:schema>
|
data/datacite_mds.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency "yard"
|
26
26
|
spec.add_development_dependency "travis"
|
27
27
|
spec.add_development_dependency "coveralls"
|
28
|
-
|
29
|
-
|
28
|
+
|
29
|
+
spec.add_dependency "nokogiri", "~> 1.6"
|
30
30
|
|
31
31
|
end
|
data/lib/datacite_mds/version.rb
CHANGED
data/lib/datacite_mds.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
require "datacite_mds/version"
|
2
2
|
require 'net/http'
|
3
3
|
require 'openssl'
|
4
|
+
require 'nokogiri'
|
4
5
|
|
5
6
|
module Datacite
|
6
7
|
|
7
8
|
ENDPOINT = 'https://mds.datacite.org/'
|
8
9
|
RESOURCES = { doi: '/doi', metadata: '/metadata', media: '/media' }
|
10
|
+
DATACITE_SCHEMA = Nokogiri::XML::Schema(File.open("data/xsd/datacite-metadata-v3.1.xsd"))
|
9
11
|
|
10
12
|
|
11
13
|
# Wraps up Mds functionality wihin an object
|
@@ -14,23 +16,24 @@ module Datacite
|
|
14
16
|
# @attr [String] username the Datacentre's authorised username
|
15
17
|
# @attr [String] passwd the Datacentre's authorised password
|
16
18
|
# @attr [Boolean] test_mode indicates whether to make APi calls
|
17
|
-
#
|
19
|
+
# in test mode
|
18
20
|
# @attr [URI] uri the object wrapping up the Datacite Endpoint
|
19
|
-
# @attr [Net::HTTP] http the object wrapping up the http
|
20
|
-
#
|
21
|
+
# @attr [Net::HTTP] http the object wrapping up the http
|
22
|
+
# connection to Datacite Endpoint
|
21
23
|
class Mds
|
22
24
|
|
25
|
+
|
23
26
|
# creates a new Mds object, passing an options hash
|
24
27
|
#
|
25
28
|
# @param options [Hash] the options to create an Mds objects with.
|
26
29
|
# @option options [Hash] :authorize Authorization includes two keys
|
27
|
-
#
|
30
|
+
# :usr [String], :pwd [String]
|
28
31
|
# @option options [String] :test_mode If true, all API calls to
|
29
|
-
#
|
32
|
+
# Datacite will occur in test mode
|
30
33
|
#
|
31
34
|
# @note If :authorize is not passed as an option , then the method
|
32
|
-
#
|
33
|
-
#
|
35
|
+
# will look for the usrname and password in environment variables
|
36
|
+
# DATACITE_USR and DATACITE_PWD.
|
34
37
|
#
|
35
38
|
def initialize(**options)
|
36
39
|
if options[:authorize]
|
@@ -48,8 +51,8 @@ module Datacite
|
|
48
51
|
# Returns a url associated with a given DOI
|
49
52
|
# @param doi [String] a Data Object identifier
|
50
53
|
# @return [Net::HTTPResponse] Succesful operation will
|
51
|
-
#
|
52
|
-
#
|
54
|
+
# return HTTPOK and the response body will contain
|
55
|
+
# the URL (String) representing the dataset.
|
53
56
|
def resolve(doi)
|
54
57
|
@uri.path = RESOURCES[:doi] + '/' + doi
|
55
58
|
@http = Net::HTTP.new(@uri.host, @uri.port)
|
@@ -59,8 +62,8 @@ module Datacite
|
|
59
62
|
|
60
63
|
# Returns a list of all DOIs for the requesting datacentre
|
61
64
|
# @return [Net::HTTPResponse] Succesful operation will
|
62
|
-
#
|
63
|
-
#
|
65
|
+
# return HTTPOK and the response body will contain
|
66
|
+
# a list (String) of all relevant DOIs.
|
64
67
|
# @note There is no guaranteed order in the list of DOIs
|
65
68
|
def get_all_dois
|
66
69
|
@uri.path = RESOURCES[:doi]
|
@@ -76,8 +79,8 @@ module Datacite
|
|
76
79
|
# @param doi [String] a Data Object Identifier
|
77
80
|
# @param url [String] the dataset's location
|
78
81
|
# @return [Net::HTTPResponse] Succesful operation will
|
79
|
-
#
|
80
|
-
#
|
82
|
+
# return HTTPCreated and the response body will
|
83
|
+
# provide a short explanation of the status code.
|
81
84
|
def mint(doi, url)
|
82
85
|
@uri.path = RESOURCES[:doi]
|
83
86
|
@http = Net::HTTP.new(@uri.host, @uri.port)
|
@@ -93,10 +96,10 @@ module Datacite
|
|
93
96
|
|
94
97
|
# Stores new version of metadata.
|
95
98
|
# @param xml_string [String] xml conforming to
|
96
|
-
#
|
99
|
+
# https://schema.datacite.org/
|
97
100
|
# @return [Net::HTTPResponse] Succesful operation will
|
98
|
-
#
|
99
|
-
#
|
101
|
+
# return HTTPCreated and the response body will
|
102
|
+
# provide a short explanation of the status code.
|
100
103
|
def upload_metadata(xml_string)
|
101
104
|
@uri.path = RESOURCES[:metadata]
|
102
105
|
@http = Net::HTTP.new(@uri.host, @uri.port)
|
@@ -113,8 +116,8 @@ module Datacite
|
|
113
116
|
# associated with the DOI.
|
114
117
|
# @param doi [String] a Data Object identifier
|
115
118
|
# @return [Net::HTTPResponse] Succesful operation will
|
116
|
-
#
|
117
|
-
#
|
119
|
+
# return HTTPOK and the response body will consist
|
120
|
+
# of XML representing a dataset's metadata.
|
118
121
|
def get_metadata(doi)
|
119
122
|
@uri.path = RESOURCES[:metadata] + '/' + doi
|
120
123
|
@http = Net::HTTP.new(@uri.host, @uri.port)
|
@@ -135,7 +138,32 @@ module Datacite
|
|
135
138
|
end
|
136
139
|
|
137
140
|
|
138
|
-
|
141
|
+
|
142
|
+
# Validates the passed XML against the Datacite XML schema v3.1.
|
143
|
+
# Method will first check the well-formedness of the XML string and
|
144
|
+
# then validate it against the Schema
|
145
|
+
# @param xml_doc [String] an XML string, representing dataset metadata
|
146
|
+
# @return Boolean True if XML is valid. If XML is invalid then the
|
147
|
+
# @errors class variable will also be set, containing the XML parser
|
148
|
+
# errors
|
149
|
+
def self.metadata_valid?(xml_doc)
|
150
|
+
|
151
|
+
begin
|
152
|
+
doc = Nokogiri::XML(xml_doc) { |config| config.strict }
|
153
|
+
rescue Nokogiri::XML::SyntaxError => e
|
154
|
+
raise ArgumentError, "Badly-formed meta-data XML: #{e.message}"
|
155
|
+
end
|
156
|
+
|
157
|
+
@errors = DATACITE_SCHEMA.validate(doc)
|
158
|
+
@errors.empty?
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
# Returns the XML parser errors, as set by metadata_valid? class method
|
163
|
+
def self.validation_errors
|
164
|
+
@errors
|
165
|
+
end
|
166
|
+
|
139
167
|
|
140
168
|
private
|
141
169
|
|
@@ -143,7 +171,7 @@ module Datacite
|
|
143
171
|
# @private
|
144
172
|
# @param request [Net::HTTPRequest] the request
|
145
173
|
# @param request_limit [FixNum] the number of times to keep
|
146
|
-
#
|
174
|
+
# requesting after each redirect
|
147
175
|
# @return [Net::HTTPResponse] the response
|
148
176
|
def fetch(request, http, request_limit = 5)
|
149
177
|
r = http.request(request)
|
@@ -158,7 +186,7 @@ module Datacite
|
|
158
186
|
# Sets SSL options on Http object
|
159
187
|
# @private
|
160
188
|
# @note this settings are required in order to use the Datacite
|
161
|
-
#
|
189
|
+
# API
|
162
190
|
def set_security
|
163
191
|
@http.use_ssl = true
|
164
192
|
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datacite_mds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Heath
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-01-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -96,19 +96,19 @@ dependencies:
|
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
|
-
name:
|
99
|
+
name: nokogiri
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- - "
|
102
|
+
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: '
|
105
|
-
type: :
|
104
|
+
version: '1.6'
|
105
|
+
type: :runtime
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- - "
|
109
|
+
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: '
|
111
|
+
version: '1.6'
|
112
112
|
description: The MDS is a service for data publishers to mint DOIs and register associated
|
113
113
|
metadata. It is aimed mainly at scientific and research data publishers. This gem
|
114
114
|
allows for simple and seamless interaction with this service.
|
@@ -128,6 +128,14 @@ files:
|
|
128
128
|
- Rakefile
|
129
129
|
- bin/console
|
130
130
|
- bin/setup
|
131
|
+
- data/xsd/datacite-metadata-v3.1.xsd
|
132
|
+
- data/xsd/include/datacite-contributorType-v3.1.xsd
|
133
|
+
- data/xsd/include/datacite-dateType-v3.xsd
|
134
|
+
- data/xsd/include/datacite-descriptionType-v3.xsd
|
135
|
+
- data/xsd/include/datacite-relatedIdentifierType-v3.1.xsd
|
136
|
+
- data/xsd/include/datacite-relationType-v3.1.xsd
|
137
|
+
- data/xsd/include/datacite-resourceType-v3.xsd
|
138
|
+
- data/xsd/include/datacite-titleType-v3.xsd
|
131
139
|
- datacite_mds.gemspec
|
132
140
|
- lib/datacite_mds.rb
|
133
141
|
- lib/datacite_mds/version.rb
|