mods 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,19 +37,20 @@ TODO: Write usage instructions here
37
37
 
38
38
  == Releases
39
39
 
40
- 0.0.16 add role convenience methods (within name node)
41
- 0.0.15 make namespace aware processing the default
42
- 0.0.14 don't lose xml encoding in reader.normalize_mods under jruby
43
- 0.0.13 really really fix removal of xsi:schemaLocation in jruby
44
- 0.0.12 fix failing jruby test
45
- 0.0.11 fix remove xsi:schemaLocation attribute from mods element when not using namespaces
46
- 0.0.10 remove xsi:schemaLocation attribute from mods element when not using namespaces
47
- 0.0.9 implement from_nk_node as way to load record object
48
- 0.0.8 implement relatedItem and attributes on all simple top level elements
49
- 0.0.7 implement part
50
- 0.0.6 implement recordInfo, fix to work under jruby
51
- 0.0.5 implement subject, change a few constants
52
- 0.0.4 implement language, location, origin_info, physical_description
53
- 0.0.3 use nom-xml gem and make this more nokogiri-ish; implement name, title, and simple top level elements with no subelements
54
- 0.0.2 Set up rake tasks, publishing rdoc, and continuous integration.
55
- 0.0.1 Grab the name
40
+ * <b>0.0.17</b> add display_value and display_value_w_date to name node; add personal_names_w_dates to record
41
+ * <b>0.0.16</b> add role convenience methods (within name node)
42
+ * <b>0.0.15</b> make namespace aware processing the default
43
+ * <b>0.0.14</b> don't lose xml encoding in reader.normalize_mods under jruby
44
+ * <b>0.0.13</b> really really fix removal of xsi:schemaLocation in jruby
45
+ * <b>0.0.12</b> fix failing jruby test
46
+ * <b>0.0.11</b> fix remove xsi:schemaLocation attribute from mods element when not using namespaces
47
+ * <b>0.0.10</b> remove xsi:schemaLocation attribute from mods element when not using namespaces
48
+ * <b>0.0.9</b> implement from_nk_node as way to load record object
49
+ * <b>0.0.8</b> implement relatedItem and attributes on all simple top level elements
50
+ * <b>0.0.7</b> implement part
51
+ * <b>0.0.6</b> implement recordInfo, fix to work under jruby
52
+ * <b>0.0.5</b> implement subject, change a few constants
53
+ * <b>0.0.4</b> implement language, location, origin_info, physical_description
54
+ * <b>0.0.3</b> use nom-xml gem and make this more nokogiri-ish; implement name, title, and simple top level elements with no subelements
55
+ * <b>0.0.2</b> Set up rake tasks, publishing rdoc, and continuous integration.
56
+ * <b>0.0.1</b> Grab the name
@@ -16,52 +16,52 @@ module Mods
16
16
 
17
17
  class Record
18
18
 
19
- # set the NOM terminology; do NOT use namespaces
19
+ # set the NOM terminology; WITH namespaces
20
20
  # NOTES:
21
21
  # 1. certain words, such as 'type' 'name' 'description' are reserved words in jruby or nokogiri
22
22
  # when the terminology would use these words, a suffix of '_at' is added if it is an attribute,
23
23
  # (e.g. 'type_at' for @type) and a suffix of '_el' is added if it is an element.
24
24
  # 2. the underscore prefix variant terms are a way of making subterms for a node available
25
25
  # to any instance of said node and are not intended to be used externally
26
- # @param mods_ng_xml a Nokogiri::Xml::Document object containing MODS (without namespaces)
27
- def set_terminology_no_ns(mods_ng_xml)
28
- mods_ng_xml.set_terminology() do |t|
26
+ # @param mods_ng_xml a Nokogiri::Xml::Document object containing MODS (with namespaces)
27
+ def set_terminology_ns(mods_ng_xml)
28
+ mods_ng_xml.set_terminology(:namespaces => { 'm' => Mods::MODS_NS }) do |t|
29
29
 
30
30
  # FIXME: may want to deal with camelcase vs. underscore in method_missing
31
31
 
32
32
  # ABSTRACT -------------------------------------------------------------------------------
33
- t.abstract :path => '/mods/abstract'
34
- t._abstract :path => '//abstract' do |n|
33
+ t.abstract :path => '/m:mods/m:abstract'
34
+ t._abstract :path => '//m:abstract' do |n|
35
35
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
36
36
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
37
37
  end
38
-
38
+
39
39
  # ACCESS_CONDITION -----------------------------------------------------------------------
40
- t.accessCondition :path => '/mods/accessCondition'
41
- t._accessCondition :path => '//accessCondition' do |n|
40
+ t.accessCondition :path => '/m:mods/m:accessCondition'
41
+ t._accessCondition :path => '//m:accessCondition' do |n|
42
42
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
43
43
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
44
44
  end
45
-
45
+
46
46
  # CLASSIFICATION -------------------------------------------------------------------------
47
- t.classification :path => '/mods/classification'
48
- t._classification :path => '//classification' do |n|
47
+ t.classification :path => '/m:mods/m:classification'
48
+ t._classification :path => '//m:classification' do |n|
49
49
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
50
50
  n.edition :path => '@edition', :accessor => lambda { |a| a.text }
51
51
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
52
52
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
53
53
  }
54
54
  end
55
-
55
+
56
56
  # EXTENSION ------------------------------------------------------------------------------
57
- t.extension :path => '/mods/extension'
58
- t._extension :path => '//extension' do |n|
57
+ t.extension :path => '/m:mods/m:extension'
58
+ t._extension :path => '//m:extension' do |n|
59
59
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
60
60
  end
61
-
61
+
62
62
  # GENRE ----------------------------------------------------------------------------------
63
- t.genre :path => '/mods/genre'
64
- t._genre :path => '//genre' do |n|
63
+ t.genre :path => '/m:mods/m:genre'
64
+ t._genre :path => '//m:genre' do |n|
65
65
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
66
66
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
67
67
  n.usage :path => '@usage', :accessor => lambda { |a| a.text }
@@ -69,24 +69,24 @@ module Mods
69
69
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
70
70
  }
71
71
  end
72
-
72
+
73
73
  # IDENTIIER ------------------------------------------------------------------------------
74
- t.identifier :path => '/mods/identifier'
75
- t._identifier :path => '//identifier' do |n|
74
+ t.identifier :path => '/m:mods/m:identifier'
75
+ t._identifier :path => '//m:identifier' do |n|
76
76
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
77
77
  n.invalid :path => '@invalid', :accessor => lambda { |a| a.text }
78
78
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
79
79
  end
80
-
80
+
81
81
  # LANGUAGE -------------------------------------------------------------------------------
82
- t.language :path => '/mods/language'
83
- t._language :path => '//language' do |n|
84
- n.languageTerm :path => 'languageTerm'
85
- n.code_term :path => 'languageTerm[@type="code"]'
86
- n.text_term :path => 'languageTerm[@type="text"]'
87
- n.scriptTerm :path => 'scriptTerm'
82
+ t.language :path => '/m:mods/m:language'
83
+ t._language :path => '//m:language' do |n|
84
+ n.languageTerm :path => 'm:languageTerm'
85
+ n.code_term :path => 'm:languageTerm[@type="code"]'
86
+ n.text_term :path => 'm:languageTerm[@type="text"]'
87
+ n.scriptTerm :path => 'm:scriptTerm'
88
88
  end
89
- t._languageTerm :path => '//languageTerm' do |lt|
89
+ t._languageTerm :path => '//m:languageTerm' do |lt|
90
90
  lt.type_at :path => '@type', :accessor => lambda { |a| a.text }
91
91
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
92
92
  lt.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
@@ -94,29 +94,29 @@ module Mods
94
94
  end # t.language
95
95
 
96
96
  # LOCATION -------------------------------------------------------------------------------
97
- t.location :path => '/mods/location'
98
- t._location :path => '//location' do |n|
99
- n.physicalLocation :path => 'physicalLocation' do |e|
97
+ t.location :path => '/m:mods/m:location'
98
+ t._location :path => '//m:location' do |n|
99
+ n.physicalLocation :path => 'm:physicalLocation' do |e|
100
100
  e.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
101
101
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
102
102
  e.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
103
103
  }
104
104
  end
105
- n.shelfLocator :path => 'shelfLocator'
106
- n.url :path => 'url' do |e|
105
+ n.shelfLocator :path => 'm:shelfLocator'
106
+ n.url :path => 'm:url' do |e|
107
107
  e.dateLastAccessed :path => '@dateLastAccessed', :accessor => lambda { |a| a.text }
108
108
  e.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
109
109
  e.note :path => '@note', :accessor => lambda { |a| a.text }
110
110
  e.access :path => '@access', :accessor => lambda { |a| a.text }
111
111
  e.usage :path => '@usage', :accessor => lambda { |a| a.text }
112
112
  end
113
- n.holdingSimple :path => 'holdingSimple'
114
- n.holdingExternal :path => 'holdingExternal'
113
+ n.holdingSimple :path => 'm:holdingSimple'
114
+ n.holdingExternal :path => 'm:holdingExternal'
115
115
  end # t.location
116
-
116
+
117
117
  # NAME ------------------------------------------------------------------------------------
118
- t.plain_name :path => '/mods/name'
119
- t._plain_name :path => '//name' do |n|
118
+ t.plain_name :path => '/m:mods/m:name'
119
+ t._plain_name :path => '//m:name' do |n|
120
120
  Mods::Name::ATTRIBUTES.each { |attr_name|
121
121
  if attr_name != 'type'
122
122
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
@@ -125,23 +125,28 @@ module Mods
125
125
  end
126
126
  }
127
127
  # elements
128
- n.namePart :path => 'namePart' do |np|
128
+ n.namePart :path => 'm:namePart' do |np|
129
129
  np.type_at :path => '@type', :accessor => lambda { |a| a.text }
130
130
  end
131
- n.displayForm :path => 'displayForm'
132
- n.affiliation :path => 'affiliation'
133
- n.description_el :path => 'description' # description is used by Nokogiri
134
- n.role :path => 'role' do |r|
135
- r.roleTerm :path => 'roleTerm' do |rt|
131
+ n.family_name :path => 'm:namePart[@type="family"]'
132
+ n.given_name :path => 'm:namePart[@type="given"]'
133
+ n.termsOfAddress :path => 'm:namePart[@type="termsOfAddress"]'
134
+ n.date :path => 'm:namePart[@type="date"]'
135
+
136
+ n.displayForm :path => 'm:displayForm'
137
+ n.affiliation :path => 'm:affiliation'
138
+ n.description_el :path => 'm:description' # description is used by Nokogiri
139
+ n.role :path => 'm:role' do |r|
140
+ r.roleTerm :path => 'm:roleTerm' do |rt|
136
141
  rt.type_at :path => "@type", :accessor => lambda { |a| a.text }
137
142
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
138
143
  rt.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
139
144
  }
140
145
  end
141
- # convenience method
146
+ # role convenience method
142
147
  r.authority :path => '.', :accessor => lambda { |role_node|
143
148
  a = nil
144
- role_node.roleTerm.each { |role_t|
149
+ role_node.roleTerm.each { |role_t|
145
150
  # role_t.authority will be [] if it is missing from an earlier roleTerm
146
151
  if role_t.authority && (!a || a.size == 0)
147
152
  a = role_t.authority
@@ -149,21 +154,21 @@ module Mods
149
154
  }
150
155
  a
151
156
  }
152
- # convenience method
157
+ # role convenience method
153
158
  r.code :path => '.', :accessor => lambda { |role_node|
154
159
  c = nil
155
160
  role_node.roleTerm.each { |role_t|
156
- if role_t.type_at == 'code'
161
+ if role_t.type_at == 'code'
157
162
  c ||= role_t.text
158
163
  end
159
164
  }
160
165
  c
161
166
  }
162
- # convenience method
167
+ # role convenience method
163
168
  r.value :path => '.', :accessor => lambda { |role_node|
164
169
  val = nil
165
170
  role_node.roleTerm.each { |role_t|
166
- if role_t.type_at == 'text'
171
+ if role_t.type_at == 'text'
167
172
  val ||= role_t.text
168
173
  end
169
174
  }
@@ -174,43 +179,89 @@ module Mods
174
179
  val
175
180
  }
176
181
  end # role node
182
+
183
+ # name convenience method
184
+ # uses the displayForm of a name if present
185
+ # if no displayForm, try to make a string from family, given and terms of address
186
+ # otherwise, return all non-date nameParts concatenated together
187
+ n.display_value :path => '.', :single => true, :accessor => lambda {|name_node|
188
+ dv = ''
189
+ if name_node.displayForm && name_node.displayForm.text.size > 0
190
+ dv = name_node.displayForm.text
191
+ end
192
+ if dv.empty?
193
+ if name_node.type_at == 'personal'
194
+ if name_node.family_name.size > 0
195
+ dv = name_node.given_name.size > 0 ? "#{name_node.family_name.text}, #{name_node.given_name.text}" : name_node.family_name.text
196
+ elsif name_node.given_name.size > 0
197
+ dv = name_node.given_name.text
198
+ end
199
+ if !dv.empty?
200
+ first = true
201
+ name_node.namePart.each { |np|
202
+ if np.type_at == 'termsOfAddress' && !np.text.empty?
203
+ if first
204
+ dv = dv + " " + np.text
205
+ first = false
206
+ else
207
+ dv = dv + ", " + np.text
208
+ end
209
+ end
210
+ }
211
+ else # no family or given name
212
+ dv = name_node.namePart.select {|np| np.type_at != 'date' && !np.text.empty?}.join(" ")
213
+ end
214
+ else # not a personal name
215
+ dv = name_node.namePart.select {|np| np.type_at != 'date' && !np.text.empty?}.join(" ")
216
+ end
217
+ end
218
+ dv.strip.empty? ? nil : dv.strip
219
+ }
220
+
221
+ # name convenience method
222
+ n.display_value_w_date :path => '.', :single => true, :accessor => lambda {|name_node|
223
+ dv = '' + name_node.display_value
224
+ name_node.namePart.each { |np|
225
+ if np.type_at == 'date' && !np.text.empty? && !dv.end_with?(np.text)
226
+ dv = dv + ", #{np.text}"
227
+ end
228
+ }
229
+ if dv.start_with?(', ')
230
+ dv.sub(', ', '')
231
+ end
232
+ dv.strip.empty? ? nil : dv.strip
233
+ }
177
234
  end # t._plain_name
178
235
 
179
- t.personal_name :path => '/mods/name[@type="personal"]'
180
- t._personal_name :path => '//name[@type="personal"]' do |n|
181
- n.family_name :path => 'namePart[@type="family"]'
182
- n.given_name :path => 'namePart[@type="given"]'
183
- n.termsOfAddress :path => 'namePart[@type="termsOfAddress"]'
184
- n.date :path => 'namePart[@type="date"]'
185
- end
186
-
187
- t.corporate_name :path => '/mods/name[@type="corporate"]'
188
- t._corporate_name :path => '//name[@type="corporate"]'
189
- t.conference_name :path => '/mods/name[@type="conference"]'
190
- t._conference_name :path => '//name[@type="conference"]'
236
+ t.personal_name :path => '/m:mods/m:name[@type="personal"]'
237
+ t._personal_name :path => '//m:name[@type="personal"]'
238
+ t.corporate_name :path => '/m:mods/m:name[@type="corporate"]'
239
+ t._corporate_name :path => '//m:name[@type="corporate"]'
240
+ t.conference_name :path => '/m:mods/m:name[@type="conference"]'
241
+ t._conference_name :path => '//m:name[@type="conference"]'
191
242
 
192
243
  # NOTE ---------------------------------------------------------------------------------
193
- t.note :path => '/mods/note'
194
- t._note :path => '//note' do |n|
244
+ t.note :path => '/m:mods/m:note'
245
+ t._note :path => '//m:note' do |n|
195
246
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
196
247
  n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
197
248
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
198
249
  end
199
-
250
+
200
251
  # ORIGIN_INFO --------------------------------------------------------------------------
201
- t.origin_info :path => '/mods/originInfo'
202
- t._origin_info :path => '//originInfo' do |n|
203
- n.place :path => 'place' do |e|
204
- e.placeTerm :path => 'placeTerm' do |ee|
252
+ t.origin_info :path => '/m:mods/m:originInfo'
253
+ t._origin_info :path => '//m:originInfo' do |n|
254
+ n.place :path => 'm:place' do |e|
255
+ e.placeTerm :path => 'm:placeTerm' do |ee|
205
256
  ee.type_at :path => '@type', :accessor => lambda { |a| a.text }
206
257
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
207
258
  ee.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
208
259
  }
209
260
  end
210
261
  end
211
- n.publisher :path => 'publisher'
262
+ n.publisher :path => 'm:publisher'
212
263
  Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |date_el|
213
- n.send date_el, :path => "#{date_el}" do |d|
264
+ n.send date_el, :path => "m:#{date_el}" do |d|
214
265
  Mods::DATE_ATTRIBS.each { |attr_name|
215
266
  d.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
216
267
  }
@@ -219,161 +270,161 @@ module Mods
219
270
  end
220
271
  end
221
272
  }
222
- n.edition :path => 'edition'
223
- n.issuance :path => 'issuance'
224
- n.frequency :path => 'frequency' do |f|
273
+ n.edition :path => 'm:edition'
274
+ n.issuance :path => 'm:issuance'
275
+ n.frequency :path => 'm:frequency' do |f|
225
276
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
226
277
  f.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
227
278
  }
228
279
  end
229
280
  end # t.origin_info
230
-
281
+
231
282
  # PART -----------------------------------------------------------------------------------
232
- t.part :path => '/mods/part'
233
- t._part :path => '//part' do |n|
283
+ t.part :path => '/m:mods/m:part'
284
+ t._part :path => '//m:part' do |n|
234
285
  # attributes
235
286
  n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
236
287
  n.order :path => '@order', :accessor => lambda { |a| a.text }
237
288
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
238
289
  # child elements
239
- n.detail :path => 'detail' do |e|
290
+ n.detail :path => 'm:detail' do |e|
240
291
  # attributes
241
292
  e.level :path => '@level', :accessor => lambda { |a| a.text }
242
293
  e.type_at :path => '@type', :accessor => lambda { |a| a.text }
243
294
  # elements
244
- e.number :path => 'number'
245
- e.caption :path => 'caption'
246
- e.title :path => 'title'
295
+ e.number :path => 'm:number'
296
+ e.caption :path => 'm:caption'
297
+ e.title :path => 'm:title'
247
298
  end
248
- n.extent :path => 'extent' do |e| # TODO: extent is ordered in xml schema
299
+ n.extent :path => 'm:extent' do |e| # TODO: extent is ordered in xml schema
249
300
  # attributes
250
301
  e.unit :path => '@unit', :accessor => lambda { |a| a.text }
251
302
  # elements
252
- e.start :path => 'start'
253
- e.end :path => 'end'
254
- e.total :path => 'total'
255
- e.list :path => 'list'
303
+ e.start :path => 'm:start'
304
+ e.end :path => 'm:end'
305
+ e.total :path => 'm:total'
306
+ e.list :path => 'm:list'
256
307
  end
257
- n.date :path => 'date' do |e|
308
+ n.date :path => 'm:date' do |e|
258
309
  Mods::DATE_ATTRIBS.reject { |a| a == 'keyDate' }.each { |attr_name|
259
310
  e.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
260
311
  }
261
312
  end
262
- n.text_el :path => 'text' do |e|
313
+ n.text_el :path => 'm:text' do |e|
263
314
  e.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
264
315
  e.type_at :path => '@type', :accessor => lambda { |a| a.text }
265
316
  end
266
317
  end # t._part
267
-
318
+
268
319
  # PHYSICAL_DESCRIPTION -------------------------------------------------------------------
269
- t.physical_description :path => '/mods/physicalDescription'
270
- t._physical_description :path => '//physicalDescription' do |n|
271
- n.digitalOrigin :path => 'digitalOrigin'
272
- n.extent :path => 'extent'
273
- n.form :path => 'form' do |f|
320
+ t.physical_description :path => '/m:mods/m:physicalDescription'
321
+ t._physical_description :path => '//m:physicalDescription' do |n|
322
+ n.digitalOrigin :path => 'm:digitalOrigin'
323
+ n.extent :path => 'm:extent'
324
+ n.form :path => 'm:form' do |f|
274
325
  f.type_at :path => '@type', :accessor => lambda { |a| a.text }
275
326
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
276
327
  f.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
277
328
  }
278
329
  end
279
- n.internetMediaType :path => 'internetMediaType'
280
- n.note :path => 'note' do |nn|
330
+ n.internetMediaType :path => 'm:internetMediaType'
331
+ n.note :path => 'm:note' do |nn|
281
332
  nn.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
282
333
  nn.type_at :path => '@type', :accessor => lambda { |a| a.text }
283
334
  end
284
- n.reformattingQuality :path => 'reformattingQuality'
335
+ n.reformattingQuality :path => 'm:reformattingQuality'
285
336
  end
286
-
337
+
287
338
  # RECORD_INFO --------------------------------------------------------------------------
288
- t.record_info :path => '/mods/recordInfo'
289
- t._record_info :path => '//recordInfo' do |n|
339
+ t.record_info :path => '/m:mods/m:recordInfo'
340
+ t._record_info :path => '//m:recordInfo' do |n|
290
341
  # attributes
291
342
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
292
343
  Mods::LANG_ATTRIBS.each { |attr_name|
293
344
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
294
345
  }
295
346
  # child elements
296
- n.recordContentSource :path => 'recordContentSource' do |r|
347
+ n.recordContentSource :path => 'm:recordContentSource' do |r|
297
348
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
298
349
  r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
299
350
  }
300
351
  end
301
- n.recordCreationDate :path => 'recordCreationDate' do |r|
352
+ n.recordCreationDate :path => 'm:recordCreationDate' do |r|
302
353
  Mods::DATE_ATTRIBS.each { |attr_name|
303
354
  r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
304
355
  }
305
356
  end
306
- n.recordChangeDate :path => 'recordChangeDate' do |r|
357
+ n.recordChangeDate :path => 'm:recordChangeDate' do |r|
307
358
  Mods::DATE_ATTRIBS.each { |attr_name|
308
359
  r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
309
360
  }
310
361
  end
311
- n.recordIdentifier :path => 'recordIdentifier' do |r|
362
+ n.recordIdentifier :path => 'm:recordIdentifier' do |r|
312
363
  r.source :path => '@source', :accessor => lambda { |a| a.text }
313
364
  end
314
- n.recordOrigin :path => 'recordOrigin'
315
- n.languageOfCataloging :path => 'languageOfCataloging' do |r|
365
+ n.recordOrigin :path => 'm:recordOrigin'
366
+ n.languageOfCataloging :path => 'm:languageOfCataloging' do |r|
316
367
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
317
368
  r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
318
369
  }
319
- r.languageTerm :path => 'languageTerm'
320
- r.scriptTerm :path => 'scriptTerm'
370
+ r.languageTerm :path => 'm:languageTerm'
371
+ r.scriptTerm :path => 'm:scriptTerm'
321
372
  end
322
- n.descriptionStandard :path => 'descriptionStandard' do |r|
373
+ n.descriptionStandard :path => 'm:descriptionStandard' do |r|
323
374
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
324
375
  r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
325
376
  }
326
377
  end
327
378
  end # t._record_info
328
-
379
+
329
380
  # RELATED_ITEM-------------------------------------------------------------------------
330
- t.related_item :path => '/mods/relatedItem' do |n|
381
+ t.related_item :path => '/m:mods/m:relatedItem' do |n|
331
382
  # attributes
332
383
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
333
384
  n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
334
385
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
335
386
  # elements
336
387
  n.abstract :path => 'abstract'
337
- n.accessCondition :path => 'accessCondition'
338
- n.classification :path => 'classification'
339
- n.extension :path => 'extension'
340
- n.genre :path => 'genre'
341
- n.identifier :path => 'identifier'
342
- n.language :path => 'language'
343
- n.location :path => 'location'
344
- n.name_el :path => 'name' # Note: 'name' is used by Nokogiri
345
- n.personal_name :path => 'name[@type="personal"]'
346
- n.corporate_name :path => 'name[@type="corporate"]'
347
- n.conference_name :path => 'name[@type="conference"]'
348
- n.note :path => 'note'
349
- n.originInfo :path => 'originInfo'
350
- n.part :path => 'part'
351
- n.physicalDescription :path => 'physicalDescription'
352
- n.recordInfo :path => 'recordInfo'
353
- n.subject :path => 'subject'
354
- n.tableOfContents :path => 'tableOfContents'
355
- n.targetAudience :path => 'targetAudience'
356
- n.titleInfo :path => 'titleInfo'
357
- n.typeOfResource :path => 'typeOfResource'
388
+ n.accessCondition :path => 'm:accessCondition'
389
+ n.classification :path => 'm:classification'
390
+ n.extension :path => 'm:extension'
391
+ n.genre :path => 'm:genre'
392
+ n.identifier :path => 'm:identifier'
393
+ n.language :path => 'm:language'
394
+ n.location :path => 'm:location'
395
+ n.name_el :path => 'm:name' # Note: 'name' is used by Nokogiri
396
+ n.personal_name :path => 'm:name[@type="personal"]'
397
+ n.corporate_name :path => 'm:name[@type="corporate"]'
398
+ n.conference_name :path => 'm:name[@type="conference"]'
399
+ n.note :path => 'm:note'
400
+ n.originInfo :path => 'm:originInfo'
401
+ n.part :path => 'm:part'
402
+ n.physicalDescription :path => 'm:physicalDescription'
403
+ n.recordInfo :path => 'm:recordInfo'
404
+ n.subject :path => 'm:subject'
405
+ n.tableOfContents :path => 'm:tableOfContents'
406
+ n.targetAudience :path => 'm:targetAudience'
407
+ n.titleInfo :path => 'm:titleInfo'
408
+ n.typeOfResource :path => 'm:typeOfResource'
358
409
  end
359
410
 
360
411
  # SUBJECT -----------------------------------------------------------------------------
361
- t.subject :path => '/mods/subject'
362
- t._subject :path => '//subject' do |n|
412
+ t.subject :path => '/m:mods/m:subject'
413
+ t._subject :path => '//m:subject' do |n|
363
414
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
364
415
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
365
416
  }
366
- n.topic :path => 'topic' do |n1|
417
+ n.topic :path => 'm:topic' do |n1|
367
418
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
368
419
  n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
369
420
  }
370
421
  end
371
- n.geographic :path => 'geographic' do |n1|
422
+ n.geographic :path => 'm:geographic' do |n1|
372
423
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
373
424
  n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
374
425
  }
375
426
  end
376
- n.temporal :path => 'temporal' do |n1|
427
+ n.temporal :path => 'm:temporal' do |n1|
377
428
  # date attributes as elements
378
429
  Mods::DATE_ATTRIBS.each { |attr_name|
379
430
  n1.send attr_name, :path => "#{attr_name}"
@@ -386,73 +437,73 @@ module Mods
386
437
  n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
387
438
  }
388
439
  end
389
- n.titleInfo :path => 'titleInfo' do |t1|
440
+ n.titleInfo :path => 'm:titleInfo' do |t1|
390
441
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
391
442
  t1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
392
443
  }
393
444
  end
394
445
  # Note: 'name' is used by Nokogiri
395
- n.name_el :path => 'name' do |t1|
446
+ n.name_el :path => 'm:name' do |t1|
396
447
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
397
448
  t1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
398
449
  }
399
450
  end
400
- n.personal_name :path => 'name[@type="personal"]'
401
- n.corporate_name :path => 'name[@type="corporate"]'
402
- n.conference_name :path => 'name[@type="conference"]'
403
- n.geographicCode :path => 'geographicCode' do |g|
451
+ n.personal_name :path => 'm:name[@type="personal"]'
452
+ n.corporate_name :path => 'm:name[@type="corporate"]'
453
+ n.conference_name :path => 'm:name[@type="conference"]'
454
+ n.geographicCode :path => 'm:geographicCode' do |g|
404
455
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
405
456
  g.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
406
457
  }
407
458
  end
408
- n.genre :path => 'genre' do |n1|
459
+ n.genre :path => 'm:genre' do |n1|
409
460
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
410
461
  n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
411
462
  }
412
463
  end
413
- n.hierarchicalGeographic :path => 'hierarchicalGeographic' do |n1|
464
+ n.hierarchicalGeographic :path => 'm:hierarchicalGeographic' do |n1|
414
465
  Mods::Subject::HIER_GEO_CHILD_ELEMENTS.each { |elname|
415
- n1.send elname, :path => "#{elname}"
466
+ n1.send elname, :path => "m:#{elname}"
416
467
  }
417
468
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
418
469
  n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
419
470
  }
420
471
  end
421
- n.cartographics :path => 'cartographics' do |n1|
422
- n1.scale :path => 'scale'
423
- n1.projection :path => 'projection'
424
- n1.coordinates :path => 'coordinates'
472
+ n.cartographics :path => 'm:cartographics' do |n1|
473
+ n1.scale :path => 'm:scale'
474
+ n1.projection :path => 'm:projection'
475
+ n1.coordinates :path => 'm:coordinates'
425
476
  Mods::Subject::CARTOGRAPHICS_CHILD_ELEMENTS.each { |elname|
426
- n1.send elname, :path => "#{elname}"
477
+ n1.send elname, :path => "m:#{elname}"
427
478
  }
428
479
  end
429
- n.occupation :path => 'occupation' do |n1|
480
+ n.occupation :path => 'm:occupation' do |n1|
430
481
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
431
482
  n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
432
483
  }
433
484
  end
434
485
  end # t.subject
435
-
486
+
436
487
  # TABLE_OF_CONTENTS ---------------------------------------------------------------------
437
- t.tableOfContents :path => '/mods/tableOfContents'
438
- t._tableOfContents :path => '//tableOfContents' do |n|
488
+ t.tableOfContents :path => '/m:mods/m:tableOfContents'
489
+ t._tableOfContents :path => '//m:tableOfContents' do |n|
439
490
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
440
491
  n.shareable :path => '@shareable', :accessor => lambda { |a| a.text }
441
492
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
442
493
  end
443
-
494
+
444
495
  # TARGET_AUDIENCE -----------------------------------------------------------------------
445
- t.targetAudience :path => '/mods/targetAudience'
446
- t._targetAudience :path => '//targetAudience' do |n|
496
+ t.targetAudience :path => '/m:mods/m:targetAudience'
497
+ t._targetAudience :path => '//m:targetAudience' do |n|
447
498
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
448
499
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
449
500
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
450
501
  }
451
502
  end
452
-
503
+
453
504
  # TITLE_INFO ----------------------------------------------------------------------------
454
- t.title_info :path => '/mods/titleInfo'
455
- t._title_info :path => '//titleInfo' do |n|
505
+ t.title_info :path => '/m:mods/m:titleInfo'
506
+ t._title_info :path => '//m:titleInfo' do |n|
456
507
  Mods::TitleInfo::ATTRIBUTES.each { |attr_name|
457
508
  if attr_name != 'type'
458
509
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
@@ -460,27 +511,32 @@ module Mods
460
511
  n.type_at :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
461
512
  end
462
513
  }
463
- n.title :path => 'title'
464
- n.subTitle :path => 'subTitle'
465
- n.nonSort :path => 'nonSort'
466
- n.partNumber :path => 'partNumber'
467
- n.partName :path => 'partName'
514
+ n.title :path => 'm:title'
515
+ n.subTitle :path => 'm:subTitle'
516
+ n.nonSort :path => 'm:nonSort'
517
+ n.partNumber :path => 'm:partNumber'
518
+ n.partName :path => 'm:partName'
519
+ # convenience method
468
520
  n.sort_title :path => '.', :accessor => lambda { |node|
469
- if node.type_at != "alternative" || (node.type_at == "alternative" && mods_ng_xml.xpath('/mods/titleInfo').size == 1)
521
+ if node.type_at != "alternative" || (node.type_at == "alternative" &&
522
+ mods_ng_xml.xpath('/m:mods/m:titleInfo', {'m' => Mods::MODS_NS}).size == 1)
470
523
  node.title.text + (!node.subTitle.text.empty? ? "#{@title_delimiter}#{node.subTitle.text}" : "" )
471
524
  end
472
525
  }
526
+ # convenience method
473
527
  n.full_title :path => '.', :accessor => lambda { |node|
474
528
  (!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
475
529
  node.title.text +
476
530
  (!node.subTitle.text.empty? ? "#{@title_delimiter}#{node.subTitle.text}" : "" )
477
531
  }
532
+ # convenience method
478
533
  n.short_title :path => '.', :accessor => lambda { |node|
479
534
  if node.type_at != "alternative"
480
535
  (!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
481
536
  node.title.text
482
537
  end
483
538
  }
539
+ # convenience method
484
540
  n.alternative_title :path => '.', :accessor => lambda { |node|
485
541
  if node.type_at == "alternative"
486
542
  (!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
@@ -488,53 +544,52 @@ module Mods
488
544
  end
489
545
  }
490
546
  end # t._title_info
491
-
547
+
492
548
  # TYPE_OF_RESOURCE --------------------------------------------------------------------
493
- t.typeOfResource :path => '/mods/typeOfResource'
494
- t._typeOfResource :path => '//typeOfResource' do |n|
549
+ t.typeOfResource :path => '/m:mods/m:typeOfResource'
550
+ t._typeOfResource :path => '//m:typeOfResource' do |n|
495
551
  n.collection :path => '@collection', :accessor => lambda { |a| a.text }
496
552
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
497
553
  n.manuscript :path => '@manuscript', :accessor => lambda { |a| a.text }
498
554
  n.usage :path => '@usage', :accessor => lambda { |a| a.text }
499
555
  end
500
-
501
- end # terminology
502
556
 
503
- mods_ng_xml.nom!
557
+ end # terminology
558
+
559
+ mods_ng_xml.nom!
504
560
  mods_ng_xml
505
- end # set_terminology_no_ns
506
-
507
-
508
- # set the NOM terminology; WITH namespaces
561
+ end # set_terminology_ns
562
+
563
+ # set the NOM terminology; do NOT use namespaces
509
564
  # NOTES:
510
565
  # 1. certain words, such as 'type' 'name' 'description' are reserved words in jruby or nokogiri
511
566
  # when the terminology would use these words, a suffix of '_at' is added if it is an attribute,
512
567
  # (e.g. 'type_at' for @type) and a suffix of '_el' is added if it is an element.
513
568
  # 2. the underscore prefix variant terms are a way of making subterms for a node available
514
569
  # to any instance of said node and are not intended to be used externally
515
- # @param mods_ng_xml a Nokogiri::Xml::Document object containing MODS (with namespaces)
516
- def set_terminology_ns(mods_ng_xml)
517
- mods_ng_xml.set_terminology(:namespaces => { 'm' => Mods::MODS_NS }) do |t|
570
+ # @param mods_ng_xml a Nokogiri::Xml::Document object containing MODS (without namespaces)
571
+ def set_terminology_no_ns(mods_ng_xml)
572
+ mods_ng_xml.set_terminology() do |t|
518
573
 
519
574
  # FIXME: may want to deal with camelcase vs. underscore in method_missing
520
575
 
521
576
  # ABSTRACT -------------------------------------------------------------------------------
522
- t.abstract :path => '/m:mods/m:abstract'
523
- t._abstract :path => '//m:abstract' do |n|
577
+ t.abstract :path => '/mods/abstract'
578
+ t._abstract :path => '//abstract' do |n|
524
579
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
525
580
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
526
581
  end
527
582
 
528
583
  # ACCESS_CONDITION -----------------------------------------------------------------------
529
- t.accessCondition :path => '/m:mods/m:accessCondition'
530
- t._accessCondition :path => '//m:accessCondition' do |n|
584
+ t.accessCondition :path => '/mods/accessCondition'
585
+ t._accessCondition :path => '//accessCondition' do |n|
531
586
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
532
587
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
533
588
  end
534
589
 
535
590
  # CLASSIFICATION -------------------------------------------------------------------------
536
- t.classification :path => '/m:mods/m:classification'
537
- t._classification :path => '//m:classification' do |n|
591
+ t.classification :path => '/mods/classification'
592
+ t._classification :path => '//classification' do |n|
538
593
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
539
594
  n.edition :path => '@edition', :accessor => lambda { |a| a.text }
540
595
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
@@ -543,14 +598,14 @@ module Mods
543
598
  end
544
599
 
545
600
  # EXTENSION ------------------------------------------------------------------------------
546
- t.extension :path => '/m:mods/m:extension'
547
- t._extension :path => '//m:extension' do |n|
601
+ t.extension :path => '/mods/extension'
602
+ t._extension :path => '//extension' do |n|
548
603
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
549
604
  end
550
605
 
551
606
  # GENRE ----------------------------------------------------------------------------------
552
- t.genre :path => '/m:mods/m:genre'
553
- t._genre :path => '//m:genre' do |n|
607
+ t.genre :path => '/mods/genre'
608
+ t._genre :path => '//genre' do |n|
554
609
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
555
610
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
556
611
  n.usage :path => '@usage', :accessor => lambda { |a| a.text }
@@ -560,22 +615,22 @@ module Mods
560
615
  end
561
616
 
562
617
  # IDENTIIER ------------------------------------------------------------------------------
563
- t.identifier :path => '/m:mods/m:identifier'
564
- t._identifier :path => '//m:identifier' do |n|
618
+ t.identifier :path => '/mods/identifier'
619
+ t._identifier :path => '//identifier' do |n|
565
620
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
566
621
  n.invalid :path => '@invalid', :accessor => lambda { |a| a.text }
567
622
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
568
623
  end
569
624
 
570
625
  # LANGUAGE -------------------------------------------------------------------------------
571
- t.language :path => '/m:mods/m:language'
572
- t._language :path => '//m:language' do |n|
573
- n.languageTerm :path => 'm:languageTerm'
574
- n.code_term :path => 'm:languageTerm[@type="code"]'
575
- n.text_term :path => 'm:languageTerm[@type="text"]'
576
- n.scriptTerm :path => 'm:scriptTerm'
626
+ t.language :path => '/mods/language'
627
+ t._language :path => '//language' do |n|
628
+ n.languageTerm :path => 'languageTerm'
629
+ n.code_term :path => 'languageTerm[@type="code"]'
630
+ n.text_term :path => 'languageTerm[@type="text"]'
631
+ n.scriptTerm :path => 'scriptTerm'
577
632
  end
578
- t._languageTerm :path => '//m:languageTerm' do |lt|
633
+ t._languageTerm :path => '//languageTerm' do |lt|
579
634
  lt.type_at :path => '@type', :accessor => lambda { |a| a.text }
580
635
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
581
636
  lt.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
@@ -583,29 +638,29 @@ module Mods
583
638
  end # t.language
584
639
 
585
640
  # LOCATION -------------------------------------------------------------------------------
586
- t.location :path => '/m:mods/m:location'
587
- t._location :path => '//m:location' do |n|
588
- n.physicalLocation :path => 'm:physicalLocation' do |e|
641
+ t.location :path => '/mods/location'
642
+ t._location :path => '//location' do |n|
643
+ n.physicalLocation :path => 'physicalLocation' do |e|
589
644
  e.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
590
645
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
591
646
  e.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
592
647
  }
593
648
  end
594
- n.shelfLocator :path => 'm:shelfLocator'
595
- n.url :path => 'm:url' do |e|
649
+ n.shelfLocator :path => 'shelfLocator'
650
+ n.url :path => 'url' do |e|
596
651
  e.dateLastAccessed :path => '@dateLastAccessed', :accessor => lambda { |a| a.text }
597
652
  e.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
598
653
  e.note :path => '@note', :accessor => lambda { |a| a.text }
599
654
  e.access :path => '@access', :accessor => lambda { |a| a.text }
600
655
  e.usage :path => '@usage', :accessor => lambda { |a| a.text }
601
656
  end
602
- n.holdingSimple :path => 'm:holdingSimple'
603
- n.holdingExternal :path => 'm:holdingExternal'
657
+ n.holdingSimple :path => 'holdingSimple'
658
+ n.holdingExternal :path => 'holdingExternal'
604
659
  end # t.location
605
660
 
606
661
  # NAME ------------------------------------------------------------------------------------
607
- t.plain_name :path => '/m:mods/m:name'
608
- t._plain_name :path => '//m:name' do |n|
662
+ t.plain_name :path => '/mods/name'
663
+ t._plain_name :path => '//name' do |n|
609
664
  Mods::Name::ATTRIBUTES.each { |attr_name|
610
665
  if attr_name != 'type'
611
666
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
@@ -614,14 +669,19 @@ module Mods
614
669
  end
615
670
  }
616
671
  # elements
617
- n.namePart :path => 'm:namePart' do |np|
672
+ n.namePart :path => 'namePart' do |np|
618
673
  np.type_at :path => '@type', :accessor => lambda { |a| a.text }
619
- end
620
- n.displayForm :path => 'm:displayForm'
621
- n.affiliation :path => 'm:affiliation'
622
- n.description_el :path => 'm:description' # description is used by Nokogiri
623
- n.role :path => 'm:role' do |r|
624
- r.roleTerm :path => 'm:roleTerm' do |rt|
674
+ end
675
+ n.family_name :path => 'namePart[@type="family"]'
676
+ n.given_name :path => 'namePart[@type="given"]'
677
+ n.termsOfAddress :path => 'namePart[@type="termsOfAddress"]'
678
+ n.date :path => 'namePart[@type="date"]'
679
+
680
+ n.displayForm :path => 'displayForm'
681
+ n.affiliation :path => 'affiliation'
682
+ n.description_el :path => 'description' # description is used by Nokogiri
683
+ n.role :path => 'role' do |r|
684
+ r.roleTerm :path => 'roleTerm' do |rt|
625
685
  rt.type_at :path => "@type", :accessor => lambda { |a| a.text }
626
686
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
627
687
  rt.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
@@ -630,7 +690,7 @@ module Mods
630
690
  # convenience method
631
691
  r.authority :path => '.', :accessor => lambda { |role_node|
632
692
  a = nil
633
- role_node.roleTerm.each { |role_t|
693
+ role_node.roleTerm.each { |role_t|
634
694
  # role_t.authority will be [] if it is missing from an earlier roleTerm
635
695
  if role_t.authority && (!a || a.size == 0)
636
696
  a = role_t.authority
@@ -642,7 +702,7 @@ module Mods
642
702
  r.code :path => '.', :accessor => lambda { |role_node|
643
703
  c = nil
644
704
  role_node.roleTerm.each { |role_t|
645
- if role_t.type_at == 'code'
705
+ if role_t.type_at == 'code'
646
706
  c ||= role_t.text
647
707
  end
648
708
  }
@@ -652,7 +712,7 @@ module Mods
652
712
  r.value :path => '.', :accessor => lambda { |role_node|
653
713
  val = nil
654
714
  role_node.roleTerm.each { |role_t|
655
- if role_t.type_at == 'text'
715
+ if role_t.type_at == 'text'
656
716
  val ||= role_t.text
657
717
  end
658
718
  }
@@ -663,43 +723,89 @@ module Mods
663
723
  val
664
724
  }
665
725
  end # role node
666
- end # t._plain_name
667
726
 
668
- t.personal_name :path => '/m:mods/m:name[@type="personal"]'
669
- t._personal_name :path => '//m:name[@type="personal"]' do |n|
670
- n.family_name :path => 'm:namePart[@type="family"]'
671
- n.given_name :path => 'm:namePart[@type="given"]'
672
- n.termsOfAddress :path => 'm:namePart[@type="termsOfAddress"]'
673
- n.date :path => 'm:namePart[@type="date"]'
674
- end
727
+ # name convenience method
728
+ # uses the displayForm of a name if present
729
+ # if no displayForm, try to make a string from family, given and terms of address
730
+ # otherwise, return all non-date nameParts concatenated together
731
+ n.display_value :path => '.', :single => true, :accessor => lambda {|name_node|
732
+ dv = ''
733
+ if name_node.displayForm && name_node.displayForm.text.size > 0
734
+ dv = name_node.displayForm.text
735
+ end
736
+ if dv.empty?
737
+ if name_node.type_at == 'personal'
738
+ if name_node.family_name.size > 0
739
+ dv = name_node.given_name.size > 0 ? "#{name_node.family_name.text}, #{name_node.given_name.text}" : name_node.family_name.text
740
+ elsif name_node.given_name.size > 0
741
+ dv = name_node.given_name.text
742
+ end
743
+ if !dv.empty?
744
+ first = true
745
+ name_node.namePart.each { |np|
746
+ if np.type_at == 'termsOfAddress' && !np.text.empty?
747
+ if first
748
+ dv = dv + " " + np.text
749
+ first = false
750
+ else
751
+ dv = dv + ", " + np.text
752
+ end
753
+ end
754
+ }
755
+ else # no family or given name
756
+ dv = name_node.namePart.select {|np| np.type_at != 'date' && !np.text.empty?}.join(" ")
757
+ end
758
+ else # not a personal name
759
+ dv = name_node.namePart.select {|np| np.type_at != 'date' && !np.text.empty?}.join(" ")
760
+ end
761
+ end
762
+ dv.strip.empty? ? nil : dv.strip
763
+ }
764
+
765
+ # name convenience method
766
+ n.display_value_w_date :path => '.', :single => true, :accessor => lambda {|name_node|
767
+ dv = '' + name_node.display_value
768
+ name_node.namePart.each { |np|
769
+ if np.type_at == 'date' && !np.text.empty? && !dv.end_with?(np.text)
770
+ dv = dv + ", #{np.text}"
771
+ end
772
+ }
773
+ if dv.start_with?(', ')
774
+ dv.sub(', ', '')
775
+ end
776
+ dv.strip.empty? ? nil : dv.strip
777
+ }
778
+ end # t._plain_name
675
779
 
676
- t.corporate_name :path => '/m:mods/m:name[@type="corporate"]'
677
- t._corporate_name :path => '//m:name[@type="corporate"]'
678
- t.conference_name :path => '/m:mods/m:name[@type="conference"]'
679
- t._conference_name :path => '//m:name[@type="conference"]'
780
+ t.personal_name :path => '/mods/name[@type="personal"]'
781
+ t._personal_name :path => '//name[@type="personal"]'
782
+ t.corporate_name :path => '/mods/name[@type="corporate"]'
783
+ t._corporate_name :path => '//name[@type="corporate"]'
784
+ t.conference_name :path => '/mods/name[@type="conference"]'
785
+ t._conference_name :path => '//name[@type="conference"]'
680
786
 
681
787
  # NOTE ---------------------------------------------------------------------------------
682
- t.note :path => '/m:mods/m:note'
683
- t._note :path => '//m:note' do |n|
788
+ t.note :path => '/mods/note'
789
+ t._note :path => '//note' do |n|
684
790
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
685
791
  n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
686
792
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
687
793
  end
688
794
 
689
795
  # ORIGIN_INFO --------------------------------------------------------------------------
690
- t.origin_info :path => '/m:mods/m:originInfo'
691
- t._origin_info :path => '//m:originInfo' do |n|
692
- n.place :path => 'm:place' do |e|
693
- e.placeTerm :path => 'm:placeTerm' do |ee|
796
+ t.origin_info :path => '/mods/originInfo'
797
+ t._origin_info :path => '//originInfo' do |n|
798
+ n.place :path => 'place' do |e|
799
+ e.placeTerm :path => 'placeTerm' do |ee|
694
800
  ee.type_at :path => '@type', :accessor => lambda { |a| a.text }
695
801
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
696
802
  ee.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
697
803
  }
698
804
  end
699
805
  end
700
- n.publisher :path => 'm:publisher'
806
+ n.publisher :path => 'publisher'
701
807
  Mods::ORIGIN_INFO_DATE_ELEMENTS.each { |date_el|
702
- n.send date_el, :path => "m:#{date_el}" do |d|
808
+ n.send date_el, :path => "#{date_el}" do |d|
703
809
  Mods::DATE_ATTRIBS.each { |attr_name|
704
810
  d.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
705
811
  }
@@ -708,9 +814,9 @@ module Mods
708
814
  end
709
815
  end
710
816
  }
711
- n.edition :path => 'm:edition'
712
- n.issuance :path => 'm:issuance'
713
- n.frequency :path => 'm:frequency' do |f|
817
+ n.edition :path => 'edition'
818
+ n.issuance :path => 'issuance'
819
+ n.frequency :path => 'frequency' do |f|
714
820
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
715
821
  f.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
716
822
  }
@@ -718,97 +824,97 @@ module Mods
718
824
  end # t.origin_info
719
825
 
720
826
  # PART -----------------------------------------------------------------------------------
721
- t.part :path => '/m:mods/m:part'
722
- t._part :path => '//m:part' do |n|
827
+ t.part :path => '/mods/part'
828
+ t._part :path => '//part' do |n|
723
829
  # attributes
724
830
  n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
725
831
  n.order :path => '@order', :accessor => lambda { |a| a.text }
726
832
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
727
833
  # child elements
728
- n.detail :path => 'm:detail' do |e|
834
+ n.detail :path => 'detail' do |e|
729
835
  # attributes
730
836
  e.level :path => '@level', :accessor => lambda { |a| a.text }
731
837
  e.type_at :path => '@type', :accessor => lambda { |a| a.text }
732
838
  # elements
733
- e.number :path => 'm:number'
734
- e.caption :path => 'm:caption'
735
- e.title :path => 'm:title'
839
+ e.number :path => 'number'
840
+ e.caption :path => 'caption'
841
+ e.title :path => 'title'
736
842
  end
737
- n.extent :path => 'm:extent' do |e| # TODO: extent is ordered in xml schema
843
+ n.extent :path => 'extent' do |e| # TODO: extent is ordered in xml schema
738
844
  # attributes
739
845
  e.unit :path => '@unit', :accessor => lambda { |a| a.text }
740
846
  # elements
741
- e.start :path => 'm:start'
742
- e.end :path => 'm:end'
743
- e.total :path => 'm:total'
744
- e.list :path => 'm:list'
847
+ e.start :path => 'start'
848
+ e.end :path => 'end'
849
+ e.total :path => 'total'
850
+ e.list :path => 'list'
745
851
  end
746
- n.date :path => 'm:date' do |e|
852
+ n.date :path => 'date' do |e|
747
853
  Mods::DATE_ATTRIBS.reject { |a| a == 'keyDate' }.each { |attr_name|
748
854
  e.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
749
855
  }
750
856
  end
751
- n.text_el :path => 'm:text' do |e|
857
+ n.text_el :path => 'text' do |e|
752
858
  e.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
753
859
  e.type_at :path => '@type', :accessor => lambda { |a| a.text }
754
860
  end
755
861
  end # t._part
756
862
 
757
863
  # PHYSICAL_DESCRIPTION -------------------------------------------------------------------
758
- t.physical_description :path => '/m:mods/m:physicalDescription'
759
- t._physical_description :path => '//m:physicalDescription' do |n|
760
- n.digitalOrigin :path => 'm:digitalOrigin'
761
- n.extent :path => 'm:extent'
762
- n.form :path => 'm:form' do |f|
864
+ t.physical_description :path => '/mods/physicalDescription'
865
+ t._physical_description :path => '//physicalDescription' do |n|
866
+ n.digitalOrigin :path => 'digitalOrigin'
867
+ n.extent :path => 'extent'
868
+ n.form :path => 'form' do |f|
763
869
  f.type_at :path => '@type', :accessor => lambda { |a| a.text }
764
870
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
765
871
  f.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
766
872
  }
767
873
  end
768
- n.internetMediaType :path => 'm:internetMediaType'
769
- n.note :path => 'm:note' do |nn|
874
+ n.internetMediaType :path => 'internetMediaType'
875
+ n.note :path => 'note' do |nn|
770
876
  nn.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
771
877
  nn.type_at :path => '@type', :accessor => lambda { |a| a.text }
772
878
  end
773
- n.reformattingQuality :path => 'm:reformattingQuality'
879
+ n.reformattingQuality :path => 'reformattingQuality'
774
880
  end
775
881
 
776
882
  # RECORD_INFO --------------------------------------------------------------------------
777
- t.record_info :path => '/m:mods/m:recordInfo'
778
- t._record_info :path => '//m:recordInfo' do |n|
883
+ t.record_info :path => '/mods/recordInfo'
884
+ t._record_info :path => '//recordInfo' do |n|
779
885
  # attributes
780
886
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
781
887
  Mods::LANG_ATTRIBS.each { |attr_name|
782
888
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
783
889
  }
784
890
  # child elements
785
- n.recordContentSource :path => 'm:recordContentSource' do |r|
891
+ n.recordContentSource :path => 'recordContentSource' do |r|
786
892
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
787
893
  r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
788
894
  }
789
895
  end
790
- n.recordCreationDate :path => 'm:recordCreationDate' do |r|
896
+ n.recordCreationDate :path => 'recordCreationDate' do |r|
791
897
  Mods::DATE_ATTRIBS.each { |attr_name|
792
898
  r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
793
899
  }
794
900
  end
795
- n.recordChangeDate :path => 'm:recordChangeDate' do |r|
901
+ n.recordChangeDate :path => 'recordChangeDate' do |r|
796
902
  Mods::DATE_ATTRIBS.each { |attr_name|
797
903
  r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
798
904
  }
799
905
  end
800
- n.recordIdentifier :path => 'm:recordIdentifier' do |r|
906
+ n.recordIdentifier :path => 'recordIdentifier' do |r|
801
907
  r.source :path => '@source', :accessor => lambda { |a| a.text }
802
908
  end
803
- n.recordOrigin :path => 'm:recordOrigin'
804
- n.languageOfCataloging :path => 'm:languageOfCataloging' do |r|
909
+ n.recordOrigin :path => 'recordOrigin'
910
+ n.languageOfCataloging :path => 'languageOfCataloging' do |r|
805
911
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
806
912
  r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
807
913
  }
808
- r.languageTerm :path => 'm:languageTerm'
809
- r.scriptTerm :path => 'm:scriptTerm'
914
+ r.languageTerm :path => 'languageTerm'
915
+ r.scriptTerm :path => 'scriptTerm'
810
916
  end
811
- n.descriptionStandard :path => 'm:descriptionStandard' do |r|
917
+ n.descriptionStandard :path => 'descriptionStandard' do |r|
812
918
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
813
919
  r.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
814
920
  }
@@ -816,53 +922,53 @@ module Mods
816
922
  end # t._record_info
817
923
 
818
924
  # RELATED_ITEM-------------------------------------------------------------------------
819
- t.related_item :path => '/m:mods/m:relatedItem' do |n|
925
+ t.related_item :path => '/mods/relatedItem' do |n|
820
926
  # attributes
821
927
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
822
928
  n.id_at :path => '@ID', :accessor => lambda { |a| a.text }
823
929
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
824
930
  # elements
825
931
  n.abstract :path => 'abstract'
826
- n.accessCondition :path => 'm:accessCondition'
827
- n.classification :path => 'm:classification'
828
- n.extension :path => 'm:extension'
829
- n.genre :path => 'm:genre'
830
- n.identifier :path => 'm:identifier'
831
- n.language :path => 'm:language'
832
- n.location :path => 'm:location'
833
- n.name_el :path => 'm:name' # Note: 'name' is used by Nokogiri
834
- n.personal_name :path => 'm:name[@type="personal"]'
835
- n.corporate_name :path => 'm:name[@type="corporate"]'
836
- n.conference_name :path => 'm:name[@type="conference"]'
837
- n.note :path => 'm:note'
838
- n.originInfo :path => 'm:originInfo'
839
- n.part :path => 'm:part'
840
- n.physicalDescription :path => 'm:physicalDescription'
841
- n.recordInfo :path => 'm:recordInfo'
842
- n.subject :path => 'm:subject'
843
- n.tableOfContents :path => 'm:tableOfContents'
844
- n.targetAudience :path => 'm:targetAudience'
845
- n.titleInfo :path => 'm:titleInfo'
846
- n.typeOfResource :path => 'm:typeOfResource'
932
+ n.accessCondition :path => 'accessCondition'
933
+ n.classification :path => 'classification'
934
+ n.extension :path => 'extension'
935
+ n.genre :path => 'genre'
936
+ n.identifier :path => 'identifier'
937
+ n.language :path => 'language'
938
+ n.location :path => 'location'
939
+ n.name_el :path => 'name' # Note: 'name' is used by Nokogiri
940
+ n.personal_name :path => 'name[@type="personal"]'
941
+ n.corporate_name :path => 'name[@type="corporate"]'
942
+ n.conference_name :path => 'name[@type="conference"]'
943
+ n.note :path => 'note'
944
+ n.originInfo :path => 'originInfo'
945
+ n.part :path => 'part'
946
+ n.physicalDescription :path => 'physicalDescription'
947
+ n.recordInfo :path => 'recordInfo'
948
+ n.subject :path => 'subject'
949
+ n.tableOfContents :path => 'tableOfContents'
950
+ n.targetAudience :path => 'targetAudience'
951
+ n.titleInfo :path => 'titleInfo'
952
+ n.typeOfResource :path => 'typeOfResource'
847
953
  end
848
954
 
849
955
  # SUBJECT -----------------------------------------------------------------------------
850
- t.subject :path => '/m:mods/m:subject'
851
- t._subject :path => '//m:subject' do |n|
956
+ t.subject :path => '/mods/subject'
957
+ t._subject :path => '//subject' do |n|
852
958
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
853
959
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
854
960
  }
855
- n.topic :path => 'm:topic' do |n1|
961
+ n.topic :path => 'topic' do |n1|
856
962
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
857
963
  n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
858
964
  }
859
965
  end
860
- n.geographic :path => 'm:geographic' do |n1|
966
+ n.geographic :path => 'geographic' do |n1|
861
967
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
862
968
  n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
863
969
  }
864
970
  end
865
- n.temporal :path => 'm:temporal' do |n1|
971
+ n.temporal :path => 'temporal' do |n1|
866
972
  # date attributes as elements
867
973
  Mods::DATE_ATTRIBS.each { |attr_name|
868
974
  n1.send attr_name, :path => "#{attr_name}"
@@ -875,47 +981,47 @@ module Mods
875
981
  n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
876
982
  }
877
983
  end
878
- n.titleInfo :path => 'm:titleInfo' do |t1|
984
+ n.titleInfo :path => 'titleInfo' do |t1|
879
985
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
880
986
  t1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
881
987
  }
882
988
  end
883
989
  # Note: 'name' is used by Nokogiri
884
- n.name_el :path => 'm:name' do |t1|
990
+ n.name_el :path => 'name' do |t1|
885
991
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
886
992
  t1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
887
993
  }
888
994
  end
889
- n.personal_name :path => 'm:name[@type="personal"]'
890
- n.corporate_name :path => 'm:name[@type="corporate"]'
891
- n.conference_name :path => 'm:name[@type="conference"]'
892
- n.geographicCode :path => 'm:geographicCode' do |g|
995
+ n.personal_name :path => 'name[@type="personal"]'
996
+ n.corporate_name :path => 'name[@type="corporate"]'
997
+ n.conference_name :path => 'name[@type="conference"]'
998
+ n.geographicCode :path => 'geographicCode' do |g|
893
999
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
894
1000
  g.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
895
1001
  }
896
1002
  end
897
- n.genre :path => 'm:genre' do |n1|
1003
+ n.genre :path => 'genre' do |n1|
898
1004
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
899
1005
  n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
900
1006
  }
901
1007
  end
902
- n.hierarchicalGeographic :path => 'm:hierarchicalGeographic' do |n1|
1008
+ n.hierarchicalGeographic :path => 'hierarchicalGeographic' do |n1|
903
1009
  Mods::Subject::HIER_GEO_CHILD_ELEMENTS.each { |elname|
904
- n1.send elname, :path => "m:#{elname}"
1010
+ n1.send elname, :path => "#{elname}"
905
1011
  }
906
1012
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
907
1013
  n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
908
1014
  }
909
1015
  end
910
- n.cartographics :path => 'm:cartographics' do |n1|
911
- n1.scale :path => 'm:scale'
912
- n1.projection :path => 'm:projection'
913
- n1.coordinates :path => 'm:coordinates'
1016
+ n.cartographics :path => 'cartographics' do |n1|
1017
+ n1.scale :path => 'scale'
1018
+ n1.projection :path => 'projection'
1019
+ n1.coordinates :path => 'coordinates'
914
1020
  Mods::Subject::CARTOGRAPHICS_CHILD_ELEMENTS.each { |elname|
915
- n1.send elname, :path => "m:#{elname}"
1021
+ n1.send elname, :path => "#{elname}"
916
1022
  }
917
1023
  end
918
- n.occupation :path => 'm:occupation' do |n1|
1024
+ n.occupation :path => 'occupation' do |n1|
919
1025
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
920
1026
  n1.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
921
1027
  }
@@ -923,16 +1029,16 @@ module Mods
923
1029
  end # t.subject
924
1030
 
925
1031
  # TABLE_OF_CONTENTS ---------------------------------------------------------------------
926
- t.tableOfContents :path => '/m:mods/m:tableOfContents'
927
- t._tableOfContents :path => '//m:tableOfContents' do |n|
1032
+ t.tableOfContents :path => '/mods/tableOfContents'
1033
+ t._tableOfContents :path => '//tableOfContents' do |n|
928
1034
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
929
1035
  n.shareable :path => '@shareable', :accessor => lambda { |a| a.text }
930
1036
  n.type_at :path => '@type', :accessor => lambda { |a| a.text }
931
1037
  end
932
1038
 
933
1039
  # TARGET_AUDIENCE -----------------------------------------------------------------------
934
- t.targetAudience :path => '/m:mods/m:targetAudience'
935
- t._targetAudience :path => '//m:targetAudience' do |n|
1040
+ t.targetAudience :path => '/mods/targetAudience'
1041
+ t._targetAudience :path => '//targetAudience' do |n|
936
1042
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
937
1043
  Mods::AUTHORITY_ATTRIBS.each { |attr_name|
938
1044
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
@@ -940,8 +1046,8 @@ module Mods
940
1046
  end
941
1047
 
942
1048
  # TITLE_INFO ----------------------------------------------------------------------------
943
- t.title_info :path => '/m:mods/m:titleInfo'
944
- t._title_info :path => '//m:titleInfo' do |n|
1049
+ t.title_info :path => '/mods/titleInfo'
1050
+ t._title_info :path => '//titleInfo' do |n|
945
1051
  Mods::TitleInfo::ATTRIBUTES.each { |attr_name|
946
1052
  if attr_name != 'type'
947
1053
  n.send attr_name, :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
@@ -949,32 +1055,27 @@ module Mods
949
1055
  n.type_at :path => "@#{attr_name}", :accessor => lambda { |a| a.text }
950
1056
  end
951
1057
  }
952
- n.title :path => 'm:title'
953
- n.subTitle :path => 'm:subTitle'
954
- n.nonSort :path => 'm:nonSort'
955
- n.partNumber :path => 'm:partNumber'
956
- n.partName :path => 'm:partName'
957
- # convenience method
1058
+ n.title :path => 'title'
1059
+ n.subTitle :path => 'subTitle'
1060
+ n.nonSort :path => 'nonSort'
1061
+ n.partNumber :path => 'partNumber'
1062
+ n.partName :path => 'partName'
958
1063
  n.sort_title :path => '.', :accessor => lambda { |node|
959
- if node.type_at != "alternative" || (node.type_at == "alternative" &&
960
- mods_ng_xml.xpath('/m:mods/m:titleInfo', {'m' => Mods::MODS_NS}).size == 1)
1064
+ if node.type_at != "alternative" || (node.type_at == "alternative" && mods_ng_xml.xpath('/mods/titleInfo').size == 1)
961
1065
  node.title.text + (!node.subTitle.text.empty? ? "#{@title_delimiter}#{node.subTitle.text}" : "" )
962
1066
  end
963
1067
  }
964
- # convenience method
965
1068
  n.full_title :path => '.', :accessor => lambda { |node|
966
1069
  (!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
967
1070
  node.title.text +
968
1071
  (!node.subTitle.text.empty? ? "#{@title_delimiter}#{node.subTitle.text}" : "" )
969
1072
  }
970
- # convenience method
971
1073
  n.short_title :path => '.', :accessor => lambda { |node|
972
1074
  if node.type_at != "alternative"
973
1075
  (!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
974
1076
  node.title.text
975
1077
  end
976
1078
  }
977
- # convenience method
978
1079
  n.alternative_title :path => '.', :accessor => lambda { |node|
979
1080
  if node.type_at == "alternative"
980
1081
  (!node.nonSort.text.empty? ? "#{node.nonSort.text} " : "" ) +
@@ -984,8 +1085,8 @@ module Mods
984
1085
  end # t._title_info
985
1086
 
986
1087
  # TYPE_OF_RESOURCE --------------------------------------------------------------------
987
- t.typeOfResource :path => '/m:mods/m:typeOfResource'
988
- t._typeOfResource :path => '//m:typeOfResource' do |n|
1088
+ t.typeOfResource :path => '/mods/typeOfResource'
1089
+ t._typeOfResource :path => '//typeOfResource' do |n|
989
1090
  n.collection :path => '@collection', :accessor => lambda { |a| a.text }
990
1091
  n.displayLabel :path => '@displayLabel', :accessor => lambda { |a| a.text }
991
1092
  n.manuscript :path => '@manuscript', :accessor => lambda { |a| a.text }
@@ -993,12 +1094,11 @@ module Mods
993
1094
  end
994
1095
 
995
1096
  end # terminology
996
-
997
- mods_ng_xml.nom!
1097
+
1098
+ mods_ng_xml.nom!
998
1099
  mods_ng_xml
999
- end # set_terminology_ns
1000
-
1001
- end
1002
-
1003
- end
1100
+ end # set_terminology_no_ns
1101
+
1102
+ end # Record class
1103
+ end # Mods module
1004
1104