316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
|
# File 'lib/marc/xml_parsers.rb', line 316
def build_record
r = MARC::Record.new()
until (@parser.local_name == 'record' and @parser.node_type == XML::Reader::TYPE_END_ELEMENT) do
@parser.read
next if @parser.node_type == XML::Reader::TYPE_END_ELEMENT
case @parser.local_name
when 'leader'
@parser.read
r.leader = @parser.value
when 'controlfield'
tag = @parser['tag']
@parser.read
r << MARC::ControlField.new(tag, @parser.value)
when 'datafield'
data = MARC::DataField.new(@parser['tag'], @parser['ind1'], @parser['ind2'])
while (@parser.read and !(@parser.local_name == 'datafield' and @parser.node_type == XML::Reader::TYPE_END_ELEMENT)) do
next if @parser.node_type == XML::Reader::TYPE_END_ELEMENT
case @parser.local_name
when 'subfield'
code =@parser['code']
@parser.read
data.append(MARC::Subfield.new(code, @parser.value))
end
end
r << data
end end return r
end
|