All pastes #2054021 Raw Edit

Unnamed

public sql v1 · immutable
#2054021 ·published 2011-05-05 00:27 UTC
rendered paste body
CREATE OR REPLACE FUNCTION marc_cleanup_james (TEXT) RETURNS TEXT AS $$$_ = $_[0];s/\n\s*//g; # linebreaks and whitespace#  add indicators to tags without thems/datafield tag="(...)">/datafield tag="$1" ind1=" " ind2=" ">/g;# make blank indicators from null oness/ind1=""/ind1=" "/g;s/ind2=""/ind2=" "/g;# remove namespace stuffs/ xmlns.marc.\"http...www.loc.gov.MARC21.slim.\" //g;s/ xmlns\:marc\=\"http\:\/\/www\.loc\.gov\/MARC21\/slim\"//g;s/marc\:record/record/g;#delete datafields without a tag values/<datafield tag="".+?<\/datafield>//g;# seen a few examples of thiss/tag="undefined"/tag="020"/g;# make subfields a 999 if they only have 1 character tagss/tag="."/tag="999"/g;# if they have 2 character tags, add a 0 to the fields/tag="(..)"/tag="0$1"/g;# remove empty elementss/<datafield tag="..." ind1=" " ind2=" "\/>//g;return $_;$$ LANGUAGE plperlu;