lib/marc_cleanup/bib_rubymarc_fixes.rb
### Replace invalid XML 1.0 characters with a space
Replace invalid XML 1.0 characters with a space
Replace invalid XML 1 . 0 characters with a space
def invalid_xml_fix(record)
    bad_xml_range = /[\u0000-\u0008\u000B\u000C\u000E-\u001C\u007F-\u0084\u0086-\u009F\uFDD0-\uFDEF\uFFFE\uFFFF]/
    record.leader.gsub!(bad_xml_range, ' ')
    record.fields.each do |field|
      field_index = record.fields.index(field)
      if field.class == MARC::DataField
        curr_subfield = 0
        final_subfield = field.subfields.length
        while curr_subfield < final_subfield
          record.fields[field_index].subfields[curr_subfield].value.gsub!(bad_xml_range, ' ')
          curr_subfield += 1
        end
      else
        record.fields[field_index].value.gsub!(bad_xml_range, ' ')
      end
    end
    record
  end
def invalid_xml_fix ( record ) bad_xml_range = / [ \u0000 - \u0008 \u000B \u000C \u000E - \u001C \u007F - \u0084 \u0086 - \u009F \uFDD0 - \uFDEF \uFFFE \uFFFF ] / record . leader . gsub! ( bad_xml_range , ' ' ) record . fields . each do | field | field_index = record . fields . index ( field ) if field . class == MARC :: DataField curr_subfield = 0 final_subfield = field . subfields . length while curr_subfield < final_subfield record . fields [ field_index ] . subfields [ curr_subfield ] . value . gsub! ( bad_xml_range , ' ' ) curr_subfield += 1 end else record . fields [ field_index ] . value . gsub! ( bad_xml_range , ' ' ) end end record end
Replace invalid XML 1.0 characters with a space
Replace invalid XML 1 . 0 characters with a space
record