mods 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/lib/mods/nom_terminology.rb +248 -249
- data/lib/mods/reader.rb +2 -4
- data/lib/mods/record.rb +5 -1
- data/lib/mods/version.rb +1 -1
- data/mods.gemspec +4 -4
- data/spec/language_spec.rb +30 -30
- data/spec/location_spec.rb +44 -44
- data/spec/name_spec.rb +155 -155
- data/spec/origin_info_spec.rb +32 -32
- data/spec/part_spec.rb +122 -122
- data/spec/physical_description_spec.rb +18 -18
- data/spec/reader_spec.rb +41 -40
- data/spec/record_info_spec.rb +120 -120
- data/spec/record_spec.rb +63 -58
- data/spec/related_item_spec.rb +76 -76
- data/spec/subject_spec.rb +165 -165
- data/spec/title_spec.rb +44 -44
- data/spec/top_level_elmnts_simple_spec.rb +61 -61
- metadata +28 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbfc453c27c3716eb928f59f53b2657c0fe246ab
|
4
|
+
data.tar.gz: b5c4b5eae1e685f381bd2ace70e6f9fb4b21fb1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 391b47928854bcb135a0e44c7a05c38ec71695b7a2a86a147ad1aa86e973225f73179a8d7e7bc8f198b489e8f77fac90c1dbd0ca2b144d5f4440d61a2a63c90e
|
7
|
+
data.tar.gz: ec5f06c7246778c9f923717c8fd22b466d30d0cdc7cba2665c69800c4bf23a139f065902a1c556a24928417cae680859e1f18b6468863e5208b1c477e73c7b05
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/lib/mods/nom_terminology.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
module Mods
|
2
|
-
|
2
|
+
|
3
3
|
# from: http://www.loc.gov/standards/mods/v3/mods-userguide-generalapp.html
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
4
|
+
|
5
|
+
# Nokogiri 1.6.6 introduced lang as a built-in attribute
|
6
|
+
LANG_ATTRIBS = (Nokogiri::VERSION < "1.6.6") ?
|
7
|
+
['script', 'transliteration', 'lang'] :
|
8
|
+
['script', 'transliteration']
|
9
|
+
|
11
10
|
LINKING_ATTRIBS = ['xlink', 'ID']
|
12
11
|
|
13
12
|
DATE_ATTRIBS = ['encoding', 'point', 'keyDate', 'qualifier']
|
@@ -15,69 +14,69 @@ module Mods
|
|
15
14
|
POINT_ATTRIB_VALUES = ['start', 'end']
|
16
15
|
KEY_DATE_ATTRIB_VALUES = ['yes']
|
17
16
|
QUALIFIER_ATTRIB_VALUES = ['approximate', 'inferred', 'questionable']
|
18
|
-
|
17
|
+
|
19
18
|
AUTHORITY_ATTRIBS = ['authority', 'authorityURI', 'valueURI']
|
20
19
|
|
21
20
|
class Record
|
22
|
-
|
21
|
+
|
23
22
|
# set the NOM terminology; WITH namespaces
|
24
23
|
# NOTES:
|
25
24
|
# 1. certain words, such as 'type' 'name' 'description' are reserved words in jruby or nokogiri
|
26
|
-
# when the terminology would use these words, a suffix of '_at' is added if it is an attribute,
|
25
|
+
# when the terminology would use these words, a suffix of '_at' is added if it is an attribute,
|
27
26
|
# (e.g. 'type_at' for @type) and a suffix of '_el' is added if it is an element.
|
28
|
-
# 2. the underscore prefix variant terms are a way of making subterms for a node available
|
27
|
+
# 2. the underscore prefix variant terms are a way of making subterms for a node available
|
29
28
|
# to any instance of said node and are not intended to be used externally
|
30
29
|
# @param mods_ng_xml a Nokogiri::Xml::Document object containing MODS (with namespaces)
|
31
30
|
def set_terminology_ns(mods_ng_xml)
|
32
31
|
mods_ng_xml.set_terminology(:namespaces => { 'm' => Mods::MODS_NS }) do |t|
|
33
32
|
|
34
|
-
# FIXME: may want to deal with camelcase vs. underscore in method_missing
|
33
|
+
# FIXME: may want to deal with camelcase vs. underscore in method_missing
|
35
34
|
|
36
35
|
# ABSTRACT -------------------------------------------------------------------------------
|
37
|
-
t.abstract
|
36
|
+
t.abstract :path => '/m:mods/m:abstract'
|
38
37
|
t._abstract :path => '//m:abstract' do |n|
|
39
38
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
40
|
-
n.type_at
|
39
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
41
40
|
Mods::LANG_ATTRIBS.each { |attr_name|
|
42
41
|
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
43
42
|
}
|
44
43
|
end
|
45
44
|
|
46
45
|
# ACCESS_CONDITION -----------------------------------------------------------------------
|
47
|
-
t.accessCondition
|
46
|
+
t.accessCondition :path => '/m:mods/m:accessCondition'
|
48
47
|
t._accessCondition :path => '//m:accessCondition' do |n|
|
49
|
-
n.displayLabel
|
50
|
-
n.type_at
|
48
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
49
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
51
50
|
Mods::LANG_ATTRIBS.each { |attr_name|
|
52
51
|
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
53
52
|
}
|
54
53
|
end
|
55
54
|
|
56
55
|
# CLASSIFICATION -------------------------------------------------------------------------
|
57
|
-
t.classification
|
56
|
+
t.classification :path => '/m:mods/m:classification'
|
58
57
|
t._classification :path => '//m:classification' do |n|
|
59
|
-
n.displayLabel
|
60
|
-
n.edition
|
58
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
59
|
+
n.edition :path => '@edition', :accessor => lambda { |a| a.text }
|
61
60
|
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
62
61
|
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
63
62
|
}
|
64
63
|
Mods::LANG_ATTRIBS.each { |attr_name|
|
65
64
|
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
66
65
|
}
|
67
|
-
end
|
66
|
+
end
|
68
67
|
|
69
68
|
# EXTENSION ------------------------------------------------------------------------------
|
70
|
-
t.extension
|
69
|
+
t.extension :path => '/m:mods/m:extension'
|
71
70
|
t._extension :path => '//m:extension' do |n|
|
72
71
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
73
72
|
end
|
74
73
|
|
75
74
|
# GENRE ----------------------------------------------------------------------------------
|
76
|
-
t.genre
|
75
|
+
t.genre :path => '/m:mods/m:genre'
|
77
76
|
t._genre :path => '//m:genre' do |n|
|
78
77
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
79
|
-
n.type_at
|
80
|
-
n.usage
|
78
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
79
|
+
n.usage :path => '@usage', :accessor => lambda { |a| a.text }
|
81
80
|
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
82
81
|
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
83
82
|
}
|
@@ -87,18 +86,18 @@ module Mods
|
|
87
86
|
end
|
88
87
|
|
89
88
|
# IDENTIIER ------------------------------------------------------------------------------
|
90
|
-
t.identifier
|
89
|
+
t.identifier :path => '/m:mods/m:identifier'
|
91
90
|
t._identifier :path => '//m:identifier' do |n|
|
92
91
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
93
|
-
n.invalid
|
94
|
-
n.type_at
|
92
|
+
n.invalid :path => '@invalid', :accessor => lambda { |a| a.text }
|
93
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
95
94
|
Mods::LANG_ATTRIBS.each { |attr_name|
|
96
95
|
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
97
96
|
}
|
98
97
|
end
|
99
98
|
|
100
99
|
# LANGUAGE -------------------------------------------------------------------------------
|
101
|
-
t.language
|
100
|
+
t.language :path => '/m:mods/m:language'
|
102
101
|
t._language :path => '//m:language' do |n|
|
103
102
|
# attributes
|
104
103
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
@@ -107,19 +106,19 @@ module Mods
|
|
107
106
|
}
|
108
107
|
# child elements
|
109
108
|
n.languageTerm :path => 'm:languageTerm'
|
110
|
-
n.code_term
|
111
|
-
n.text_term
|
112
|
-
n.scriptTerm
|
109
|
+
n.code_term :path => 'm:languageTerm[@type="code"]'
|
110
|
+
n.text_term :path => 'm:languageTerm[@type="text"]'
|
111
|
+
n.scriptTerm :path => 'm:scriptTerm'
|
113
112
|
end
|
114
113
|
t._languageTerm :path => '//m:languageTerm' do |lt|
|
115
|
-
lt.type_at
|
114
|
+
lt.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
116
115
|
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
117
116
|
lt.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
118
117
|
}
|
119
118
|
end # t.language
|
120
119
|
|
121
120
|
# LOCATION -------------------------------------------------------------------------------
|
122
|
-
t.location
|
121
|
+
t.location :path => '/m:mods/m:location'
|
123
122
|
t._location :path => '//m:location' do |n|
|
124
123
|
# attributes
|
125
124
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
@@ -128,7 +127,7 @@ module Mods
|
|
128
127
|
}
|
129
128
|
# child elements
|
130
129
|
n.physicalLocation :path => 'm:physicalLocation' do |e|
|
131
|
-
e.displayLabel
|
130
|
+
e.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
132
131
|
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
133
132
|
e.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
134
133
|
}
|
@@ -136,17 +135,17 @@ module Mods
|
|
136
135
|
n.shelfLocator :path => 'm:shelfLocator'
|
137
136
|
n.url :path => 'm:url' do |e|
|
138
137
|
e.dateLastAccessed :path => '@dateLastAccessed', :accessor => lambda { |a| a.text }
|
139
|
-
e.displayLabel
|
140
|
-
e.note
|
138
|
+
e.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
139
|
+
e.note :path => '@note', :accessor => lambda { |a| a.text }
|
141
140
|
e.access :path => '@access', :accessor => lambda { |a| a.text }
|
142
|
-
e.usage
|
141
|
+
e.usage :path => '@usage', :accessor => lambda { |a| a.text }
|
143
142
|
end
|
144
|
-
n.holdingSimple
|
143
|
+
n.holdingSimple :path => 'm:holdingSimple'
|
145
144
|
n.holdingExternal :path => 'm:holdingExternal'
|
146
145
|
end # t.location
|
147
146
|
|
148
147
|
# NAME ------------------------------------------------------------------------------------
|
149
|
-
t.plain_name
|
148
|
+
t.plain_name :path => '/m:mods/m:name'
|
150
149
|
t._plain_name :path => '//m:name' do |n|
|
151
150
|
Mods::Name::ATTRIBUTES.each { |attr_name|
|
152
151
|
if attr_name != 'type'
|
@@ -159,15 +158,15 @@ module Mods
|
|
159
158
|
n.namePart :path => 'm:namePart' do |np|
|
160
159
|
np.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
161
160
|
end
|
162
|
-
n.family_name
|
163
|
-
n.given_name
|
161
|
+
n.family_name :path => 'm:namePart[@type="family"]'
|
162
|
+
n.given_name :path => 'm:namePart[@type="given"]'
|
164
163
|
n.termsOfAddress :path => 'm:namePart[@type="termsOfAddress"]'
|
165
|
-
n.date
|
166
|
-
|
164
|
+
n.date :path => 'm:namePart[@type="date"]'
|
165
|
+
|
167
166
|
n.displayForm :path => 'm:displayForm'
|
168
167
|
n.affiliation :path => 'm:affiliation'
|
169
168
|
n.description_el :path => 'm:description' # description is used by Nokogiri
|
170
|
-
n.role :path => 'm:role' do |r|
|
169
|
+
n.role :path => 'm:role' do |r|
|
171
170
|
r.roleTerm :path => 'm:roleTerm' do |rt|
|
172
171
|
rt.type_at :path => "@type", :accessor => lambda { |a| a.text }
|
173
172
|
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
@@ -175,7 +174,7 @@ module Mods
|
|
175
174
|
}
|
176
175
|
end
|
177
176
|
# role convenience method
|
178
|
-
r.authority :path => '.', :accessor => lambda { |role_node|
|
177
|
+
r.authority :path => '.', :accessor => lambda { |role_node|
|
179
178
|
a = nil
|
180
179
|
role_node.roleTerm.each { |role_t|
|
181
180
|
# role_t.authority will be [] if it is missing from an earlier roleTerm
|
@@ -185,10 +184,10 @@ module Mods
|
|
185
184
|
}
|
186
185
|
a
|
187
186
|
}
|
188
|
-
# role convenience method
|
189
|
-
r.code :path => '.', :accessor => lambda { |role_node|
|
187
|
+
# role convenience method
|
188
|
+
r.code :path => '.', :accessor => lambda { |role_node|
|
190
189
|
c = nil
|
191
|
-
role_node.roleTerm.each { |role_t|
|
190
|
+
role_node.roleTerm.each { |role_t|
|
192
191
|
if role_t.type_at == 'code'
|
193
192
|
c ||= role_t.text
|
194
193
|
end
|
@@ -196,9 +195,9 @@ module Mods
|
|
196
195
|
c
|
197
196
|
}
|
198
197
|
# role convenience method
|
199
|
-
r.value :path => '.', :accessor => lambda { |role_node|
|
198
|
+
r.value :path => '.', :accessor => lambda { |role_node|
|
200
199
|
val = nil
|
201
|
-
role_node.roleTerm.each { |role_t|
|
200
|
+
role_node.roleTerm.each { |role_t|
|
202
201
|
if role_t.type_at == 'text'
|
203
202
|
val ||= role_t.text
|
204
203
|
end
|
@@ -210,7 +209,7 @@ module Mods
|
|
210
209
|
val
|
211
210
|
}
|
212
211
|
end # role node
|
213
|
-
|
212
|
+
|
214
213
|
# name convenience method
|
215
214
|
# uses the displayForm of a name if present
|
216
215
|
# if no displayForm, try to make a string from family, given and terms of address
|
@@ -229,7 +228,7 @@ module Mods
|
|
229
228
|
end
|
230
229
|
if !dv.empty?
|
231
230
|
first = true
|
232
|
-
name_node.namePart.each { |np|
|
231
|
+
name_node.namePart.each { |np|
|
233
232
|
if np.type_at == 'termsOfAddress' && !np.text.empty?
|
234
233
|
if first
|
235
234
|
dv = dv + " " + np.text
|
@@ -239,7 +238,7 @@ module Mods
|
|
239
238
|
end
|
240
239
|
end
|
241
240
|
}
|
242
|
-
else # no family or given name
|
241
|
+
else # no family or given name
|
243
242
|
dv = name_node.namePart.select {|np| np.type_at != 'date' && !np.text.empty?}.join(" ")
|
244
243
|
end
|
245
244
|
else # not a personal name
|
@@ -248,12 +247,12 @@ module Mods
|
|
248
247
|
end
|
249
248
|
dv.strip.empty? ? nil : dv.strip
|
250
249
|
}
|
251
|
-
|
250
|
+
|
252
251
|
# name convenience method
|
253
252
|
n.display_value_w_date :path => '.', :single => true, :accessor => lambda {|name_node|
|
254
|
-
dv = ''
|
253
|
+
dv = ''
|
255
254
|
dv = dv + name_node.display_value if name_node.display_value
|
256
|
-
name_node.namePart.each { |np|
|
255
|
+
name_node.namePart.each { |np|
|
257
256
|
if np.type_at == 'date' && !np.text.empty? && !dv.end_with?(np.text)
|
258
257
|
dv = dv + ", #{np.text}"
|
259
258
|
end
|
@@ -265,19 +264,19 @@ module Mods
|
|
265
264
|
}
|
266
265
|
end # t._plain_name
|
267
266
|
|
268
|
-
t.personal_name
|
269
|
-
t._personal_name
|
270
|
-
t.corporate_name
|
271
|
-
t._corporate_name
|
272
|
-
t.conference_name
|
267
|
+
t.personal_name :path => '/m:mods/m:name[@type="personal"]'
|
268
|
+
t._personal_name :path => '//m:name[@type="personal"]'
|
269
|
+
t.corporate_name :path => '/m:mods/m:name[@type="corporate"]'
|
270
|
+
t._corporate_name :path => '//m:name[@type="corporate"]'
|
271
|
+
t.conference_name :path => '/m:mods/m:name[@type="conference"]'
|
273
272
|
t._conference_name :path => '//m:name[@type="conference"]'
|
274
273
|
|
275
274
|
# NOTE ---------------------------------------------------------------------------------
|
276
275
|
t.note :path => '/m:mods/m:note'
|
277
276
|
t._note :path => '//m:note' do |n|
|
278
277
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
279
|
-
n.id_at
|
280
|
-
n.type_at
|
278
|
+
n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
|
279
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
281
280
|
Mods::LANG_ATTRIBS.each { |attr_name|
|
282
281
|
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
283
282
|
}
|
@@ -311,8 +310,8 @@ module Mods
|
|
311
310
|
end
|
312
311
|
end
|
313
312
|
}
|
314
|
-
n.edition
|
315
|
-
n.issuance
|
313
|
+
n.edition :path => 'm:edition'
|
314
|
+
n.issuance :path => 'm:issuance'
|
316
315
|
n.frequency :path => 'm:frequency' do |f|
|
317
316
|
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
318
317
|
f.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
@@ -321,12 +320,12 @@ module Mods
|
|
321
320
|
end # t.origin_info
|
322
321
|
|
323
322
|
# PART -----------------------------------------------------------------------------------
|
324
|
-
t.part
|
323
|
+
t.part :path => '/m:mods/m:part'
|
325
324
|
t._part :path => '//m:part' do |n|
|
326
325
|
# attributes
|
327
|
-
n.id_at
|
328
|
-
n.order
|
329
|
-
n.type_at
|
326
|
+
n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
|
327
|
+
n.order :path => '@order', :accessor => lambda { |a| a.text }
|
328
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
330
329
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
331
330
|
Mods::LANG_ATTRIBS.each { |attr_name|
|
332
331
|
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
@@ -334,35 +333,35 @@ module Mods
|
|
334
333
|
# child elements
|
335
334
|
n.detail :path => 'm:detail' do |e|
|
336
335
|
# attributes
|
337
|
-
e.level
|
338
|
-
e.type_at :path => '@type',
|
336
|
+
e.level :path => '@level', :accessor => lambda { |a| a.text }
|
337
|
+
e.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
339
338
|
# elements
|
340
|
-
e.number
|
339
|
+
e.number :path => 'm:number'
|
341
340
|
e.caption :path => 'm:caption'
|
342
|
-
e.title
|
341
|
+
e.title :path => 'm:title'
|
343
342
|
end
|
344
|
-
n.extent
|
343
|
+
n.extent :path => 'm:extent' do |e| # TODO: extent is ordered in xml schema
|
345
344
|
# attributes
|
346
|
-
e.unit
|
345
|
+
e.unit :path => '@unit', :accessor => lambda { |a| a.text }
|
347
346
|
# elements
|
348
347
|
e.start :path => 'm:start'
|
349
|
-
e.end
|
348
|
+
e.end :path => 'm:end'
|
350
349
|
e.total :path => 'm:total'
|
351
|
-
e.list
|
350
|
+
e.list :path => 'm:list'
|
352
351
|
end
|
353
|
-
n.date :path => 'm:date' do |e|
|
352
|
+
n.date :path => 'm:date' do |e|
|
354
353
|
Mods::DATE_ATTRIBS.reject { |a| a == 'keyDate' }.each { |attr_name|
|
355
354
|
e.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
356
355
|
}
|
357
356
|
end
|
358
|
-
n.text_el :path => 'm:text' do |e|
|
357
|
+
n.text_el :path => 'm:text' do |e|
|
359
358
|
e.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
360
|
-
e.type_at
|
359
|
+
e.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
361
360
|
end
|
362
361
|
end # t._part
|
363
362
|
|
364
363
|
# PHYSICAL_DESCRIPTION -------------------------------------------------------------------
|
365
|
-
t.physical_description
|
364
|
+
t.physical_description :path => '/m:mods/m:physicalDescription'
|
366
365
|
t._physical_description :path => '//m:physicalDescription' do |n|
|
367
366
|
# attributes
|
368
367
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
@@ -387,7 +386,7 @@ module Mods
|
|
387
386
|
end
|
388
387
|
|
389
388
|
# RECORD_INFO --------------------------------------------------------------------------
|
390
|
-
t.record_info
|
389
|
+
t.record_info :path => '/m:mods/m:recordInfo'
|
391
390
|
t._record_info :path => '//m:recordInfo' do |n|
|
392
391
|
# attributes
|
393
392
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
@@ -432,35 +431,35 @@ module Mods
|
|
432
431
|
t.related_item :path => '/m:mods/m:relatedItem' do |n|
|
433
432
|
# attributes
|
434
433
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
435
|
-
n.id_at
|
436
|
-
n.type_at
|
434
|
+
n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
|
435
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
437
436
|
# elements
|
438
|
-
n.abstract
|
437
|
+
n.abstract :path => 'abstract'
|
439
438
|
n.accessCondition :path => 'm:accessCondition'
|
440
|
-
n.classification
|
441
|
-
n.extension
|
442
|
-
n.genre
|
443
|
-
n.identifier
|
444
|
-
n.language
|
445
|
-
n.location
|
446
|
-
n.name_el
|
447
|
-
n.personal_name
|
448
|
-
n.corporate_name
|
439
|
+
n.classification :path => 'm:classification'
|
440
|
+
n.extension :path => 'm:extension'
|
441
|
+
n.genre :path => 'm:genre'
|
442
|
+
n.identifier :path => 'm:identifier'
|
443
|
+
n.language :path => 'm:language'
|
444
|
+
n.location :path => 'm:location'
|
445
|
+
n.name_el :path => 'm:name' # Note: 'name' is used by Nokogiri
|
446
|
+
n.personal_name :path => 'm:name[@type="personal"]'
|
447
|
+
n.corporate_name :path => 'm:name[@type="corporate"]'
|
449
448
|
n.conference_name :path => 'm:name[@type="conference"]'
|
450
|
-
n.note
|
451
|
-
n.originInfo
|
452
|
-
n.part
|
449
|
+
n.note :path => 'm:note'
|
450
|
+
n.originInfo :path => 'm:originInfo'
|
451
|
+
n.part :path => 'm:part'
|
453
452
|
n.physicalDescription :path => 'm:physicalDescription'
|
454
|
-
n.recordInfo
|
455
|
-
n.subject
|
453
|
+
n.recordInfo :path => 'm:recordInfo'
|
454
|
+
n.subject :path => 'm:subject'
|
456
455
|
n.tableOfContents :path => 'm:tableOfContents'
|
457
|
-
n.targetAudience
|
458
|
-
n.titleInfo
|
459
|
-
n.typeOfResource
|
456
|
+
n.targetAudience :path => 'm:targetAudience'
|
457
|
+
n.titleInfo :path => 'm:titleInfo'
|
458
|
+
n.typeOfResource :path => 'm:typeOfResource'
|
460
459
|
end
|
461
460
|
|
462
461
|
# SUBJECT -----------------------------------------------------------------------------
|
463
|
-
t.subject
|
462
|
+
t.subject :path => '/m:mods/m:subject'
|
464
463
|
t._subject :path => '//m:subject' do |n|
|
465
464
|
# attributes
|
466
465
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
@@ -471,9 +470,9 @@ module Mods
|
|
471
470
|
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
472
471
|
}
|
473
472
|
# child elements
|
474
|
-
n.cartographics
|
475
|
-
n1.scale
|
476
|
-
n1.projection
|
473
|
+
n.cartographics :path => 'm:cartographics' do |n1|
|
474
|
+
n1.scale :path => 'm:scale'
|
475
|
+
n1.projection :path => 'm:projection'
|
477
476
|
n1.coordinates :path => 'm:coordinates'
|
478
477
|
Mods::Subject::CARTOGRAPHICS_CHILD_ELEMENTS.each { |elname|
|
479
478
|
n1.send elname, :path => "m:#{elname}"
|
@@ -494,7 +493,7 @@ module Mods
|
|
494
493
|
gc.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
495
494
|
}
|
496
495
|
# convenience method
|
497
|
-
gc.translated_value :path => '.', :accessor => lambda { |gc_node|
|
496
|
+
gc.translated_value :path => '.', :accessor => lambda { |gc_node|
|
498
497
|
code_val ||= gc_node.text
|
499
498
|
xval = nil
|
500
499
|
if code_val
|
@@ -522,10 +521,10 @@ module Mods
|
|
522
521
|
t1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
523
522
|
}
|
524
523
|
end
|
525
|
-
n.personal_name
|
526
|
-
n.corporate_name
|
524
|
+
n.personal_name :path => 'm:name[@type="personal"]'
|
525
|
+
n.corporate_name :path => 'm:name[@type="corporate"]'
|
527
526
|
n.conference_name :path => 'm:name[@type="conference"]'
|
528
|
-
n.occupation
|
527
|
+
n.occupation :path => 'm:occupation' do |n1|
|
529
528
|
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
530
529
|
n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
531
530
|
}
|
@@ -552,20 +551,20 @@ module Mods
|
|
552
551
|
end # t.subject
|
553
552
|
|
554
553
|
# TABLE_OF_CONTENTS ---------------------------------------------------------------------
|
555
|
-
t.tableOfContents
|
554
|
+
t.tableOfContents :path => '/m:mods/m:tableOfContents'
|
556
555
|
t._tableOfContents :path => '//m:tableOfContents' do |n|
|
557
|
-
n.displayLabel
|
558
|
-
n.shareable
|
559
|
-
n.type_at
|
556
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
557
|
+
n.shareable :path => '@shareable', :accessor => lambda { |a| a.text }
|
558
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
560
559
|
Mods::LANG_ATTRIBS.each { |attr_name|
|
561
560
|
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
562
561
|
}
|
563
562
|
end
|
564
563
|
|
565
564
|
# TARGET_AUDIENCE -----------------------------------------------------------------------
|
566
|
-
t.targetAudience
|
565
|
+
t.targetAudience :path => '/m:mods/m:targetAudience'
|
567
566
|
t._targetAudience :path => '//m:targetAudience' do |n|
|
568
|
-
n.displayLabel
|
567
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
569
568
|
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
570
569
|
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
571
570
|
}
|
@@ -575,7 +574,7 @@ module Mods
|
|
575
574
|
end
|
576
575
|
|
577
576
|
# TITLE_INFO ----------------------------------------------------------------------------
|
578
|
-
t.title_info
|
577
|
+
t.title_info :path => '/m:mods/m:titleInfo'
|
579
578
|
t._title_info :path => '//m:titleInfo' do |n|
|
580
579
|
Mods::TitleInfo::ATTRIBUTES.each { |attr_name|
|
581
580
|
if attr_name != 'type'
|
@@ -583,114 +582,114 @@ module Mods
|
|
583
582
|
else
|
584
583
|
n.type_at :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
585
584
|
end
|
586
|
-
}
|
587
|
-
n.title
|
588
|
-
n.subTitle
|
589
|
-
n.nonSort
|
585
|
+
}
|
586
|
+
n.title :path => 'm:title'
|
587
|
+
n.subTitle :path => 'm:subTitle'
|
588
|
+
n.nonSort :path => 'm:nonSort'
|
590
589
|
n.partNumber :path => 'm:partNumber'
|
591
|
-
n.partName
|
590
|
+
n.partName :path => 'm:partName'
|
592
591
|
# convenience method
|
593
|
-
n.sort_title :path => '.', :accessor => lambda { |node|
|
594
|
-
if node.type_at != "alternative" || (node.type_at == "alternative" &&
|
592
|
+
n.sort_title :path => '.', :accessor => lambda { |node|
|
593
|
+
if node.type_at != "alternative" || (node.type_at == "alternative" &&
|
595
594
|
mods_ng_xml.xpath('/m:mods/m:titleInfo', {'m' => Mods::MODS_NS}).size == 1)
|
596
|
-
node.title.text + (!node.subTitle.text.empty? ? "#{@title_delimiter}#{node.subTitle.text}" : "" )
|
595
|
+
node.title.text + (!node.subTitle.text.empty? ? "#{@title_delimiter}#{node.subTitle.text}" : "" )
|
597
596
|
end
|
598
597
|
}
|
599
598
|
# convenience method
|
600
|
-
n.full_title :path => '.', :accessor => lambda { |node|
|
601
|
-
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
602
|
-
node.title.text +
|
603
|
-
(!node.subTitle.text.empty? ? "#{@title_delimiter}#{node.subTitle.text}" : "" )
|
599
|
+
n.full_title :path => '.', :accessor => lambda { |node|
|
600
|
+
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
601
|
+
node.title.text +
|
602
|
+
(!node.subTitle.text.empty? ? "#{@title_delimiter}#{node.subTitle.text}" : "" )
|
604
603
|
}
|
605
604
|
# convenience method
|
606
|
-
n.short_title :path => '.', :accessor => lambda { |node|
|
605
|
+
n.short_title :path => '.', :accessor => lambda { |node|
|
607
606
|
if node.type_at != "alternative"
|
608
|
-
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
607
|
+
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
609
608
|
node.title.text
|
610
609
|
end
|
611
610
|
}
|
612
611
|
# convenience method
|
613
|
-
n.alternative_title :path => '.', :accessor => lambda { |node|
|
612
|
+
n.alternative_title :path => '.', :accessor => lambda { |node|
|
614
613
|
if node.type_at == "alternative"
|
615
|
-
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
614
|
+
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
616
615
|
node.title.text
|
617
616
|
end
|
618
617
|
}
|
619
618
|
end # t._title_info
|
620
619
|
|
621
620
|
# TYPE_OF_RESOURCE --------------------------------------------------------------------
|
622
|
-
t.typeOfResource
|
621
|
+
t.typeOfResource :path => '/m:mods/m:typeOfResource'
|
623
622
|
t._typeOfResource :path => '//m:typeOfResource' do |n|
|
624
|
-
n.collection
|
625
|
-
n.displayLabel
|
626
|
-
n.manuscript
|
627
|
-
n.usage
|
623
|
+
n.collection :path => '@collection', :accessor => lambda { |a| a.text }
|
624
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
625
|
+
n.manuscript :path => '@manuscript', :accessor => lambda { |a| a.text }
|
626
|
+
n.usage :path => '@usage', :accessor => lambda { |a| a.text }
|
628
627
|
end
|
629
628
|
|
630
629
|
end # terminology
|
631
|
-
|
632
|
-
mods_ng_xml.nom!
|
630
|
+
|
631
|
+
mods_ng_xml.nom!
|
633
632
|
mods_ng_xml
|
634
633
|
end # set_terminology_ns
|
635
|
-
|
634
|
+
|
636
635
|
# set the NOM terminology; do NOT use namespaces
|
637
636
|
# NOTES:
|
638
637
|
# 1. certain words, such as 'type' 'name' 'description' are reserved words in jruby or nokogiri
|
639
|
-
# when the terminology would use these words, a suffix of '_at' is added if it is an attribute,
|
638
|
+
# when the terminology would use these words, a suffix of '_at' is added if it is an attribute,
|
640
639
|
# (e.g. 'type_at' for @type) and a suffix of '_el' is added if it is an element.
|
641
|
-
# 2. the underscore prefix variant terms are a way of making subterms for a node available
|
640
|
+
# 2. the underscore prefix variant terms are a way of making subterms for a node available
|
642
641
|
# to any instance of said node and are not intended to be used externally
|
643
642
|
# @param mods_ng_xml a Nokogiri::Xml::Document object containing MODS (without namespaces)
|
644
643
|
def set_terminology_no_ns(mods_ng_xml)
|
645
644
|
mods_ng_xml.set_terminology() do |t|
|
646
645
|
|
647
|
-
# FIXME: may want to deal with camelcase vs. underscore in method_missing
|
646
|
+
# FIXME: may want to deal with camelcase vs. underscore in method_missing
|
648
647
|
|
649
648
|
# ABSTRACT -------------------------------------------------------------------------------
|
650
|
-
t.abstract
|
649
|
+
t.abstract :path => '/mods/abstract'
|
651
650
|
t._abstract :path => '//abstract' do |n|
|
652
651
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
653
|
-
n.type_at
|
652
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
654
653
|
Mods::LANG_ATTRIBS.each { |attr_name|
|
655
654
|
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
656
655
|
}
|
657
656
|
end
|
658
657
|
|
659
658
|
# ACCESS_CONDITION -----------------------------------------------------------------------
|
660
|
-
t.accessCondition
|
659
|
+
t.accessCondition :path => '/mods/accessCondition'
|
661
660
|
t._accessCondition :path => '//accessCondition' do |n|
|
662
661
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
663
|
-
n.type_at
|
662
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
664
663
|
Mods::LANG_ATTRIBS.each { |attr_name|
|
665
664
|
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
666
665
|
}
|
667
666
|
end
|
668
667
|
|
669
668
|
# CLASSIFICATION -------------------------------------------------------------------------
|
670
|
-
t.classification
|
669
|
+
t.classification :path => '/mods/classification'
|
671
670
|
t._classification :path => '//classification' do |n|
|
672
|
-
n.displayLabel
|
673
|
-
n.edition
|
671
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
672
|
+
n.edition :path => '@edition', :accessor => lambda { |a| a.text }
|
674
673
|
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
675
674
|
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
676
675
|
}
|
677
676
|
Mods::LANG_ATTRIBS.each { |attr_name|
|
678
677
|
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
679
678
|
}
|
680
|
-
end
|
679
|
+
end
|
681
680
|
|
682
681
|
# EXTENSION ------------------------------------------------------------------------------
|
683
|
-
t.extension
|
682
|
+
t.extension :path => '/mods/extension'
|
684
683
|
t._extension :path => '//extension' do |n|
|
685
684
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
686
685
|
end
|
687
686
|
|
688
687
|
# GENRE ----------------------------------------------------------------------------------
|
689
|
-
t.genre
|
688
|
+
t.genre :path => '/mods/genre'
|
690
689
|
t._genre :path => '//genre' do |n|
|
691
690
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
692
691
|
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
693
|
-
n.usage
|
692
|
+
n.usage :path => '@usage', :accessor => lambda { |a| a.text }
|
694
693
|
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
695
694
|
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
696
695
|
}
|
@@ -700,7 +699,7 @@ module Mods
|
|
700
699
|
end
|
701
700
|
|
702
701
|
# IDENTIIER ------------------------------------------------------------------------------
|
703
|
-
t.identifier
|
702
|
+
t.identifier :path => '/mods/identifier'
|
704
703
|
t._identifier :path => '//identifier' do |n|
|
705
704
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
706
705
|
n.invalid :path => '@invalid', :accessor => lambda { |a| a.text }
|
@@ -711,7 +710,7 @@ module Mods
|
|
711
710
|
end
|
712
711
|
|
713
712
|
# LANGUAGE -------------------------------------------------------------------------------
|
714
|
-
t.language
|
713
|
+
t.language :path => '/mods/language'
|
715
714
|
t._language :path => '//language' do |n|
|
716
715
|
# attributes
|
717
716
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
@@ -720,9 +719,9 @@ module Mods
|
|
720
719
|
}
|
721
720
|
# child elements
|
722
721
|
n.languageTerm :path => 'languageTerm'
|
723
|
-
n.code_term
|
724
|
-
n.text_term
|
725
|
-
n.scriptTerm
|
722
|
+
n.code_term :path => 'languageTerm[@type="code"]'
|
723
|
+
n.text_term :path => 'languageTerm[@type="text"]'
|
724
|
+
n.scriptTerm :path => 'scriptTerm'
|
726
725
|
end
|
727
726
|
t._languageTerm :path => '//languageTerm' do |lt|
|
728
727
|
lt.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
@@ -749,12 +748,12 @@ module Mods
|
|
749
748
|
n.shelfLocator :path => 'shelfLocator'
|
750
749
|
n.url :path => 'url' do |e|
|
751
750
|
e.dateLastAccessed :path => '@dateLastAccessed', :accessor => lambda { |a| a.text }
|
752
|
-
e.displayLabel
|
753
|
-
e.note
|
751
|
+
e.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
752
|
+
e.note :path => '@note', :accessor => lambda { |a| a.text }
|
754
753
|
e.access :path => '@access', :accessor => lambda { |a| a.text }
|
755
|
-
e.usage
|
754
|
+
e.usage :path => '@usage', :accessor => lambda { |a| a.text }
|
756
755
|
end
|
757
|
-
n.holdingSimple
|
756
|
+
n.holdingSimple :path => 'holdingSimple'
|
758
757
|
n.holdingExternal :path => 'holdingExternal'
|
759
758
|
end # t.location
|
760
759
|
|
@@ -772,15 +771,15 @@ module Mods
|
|
772
771
|
n.namePart :path => 'namePart' do |np|
|
773
772
|
np.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
774
773
|
end
|
775
|
-
n.family_name
|
776
|
-
n.given_name
|
774
|
+
n.family_name :path => 'namePart[@type="family"]'
|
775
|
+
n.given_name :path => 'namePart[@type="given"]'
|
777
776
|
n.termsOfAddress :path => 'namePart[@type="termsOfAddress"]'
|
778
|
-
n.date
|
777
|
+
n.date :path => 'namePart[@type="date"]'
|
779
778
|
|
780
|
-
n.displayForm
|
781
|
-
n.affiliation
|
779
|
+
n.displayForm :path => 'displayForm'
|
780
|
+
n.affiliation :path => 'affiliation'
|
782
781
|
n.description_el :path => 'description' # description is used by Nokogiri
|
783
|
-
n.role :path => 'role' do |r|
|
782
|
+
n.role :path => 'role' do |r|
|
784
783
|
r.roleTerm :path => 'roleTerm' do |rt|
|
785
784
|
rt.type_at :path => "@type", :accessor => lambda { |a| a.text }
|
786
785
|
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
@@ -788,9 +787,9 @@ module Mods
|
|
788
787
|
}
|
789
788
|
end
|
790
789
|
# convenience method
|
791
|
-
r.authority :path => '.', :accessor => lambda { |role_node|
|
790
|
+
r.authority :path => '.', :accessor => lambda { |role_node|
|
792
791
|
a = nil
|
793
|
-
role_node.roleTerm.each { |role_t|
|
792
|
+
role_node.roleTerm.each { |role_t|
|
794
793
|
# role_t.authority will be [] if it is missing from an earlier roleTerm
|
795
794
|
if role_t.authority && (!a || a.size == 0)
|
796
795
|
a = role_t.authority
|
@@ -798,21 +797,21 @@ module Mods
|
|
798
797
|
}
|
799
798
|
a
|
800
799
|
}
|
801
|
-
# convenience method
|
802
|
-
r.code :path => '.', :accessor => lambda { |role_node|
|
800
|
+
# convenience method
|
801
|
+
r.code :path => '.', :accessor => lambda { |role_node|
|
803
802
|
c = nil
|
804
|
-
role_node.roleTerm.each { |role_t|
|
805
|
-
if role_t.type_at == 'code'
|
803
|
+
role_node.roleTerm.each { |role_t|
|
804
|
+
if role_t.type_at == 'code'
|
806
805
|
c ||= role_t.text
|
807
806
|
end
|
808
807
|
}
|
809
808
|
c
|
810
809
|
}
|
811
810
|
# convenience method
|
812
|
-
r.value :path => '.', :accessor => lambda { |role_node|
|
811
|
+
r.value :path => '.', :accessor => lambda { |role_node|
|
813
812
|
val = nil
|
814
|
-
role_node.roleTerm.each { |role_t|
|
815
|
-
if role_t.type_at == 'text'
|
813
|
+
role_node.roleTerm.each { |role_t|
|
814
|
+
if role_t.type_at == 'text'
|
816
815
|
val ||= role_t.text
|
817
816
|
end
|
818
817
|
}
|
@@ -842,7 +841,7 @@ module Mods
|
|
842
841
|
end
|
843
842
|
if !dv.empty?
|
844
843
|
first = true
|
845
|
-
name_node.namePart.each { |np|
|
844
|
+
name_node.namePart.each { |np|
|
846
845
|
if np.type_at == 'termsOfAddress' && !np.text.empty?
|
847
846
|
if first
|
848
847
|
dv = dv + " " + np.text
|
@@ -861,11 +860,11 @@ module Mods
|
|
861
860
|
end
|
862
861
|
dv.strip.empty? ? nil : dv.strip
|
863
862
|
}
|
864
|
-
|
863
|
+
|
865
864
|
# name convenience method
|
866
865
|
n.display_value_w_date :path => '.', :single => true, :accessor => lambda {|name_node|
|
867
866
|
dv = '' + name_node.display_value
|
868
|
-
name_node.namePart.each { |np|
|
867
|
+
name_node.namePart.each { |np|
|
869
868
|
if np.type_at == 'date' && !np.text.empty? && !dv.end_with?(np.text)
|
870
869
|
dv = dv + ", #{np.text}"
|
871
870
|
end
|
@@ -877,11 +876,11 @@ module Mods
|
|
877
876
|
}
|
878
877
|
end # t._plain_name
|
879
878
|
|
880
|
-
t.personal_name
|
881
|
-
t._personal_name
|
882
|
-
t.corporate_name
|
883
|
-
t._corporate_name
|
884
|
-
t.conference_name
|
879
|
+
t.personal_name :path => '/mods/name[@type="personal"]'
|
880
|
+
t._personal_name :path => '//name[@type="personal"]'
|
881
|
+
t.corporate_name :path => '/mods/name[@type="corporate"]'
|
882
|
+
t._corporate_name :path => '//name[@type="corporate"]'
|
883
|
+
t.conference_name :path => '/mods/name[@type="conference"]'
|
885
884
|
t._conference_name :path => '//name[@type="conference"]'
|
886
885
|
|
887
886
|
# NOTE ---------------------------------------------------------------------------------
|
@@ -923,8 +922,8 @@ module Mods
|
|
923
922
|
end
|
924
923
|
end
|
925
924
|
}
|
926
|
-
n.edition
|
927
|
-
n.issuance
|
925
|
+
n.edition :path => 'edition'
|
926
|
+
n.issuance :path => 'issuance'
|
928
927
|
n.frequency :path => 'frequency' do |f|
|
929
928
|
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
930
929
|
f.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
@@ -936,9 +935,9 @@ module Mods
|
|
936
935
|
t.part :path => '/mods/part'
|
937
936
|
t._part :path => '//part' do |n|
|
938
937
|
# attributes
|
939
|
-
n.id_at
|
940
|
-
n.order
|
941
|
-
n.type_at :path => '@type',
|
938
|
+
n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
|
939
|
+
n.order :path => '@order', :accessor => lambda { |a| a.text }
|
940
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
942
941
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
943
942
|
Mods::LANG_ATTRIBS.each { |attr_name|
|
944
943
|
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
@@ -946,35 +945,35 @@ module Mods
|
|
946
945
|
# child elements
|
947
946
|
n.detail :path => 'detail' do |e|
|
948
947
|
# attributes
|
949
|
-
e.level
|
950
|
-
e.type_at :path => '@type',
|
948
|
+
e.level :path => '@level', :accessor => lambda { |a| a.text }
|
949
|
+
e.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
951
950
|
# elements
|
952
|
-
e.number
|
951
|
+
e.number :path => 'number'
|
953
952
|
e.caption :path => 'caption'
|
954
|
-
e.title
|
953
|
+
e.title :path => 'title'
|
955
954
|
end
|
956
955
|
n.extent :path => 'extent' do |e| # TODO: extent is ordered in xml schema
|
957
956
|
# attributes
|
958
957
|
e.unit :path => '@unit', :accessor => lambda { |a| a.text }
|
959
958
|
# elements
|
960
959
|
e.start :path => 'start'
|
961
|
-
e.end
|
960
|
+
e.end :path => 'end'
|
962
961
|
e.total :path => 'total'
|
963
|
-
e.list
|
962
|
+
e.list :path => 'list'
|
964
963
|
end
|
965
|
-
n.date :path => 'date' do |e|
|
964
|
+
n.date :path => 'date' do |e|
|
966
965
|
Mods::DATE_ATTRIBS.reject { |a| a == 'keyDate' }.each { |attr_name|
|
967
966
|
e.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
968
967
|
}
|
969
968
|
end
|
970
|
-
n.text_el :path => 'text' do |e|
|
969
|
+
n.text_el :path => 'text' do |e|
|
971
970
|
e.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
972
|
-
e.type_at
|
971
|
+
e.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
973
972
|
end
|
974
973
|
end # t._part
|
975
974
|
|
976
975
|
# PHYSICAL_DESCRIPTION -------------------------------------------------------------------
|
977
|
-
t.physical_description
|
976
|
+
t.physical_description :path => '/mods/physicalDescription'
|
978
977
|
t._physical_description :path => '//physicalDescription' do |n|
|
979
978
|
# attributes
|
980
979
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
@@ -1044,31 +1043,31 @@ module Mods
|
|
1044
1043
|
t.related_item :path => '/mods/relatedItem' do |n|
|
1045
1044
|
# attributes
|
1046
1045
|
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
1047
|
-
n.id_at
|
1046
|
+
n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
|
1048
1047
|
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
1049
1048
|
# elements
|
1050
1049
|
n.abstract :path => 'abstract'
|
1051
1050
|
n.accessCondition :path => 'accessCondition'
|
1052
|
-
n.classification
|
1053
|
-
n.extension
|
1054
|
-
n.genre
|
1051
|
+
n.classification :path => 'classification'
|
1052
|
+
n.extension :path => 'extension'
|
1053
|
+
n.genre :path => 'genre'
|
1055
1054
|
n.identifier :path => 'identifier'
|
1056
|
-
n.language
|
1057
|
-
n.location
|
1058
|
-
n.name_el
|
1059
|
-
n.personal_name
|
1060
|
-
n.corporate_name
|
1055
|
+
n.language :path => 'language'
|
1056
|
+
n.location :path => 'location'
|
1057
|
+
n.name_el :path => 'name' # Note: 'name' is used by Nokogiri
|
1058
|
+
n.personal_name :path => 'name[@type="personal"]'
|
1059
|
+
n.corporate_name :path => 'name[@type="corporate"]'
|
1061
1060
|
n.conference_name :path => 'name[@type="conference"]'
|
1062
|
-
n.note
|
1061
|
+
n.note :path => 'note'
|
1063
1062
|
n.originInfo :path => 'originInfo'
|
1064
|
-
n.part
|
1063
|
+
n.part :path => 'part'
|
1065
1064
|
n.physicalDescription :path => 'physicalDescription'
|
1066
|
-
n.recordInfo
|
1067
|
-
n.subject
|
1065
|
+
n.recordInfo :path => 'recordInfo'
|
1066
|
+
n.subject :path => 'subject'
|
1068
1067
|
n.tableOfContents :path => 'tableOfContents'
|
1069
|
-
n.targetAudience
|
1070
|
-
n.titleInfo
|
1071
|
-
n.typeOfResource
|
1068
|
+
n.targetAudience :path => 'targetAudience'
|
1069
|
+
n.titleInfo :path => 'titleInfo'
|
1070
|
+
n.typeOfResource :path => 'typeOfResource'
|
1072
1071
|
end
|
1073
1072
|
|
1074
1073
|
# SUBJECT -----------------------------------------------------------------------------
|
@@ -1106,7 +1105,7 @@ module Mods
|
|
1106
1105
|
gc.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
1107
1106
|
}
|
1108
1107
|
# convenience method
|
1109
|
-
gc.translated_value :path => '.', :accessor => lambda { |gc_node|
|
1108
|
+
gc.translated_value :path => '.', :accessor => lambda { |gc_node|
|
1110
1109
|
code_val ||= gc_node.text
|
1111
1110
|
xval = nil
|
1112
1111
|
if code_val
|
@@ -1134,8 +1133,8 @@ module Mods
|
|
1134
1133
|
t1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
1135
1134
|
}
|
1136
1135
|
end
|
1137
|
-
n.personal_name
|
1138
|
-
n.corporate_name
|
1136
|
+
n.personal_name :path => 'name[@type="personal"]'
|
1137
|
+
n.corporate_name :path => 'name[@type="corporate"]'
|
1139
1138
|
n.conference_name :path => 'name[@type="conference"]'
|
1140
1139
|
n.occupation :path => 'occupation' do |n1|
|
1141
1140
|
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
@@ -1164,20 +1163,20 @@ module Mods
|
|
1164
1163
|
end # t.subject
|
1165
1164
|
|
1166
1165
|
# TABLE_OF_CONTENTS ---------------------------------------------------------------------
|
1167
|
-
t.tableOfContents
|
1166
|
+
t.tableOfContents :path => '/mods/tableOfContents'
|
1168
1167
|
t._tableOfContents :path => '//tableOfContents' do |n|
|
1169
|
-
n.displayLabel
|
1170
|
-
n.shareable
|
1171
|
-
n.type_at
|
1168
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
1169
|
+
n.shareable :path => '@shareable', :accessor => lambda { |a| a.text }
|
1170
|
+
n.type_at :path => '@type', :accessor => lambda { |a| a.text }
|
1172
1171
|
Mods::LANG_ATTRIBS.each { |attr_name|
|
1173
1172
|
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
1174
1173
|
}
|
1175
1174
|
end
|
1176
1175
|
|
1177
1176
|
# TARGET_AUDIENCE -----------------------------------------------------------------------
|
1178
|
-
t.targetAudience
|
1177
|
+
t.targetAudience :path => '/mods/targetAudience'
|
1179
1178
|
t._targetAudience :path => '//targetAudience' do |n|
|
1180
|
-
n.displayLabel
|
1179
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
1181
1180
|
Mods::AUTHORITY_ATTRIBS.each { |attr_name|
|
1182
1181
|
n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
1183
1182
|
}
|
@@ -1195,43 +1194,43 @@ module Mods
|
|
1195
1194
|
else
|
1196
1195
|
n.type_at :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
|
1197
1196
|
end
|
1198
|
-
}
|
1199
|
-
n.title
|
1200
|
-
n.subTitle
|
1201
|
-
n.nonSort
|
1197
|
+
}
|
1198
|
+
n.title :path => 'title'
|
1199
|
+
n.subTitle :path => 'subTitle'
|
1200
|
+
n.nonSort :path => 'nonSort'
|
1202
1201
|
n.partNumber :path => 'partNumber'
|
1203
|
-
n.partName
|
1204
|
-
n.sort_title :path => '.', :accessor => lambda { |node|
|
1202
|
+
n.partName :path => 'partName'
|
1203
|
+
n.sort_title :path => '.', :accessor => lambda { |node|
|
1205
1204
|
if node.type_at != "alternative" || (node.type_at == "alternative" && mods_ng_xml.xpath('/mods/titleInfo').size == 1)
|
1206
|
-
node.title.text + (!node.subTitle.text.empty? ? "#{@title_delimiter}#{node.subTitle.text}" : "" )
|
1205
|
+
node.title.text + (!node.subTitle.text.empty? ? "#{@title_delimiter}#{node.subTitle.text}" : "" )
|
1207
1206
|
end
|
1208
1207
|
}
|
1209
|
-
n.full_title :path => '.', :accessor => lambda { |node|
|
1210
|
-
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
1211
|
-
node.title.text +
|
1212
|
-
(!node.subTitle.text.empty? ? "#{@title_delimiter}#{node.subTitle.text}" : "" )
|
1208
|
+
n.full_title :path => '.', :accessor => lambda { |node|
|
1209
|
+
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
1210
|
+
node.title.text +
|
1211
|
+
(!node.subTitle.text.empty? ? "#{@title_delimiter}#{node.subTitle.text}" : "" )
|
1213
1212
|
}
|
1214
|
-
n.short_title :path => '.', :accessor => lambda { |node|
|
1213
|
+
n.short_title :path => '.', :accessor => lambda { |node|
|
1215
1214
|
if node.type_at != "alternative"
|
1216
|
-
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
1215
|
+
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
1217
1216
|
node.title.text
|
1218
1217
|
end
|
1219
1218
|
}
|
1220
|
-
n.alternative_title :path => '.', :accessor => lambda { |node|
|
1219
|
+
n.alternative_title :path => '.', :accessor => lambda { |node|
|
1221
1220
|
if node.type_at == "alternative"
|
1222
|
-
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
1221
|
+
(!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
|
1223
1222
|
node.title.text
|
1224
1223
|
end
|
1225
1224
|
}
|
1226
1225
|
end # t._title_info
|
1227
1226
|
|
1228
1227
|
# TYPE_OF_RESOURCE --------------------------------------------------------------------
|
1229
|
-
t.typeOfResource
|
1228
|
+
t.typeOfResource :path => '/mods/typeOfResource'
|
1230
1229
|
t._typeOfResource :path => '//typeOfResource' do |n|
|
1231
|
-
n.collection
|
1232
|
-
n.displayLabel
|
1233
|
-
n.manuscript
|
1234
|
-
n.usage
|
1230
|
+
n.collection :path => '@collection', :accessor => lambda { |a| a.text }
|
1231
|
+
n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
|
1232
|
+
n.manuscript :path => '@manuscript', :accessor => lambda { |a| a.text }
|
1233
|
+
n.usage :path => '@usage', :accessor => lambda { |a| a.text }
|
1235
1234
|
end
|
1236
1235
|
|
1237
1236
|
end # terminology
|