multi on non-multi mapping error implemented
[migration-tools.git] / Equinox-Migration / lib / Equinox / Migration / MapDrivenMARCXMLProc.pm
index 9297105..2854546 100644 (file)
@@ -6,6 +6,16 @@ use strict;
 use XML::Twig;
 use Equinox::Migration::SubfieldMapper 1.002;
 
+# FIXME
+#
+# sample functionality should be extracted into a new module which
+# uses E::M::SM to drive sampling of individual datafields, and
+# reports ALL datafields which occur
+#
+# --sample should give the list of all datafields
+# --samplefile should take a SM map as teh argument and introspect the mapped datafields
+
+
 =head1 NAME
 
 Equinox::Migration::MapDrivenMARCXMLProc
@@ -123,6 +133,8 @@ sub parse_record {
     $record->purge;
     $self->{data}{rptr}++;
 
+    # FIXME check for required fields here
+
     return $self->{data}{crec};
 }
 
@@ -190,10 +202,44 @@ sub process_subs {
             push @{$dataf->{multi}{$name}}, $sub->text;
         }
     } else {
+        die "Multiple occurances of a non-multi field: $tag$code at rec ",($self->{data}{rptr} + 1),"\n"
+          if (defined $dataf->{uni}{$code});
         $dataf->{uni}{$code} = $sub->text;
     }
 }
 
+=head1 MODIFIERS
+
+MapDrivenMARCXMLProc implements the following modifiers, and passes
+them to L<Equinox::Migration::SubfieldMapper>, meaning that specifying
+any other modifiers in a MDMP map file will cause a fatal error when
+it is processed.
+
+=head2 multi
+
+If a mapping is declared to be C<multi>, then MDMP expects to see more
+than one instance of that subfield per datafield, and the data is
+handled accordingly (see L</PARSED RECORDS> below).
+
+Occurring zero or one time is legal for a C<multi> mapping.
+
+A mapping which is not flagged as C<multi>, but which occurs more than
+once per datafield will cause a fatal error.
+
+=head2 bib
+
+The C<bib> modifier declares that a mapping is "bib-level", and should
+be encountered once per B<record> instead of once per B<datafield> --
+which is another way of saying that it occurs in a non-repeating
+datafield or in a controlfield.
+
+=head2 required
+
+By default, if a mapping does not occur in a datafield (or record, in
+the case of C<bib> mappings), processing continues normally. if a
+mapping has the C<required> modifier, however, it must appear, or a
+fatal error will occur.
+
 =head1 PARSED RECORDS
 
 Given: