Inheritance: MODS_Info, iMetadata_Module
Ejemplo n.º 1
0
        /// <summary> Constructor for a new instance of the SobekCM_Item class </summary>
        public SobekCM_Item()
        {
            metsInfo = new METS_Header_Info();
            behaviorInfo = new Behaviors_Info();
            divInfo = new Division_Info();
            BIBInfo = new Bibliographic_Info();
            web = new Web_Info(behaviorInfo);
            analyzed_for_complex_content = false;
            contains_complex_content = false;
            using_complex_template = false;
            DiskSize_KB = 0;
              //          main_thumbnail = String.Empty;

            // If there is a metadata configuration which calls for a metadata
            // extension module to always be used, add it now
            if (Metadata_Configuration.Metadata_Modules_To_Include.Count > 0)
            {
                foreach (Additional_Metadata_Module_Config thisConfig in Metadata_Configuration.Metadata_Modules_To_Include)
                {
                    iMetadata_Module toInclude = thisConfig.Get_Module();
                    if (toInclude != null)
                    {
                        Add_Metadata_Module( thisConfig.Key, toInclude );
                    }
                }
            }
        }
        /// <summary> Reads the MARC Core-compliant section of XML and stores the data in the provided digital resource </summary>
        /// <param name="r"> XmlTextReader from which to read the marc data </param>
        /// <param name="thisBibInfo">Bibliographic object into which most the values are read</param>
        /// <param name="package"> Digital resource object to save the data to if this is reading the top-level bibDesc (OPTIONAL)</param>
        /// <param name="Importing_Record"> Importing record flag is used to determine if special treatment should be applied to the 001 identifier.  If this is reading MarcXML from a dmdSec, this is set to false </param>
        /// <param name="Options"> Dictionary of any options which this metadata reader/writer may utilize </param>
        public static void Read_MarcXML_Info(XmlReader r, Bibliographic_Info thisBibInfo, SobekCM_Item package, bool Importing_Record, Dictionary<string, object> Options )
        {
            // Create the MARC_XML_Reader to load everything into first
            MARC_Record record = new MARC_Record();

            // Read from the file
            record.Read_MARC_Info(r);

            // Handle optional mapping first for retaining the 856 as a related link
            if ((Options != null) && (Options.ContainsKey("MarcXML_File_ReaderWriter.Retain_856_As_Related_Link")))
            {
                if (Options["MarcXML_File_ReaderWriter.Retain_856_As_Related_Link"].ToString().ToUpper() == "TRUE")
                {
                    if ((record.Get_Data_Subfield(856, 'u').Length > 0) && (record.Get_Data_Subfield(856, 'y').Length > 0))
                    {
                        string url856 = record.Get_Data_Subfield(856, 'u');
                        string label856 = record.Get_Data_Subfield(856, 'y');

                        thisBibInfo.Location.Other_URL = url856;
                        thisBibInfo.Location.Other_URL_Note = label856;
                    }
                }
            }

            // Now, load values into the bib package
            // Load the date ( 260 |c )
            thisBibInfo.Origin_Info.MARC_DateIssued = Remove_Trailing_Punctuation(record.Get_Data_Subfield(260, 'c'));

            // Load the descriptions and notes about this item
            Add_Descriptions(thisBibInfo, record);

            // Look for the 786  with special identifiers to map back into the source notes
            foreach (MARC_Field thisRecord in record[786])
            {
                if ((thisRecord.Indicators == "0 ") && (thisRecord.Subfield_Count == 1) && (thisRecord.has_Subfield('n')))
                    thisBibInfo.Add_Note(thisRecord.Subfields[0].Data, Note_Type_Enum.Source);
            }

            // Add the contents (505)
            if (record.Get_Data_Subfield(505, 'a').Length > 2)
            {
                thisBibInfo.Add_TableOfContents(record.Get_Data_Subfield(505, 'a'));
            }

            // Get the scale information (034)
            if (record.Get_Data_Subfield(034, 'b').Length > 2)
            {
                thisBibInfo.Add_Scale(record.Get_Data_Subfield(034, 'b'), "SUBJ034");
            }

            // Get the scale information (255)
            if ((record.Get_Data_Subfield(255, 'a').Length > 2) || (record.Get_Data_Subfield(255, 'b').Length > 2) || (record.Get_Data_Subfield(255, 'c').Length > 2))
            {
                thisBibInfo.Add_Scale(record.Get_Data_Subfield(255, 'a'), record.Get_Data_Subfield(255, 'b'), record.Get_Data_Subfield(255, 'c'), "SUBJ255");
            }

            // Get the coordinate information (034)
            if ((record.Get_Data_Subfield(034, 'd').Length > 0) && (record.Get_Data_Subfield(034, 'e').Length > 0) && (record.Get_Data_Subfield(034, 'f').Length > 0) && (record.Get_Data_Subfield(034, 'g').Length > 0))
            {
                // This is an extra metadata component
                GeoSpatial_Information geoInfo = package.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information;
                if (geoInfo == null)
                {
                    geoInfo = new GeoSpatial_Information();
                    package.Add_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY, geoInfo);
                }

                if (geoInfo.Polygon_Count == 0)
                {
                    try
                    {

                        string d_field = record.Get_Data_Subfield(034, 'd').Replace("O", "0");
                        string e_field = record.Get_Data_Subfield(034, 'e').Replace("O", "0");
                        string f_field = record.Get_Data_Subfield(034, 'f').Replace("O", "0");
                        string g_field = record.Get_Data_Subfield(034, 'g').Replace("O", "0");

                        double d_value = 1;
                        double e_value = 1;
                        double f_value = 1;
                        double g_value = 1;

                        if (d_field.Contains("."))
                        {
                            if (d_field.Contains("W"))
                            {
                                d_value = -1*Convert.ToDouble(d_field.Replace("W", ""));
                            }
                            else
                            {
                                d_value = Convert.ToDouble(d_field.Replace("E", ""));
                            }
                        }
                        else
                        {
                            d_value = Convert.ToDouble(d_field.Substring(1, 3)) + (Convert.ToDouble(d_field.Substring(4, 2))/60);

                            if ((d_field[0] == '-') || (d_field[0] == 'W'))
                            {
                                d_value = -1*d_value;
                            }
                        }

                        if (d_value < -180)
                            d_value = d_value + 360;

                        if (e_field.Contains("."))
                        {
                            if (e_field.Contains("W"))
                            {
                                e_value = -1*Convert.ToDouble(e_field.Replace("W", ""));
                            }
                            else
                            {
                                e_value = Convert.ToDouble(e_field.Replace("E", ""));
                            }
                        }
                        else
                        {
                            e_value = Convert.ToDouble(e_field.Substring(1, 3)) + (Convert.ToDouble(e_field.Substring(4, 2))/60);

                            if ((e_field[0] == '-') || (e_field[0] == 'W'))
                            {
                                e_value = -1*e_value;
                            }
                        }

                        if (e_value < -180)
                            e_value = e_value + 360;

                        if (f_field.Contains("."))
                        {
                            if (f_field.Contains("S"))
                            {
                                f_value = -1*Convert.ToDouble(f_field.Replace("S", ""));
                            }
                            else
                            {
                                f_value = Convert.ToDouble(f_field.Replace("N", ""));
                            }
                        }
                        else
                        {
                            f_value = Convert.ToDouble(f_field.Substring(1, 3)) + (Convert.ToDouble(f_field.Substring(4, 2))/60);

                            if ((f_field[0] == '-') || (f_field[0] == 'S'))
                            {
                                f_value = -1*f_value;
                            }
                        }

                        if (g_field.Contains("."))
                        {
                            if (g_field.Contains("S"))
                            {
                                g_value = -1*Convert.ToDouble(g_field.Replace("S", ""));
                            }
                            else
                            {
                                g_value = Convert.ToDouble(g_field.Replace("N", ""));
                            }
                        }
                        else
                        {
                            g_value = Convert.ToDouble(g_field.Substring(1, 3)) + (Convert.ToDouble(g_field.Substring(4, 2))/60);

                            if ((g_field[0] == '-') || (g_field[0] == 'S'))
                            {
                                g_value = -1*g_value;
                            }
                        }
                        Coordinate_Polygon polygon = new Coordinate_Polygon();
                        polygon.Add_Edge_Point(f_value, d_value);
                        polygon.Add_Edge_Point(g_value, d_value);
                        polygon.Add_Edge_Point(g_value, e_value);
                        polygon.Add_Edge_Point(f_value, e_value);
                        polygon.Label = "Map Coverage";
                        geoInfo.Add_Polygon(polygon);
                    }
                    catch {   }
                }
            }

            // Add the abstract ( 520 |a )
            foreach (MARC_Field thisRecord in record[520])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    Abstract_Info newAbstract = new Abstract_Info();
                    switch (thisRecord.Indicator1)
                    {
                        case ' ':
                            newAbstract.Type = "summary";
                            newAbstract.Display_Label = "Summary";
                            break;

                        case '0':
                            newAbstract.Type = "subject";
                            newAbstract.Display_Label = "Subject";
                            break;

                        case '1':
                            newAbstract.Type = "review";
                            newAbstract.Display_Label = "Review";
                            break;

                        case '2':
                            newAbstract.Type = "scope and content";
                            newAbstract.Display_Label = "Scope and Content";
                            break;

                        case '4':
                            newAbstract.Type = "content advice";
                            newAbstract.Display_Label = "Content Advice";
                            break;

                        default:
                            newAbstract.Display_Label = "Abstract";
                            break;
                    }

                    if (thisRecord.has_Subfield('b'))
                    {
                        newAbstract.Abstract_Text = thisRecord['a'] + " " + thisRecord['b'];
                    }
                    else
                    {
                        newAbstract.Abstract_Text = thisRecord['a'];
                    }
                    thisBibInfo.Add_Abstract(newAbstract);
                }
            }

            // Load the format ( 300 )
            if (record.has_Field(300))
            {
                StringBuilder builder300 = new StringBuilder();
                if (record.Get_Data_Subfield(300, 'a').Length > 0)
                {
                    builder300.Append(record.Get_Data_Subfield(300, 'a').Replace(":", "").Replace(";", "").Trim());
                }
                builder300.Append(" : ");
                if (record.Get_Data_Subfield(300, 'b').Length > 0)
                {
                    builder300.Append(record.Get_Data_Subfield(300, 'b').Replace(";", "").Trim());
                }
                builder300.Append(" ; ");
                if (record.Get_Data_Subfield(300, 'c').Length > 0)
                {
                    builder300.Append(record.Get_Data_Subfield(300, 'c'));
                }
                thisBibInfo.Original_Description.Extent = builder300.ToString().Trim();
                if (thisBibInfo.Original_Description.Extent.Replace(" ", "").Replace(":", "").Replace(";", "") == "v.")
                    thisBibInfo.Original_Description.Extent = String.Empty;
            }

            // Load the current frequency (310)
            foreach (MARC_Field thisRecord in record[310])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    if (thisRecord.has_Subfield('b'))
                    {
                        thisBibInfo.Origin_Info.Add_Frequency(Remove_Trailing_Punctuation(thisRecord['a']).Replace("[", "(").Replace("]", ")") + "[" + thisRecord['b'].Replace("[", "(").Replace("]", ")") + "]");
                    }
                    else
                    {
                        thisBibInfo.Origin_Info.Add_Frequency(Remove_Trailing_Punctuation(thisRecord['a']).Replace("[", "(").Replace("]", ")"));
                    }
                }
            }

            // Load the previous frequency (321)
            foreach (MARC_Field thisRecord in record[321])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    if (thisRecord.has_Subfield('b'))
                    {
                        thisBibInfo.Origin_Info.Add_Frequency(Remove_Trailing_Punctuation(thisRecord['a']).Replace("[", "(").Replace("]", ")") + "[ FORMER " + thisRecord['b'].Replace("[", "(").Replace("]", ")") + "]");
                    }
                    else
                    {
                        thisBibInfo.Origin_Info.Add_Frequency(Remove_Trailing_Punctuation(thisRecord['a']).Replace("[", "(").Replace("]", ")") + "[ FORMER ]");
                    }
                }
            }

            // Load the edition ( 250 )
            if (record.has_Field(250))
            {
                if (record.Get_Data_Subfield(250, 'b').Length > 0)
                {
                    thisBibInfo.Origin_Info.Edition = record.Get_Data_Subfield(250, 'a').Replace("/", "").Replace("=", "").Trim() + " -- " + record.Get_Data_Subfield(250, 'b');
                }
                else
                {
                    thisBibInfo.Origin_Info.Edition = record.Get_Data_Subfield(250, 'a');
                }
            }

            // Load the language ( 008 )
            if (record.has_Field(8))
            {
                string field_08 = record[8][0].Control_Field_Value;
                if (field_08.Length > 5)
                {
                    // Get the language code
                    string languageCode = field_08.Substring(field_08.Length - 5, 3);

                    // Add as the language of the item
                    Language_Info thisLanguage = thisBibInfo.Add_Language(String.Empty, languageCode, String.Empty);

                    // Add as the language of the cataloging
                    thisBibInfo.Record.Add_Catalog_Language(new Language_Info(thisLanguage.Language_Text, thisLanguage.Language_ISO_Code, String.Empty));
                }
            }

            // Load any additional languages (041)
            foreach (MARC_Field thisRecord in record[041])
            {
                foreach (MARC_Subfield thisSubfield in thisRecord.Subfields)
                {
                    if ((thisSubfield.Subfield_Code == 'a') || (thisSubfield.Subfield_Code == 'b') || (thisSubfield.Subfield_Code == 'd') ||
                        (thisSubfield.Subfield_Code == 'e') || (thisSubfield.Subfield_Code == 'f') || (thisSubfield.Subfield_Code == 'g') ||
                        (thisSubfield.Subfield_Code == 'h'))
                    {
                        thisBibInfo.Add_Language(thisSubfield.Data);
                    }
                }
            }

            // Load the publisher ( 260 |b )
            if (record.has_Field(260))
            {
                string[] special_260_splitter = record[260][0].Control_Field_Value.Split("|".ToCharArray());
                Publisher_Info thisInfo = new Publisher_Info();
                foreach (string thisSplitter in special_260_splitter)
                {
                    if (thisSplitter.Length > 2)
                    {
                        if (thisSplitter[0] == 'a')
                        {
                            thisInfo.Add_Place(Remove_Trailing_Punctuation(thisSplitter.Substring(2).Replace(" :", "").Trim()));
                            thisInfo.Name = "[s.n.]";
                            thisBibInfo.Add_Publisher(thisInfo);
                        }

                        if (thisSplitter[0] == 'b')
                        {
                            string pubname = thisSplitter.Substring(2).Replace(";", "").Trim();
                            if ((pubname.Length > 1) && (pubname[pubname.Length - 1] == ','))
                            {
                                pubname = pubname.Substring(0, pubname.Length - 1);
                            }

                            thisInfo.Name = pubname;
                            thisBibInfo.Add_Publisher(thisInfo);
                            thisInfo = new Publisher_Info();
                        }

                        if (thisSplitter[0] == 'e')
                        {
                            thisInfo.Add_Place(thisSplitter.Substring(2).Replace("(", "").Replace(" :", "").Trim());
                        }

                        if (thisSplitter[0] == 'f')
                        {
                            string manname = thisSplitter.Substring(2).Replace(")", "").Trim();
                            if ((manname.Length > 1) && (manname[manname.Length - 1] == ','))
                            {
                                manname = manname.Substring(0, manname.Length - 1);
                            }

                            thisInfo.Name = manname;
                            thisBibInfo.Add_Manufacturer(thisInfo);
                            thisInfo = new Publisher_Info();
                        }
                    }
                }
            }

            // Load the dates from the 008
            string field_008 = String.Empty;
            if (record.has_Field(008))
            {
                field_008 = record[8][0].Control_Field_Value;
                if (field_008.Length > 14)
                {
                    // Save the two date points
                    thisBibInfo.Origin_Info.MARC_DateIssued_Start = field_008.Substring(7, 4).Trim();
                    thisBibInfo.Origin_Info.MARC_DateIssued_End = field_008.Substring(11, 4).Trim();

                    // See what type of dates they are (if they are special)
                    char date_type = field_008[6];
                    switch (date_type)
                    {
                        case 'r':
                            thisBibInfo.Origin_Info.Date_Reprinted = thisBibInfo.Origin_Info.MARC_DateIssued_Start;
                            break;

                        case 't':
                            thisBibInfo.Origin_Info.Date_Copyrighted = thisBibInfo.Origin_Info.MARC_DateIssued_End;
                            break;
                    }
                }

                if (field_008.Length > 5)
                {
                    thisBibInfo.Record.MARC_Creation_Date = field_008.Substring(0, 6);
                }
            }

            // Load the location from the 008
            if (field_008.Length > 17)
            {
                thisBibInfo.Origin_Info.Add_Place(String.Empty, field_008.Substring(15, 3), String.Empty);
            }

            // Load the main record number ( 001 )
            string idValue;
            string oclc = String.Empty;
            if (record.has_Field(1))
            {
                idValue = record[1][0].Control_Field_Value.Trim();
                if (idValue.Length > 0)
                {
                    thisBibInfo.Record.Main_Record_Identifier.Identifier = idValue;
                    if (Importing_Record)
                    {
                        if (Char.IsNumber(idValue[0]))
                        {
                            // Add this ALEPH number
                            if (thisBibInfo.ALEPH_Record != idValue)
                            {
                                thisBibInfo.Add_Identifier(idValue, "ALEPH");
                            }
                            thisBibInfo.Record.Record_Origin = "Imported from (ALEPH)" + idValue;
                        }
                        else
                        {
                            if (idValue.Length >= 7)
                            {
                                if ((idValue.IndexOf("ocm") == 0) || (idValue.IndexOf("ocn") == 0))
                                {
                                    oclc = idValue.Replace("ocn", "").Replace("ocm", "");
                                    if (thisBibInfo.OCLC_Record != oclc)
                                    {
                                        thisBibInfo.Add_Identifier(oclc, "OCLC");
                                    }
                                    thisBibInfo.Record.Record_Origin = "Imported from (OCLC)" + oclc;
                                }
                                else
                                {
                                    thisBibInfo.Add_Identifier(idValue.Substring(0, 7), "NOTIS");
                                    thisBibInfo.Record.Record_Origin = "Imported from (NOTIS)" + idValue.Substring(0, 7);
                                }
                            }
                        }
                    }
                }
            }

            // If this was OCLC record (non-local) look for a 599 added during time of export
            if (oclc.Length > 0)
            {
                if (record.has_Field(599))
                {
                    // Tracking box number will be in the |a field
                    if ((package != null) && (record[599][0].has_Subfield('a')))
                    {
                        package.Tracking.Tracking_Box = record[599][0]['a'];
                    }

                    // Disposition advice will be in the |b field
                    if ((package != null) && (record[599][0].has_Subfield('b')))
                    {
                        package.Tracking.Disposition_Advice_Notes = record[599][0]['b'];
                        string advice_notes_as_caps = package.Tracking.Disposition_Advice_Notes.ToUpper();
                        if ((advice_notes_as_caps.IndexOf("RETURN") >= 0) || (advice_notes_as_caps.IndexOf("RETAIN") >= 0))
                        {
                            package.Tracking.Disposition_Advice = 1;
                        }
                        else
                        {
                            if (advice_notes_as_caps.IndexOf("WITHDRAW") >= 0)
                            {
                                package.Tracking.Disposition_Advice = 2;
                            }
                            else if (advice_notes_as_caps.IndexOf("DISCARD") >= 0)
                            {
                                package.Tracking.Disposition_Advice = 3;
                            }
                        }
                    }

                    // Do not overlay record in the future will be in the |c field
                    if (record[599][0].has_Subfield('c'))
                    {
                        string record_overlay_notes = record[599][0]['c'].Trim();
                        if (record_overlay_notes.Length > 0)
                        {
                            if (package != null)
                            {
                                package.Tracking.Never_Overlay_Record = true;
                                package.Tracking.Internal_Comments = record_overlay_notes;
                            }
                            thisBibInfo.Record.Record_Content_Source = thisBibInfo.Record.Record_Content_Source + " (" + record_overlay_notes + ")";
                        }
                    }
                }
            }

            // Step through all of the identifiers
            foreach (MARC_Field thisRecord in record[35])
            {
                // Only continue if there is an id in this record
                if (thisRecord.has_Subfield('a'))
                {
                    // Was this the old NOTIS number?
                    if (thisRecord.Indicators == "9 ")
                    {
                        thisBibInfo.Add_Identifier(thisRecord['a'], "NOTIS");
                    }

                    // Was this the OCLC number?
                    if ((oclc.Length == 0) && (thisRecord['a'].ToUpper().IndexOf("OCOLC") >= 0))
                    {
                        thisBibInfo.Add_Identifier(thisRecord['a'].ToUpper().Replace("(OCOLC)", "").Trim(), "OCLC");
                    }

                    // Was this the BIB ID?
                    if ((package != null) && (thisRecord['a'].ToUpper().IndexOf("IID") >= 0))
                    {
                        package.BibID = thisRecord['a'].ToUpper().Replace("(IID)", "").Trim();
                    }
                }
            }

            // Also, look for the old original OCLC in the 776 10 |w
            if (thisBibInfo.OCLC_Record.Length == 0)
            {
                foreach (MARC_Field thisRecord in record[776])
                {
                    if ((thisRecord.Indicators == "1 ") && (thisRecord.has_Subfield('w')) && (thisRecord['w'].ToUpper().IndexOf("OCOLC") >= 0))
                    {
                        thisBibInfo.Add_Identifier(thisRecord['w'].ToUpper().Replace("(OCOLC)", "").Trim(), "OCLC");
                    }
                }
            }

            // Look for the LCCN in field 10
            if (record.Get_Data_Subfield(10, 'a').Length > 0)
                thisBibInfo.Add_Identifier(record.Get_Data_Subfield(10, 'a'), "LCCN");

            // Look for ISBN in field 20
            if (record.Get_Data_Subfield(20, 'a').Length > 0)
                thisBibInfo.Add_Identifier(record.Get_Data_Subfield(20, 'a'), "ISBN");

            // Look for ISSN in field 22
            if (record.Get_Data_Subfield(22, 'a').Length > 0)
                thisBibInfo.Add_Identifier(record.Get_Data_Subfield(22, 'a'), "ISSN");

            // Look for classification ( LCC ) in field 50
            if (record.Get_Data_Subfield(50, 'a').Length > 0)
            {
                string subfield_3 = String.Empty;
                if (record.Get_Data_Subfield(50, '3').Length > 0)
                {
                    subfield_3 = record.Get_Data_Subfield(50, '3');
                }
                if (record.Get_Data_Subfield(50, 'b').Length > 0)
                    thisBibInfo.Add_Classification(record.Get_Data_Subfield(50, 'a') + " " + record.Get_Data_Subfield(50, 'b'), "lcc").Display_Label = subfield_3;
                else
                    thisBibInfo.Add_Classification(record.Get_Data_Subfield(50, 'a'), "lcc").Display_Label = subfield_3;
            }

            // Look for classification ( DDC ) in field 82
            if (record.Get_Data_Subfield(82, 'a').Length > 0)
            {
                string subfield_2 = String.Empty;
                if (record.Get_Data_Subfield(82, '2').Length > 0)
                {
                    subfield_2 = record.Get_Data_Subfield(82, '2');
                }
                if (record.Get_Data_Subfield(82, 'b').Length > 0)
                    thisBibInfo.Add_Classification(record.Get_Data_Subfield(82, 'a') + " " + record.Get_Data_Subfield(82, 'b'), "ddc").Edition = subfield_2;
                else
                    thisBibInfo.Add_Classification(record.Get_Data_Subfield(82, 'a'), "ddc").Edition = subfield_2;
            }

            // Look for classification ( UDC ) in field 80
            if (record.Get_Data_Subfield(80, 'a').Length > 0)
            {
                StringBuilder builder = new StringBuilder();
                builder.Append(record.Get_Data_Subfield(80, 'a'));
                if (record.Get_Data_Subfield(80, 'b').Length > 0)
                    builder.Append(" " + record.Get_Data_Subfield(80, 'b'));
                if (record.Get_Data_Subfield(80, 'x').Length > 0)
                    builder.Append(" " + record.Get_Data_Subfield(80, 'x'));
                thisBibInfo.Add_Classification(builder.ToString(), "udc");
            }

            // Look for classification ( NLM ) in field 60
            if (record.Get_Data_Subfield(60, 'a').Length > 0)
            {
                if (record.Get_Data_Subfield(60, 'b').Length > 0)
                    thisBibInfo.Add_Classification(record.Get_Data_Subfield(60, 'a') + " " + record.Get_Data_Subfield(60, 'b'), "nlm");
                else
                    thisBibInfo.Add_Classification(record.Get_Data_Subfield(60, 'a'), "nlm");
            }

            // Look for classification ( SUDOCS or CANDOCS ) in field 86
            foreach (MARC_Field thisRecord in record[84])
            {
                string authority = String.Empty;
                switch (thisRecord.Indicator1)
                {
                    case '0':
                        authority = "sudocs";
                        break;

                    case '1':
                        authority = "candocs";
                        break;

                    default:
                        if (thisRecord.has_Subfield('2'))
                            authority = thisRecord['2'];
                        break;
                }

                if (thisRecord.has_Subfield('a'))
                    thisBibInfo.Add_Classification(thisRecord['a'], authority);
            }

            // Look for other classifications in field 084
            foreach (MARC_Field thisRecord in record[84])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    string subfield_2 = String.Empty;
                    if (thisRecord.has_Subfield('2'))
                    {
                        subfield_2 = thisRecord['2'];
                    }
                    if (thisRecord.has_Subfield('b'))
                        thisBibInfo.Add_Classification(thisRecord['a'] + " " + thisRecord['b'], subfield_2);
                    else
                        thisBibInfo.Add_Classification(thisRecord['a'], subfield_2);
                }
            }

            // Look for any other identifiers in field 24
            foreach (MARC_Field thisRecord in record[24])
            {
                string identifier_source = String.Empty;
                switch (thisRecord.Indicator1)
                {
                    case '0':
                        identifier_source = "isrc";
                        break;

                    case '1':
                        identifier_source = "upc";
                        break;

                    case '2':
                        identifier_source = "ismn";
                        break;

                    case '3':
                        identifier_source = "ian";
                        break;

                    case '4':
                        identifier_source = "sici";
                        break;

                    case '7':
                        identifier_source = thisRecord['2'];
                        break;
                }

                if (thisRecord.has_Subfield('d'))
                {
                    thisBibInfo.Add_Identifier(thisRecord['a'] + " (" + thisRecord['d'] + ")", identifier_source);
                }
                else
                {
                    thisBibInfo.Add_Identifier(thisRecord['a'], identifier_source);
                }
            }

            // Look for the ISSN in the 440 and 490 |x and LCCN in the 490 |l
            foreach (MARC_Field thisRecord in record[440])
            {
                if (thisRecord.has_Subfield('x'))
                {
                    thisBibInfo.Add_Identifier(thisRecord['x'], "ISSN");
                }
            }
            foreach (MARC_Field thisRecord in record[490])
            {
                if (thisRecord.has_Subfield('x'))
                {
                    thisBibInfo.Add_Identifier(thisRecord['x'], "ISSN");
                }
                if (thisRecord.has_Subfield('l'))
                {
                    thisBibInfo.Add_Identifier(thisRecord['l'], "LCCN");
                }
            }

            // Load all the MARC Content Sources (040)
            if (record.has_Field(40))
            {
                if (record.Get_Data_Subfield(40, 'a').Length > 0)
                {
                    thisBibInfo.Record.Add_MARC_Record_Content_Sources(record.Get_Data_Subfield(40, 'a'));
                }
                if (record.Get_Data_Subfield(40, 'b').Length > 0)
                {
                    thisBibInfo.Record.Add_MARC_Record_Content_Sources(record.Get_Data_Subfield(40, 'b'));
                }
                if (record.Get_Data_Subfield(40, 'c').Length > 0)
                {
                    thisBibInfo.Record.Add_MARC_Record_Content_Sources(record.Get_Data_Subfield(40, 'c'));
                }
                string modifying = record.Get_Data_Subfield(40, 'd');
                if (modifying.Length > 0)
                {
                    string[] modSplitter = modifying.Split("|".ToCharArray());
                    foreach (string split in modSplitter)
                    {
                        thisBibInfo.Record.Add_MARC_Record_Content_Sources(split.Trim());
                    }
                }
                if (record.Get_Data_Subfield(40, 'e').Length > 0)
                {
                    thisBibInfo.Record.Description_Standard = record.Get_Data_Subfield(40, 'e');
                }
            }

            // Add the spatial information ( 752, 662 )
            Add_Hierarchical_Subject(thisBibInfo, record, 752);
            Add_Hierarchical_Subject(thisBibInfo, record, 662);

            // Add all the subjects ( 600... 658, excluding 655 )
            Add_Personal_Name(thisBibInfo, record, 600, 4);
            Add_Corporate_Name(thisBibInfo, record, 610, 4);
            Add_Conference_Name(thisBibInfo, record, 611, 4);
            Add_Main_Title(thisBibInfo, record, 630, Title_Type_Enum.UNSPECIFIED, 1, 4);

            // Add all additional subjects
            // Letters indicate which fields are: TOPICAL, GEOGRAPHIC, TEMPORAL, GENRE, OCCUPATION
            Add_Subject(thisBibInfo, record, 648, "x", "z", "ay", "v", "");
            Add_Subject(thisBibInfo, record, 650, "ax", "z", "y", "v", "");
            Add_Subject(thisBibInfo, record, 651, "x", "az", "y", "v", "");
            Add_Subject(thisBibInfo, record, 653, "a", "", "", "", "");
            Add_Subject(thisBibInfo, record, 654, "av", "y", "z", "", "");
            Add_Subject(thisBibInfo, record, 655, "x", "z", "y", "av", "");
            Add_Subject(thisBibInfo, record, 656, "x", "z", "y", "v", "a");
            Add_Subject(thisBibInfo, record, 657, "ax", "z", "y", "v", "");
            Add_Subject(thisBibInfo, record, 690, "ax", "z", "y", "v", "");
            Add_Subject(thisBibInfo, record, 691, "x", "az", "y", "v", "");

            // Add the genres (655 -- again)
            foreach (MARC_Field thisRecord in record[655])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    if (thisRecord.has_Subfield('2'))
                        thisBibInfo.Add_Genre(thisRecord['a'], thisRecord['2']);
                    else
                        thisBibInfo.Add_Genre(thisRecord['a']);
                }
            }

            // Add the abbreviated title (210)
            foreach (MARC_Field thisRecord in record[210])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    Title_Info abbrTitle = new Title_Info(thisRecord['a'], Title_Type_Enum.Abbreviated);
                    if (thisRecord.has_Subfield('b'))
                        abbrTitle.Subtitle = thisRecord['b'];
                    thisBibInfo.Add_Other_Title(abbrTitle);
                }
            }

            // Add the title ( 245 |a, |b )
            Add_Main_Title(thisBibInfo, record, 245, Title_Type_Enum.UNSPECIFIED, 2, 1);

            // Add the translated titles ( 242 )
            Add_Main_Title(thisBibInfo, record, 242, Title_Type_Enum.Translated, 2, 2);

            // Add the alternative titles ( 246, 740 )
            Add_Main_Title(thisBibInfo, record, 246, Title_Type_Enum.Alternative, 0, 2);
            Add_Main_Title(thisBibInfo, record, 740, Title_Type_Enum.Alternative, 1, 2);

            // Add the uniform titles (130, 240, 730 )
            Add_Main_Title(thisBibInfo, record, 130, Title_Type_Enum.Uniform, 1, 2);
            Add_Main_Title(thisBibInfo, record, 240, Title_Type_Enum.Uniform, 2, 2);
            Add_Main_Title(thisBibInfo, record, 730, Title_Type_Enum.Uniform, 1, 2);

            // Add the series titles ( 440, 490 )
            Add_Main_Title(thisBibInfo, record, 440, Title_Type_Enum.UNSPECIFIED, 2, 3);
            Add_Main_Title(thisBibInfo, record, 490, Title_Type_Enum.UNSPECIFIED, 0, 3);

            // Add the creators and contributors ( 100, 110 , 111, 700, 710, 711, 720, 796, 797 )
            Add_Personal_Name(thisBibInfo, record, 100, 1);
            Add_Personal_Name(thisBibInfo, record, 700, 2);
            Add_Personal_Name(thisBibInfo, record, 796, 3);
            Add_Corporate_Name(thisBibInfo, record, 110, 1);
            Add_Corporate_Name(thisBibInfo, record, 710, 2);
            Add_Corporate_Name(thisBibInfo, record, 797, 3);
            Add_Conference_Name(thisBibInfo, record, 111, 1);
            Add_Conference_Name(thisBibInfo, record, 711, 2);

            // Add the Other Edition Value (775)
            foreach (MARC_Field thisRecord in record[775])
            {
                Related_Item_Info otherEditionItem = new Related_Item_Info();
                otherEditionItem.Relationship = Related_Item_Type_Enum.OtherVersion;
                if (thisRecord.has_Subfield('t'))
                    otherEditionItem.Main_Title.Title = thisRecord['t'];
                if (thisRecord.has_Subfield('x'))
                    otherEditionItem.Add_Identifier(thisRecord['x'], "issn");
                if (thisRecord.has_Subfield('z'))
                    otherEditionItem.Add_Identifier(thisRecord['z'], "isbn");
                if (thisRecord.has_Subfield('w'))
                {
                    string[] splitter = thisRecord['w'].Split("|".ToCharArray());
                    foreach (string thisSplitter in splitter)
                    {
                        if (thisSplitter.IndexOf("(DLC)sn") >= 0)
                        {
                            otherEditionItem.Add_Identifier(thisSplitter.Replace("(DLC)sn", "").Trim(), "lccn");
                        }
                        if (thisSplitter.IndexOf("(OCoLC)") >= 0)
                        {
                            otherEditionItem.Add_Identifier(thisSplitter.Replace("(OCoLC)", "").Trim(), "oclc");
                        }
                    }
                }
                thisBibInfo.Add_Related_Item(otherEditionItem);
            }

            // Add the Preceding Entry (780)
            foreach (MARC_Field thisRecord in record[780])
            {
                Related_Item_Info precedingItem = new Related_Item_Info();
                precedingItem.Relationship = Related_Item_Type_Enum.Preceding;
                if (thisRecord.has_Subfield('t'))
                    precedingItem.Main_Title.Title = thisRecord['t'];
                if (thisRecord.has_Subfield('x'))
                    precedingItem.Add_Identifier(thisRecord['x'], "issn");
                if (thisRecord.has_Subfield('z'))
                    precedingItem.Add_Identifier(thisRecord['z'], "isbn");
                if (thisRecord.has_Subfield('w'))
                {
                    string[] splitter = thisRecord['w'].Split("|".ToCharArray());
                    foreach (string thisSplitter in splitter)
                    {
                        if ((thisSplitter.IndexOf("(DLC)sn") >= 0) || (thisSplitter.IndexOf("(OCoLC)") >= 0))
                        {
                            if (thisSplitter.IndexOf("(DLC)sn") >= 0)
                            {
                                precedingItem.Add_Identifier(thisSplitter.Replace("(DLC)sn", "").Trim(), "lccn");
                            }
                            if (thisSplitter.IndexOf("(OCoLC)") >= 0)
                            {
                                precedingItem.Add_Identifier(thisSplitter.Replace("(OCoLC)", "").Trim(), "oclc");
                            }
                        }
                        else
                        {
                            precedingItem.Add_Identifier(thisSplitter.Trim(), String.Empty);
                        }
                    }
                    if (thisRecord.has_Subfield('o'))
                    {
                        if (thisRecord['o'].IndexOf("(SobekCM)") >= 0)
                            precedingItem.SobekCM_ID = thisRecord['o'].Replace("(SobekCM)", "").Trim();
                    }
                }
                thisBibInfo.Add_Related_Item(precedingItem);
            }

            // Add the Suceeding Entry (785)
            foreach (MARC_Field thisRecord in record[785])
            {
                Related_Item_Info succeedingItem = new Related_Item_Info();
                succeedingItem.Relationship = Related_Item_Type_Enum.Succeeding;
                if (thisRecord.has_Subfield('t'))
                    succeedingItem.Main_Title.Title = thisRecord['t'];
                if (thisRecord.has_Subfield('x'))
                    succeedingItem.Add_Identifier(thisRecord['x'], "issn");
                if (thisRecord.has_Subfield('z'))
                    succeedingItem.Add_Identifier(thisRecord['z'], "isbn");
                if (thisRecord.has_Subfield('w'))
                {
                    string[] splitter = thisRecord['w'].Split("|".ToCharArray());
                    foreach (string thisSplitter in splitter)
                    {
                        if ((thisSplitter.IndexOf("(DLC)sn") >= 0) || (thisSplitter.IndexOf("(OCoLC)") >= 0))
                        {
                            if (thisSplitter.IndexOf("(DLC)sn") >= 0)
                            {
                                succeedingItem.Add_Identifier(thisSplitter.Replace("(DLC)sn", "").Trim(), "lccn");
                            }
                            if (thisSplitter.IndexOf("(OCoLC)") >= 0)
                            {
                                succeedingItem.Add_Identifier(thisSplitter.Replace("(OCoLC)", "").Trim(), "oclc");
                            }
                        }
                        else
                        {
                            succeedingItem.Add_Identifier(thisSplitter.Trim(), String.Empty);
                        }
                    }
                }
                if (thisRecord.has_Subfield('o'))
                {
                    if (thisRecord['o'].IndexOf("(SobekCM)") >= 0)
                        succeedingItem.SobekCM_ID = thisRecord['o'].Replace("(SobekCM)", "").Trim();
                }
                thisBibInfo.Add_Related_Item(succeedingItem);
            }

            // Add the Other Relationship Entry (787)
            foreach (MARC_Field thisRecord in record[787])
            {
                Related_Item_Info otherRelationItem = new Related_Item_Info();
                otherRelationItem.Relationship = Related_Item_Type_Enum.UNKNOWN;
                if (thisRecord.has_Subfield('t'))
                    otherRelationItem.Main_Title.Title = thisRecord['t'];
                if (thisRecord.has_Subfield('x'))
                    otherRelationItem.Add_Identifier(thisRecord['x'], "issn");
                if (thisRecord.has_Subfield('z'))
                    otherRelationItem.Add_Identifier(thisRecord['z'], "isbn");
                if (thisRecord.has_Subfield('w'))
                {
                    string[] splitter = thisRecord['w'].Split("|".ToCharArray());
                    foreach (string thisSplitter in splitter)
                    {
                        if ((thisSplitter.IndexOf("(DLC)sn") >= 0) || (thisSplitter.IndexOf("(OCoLC)") >= 0))
                        {
                            if (thisSplitter.IndexOf("(DLC)sn") >= 0)
                            {
                                otherRelationItem.Add_Identifier(thisSplitter.Replace("(DLC)sn", "").Trim(), "lccn");
                            }
                            if (thisSplitter.IndexOf("(OCoLC)") >= 0)
                            {
                                otherRelationItem.Add_Identifier(thisSplitter.Replace("(OCoLC)", "").Trim(), "oclc");
                            }
                        }
                        else
                        {
                            otherRelationItem.Add_Identifier(thisSplitter.Trim(), String.Empty);
                        }
                    }
                }
                if (thisRecord.has_Subfield('o'))
                {
                    if (thisRecord['o'].IndexOf("(SobekCM)") >= 0)
                        otherRelationItem.SobekCM_ID = thisRecord['o'].Replace("(SobekCM)", "").Trim();
                }
                thisBibInfo.Add_Related_Item(otherRelationItem);
            }

            // Get the type of resource ( Leader/006, Leader/007, Serial 008/021 )
            string marc_type = String.Empty;
            switch (record.Leader[6])
            {
                case 'a':
                case 't':
                    thisBibInfo.SobekCM_Type = TypeOfResource_SobekCM_Enum.Book;
                    marc_type = "BKS";
                    break;

                case 'e':
                case 'f':
                    thisBibInfo.SobekCM_Type = TypeOfResource_SobekCM_Enum.Map;
                    marc_type = "MAP";
                    break;

                case 'c':
                case 'd':
                    thisBibInfo.SobekCM_Type = TypeOfResource_SobekCM_Enum.Book;
                    marc_type = "BKS";
                    break;

                case 'i':
                case 'j':
                    thisBibInfo.SobekCM_Type = TypeOfResource_SobekCM_Enum.Audio;
                    marc_type = "REC";
                    break;

                case 'k':
                    thisBibInfo.SobekCM_Type = TypeOfResource_SobekCM_Enum.Photograph;
                    marc_type = "VIS";
                    break;

                case 'g':
                    thisBibInfo.SobekCM_Type = TypeOfResource_SobekCM_Enum.Video;
                    marc_type = "VIS";
                    break;

                case 'r':
                    thisBibInfo.SobekCM_Type = TypeOfResource_SobekCM_Enum.Artifact;
                    marc_type = "VIS";
                    break;

                case 'm':
                    thisBibInfo.SobekCM_Type = TypeOfResource_SobekCM_Enum.Archival;
                    marc_type = "COM";
                    break;

                case 'p':
                    thisBibInfo.SobekCM_Type = TypeOfResource_SobekCM_Enum.Archival;
                    marc_type = "MIX";
                    break;

                case 'o':
                    marc_type = "VIS";
                    thisBibInfo.SobekCM_Type = TypeOfResource_SobekCM_Enum.Archival;
                    break;
            }
            if (record.Leader[7] == 'c')
                thisBibInfo.Type.Collection = true;
            if (record.Leader[7] == 's')
            {
                thisBibInfo.SobekCM_Type = TypeOfResource_SobekCM_Enum.Serial;

                if (field_008.Length > 22)
                {
                    if (field_008[21] == 'n')
                        thisBibInfo.SobekCM_Type = TypeOfResource_SobekCM_Enum.Newspaper;
                }
                marc_type = "CNR";
            }
            thisBibInfo.EncodingLevel = record.Leader[17].ToString().Replace("^", "#").Replace(" ", "#");

            if (field_008.Length > 35)
            {
                if ((marc_type == "BKS") || (marc_type == "CNR") || (marc_type == "MAP") || (marc_type == "COM") || (marc_type == "VIS"))
                {
                    switch (field_008[28])
                    {
                        case 'c':
                            thisBibInfo.Add_Genre("multilocal government publication", "marcgt");
                            break;

                        case 'f':
                            thisBibInfo.Add_Genre("federal government publication", "marcgt");
                            break;

                        case 'i':
                            thisBibInfo.Add_Genre("international intergovernmental publication", "marcgt");
                            break;

                        case 'l':
                            thisBibInfo.Add_Genre("local government publication", "marcgt");
                            break;

                        case 'm':
                            thisBibInfo.Add_Genre("multistate government publication", "marcgt");
                            break;

                        case 'o':
                            thisBibInfo.Add_Genre("government publication", "marcgt");
                            break;

                        case 's':
                            thisBibInfo.Add_Genre("government publication (state, provincial, terriorial, dependent)", "marcgt");
                            break;

                        case 'a':
                            thisBibInfo.Add_Genre("government publication (autonomous or semiautonomous component)", "marcgt");
                            break;
                    }
                }

                if ((marc_type == "BKS") || (marc_type == "CNR"))
                {
                    string nature_of_contents = field_008.Substring(24, 4);
                    if (nature_of_contents.IndexOf("a") >= 0)
                        thisBibInfo.Add_Genre("abstract or summary", "marcgt");
                    if (nature_of_contents.IndexOf("b") >= 0)
                        thisBibInfo.Add_Genre("bibliography", "marcgt");
                    if (nature_of_contents.IndexOf("c") >= 0)
                        thisBibInfo.Add_Genre("catalog", "marcgt");
                    if (nature_of_contents.IndexOf("d") >= 0)
                        thisBibInfo.Add_Genre("dictionary", "marcgt");
                    if (nature_of_contents.IndexOf("r") >= 0)
                        thisBibInfo.Add_Genre("directory", "marcgt");
                    if (nature_of_contents.IndexOf("k") >= 0)
                        thisBibInfo.Add_Genre("discography", "marcgt");
                    if (nature_of_contents.IndexOf("e") >= 0)
                        thisBibInfo.Add_Genre("encyclopedia", "marcgt");
                    if (nature_of_contents.IndexOf("q") >= 0)
                        thisBibInfo.Add_Genre("filmography", "marcgt");
                    if (nature_of_contents.IndexOf("f") >= 0)
                        thisBibInfo.Add_Genre("handbook", "marcgt");
                    if (nature_of_contents.IndexOf("i") >= 0)
                        thisBibInfo.Add_Genre("index", "marcgt");
                    if (nature_of_contents.IndexOf("w") >= 0)
                        thisBibInfo.Add_Genre("law report or digest", "marcgt");
                    if (nature_of_contents.IndexOf("g") >= 0)
                        thisBibInfo.Add_Genre("legal article", "marcgt");
                    if (nature_of_contents.IndexOf("v") >= 0)
                        thisBibInfo.Add_Genre("legal case and case notes", "marcgt");
                    if (nature_of_contents.IndexOf("l") >= 0)
                        thisBibInfo.Add_Genre("legislation", "marcgt");
                    if (nature_of_contents.IndexOf("j") >= 0)
                        thisBibInfo.Add_Genre("patent", "marcgt");
                    if (nature_of_contents.IndexOf("p") >= 0)
                        thisBibInfo.Add_Genre("programmed text", "marcgt");
                    if (nature_of_contents.IndexOf("o") >= 0)
                        thisBibInfo.Add_Genre("review", "marcgt");
                    if (nature_of_contents.IndexOf("s") >= 0)
                        thisBibInfo.Add_Genre("statistics", "marcgt");
                    if (nature_of_contents.IndexOf("n") >= 0)
                        thisBibInfo.Add_Genre("survey of literature", "marcgt");
                    if (nature_of_contents.IndexOf("t") >= 0)
                        thisBibInfo.Add_Genre("technical report", "marcgt");
                    if (nature_of_contents.IndexOf("m") >= 0)
                        thisBibInfo.Add_Genre("theses", "marcgt");
                    if (nature_of_contents.IndexOf("z") >= 0)
                        thisBibInfo.Add_Genre("treaty", "marcgt");
                    if (nature_of_contents.IndexOf("2") >= 0)
                        thisBibInfo.Add_Genre("offprint", "marcgt");
                    if (nature_of_contents.IndexOf("y") >= 0)
                        thisBibInfo.Add_Genre("yearbook", "marcgt");
                    if (nature_of_contents.IndexOf("5") >= 0)
                        thisBibInfo.Add_Genre("calendar", "marcgt");
                    if (nature_of_contents.IndexOf("6") >= 0)
                        thisBibInfo.Add_Genre("comic/graphic novel", "marcgt");

                    if (field_008[29] == '1')
                        thisBibInfo.Add_Genre("conference publication", "marcgt");
                }

                if (marc_type == "CNR")
                {
                    if (field_008[21] == 'd')
                        thisBibInfo.Add_Genre("database", "marcgt");
                    if (field_008[21] == 'l')
                        thisBibInfo.Add_Genre("loose-leaf", "marcgt");
                    if (field_008[21] == 'n')
                        thisBibInfo.Add_Genre("newspaper", "marcgt");
                    if (field_008[21] == 'p')
                        thisBibInfo.Add_Genre("periodical", "marcgt");
                    if (field_008[21] == 's')
                        thisBibInfo.Add_Genre("series", "marcgt");
                    if (field_008[21] == 'w')
                        thisBibInfo.Add_Genre("web site", "marcgt");

                    // Get the frequency
                    switch (field_008[18])
                    {
                        case 'a':
                            thisBibInfo.Origin_Info.Add_Frequency("annual", "marcfrequency");
                            break;

                        case 'b':
                            thisBibInfo.Origin_Info.Add_Frequency("bimonthly", "marcfrequency");
                            break;

                        case 'c':
                            thisBibInfo.Origin_Info.Add_Frequency("semiweekly", "marcfrequency");
                            break;

                        case 'd':
                            thisBibInfo.Origin_Info.Add_Frequency("daily", "marcfrequency");
                            break;

                        case 'e':
                            thisBibInfo.Origin_Info.Add_Frequency("biweekly", "marcfrequency");
                            break;

                        case 'f':
                            thisBibInfo.Origin_Info.Add_Frequency("semiannual", "marcfrequency");
                            break;

                        case 'g':
                            thisBibInfo.Origin_Info.Add_Frequency("biennial", "marcfrequency");
                            break;

                        case 'h':
                            thisBibInfo.Origin_Info.Add_Frequency("triennial", "marcfrequency");
                            break;

                        case 'i':
                            thisBibInfo.Origin_Info.Add_Frequency("three times a week", "marcfrequency");
                            break;

                        case 'j':
                            thisBibInfo.Origin_Info.Add_Frequency("three times a month", "marcfrequency");
                            break;

                        case 'k':
                            thisBibInfo.Origin_Info.Add_Frequency("continuously updated", "marcfrequency");
                            break;

                        case 'm':
                            thisBibInfo.Origin_Info.Add_Frequency("monthly", "marcfrequency");
                            break;

                        case 'q':
                            thisBibInfo.Origin_Info.Add_Frequency("quarterly", "marcfrequency");
                            break;

                        case 's':
                            thisBibInfo.Origin_Info.Add_Frequency("semimonthly", "marcfrequency");
                            break;

                        case 't':
                            thisBibInfo.Origin_Info.Add_Frequency("three times a year", "marcfrequency");
                            break;

                        case 'w':
                            thisBibInfo.Origin_Info.Add_Frequency("weekly", "marcfrequency");
                            break;

                        case 'z':
                            thisBibInfo.Origin_Info.Add_Frequency("other", "marcfrequency");
                            break;
                    }

                    // Get the regularity
                    switch (field_008[19])
                    {
                        case 'n':
                            thisBibInfo.Origin_Info.Add_Frequency("normalized irregular", "marcfrequency");
                            break;

                        case 'r':
                            thisBibInfo.Origin_Info.Add_Frequency("regular", "marcfrequency");
                            break;

                        case 'x':
                            thisBibInfo.Origin_Info.Add_Frequency("completely irregular", "marcfrequency");
                            break;
                    }
                }

                if (marc_type == "MAP")
                {
                    // Get the form of item
                    if (field_008[25] == 'e')
                        thisBibInfo.Add_Genre("atlas", "marcgt");
                    if (field_008[25] == 'd')
                        thisBibInfo.Add_Genre("globe", "marcgt");
                    if (field_008[25] == 'a')
                        thisBibInfo.Add_Genre("single map", "marcgt");
                    if (field_008[25] == 'b')
                        thisBibInfo.Add_Genre("map series", "marcgt");
                    if (field_008[25] == 'c')
                        thisBibInfo.Add_Genre("map serial", "marcgt");

                    // Get the projection, if there is one
                    if ((field_008.Substring(22, 2) != "  ") && (field_008.Substring(22, 2) != "||") && (field_008.Substring(22, 2) != "^^") && (field_008.Substring(22, 2) != "||"))
                    {
                        Subject_Info_Cartographics cartographicsSubject = new Subject_Info_Cartographics();
                        cartographicsSubject.ID = "SUBJ008";
                        cartographicsSubject.Projection = field_008.Substring(22, 2);
                        thisBibInfo.Add_Subject(cartographicsSubject);
                    }

                    // Get whether this is indexed
                    if (field_008[31] == '1')
                    {
                        thisBibInfo.Add_Genre("indexed", "marcgt");
                    }
                }

                if (marc_type == "REC")
                {
                    string nature_of_recording = field_008.Substring(30, 2);
                    if (nature_of_recording.IndexOf("a") >= 0)
                        thisBibInfo.Add_Genre("autobiography", "marcgt");
                    if (nature_of_recording.IndexOf("b") >= 0)
                        thisBibInfo.Add_Genre("biography", "marcgt");
                    if (nature_of_recording.IndexOf("c") >= 0)
                        thisBibInfo.Add_Genre("conference publication", "marcgt");
                    if (nature_of_recording.IndexOf("d") >= 0)
                        thisBibInfo.Add_Genre("drama", "marcgt");
                    if (nature_of_recording.IndexOf("e") >= 0)
                        thisBibInfo.Add_Genre("essay", "marcgt");
                    if (nature_of_recording.IndexOf("f") >= 0)
                        thisBibInfo.Add_Genre("fiction", "marcgt");
                    if (nature_of_recording.IndexOf("o") >= 0)
                        thisBibInfo.Add_Genre("folktale", "marcgt");
                    if (nature_of_recording.IndexOf("k") >= 0)
                        thisBibInfo.Add_Genre("humor, satire", "marcgt");
                    if (nature_of_recording.IndexOf("i") >= 0)
                        thisBibInfo.Add_Genre("instruction", "marcgt");
                    if (nature_of_recording.IndexOf("t") >= 0)
                        thisBibInfo.Add_Genre("interview", "marcgt");
                    if (nature_of_recording.IndexOf("j") >= 0)
                        thisBibInfo.Add_Genre("language instruction", "marcgt");
                    if (nature_of_recording.IndexOf("m") >= 0)
                        thisBibInfo.Add_Genre("memoir", "marcgt");
                    if (nature_of_recording.IndexOf("p") >= 0)
                        thisBibInfo.Add_Genre("poetry", "marcgt");
                    if (nature_of_recording.IndexOf("r") >= 0)
                        thisBibInfo.Add_Genre("rehearsal", "marcgt");
                    if (nature_of_recording.IndexOf("g") >= 0)
                        thisBibInfo.Add_Genre("reporting", "marcgt");
                    if (nature_of_recording.IndexOf("s") >= 0)
                        thisBibInfo.Add_Genre("sound", "marcgt");
                    if (nature_of_recording.IndexOf("l") >= 0)
                        thisBibInfo.Add_Genre("speech", "marcgt");
                }

                if (marc_type == "COM")
                {
                    switch (field_008[26])
                    {
                        case 'e':
                            thisBibInfo.Add_Genre("database", "marcgt");
                            break;

                        case 'f':
                            thisBibInfo.Add_Genre("font", "marcgt");
                            break;

                        case 'g':
                            thisBibInfo.Add_Genre("game", "marcgt");
                            break;

                        case 'a':
                            thisBibInfo.Add_Genre("numeric data", "marcgt");
                            break;

                        case 'h':
                            thisBibInfo.Add_Genre("sound", "marcgt");
                            break;
                    }
                }

                if (marc_type == "VIS")
                {
                    switch (field_008[33])
                    {
                        case 'a':
                            thisBibInfo.Add_Genre("art original", "marcgt");
                            break;

                        case 'c':
                            thisBibInfo.Add_Genre("art reproduction", "marcgt");
                            break;

                        case 'n':
                            thisBibInfo.Add_Genre("chart", "marcgt");
                            break;

                        case 'd':
                            thisBibInfo.Add_Genre("diorama", "marcgt");
                            break;

                        case 'f':
                            thisBibInfo.Add_Genre("filmstrip", "marcgt");
                            break;

                        case 'o':
                            thisBibInfo.Add_Genre("flash card", "marcgt");
                            break;

                        case 'k':
                            thisBibInfo.Add_Genre("graphic", "marcgt");
                            break;

                        case 'b':
                            thisBibInfo.Add_Genre("kit", "marcgt");
                            break;

                        case 'p':
                            thisBibInfo.Add_Genre("microscope slide", "marcgt");
                            break;

                        case 'q':
                            thisBibInfo.Add_Genre("model", "marcgt");
                            break;

                        case 'm':
                            thisBibInfo.Add_Genre("motion picture", "marcgt");
                            break;

                        case 'i':
                            thisBibInfo.Add_Genre("picture", "marcgt");
                            break;

                        case 'r':
                            thisBibInfo.Add_Genre("realia", "marcgt");
                            break;

                        case 's':
                            thisBibInfo.Add_Genre("slide", "marcgt");
                            break;

                        case 'l':
                            thisBibInfo.Add_Genre("technical drawing", "marcgt");
                            break;

                        case 'w':
                            thisBibInfo.Add_Genre("toy", "marcgt");
                            break;

                        case 't':
                            thisBibInfo.Add_Genre("transparency", "marcgt");
                            break;

                        case 'v':
                            thisBibInfo.Add_Genre("video recording", "marcgt");
                            break;
                    }
                }

                if (marc_type == "BKS")
                {
                    switch (field_008[34])
                    {
                        case 'a':
                            thisBibInfo.Add_Genre("autobiography", "marcgt");
                            break;

                        case 'b':
                            thisBibInfo.Add_Genre("individual biography", "marcgt");
                            break;

                        case 'c':
                            thisBibInfo.Add_Genre("collective biography", "marcgt");
                            break;
                    }

                    switch (field_008[33])
                    {
                        case 'a':
                            thisBibInfo.Add_Genre("comic strip", "marcgt");
                            break;

                        case 'd':
                            thisBibInfo.Add_Genre("drama", "marcgt");
                            break;

                        case 'e':
                            thisBibInfo.Add_Genre("essay", "marcgt");
                            break;

                        case 'h':
                            thisBibInfo.Add_Genre("humor, satire", "marcgt");
                            break;

                        case 'i':
                            thisBibInfo.Add_Genre("letter", "marcgt");
                            break;

                        case 'p':
                            thisBibInfo.Add_Genre("poetry", "marcgt");
                            break;

                        case 'f':
                            thisBibInfo.Add_Genre("novel", "marcgt");
                            break;

                        case 'j':
                            thisBibInfo.Add_Genre("short story", "marcgt");
                            break;

                        case 's':
                            thisBibInfo.Add_Genre("speech", "marcgt");
                            break;

                        case '0':
                            thisBibInfo.Add_Genre("non-fiction", "marcgt");
                            break;

                        case '1':
                            thisBibInfo.Add_Genre("fiction", "marcgt");
                            break;
                    }

                    if ((field_008[30] == 'h') || (field_008[31] == 'h'))
                    {
                        thisBibInfo.Add_Genre("history", "marcgt");
                    }

                    if (field_008[30] == '1')
                    {
                        thisBibInfo.Add_Genre("festschrift", "marcgt");
                    }
                }
            }

            // Look for target audience (521)
            foreach (MARC_Field thisRecord in record[521])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    if (thisRecord.has_Subfield('b'))
                    {
                        thisBibInfo.Add_Target_Audience(thisRecord['a'].Replace("[", "(").Replace("]", ")") + " [ " + thisRecord['b'].Replace("[", "(").Replace("]", ")") + " ]");
                    }
                    else
                    {
                        thisBibInfo.Add_Target_Audience(thisRecord['a'].Replace("[", "(").Replace("]", ")"));
                    }
                }
            }

            // Look for target audince (008/22)
            if ((marc_type == "BKS") || (marc_type == "COM") || (marc_type == "REC") || (marc_type == "SCO") || (marc_type == "VIS"))
            {
                if (field_008.Length > 22)
                {
                    switch (field_008[22])
                    {
                        case 'd':
                            thisBibInfo.Add_Target_Audience("adolescent", "marctarget");
                            break;

                        case 'e':
                            thisBibInfo.Add_Target_Audience("adult", "marctarget");
                            break;

                        case 'g':
                            thisBibInfo.Add_Target_Audience("general", "marctarget");
                            break;

                        case 'b':
                            thisBibInfo.Add_Target_Audience("primary", "marctarget");
                            break;

                        case 'c':
                            thisBibInfo.Add_Target_Audience("pre-adolescent", "marctarget");
                            break;

                        case 'j':
                            thisBibInfo.Add_Target_Audience("juvenile", "marctarget");
                            break;

                        case 'a':
                            thisBibInfo.Add_Target_Audience("preschool", "marctarget");
                            break;

                        case 'f':
                            thisBibInfo.Add_Target_Audience("specialized", "marctarget");
                            break;
                    }
                }
            }

            // Get any project codes ( 852 )
            if ((package != null) && (package.Behaviors.Aggregation_Count == 0))
            {
                foreach (MARC_Field thisRecord in record[852])
                {
                    if ((thisRecord.Indicators.Trim().Length == 0) && (thisRecord.has_Subfield('b')))
                    {
                        string allCodes = thisRecord['b'];
                        string[] splitAllCodes = allCodes.Split("|;".ToCharArray());
                        foreach (string splitCode in splitAllCodes)
                        {
                            package.Behaviors.Add_Aggregation(splitCode.Trim());
                        }
                    }
                }
            }
        }
        private static void Add_Subject(Bibliographic_Info thisBibInfo, MARC_Record record, int tag, string topical_codes, string geographic_codes, string temporal_codes, string genre_codes, string occupation_codes)
        {
            // Step through all of the subjects under this tag
            int subj_index = 1;
            string source;
            foreach (MARC_Field thisRecord in record[tag])
            {
                // Only continue if there is an id in this record
                if (thisRecord.has_Subfield('a'))
                {
                    // Was there  a source?
                    source = String.Empty;
                    if (thisRecord.has_Subfield('2'))
                    {
                        source = thisRecord['2'];
                    }
                    else if ((tag != 653))
                    {
                        switch (thisRecord.Indicator2)
                        {
                            case '0':
                                source = "lcsh";
                                break;

                            case '1':
                                source = "lcshac";
                                break;

                            case '2':
                                source = "mesh";
                                break;

                            case '3':
                                source = "nal";
                                break;

                            case '5':
                                source = "csh";
                                break;

                            case '6':
                                source = "rvm";
                                break;

                            case '9':
                                source = "local";
                                break;
                        }
                    }

                    Subject_Info_Standard obj = new Subject_Info_Standard();
                    obj.Authority = source;
                    obj.ID = "SUBJ" + tag + "_" + subj_index;
                    subj_index++;

                    // Add the topics
                    foreach (char thisTopicChar in topical_codes)
                    {
                        if (thisRecord.has_Subfield(thisTopicChar))
                        {
                            string topicString = thisRecord[thisTopicChar];
                            if (topicString.IndexOf("|") > 0)
                            {
                                string[] topicStringSplit = topicString.Split("|".ToCharArray());
                                foreach (string thisTopicString in topicStringSplit)
                                    obj.Add_Topic(Remove_Trailing_Punctuation(thisTopicString));
                            }
                            else
                            {
                                obj.Add_Topic(Remove_Trailing_Punctuation(topicString));
                            }
                        }
                    }

                    // Add the temporals
                    foreach (char thisTempChar in temporal_codes)
                    {
                        if (thisRecord.has_Subfield(thisTempChar))
                        {
                            string tempString = thisRecord[thisTempChar];
                            if (tempString.IndexOf("|") > 0)
                            {
                                string[] tempStringSplit = tempString.Split("|".ToCharArray());
                                foreach (string thisTempString in tempStringSplit)
                                    obj.Add_Temporal(Remove_Trailing_Punctuation(thisTempString));
                            }
                            else
                            {
                                obj.Add_Temporal(Remove_Trailing_Punctuation(tempString));
                            }
                        }
                    }

                    // Add the geographics
                    foreach (char thisGeoChar in geographic_codes)
                    {
                        if (thisRecord.has_Subfield(thisGeoChar))
                        {
                            string geoString = thisRecord[thisGeoChar];
                            if (geoString.IndexOf("|") > 0)
                            {
                                string[] geoStringSplit = geoString.Split("|".ToCharArray());
                                foreach (string thisGeoString in geoStringSplit)
                                    obj.Add_Geographic(Remove_Trailing_Punctuation(thisGeoString));
                            }
                            else
                            {
                                obj.Add_Geographic(Remove_Trailing_Punctuation(geoString));
                            }
                        }
                    }

                    // Add the genres
                    foreach (char thisGenreChar in genre_codes)
                    {
                        if (thisRecord.has_Subfield(thisGenreChar))
                        {
                            string genreString = thisRecord[thisGenreChar];
                            if (genreString.IndexOf("|") > 0)
                            {
                                string[] genreStringSplit = genreString.Split("|".ToCharArray());
                                foreach (string thisGenreString in genreStringSplit)
                                    obj.Add_Genre(Remove_Trailing_Punctuation(thisGenreString));
                            }
                            else
                            {
                                obj.Add_Genre(Remove_Trailing_Punctuation(genreString));
                            }
                        }
                    }

                    // Add the occupations
                    foreach (char thisOccChar in occupation_codes)
                    {
                        if (thisRecord.has_Subfield(thisOccChar))
                        {
                            string occString = thisRecord[thisOccChar].Replace("--", "|");
                            if (occString.IndexOf("|") > 0)
                            {
                                string[] occStringSplit = occString.Split("|".ToCharArray());
                                foreach (string thisOccString in occStringSplit)
                                    obj.Add_Occupation(Remove_Trailing_Punctuation(thisOccString.Trim()));
                            }
                            else
                            {
                                obj.Add_Occupation(Remove_Trailing_Punctuation(occString));
                            }
                        }
                    }

                    // Add this subject
                    thisBibInfo.Add_Subject(obj);
                }
            }
        }
        private static void Add_Personal_Name(Bibliographic_Info thisBibInfo, MARC_Record record, int tag, int name_type)
        {
            // Step through each instance of this tag
            foreach (MARC_Field thisRecord in record[tag])
            {
                // Create the name object
                Name_Info newName = new Name_Info();
                newName.Name_Type = Name_Info_Type_Enum.Personal;

                // Only continue if there is an id in this record
                if ((thisRecord.has_Subfield('a')) && (thisRecord['a'].ToUpper().IndexOf("PALMM") < 0))
                {
                    // Save the 'a' value
                    switch (thisRecord.Indicator1)
                    {
                        case '0':
                            newName.Given_Name = Remove_Trailing_Punctuation(thisRecord['a']);
                            newName.Full_Name = newName.Given_Name;
                            break;

                        case '1':
                            string tempName = Remove_Trailing_Punctuation(thisRecord['a']);
                            int tempCommaIndex = tempName.IndexOf(",");
                            if (tempCommaIndex > 0)
                            {
                                newName.Family_Name = tempName.Substring(0, tempCommaIndex).Trim();
                                newName.Given_Name = tempName.Substring(tempCommaIndex + 1).Trim();
                                newName.Full_Name = tempName;
                            }
                            else
                            {
                                newName.Family_Name = tempName;
                            }
                            break;

                        case '3':
                            newName.Family_Name = Remove_Trailing_Punctuation(thisRecord['a']);
                            newName.Full_Name = newName.Family_Name;
                            break;

                        default:
                            newName.Full_Name = Remove_Trailing_Punctuation(thisRecord['a']);
                            break;
                    }

                    if (thisRecord.has_Subfield('b'))
                        newName.Terms_Of_Address = thisRecord['b'];
                    if (thisRecord.has_Subfield('c'))
                    {
                        if (newName.Terms_Of_Address.Length > 0)
                        {
                            newName.Terms_Of_Address = newName.Terms_Of_Address + "; " + thisRecord['c'];
                        }
                        else
                        {
                            newName.Terms_Of_Address = thisRecord['c'];
                        }
                    }
                    if (thisRecord.has_Subfield('d'))
                        newName.Dates = Remove_Trailing_Punctuation(thisRecord['d']);
                    if (thisRecord.has_Subfield('e'))
                        newName.Add_Role(Remove_Trailing_Punctuation(thisRecord['e']));
                    if (thisRecord.has_Subfield('g'))
                        newName.Description = Remove_Trailing_Punctuation(thisRecord['g']);
                    if (thisRecord.has_Subfield('j'))
                    {
                        if (newName.Description.Length > 0)
                        {
                            newName.Description = newName.Description + "; " + thisRecord['j'];
                        }
                        else
                        {
                            newName.Description = thisRecord['j'];
                        }
                    }
                    if (thisRecord.has_Subfield('u'))
                        newName.Affiliation = Remove_Trailing_Punctuation(thisRecord['u']);
                    if (thisRecord.has_Subfield('q'))
                        newName.Display_Form = Remove_Trailing_Punctuation(thisRecord['q'].Replace("(", "").Replace(")", ""));

                    // Is there a relator code?
                    if (thisRecord.has_Subfield('4'))
                    {
                        // Get the relator code
                        string completeRelatorcode = thisRecord['4'];
                        string[] relatorCodesSplitter = completeRelatorcode.Split("|".ToCharArray());
                        foreach (string relatorcode in relatorCodesSplitter)
                        {
                            newName.Add_Role(relatorcode, "marcrelator", Name_Info_Role_Type_Enum.Code);
                        }
                    }

                    switch (name_type)
                    {
                        case 1:
                            thisBibInfo.Main_Entity_Name = newName;
                            break;

                        case 2:
                            thisBibInfo.Add_Named_Entity(newName);
                            break;

                        case 3:
                            thisBibInfo.Donor = newName;
                            break;

                        case 4:
                            Subject_Info_Name newNameSubj = new Subject_Info_Name();
                            newNameSubj.Set_Internal_Name(newName);
                            if (thisRecord.has_Subfield('v'))
                                newNameSubj.Add_Genre(Remove_Trailing_Punctuation(thisRecord['v']));
                            if (thisRecord.has_Subfield('x'))
                                newNameSubj.Add_Topic(Remove_Trailing_Punctuation(thisRecord['x']));
                            if (thisRecord.has_Subfield('y'))
                                newNameSubj.Add_Temporal(Remove_Trailing_Punctuation(thisRecord['y']));
                            if (thisRecord.has_Subfield('z'))
                                newNameSubj.Add_Geographic(Remove_Trailing_Punctuation(thisRecord['z']));
                            if (thisRecord.has_Subfield('2'))
                                newNameSubj.Authority = thisRecord['2'];
                            switch (thisRecord.Indicator2)
                            {
                                case '0':
                                    newNameSubj.Authority = "lcsh";
                                    break;

                                case '1':
                                    newNameSubj.Authority = "lcshac";
                                    break;

                                case '2':
                                    newNameSubj.Authority = "mesh";
                                    break;

                                case '3':
                                    newNameSubj.Authority = "nal";
                                    break;

                                case '5':
                                    newNameSubj.Authority = "csh";
                                    break;

                                case '6':
                                    newNameSubj.Authority = "rvm";
                                    break;
                            }
                            break;
                    }
                }
            }
        }
        private static void Add_Main_Title(Bibliographic_Info thisBibInfo, MARC_Record record, int tag, Title_Type_Enum type, int non_filling_type, int title_type)
        {
            // Step through each instance of this tag
            foreach (MARC_Field thisRecord in record[tag])
            {
                // Declare new title
                Title_Info newTitle = new Title_Info();
                newTitle.Title_Type = type;

                switch (non_filling_type)
                {
                    case 0:
                        newTitle.Title = Remove_Trailing_Punctuation(thisRecord['a']);
                        break;

                    case 1:
                        int non_filling_chars1 = 0;
                        try
                        {
                            non_filling_chars1 = Convert.ToInt16(thisRecord.Indicator1) - 48;
                        }
                        catch
                        {
                        }

                        if (non_filling_chars1 == 0)
                        {
                            newTitle.Title = Remove_Trailing_Punctuation(thisRecord['a']);
                        }
                        else
                        {
                            string complete_title = thisRecord['a'];
                            newTitle.NonSort = complete_title.Substring(0, non_filling_chars1);
                            newTitle.Title = Remove_Trailing_Punctuation(complete_title.Substring(non_filling_chars1));
                        }
                        break;

                    case 2:
                        int non_filling_chars2 = 0;
                        try
                        {
                            non_filling_chars2 = Convert.ToInt16(thisRecord.Indicator2) - 48;
                        }
                        catch
                        {
                        }

                        if (non_filling_chars2 == 0)
                        {
                            newTitle.Title = Remove_Trailing_Punctuation(thisRecord['a']);
                        }
                        else
                        {
                            string complete_title = thisRecord['a'];
                            newTitle.NonSort = complete_title.Substring(0, non_filling_chars2);
                            newTitle.Title = Remove_Trailing_Punctuation(complete_title.Substring(non_filling_chars2));
                        }
                        break;
                }

                newTitle.Title = newTitle.Title.Replace("âE", "É");

                if (thisRecord.has_Subfield('b'))
                    newTitle.Subtitle = Remove_Trailing_Punctuation(thisRecord['b'].Replace("/", ""));
                if (thisRecord.has_Subfield('n'))
                    newTitle.Add_Part_Number(thisRecord['n']);
                if (thisRecord.has_Subfield('p'))
                    newTitle.Add_Part_Name(thisRecord['p']);
                if (thisRecord.has_Subfield('y'))
                    newTitle.Language = thisRecord['y'];
                if (tag >= 700)
                    newTitle.Display_Label = "Uncontrolled";
                if (tag < 200)
                    newTitle.Display_Label = "Main Entry";
                if (tag == 246)
                {
                    switch (thisRecord.Indicator2)
                    {
                        case '0':
                            newTitle.Display_Label = "Portion of title";
                            break;

                        case '1':
                            newTitle.Display_Label = "Parallel title";
                            break;

                        case '2':
                            newTitle.Display_Label = "Distinctive title";
                            break;

                        case '3':
                            newTitle.Display_Label = "Other title";
                            break;

                        case '4':
                            newTitle.Display_Label = "Cover title";
                            break;

                        case '5':
                            newTitle.Display_Label = "Added title page title";
                            break;

                        case '6':
                            newTitle.Display_Label = "Caption title";
                            break;

                        case '7':
                            newTitle.Display_Label = "Running title";
                            break;

                        case '8':
                            newTitle.Display_Label = "Spine title";
                            break;

                        default:
                            newTitle.Display_Label = "Alternate title";
                            break;
                    }
                }
                if (thisRecord.has_Subfield('i'))
                    newTitle.Display_Label = thisRecord['i'].Replace(":", "");

                switch (title_type)
                {
                    case 1:
                        thisBibInfo.Main_Title = newTitle;
                        break;

                    case 2:
                        thisBibInfo.Add_Other_Title(newTitle);
                        break;

                    case 3:
                        thisBibInfo.SeriesTitle = newTitle;
                        break;

                    case 4:
                        Subject_Info_TitleInfo newTitleSubj = new Subject_Info_TitleInfo();
                        newTitleSubj.Set_Internal_Title(newTitle);
                        if (thisRecord.has_Subfield('v'))
                            newTitleSubj.Add_Genre(Remove_Trailing_Punctuation(thisRecord['v']));
                        if (thisRecord.has_Subfield('x'))
                            newTitleSubj.Add_Topic(Remove_Trailing_Punctuation(thisRecord['x']));
                        if (thisRecord.has_Subfield('y'))
                            newTitleSubj.Add_Temporal(Remove_Trailing_Punctuation(thisRecord['y']));
                        if (thisRecord.has_Subfield('z'))
                            newTitleSubj.Add_Geographic(Remove_Trailing_Punctuation(thisRecord['z']));
                        if (thisRecord.has_Subfield('2'))
                            newTitleSubj.Authority = thisRecord['2'];
                        switch (thisRecord.Indicator2)
                        {
                            case '0':
                                newTitleSubj.Authority = "lcsh";
                                break;

                            case '1':
                                newTitleSubj.Authority = "lcshac";
                                break;

                            case '2':
                                newTitleSubj.Authority = "mesh";
                                break;

                            case '3':
                                newTitleSubj.Authority = "nal";
                                break;

                            case '5':
                                newTitleSubj.Authority = "csh";
                                break;

                            case '6':
                                newTitleSubj.Authority = "rvm";
                                break;
                        }
                        thisBibInfo.Add_Subject(newTitleSubj);
                        break;
                }
            }
        }
        private static void Add_Hierarchical_Subject(Bibliographic_Info thisBibInfo, MARC_Record record, int tag)
        {
            int subj_index = 1;

            foreach (MARC_Field thisRecord in record[tag])
            {
                Subject_Info_HierarchicalGeographic spatial = new Subject_Info_HierarchicalGeographic();

                // Look for 'a' first
                if (thisRecord.has_Subfield('a'))
                {
                    spatial.Country = Remove_Trailing_Punctuation(thisRecord['a']);
                }

                // Look for 'b' next
                if (thisRecord.has_Subfield('b'))
                {
                    spatial.State = Remove_Trailing_Punctuation(thisRecord['b']);
                }

                // Look for 'c' next
                if (thisRecord.has_Subfield('c'))
                {
                    spatial.County = Remove_Trailing_Punctuation(thisRecord['c']);
                }

                // Look for 'd' next
                if (thisRecord.has_Subfield('d'))
                {
                    spatial.City = Remove_Trailing_Punctuation(thisRecord['d']);
                }

                // Look for area
                if (thisRecord.has_Subfield('f'))
                {
                    spatial.Area = Remove_Trailing_Punctuation(thisRecord['f']);
                }

                // Look for authority
                if (thisRecord.has_Subfield('2'))
                {
                    spatial.Authority = thisRecord['2'];
                }

                // Now, add to the object
                spatial.ID = "SUBJ" + tag + "_" + subj_index;
                subj_index++;
                thisBibInfo.Add_Subject(spatial);
            }
        }
 /// <summary> Reads the MARC Core-compliant section of XML and stores the data in the provided digital resource </summary>
 /// <param name="r"> XmlTextReader from which to read the marc data </param>
 /// <param name="thisBibInfo">Bibliographic object into which most the values are read</param>
 /// <param name="package"> Digital resource object to save the data to if this is reading the top-level bibDesc (OPTIONAL)</param>
 /// <param name="Importing_Record"> Importing record flag is used to determine if special treatment should be applied to the 001 identifier.  If this is reading MarcXML from a dmdSec, this is set to false </param>
 public static void Read_MarcXML_Info(XmlReader r, Bibliographic_Info thisBibInfo, SobekCM_Item package, bool Importing_Record )
 {
     Read_MarcXML_Info(r, thisBibInfo, package, Importing_Record, null );
 }
        /// <summary> Reads the Dublin Core-compliant section of XML and stores the data in the provided digital resource </summary>
        /// <param name="R"> XmlTextReader from which to read the dublin core data </param>
        /// <param name="BibInfo"> Digital resource object to save the data to </param>
        /// <param name="Return_Package"> The return package, if this is reading a top-level section of dublin core </param>
        public static void Read_Simple_Dublin_Core_Info(XmlReader R, Bibliographic_Info BibInfo, SobekCM_Item Return_Package )
        {
            while (R.Read())
            {
                if ((R.NodeType == XmlNodeType.EndElement) && ((R.Name == "METS:mdWrap") || (R.Name == "mdWrap")))
                    return;

                if (R.NodeType == XmlNodeType.Element)
                {
                    switch (R.Name)
                    {
                        case "dc:contributor":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                BibInfo.Add_Named_Entity(R.Value.Trim(), "Contributor");
                            }
                            break;

                        case "dc:coverage":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                Subject_Info_Standard thisSubject = new Subject_Info_Standard();
                                thisSubject.Add_Geographic(R.Value.Trim());
                                BibInfo.Add_Subject(thisSubject);
                            }
                            break;

                        case "dc:creator":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                if (BibInfo.Main_Entity_Name.hasData)
                                {
                                    BibInfo.Add_Named_Entity(R.Value.Trim());
                                }
                                else
                                {
                                    BibInfo.Main_Entity_Name.Full_Name = R.Value.Trim();
                                }
                            }
                            break;

                        case "dc:date":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                BibInfo.Origin_Info.Date_Issued = R.Value.Trim();
                            }
                            break;

                        case "dc:description":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                BibInfo.Add_Note(R.Value.Trim());
                            }
                            break;

                        case "dc:format":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                BibInfo.Original_Description.Extent = R.Value.Trim();
                            }
                            break;

                        case "dc:identifier":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                BibInfo.Add_Identifier(R.Value.Trim());
                            }
                            break;

                        case "dc:language":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                BibInfo.Add_Language(R.Value.Trim());
                            }
                            break;

                        case "dc:publisher":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                BibInfo.Add_Publisher(R.Value.Trim());
                            }
                            break;

                        case "dc:relation":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                Related_Item_Info newRelatedItem = new Related_Item_Info();
                                newRelatedItem.Main_Title.Title = R.Value.Trim();
                                BibInfo.Add_Related_Item(newRelatedItem);
                            }
                            break;

                        case "dc:rights":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                BibInfo.Access_Condition.Text = R.Value.Trim();
                            }
                            break;

                        case "dc:source":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                BibInfo.Add_Note(R.Value, Note_Type_Enum.source);
                            }
                            break;

                        case "dc:subject":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                if (R.Value.IndexOf(";") > 0)
                                {
                                    string[] splitter = R.Value.Split(";".ToCharArray());
                                    foreach (string thisSplit in splitter)
                                    {
                                        BibInfo.Add_Subject(thisSplit.Trim(), String.Empty);
                                    }
                                }
                                else
                                {
                                    BibInfo.Add_Subject(R.Value.Trim(), String.Empty);
                                }
                            }
                            break;

                        case "dc:title":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                if (BibInfo.Main_Title.Title.Length == 0)
                                {
                                    BibInfo.Main_Title.Title = R.Value.Trim();
                                }
                                else
                                {
                                    BibInfo.Add_Other_Title(R.Value.Trim(), Title_Type_Enum.alternative);
                                }
                            }
                            break;

                        case "dc:type":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                BibInfo.Type.Add_Uncontrolled_Type(R.Value.Trim());
                            }
                            break;

                        case "thesis.degree.name":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0) && ( Return_Package != null ))
                            {
                                // Ensure the thesis object exists and is added
                                Thesis_Dissertation_Info thesisInfo = Return_Package.Get_Metadata_Module(GlobalVar.THESIS_METADATA_MODULE_KEY) as Thesis_Dissertation_Info;
                                if (thesisInfo == null)
                                {
                                    thesisInfo = new Thesis_Dissertation_Info();
                                    Return_Package.Add_Metadata_Module(GlobalVar.THESIS_METADATA_MODULE_KEY, thesisInfo);
                                }

                                thesisInfo.Degree = R.Value.Trim();
                            }
                            break;

                        case "thesis.degree.level":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0) && (Return_Package != null))
                            {
                                // Ensure the thesis object exists and is added
                                Thesis_Dissertation_Info thesisInfo = Return_Package.Get_Metadata_Module(GlobalVar.THESIS_METADATA_MODULE_KEY) as Thesis_Dissertation_Info;
                                if (thesisInfo == null)
                                {
                                    thesisInfo = new Thesis_Dissertation_Info();
                                    Return_Package.Add_Metadata_Module(GlobalVar.THESIS_METADATA_MODULE_KEY, thesisInfo);
                                }

                                string temp = R.Value.Trim().ToLower();
                                if ((temp == "doctorate") || (temp == "doctoral"))
                                    thesisInfo.Degree_Level = Thesis_Dissertation_Info.Thesis_Degree_Level_Enum.Doctorate;
                                if ((temp == "masters") || (temp == "master's"))
                                    thesisInfo.Degree_Level = Thesis_Dissertation_Info.Thesis_Degree_Level_Enum.Masters;
                                if ((temp == "bachelors") || (temp == "bachelor's"))
                                    thesisInfo.Degree_Level = Thesis_Dissertation_Info.Thesis_Degree_Level_Enum.Bachelors;
                                if ((temp == "post-doctorate") || (temp == "post-doctoral"))
                                    thesisInfo.Degree_Level = Thesis_Dissertation_Info.Thesis_Degree_Level_Enum.Bachelors;
                            }
                            break;

                        case "thesis.degree.discipline":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0) && (Return_Package != null))
                            {
                                // Ensure the thesis object exists and is added
                                Thesis_Dissertation_Info thesisInfo = Return_Package.Get_Metadata_Module(GlobalVar.THESIS_METADATA_MODULE_KEY) as Thesis_Dissertation_Info;
                                if (thesisInfo == null)
                                {
                                    thesisInfo = new Thesis_Dissertation_Info();
                                    Return_Package.Add_Metadata_Module(GlobalVar.THESIS_METADATA_MODULE_KEY, thesisInfo);
                                }

                                thesisInfo.Add_Degree_Discipline(R.Value.Trim());
                            }
                            break;

                        case "thesis.degree.grantor":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0) && (Return_Package != null))
                            {
                                // Ensure the thesis object exists and is added
                                Thesis_Dissertation_Info thesisInfo = Return_Package.Get_Metadata_Module(GlobalVar.THESIS_METADATA_MODULE_KEY) as Thesis_Dissertation_Info;
                                if (thesisInfo == null)
                                {
                                    thesisInfo = new Thesis_Dissertation_Info();
                                    Return_Package.Add_Metadata_Module(GlobalVar.THESIS_METADATA_MODULE_KEY, thesisInfo);
                                }

                                thesisInfo.Degree_Grantor = R.Value.Trim();
                            }
                            break;
                    }
                }
            }
        }
        private static void Add_Corporate_Name(Bibliographic_Info thisBibInfo, MARC_Record record, int tag, int name_type)
        {
            // Step through each instance of this tag
            foreach (MARC_Field thisRecord in record[tag])
            {
                if ((name_type != 3) || (thisRecord.Indicator2 == '3'))
                {
                    // Create the name object
                    Name_Info newName = new Name_Info();
                    newName.Name_Type = Name_Info_Type_Enum.Corporate;

                    // Only continue if there is an id in this record
                    if ((thisRecord.has_Subfield('a')) && (thisRecord['a'].ToUpper().IndexOf("PALMM") < 0))
                    {
                        newName.Full_Name = Remove_Trailing_Punctuation(thisRecord['a']);
                        if (thisRecord.has_Subfield('b'))
                        {
                            newName.Full_Name = newName.Full_Name + " -- " + Remove_Trailing_Punctuation(thisRecord['b']);
                        }
                        if (thisRecord.has_Subfield('c'))
                            newName.Description = thisRecord['c'];
                        if (thisRecord.has_Subfield('d'))
                            newName.Dates = Remove_Trailing_Punctuation(thisRecord['d']);
                        if (thisRecord.has_Subfield('e'))
                            newName.Add_Role(Remove_Trailing_Punctuation(thisRecord['e']));
                        if (thisRecord.has_Subfield('u'))
                            newName.Affiliation = Remove_Trailing_Punctuation(thisRecord['u']);

                        // Is there a relator code?
                        if (thisRecord.has_Subfield('4'))
                        {
                            // Get the relator code
                            string relatorcode = thisRecord['4'];
                            newName.Add_Role(relatorcode, "marcrelator", Name_Info_Role_Type_Enum.Code);
                        }

                        switch (name_type)
                        {
                            case 1:
                                thisBibInfo.Main_Entity_Name = newName;
                                break;

                            case 2:
                                thisBibInfo.Add_Named_Entity(newName);
                                break;

                            case 3:
                                thisBibInfo.Donor = newName;
                                break;

                            case 4:
                                Subject_Info_Name newNameSubj = new Subject_Info_Name();
                                newNameSubj.Set_Internal_Name(newName);
                                if (thisRecord.has_Subfield('v'))
                                    newNameSubj.Add_Genre(Remove_Trailing_Punctuation(thisRecord['v']));
                                if (thisRecord.has_Subfield('x'))
                                    newNameSubj.Add_Topic(Remove_Trailing_Punctuation(thisRecord['x']));
                                if (thisRecord.has_Subfield('y'))
                                    newNameSubj.Add_Temporal(Remove_Trailing_Punctuation(thisRecord['y']));
                                if (thisRecord.has_Subfield('z'))
                                    newNameSubj.Add_Geographic(Remove_Trailing_Punctuation(thisRecord['z']));
                                if (thisRecord.has_Subfield('2'))
                                    newNameSubj.Authority = thisRecord['2'];
                                switch (thisRecord.Indicator2)
                                {
                                    case '0':
                                        newNameSubj.Authority = "lcsh";
                                        break;

                                    case '1':
                                        newNameSubj.Authority = "lcshac";
                                        break;

                                    case '2':
                                        newNameSubj.Authority = "mesh";
                                        break;

                                    case '3':
                                        newNameSubj.Authority = "nal";
                                        break;

                                    case '5':
                                        newNameSubj.Authority = "csh";
                                        break;

                                    case '6':
                                        newNameSubj.Authority = "rvm";
                                        break;
                                }
                                break;
                        }
                    }
                }
            }
        }
 /// <summary> Add the bibliographic information as MODS to the output stream for a given digital resource </summary>
 /// <param name="Output"> Output stream for this metadata to be written to </param>
 /// <param name="thisBibInfo"> Source digital resource bibliographic information </param>
 public static void Write_MODS(TextWriter Output, Bibliographic_Info thisBibInfo)
 {
     thisBibInfo.Add_MODS(Output, null);
 }
        /// <summary> Reads the MODS-compliant section of XML and stores the data in the provided digital resource </summary>
        /// <param name="r"> XmlTextReader from which to read the MODS data </param>
        /// <param name="package"> Digital resource object to save the data to </param>
        public static void Read_MODS_Info(XmlReader r, Bibliographic_Info thisBibInfo, SobekCM_Item Return_Item)
        {
            while (r.Read())
            {
                if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "METS:mdWrap") || (r.Name == "mdWrap") || (r.Name == "mods")))
                    return;

                if (r.NodeType == XmlNodeType.Element)
                {
                    switch (r.Name)
                    {
                        case "mods:abstract":
                        case "abstract":
                            Abstract_Info thisAbstract = new Abstract_Info();
                            if (r.MoveToAttribute("ID"))
                                thisAbstract.ID = r.Value;
                            if (r.MoveToAttribute("type"))
                                thisAbstract.Type = r.Value;
                            if (r.MoveToAttribute("displayLabel"))
                                thisAbstract.Display_Label = r.Value;
                            if (r.MoveToAttribute("lang"))
                                thisAbstract.Language = r.Value;
                            r.Read();
                            if (r.NodeType == XmlNodeType.Text)
                            {
                                thisAbstract.Abstract_Text = r.Value;
                                thisBibInfo.Add_Abstract(thisAbstract);
                            }
                            break;

                        case "mods:accessCondition":
                        case "accessCondition":
                            if (r.MoveToAttribute("ID"))
                                thisBibInfo.Access_Condition.ID = r.Value;
                            if (r.MoveToAttribute("type"))
                                thisBibInfo.Access_Condition.Type = r.Value;
                            if (r.MoveToAttribute("displayLabel"))
                                thisBibInfo.Access_Condition.Display_Label = r.Value;
                            if (r.MoveToAttribute("lang"))
                                thisBibInfo.Access_Condition.Language = r.Value;
                            r.Read();
                            if (r.NodeType == XmlNodeType.Text)
                            {
                                thisBibInfo.Access_Condition.Text = r.Value;
                            }
                            break;

                        case "mods:classification":
                        case "classification":
                            Classification_Info thisClassification = new Classification_Info();
                            if (r.MoveToAttribute("edition"))
                                thisClassification.Edition = r.Value;
                            if (r.MoveToAttribute("authority"))
                                thisClassification.Authority = r.Value;
                            if (r.MoveToAttribute("displayLabel"))
                                thisClassification.Display_Label = r.Value;
                            r.Read();
                            if (r.NodeType == XmlNodeType.Text)
                            {
                                thisClassification.Classification = r.Value;
                                thisBibInfo.Add_Classification(thisClassification);
                            }
                            break;

                        case "mods:identifier":
                        case "identifier":
                            Identifier_Info thisIdentifier = new Identifier_Info();
                            if (r.MoveToAttribute("type"))
                                thisIdentifier.Type = r.Value;
                            if (r.MoveToAttribute("displayLabel"))
                                thisIdentifier.Display_Label = r.Value;
                            r.Read();
                            if (r.NodeType == XmlNodeType.Text)
                            {
                                thisIdentifier.Identifier = r.Value;
                                thisBibInfo.Add_Identifier(thisIdentifier);
                            }
                            break;

                        case "mods:genre":
                        case "genre":
                            Genre_Info thisGenre = new Genre_Info();
                            if (r.MoveToAttribute("ID"))
                                thisGenre.ID = r.Value;
                            if (r.MoveToAttribute("authority"))
                                thisGenre.Authority = r.Value;
                            if (r.MoveToAttribute("lang"))
                                thisGenre.Language = r.Value;
                            r.Read();
                            if (r.NodeType == XmlNodeType.Text)
                            {
                                thisGenre.Genre_Term = r.Value;
                                thisBibInfo.Add_Genre(thisGenre);
                            }
                            break;

                        case "mods:language":
                        case "language":
                            string language_text = String.Empty;
                            string language_rfc_code = String.Empty;
                            string language_iso_code = String.Empty;
                            string language_id = String.Empty;
                            if (r.MoveToAttribute("ID"))
                                language_id = r.Value;
                            while (r.Read())
                            {
                                if ((r.NodeType == XmlNodeType.Element) && ((r.Name == "mods:languageTerm") || (r.Name == "languageTerm")))
                                {
                                    if (r.MoveToAttribute("type"))
                                    {
                                        switch (r.Value)
                                        {
                                            case "code":
                                                if (r.MoveToAttribute("authority"))
                                                {
                                                    if (r.Value == "rfc3066")
                                                    {
                                                        r.Read();
                                                        if (r.NodeType == XmlNodeType.Text)
                                                        {
                                                            language_rfc_code = r.Value;
                                                        }
                                                    }
                                                    else if (r.Value == "iso639-2b")
                                                    {
                                                        r.Read();
                                                        if (r.NodeType == XmlNodeType.Text)
                                                        {
                                                            language_iso_code = r.Value;
                                                        }
                                                    }
                                                }
                                                break;

                                            case "text":
                                                r.Read();
                                                if (r.NodeType == XmlNodeType.Text)
                                                {
                                                    language_text = r.Value;
                                                }
                                                // Quick check for a change we started in 2010
                                                if (language_text == "governmental publication")
                                                    language_text = "government publication";
                                                break;

                                            default:
                                                r.Read();
                                                if (r.NodeType == XmlNodeType.Text)
                                                {
                                                    language_text = r.Value;
                                                }
                                                break;
                                        }
                                    }
                                    else
                                    {
                                        r.Read();
                                        if (r.NodeType == XmlNodeType.Text)
                                        {
                                            language_text = r.Value;
                                        }
                                    }
                                }

                                if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:language") || (r.Name == "language")))
                                {
                                    break;
                                }
                            }

                            if ((language_text.Length > 0) || (language_rfc_code.Length > 0) || (language_iso_code.Length > 0))
                            {
                                thisBibInfo.Add_Language(language_text, language_iso_code, language_rfc_code);
                            }
                            break;

                        case "mods:location":
                        case "location":
                            while (r.Read())
                            {
                                if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:location") || (r.Name == "location")))
                                    break;

                                if (r.NodeType == XmlNodeType.Element)
                                {
                                    if ((r.Name == "mods:physicalLocation") || (r.Name == "physicalLocation"))
                                    {
                                        if (r.MoveToAttribute("type"))
                                        {
                                            if (r.Value == "code")
                                            {
                                                r.Read();
                                                if (r.NodeType == XmlNodeType.Text)
                                                {
                                                    thisBibInfo.Location.Holding_Code = r.Value;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            r.Read();
                                            if (r.NodeType == XmlNodeType.Text)
                                            {
                                                thisBibInfo.Location.Holding_Name = r.Value;
                                            }
                                        }
                                    }
                                    if ((r.Name == "mods:url") || (r.Name == "url"))
                                    {
                                        // TEST
                                        if (r.MoveToAttribute("access"))
                                        {
                                            if (r.Value == "object in context")
                                            {
                                                r.Read();
                                                if (r.NodeType == XmlNodeType.Text)
                                                {
                                                    thisBibInfo.Location.PURL = r.Value;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            string url_displayLabel = r.GetAttribute("displayLabel");
                                            string url_note = r.GetAttribute("note");
                                            r.Read();
                                            if (r.NodeType == XmlNodeType.Text)
                                            {
                                                if ((url_displayLabel != null) && (url_displayLabel == "Finding Guide"))
                                                {
                                                    if (url_note != null)
                                                    {
                                                        thisBibInfo.Location.EAD_Name = url_note;
                                                    }
                                                    thisBibInfo.Location.EAD_URL = r.Value;
                                                }
                                                else
                                                {
                                                    if (url_displayLabel != null)
                                                    {
                                                        thisBibInfo.Location.Other_URL_Display_Label = url_displayLabel;
                                                    }

                                                    if (url_note != null)
                                                    {
                                                        thisBibInfo.Location.Other_URL_Note = url_note;
                                                    }
                                                    thisBibInfo.Location.Other_URL = r.Value;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            break;

                        case "mods:name":
                        case "name":
                            Name_Info tempNewName = read_name_object(r);
                            if (tempNewName.Main_Entity)
                                thisBibInfo.Main_Entity_Name = tempNewName;
                            else
                            {
                                bool donor = false;
                                foreach (Name_Info_Role role in tempNewName.Roles)
                                {
                                    if ((role.Role == "donor") || (role.Role == "honoree") || (role.Role == "endowment") || (role.Role == "collection"))
                                    {
                                        donor = true;
                                        break;
                                    }
                                }
                                if (donor)
                                {
                                    thisBibInfo.Donor = tempNewName;
                                }
                                else
                                {
                                    thisBibInfo.Add_Named_Entity(tempNewName);
                                }
                            }
                            break;

                        case "mods:note":
                        case "note":
                            Note_Info newNote = new Note_Info();
                            if (r.MoveToAttribute("ID"))
                                newNote.ID = r.Value;
                            if (r.MoveToAttribute("type"))
                                newNote.Note_Type_String = r.Value;
                            if (r.MoveToAttribute("displayLabel"))
                                newNote.Display_Label = r.Value;
                            r.Read();
                            if (r.NodeType == XmlNodeType.Text)
                            {
                                newNote.Note = r.Value;
                                thisBibInfo.Add_Note(newNote);
                            }
                            break;

                        case "mods:Origin_Info":
                        case "Origin_Info":
                        case "mods:originInfo":
                        case "originInfo":
                            while (r.Read())
                            {
                                if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:Origin_Info") || (r.Name == "Origin_Info") || (r.Name == "mods:originInfo") || (r.Name == "originInfo")))
                                    break;

                                if (r.NodeType == XmlNodeType.Element)
                                {
                                    switch (r.Name)
                                    {
                                        case "mods:publisher":
                                        case "publisher":
                                            r.Read();
                                            if (r.NodeType == XmlNodeType.Text)
                                            {
                                                thisBibInfo.Origin_Info.Add_Publisher(r.Value);
                                                thisBibInfo.Add_Publisher(r.Value);
                                            }
                                            break;

                                        case "mods:place":
                                        case "place":
                                            string place_text = String.Empty;
                                            string place_marc = String.Empty;
                                            string place_iso = String.Empty;
                                            while ((r.Read()) && (!(((r.Name == "mods:place") || (r.Name == "place")) && (r.NodeType == XmlNodeType.EndElement))))
                                            {
                                                if ((r.NodeType == XmlNodeType.Element) && ((r.Name == "mods:placeTerm") || (r.Name == "placeTerm")))
                                                {
                                                    if ((r.MoveToAttribute("type")) && (r.Value == "code"))
                                                    {
                                                        if (r.MoveToAttribute("authority"))
                                                        {
                                                            switch (r.Value)
                                                            {
                                                                case "marccountry":
                                                                    r.Read();
                                                                    if (r.NodeType == XmlNodeType.Text)
                                                                    {
                                                                        place_marc = r.Value;
                                                                    }
                                                                    break;

                                                                case "iso3166":
                                                                    r.Read();
                                                                    if (r.NodeType == XmlNodeType.Text)
                                                                    {
                                                                        place_iso = r.Value;
                                                                    }
                                                                    break;
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        r.Read();
                                                        if (r.NodeType == XmlNodeType.Text)
                                                        {
                                                            place_text = r.Value;
                                                        }
                                                    }
                                                }
                                            }
                                            if ((place_text.Length > 0) || (place_marc.Length > 0) || (place_iso.Length > 0))
                                            {
                                                thisBibInfo.Origin_Info.Add_Place(place_text, place_marc, place_iso);
                                            }
                                            break;

                                        case "mods:dateIssued":
                                        case "dateIssued":
                                            if ((r.MoveToAttribute("encoding")) && (r.Value == "marc"))
                                            {
                                                if (r.MoveToAttribute("point"))
                                                {
                                                    if (r.Value == "start")
                                                    {
                                                        r.Read();
                                                        if (r.NodeType == XmlNodeType.Text)
                                                        {
                                                            thisBibInfo.Origin_Info.MARC_DateIssued_Start = r.Value;
                                                        }
                                                    }
                                                    else if (r.Value == "end")
                                                    {
                                                        r.Read();
                                                        if (r.NodeType == XmlNodeType.Text)
                                                        {
                                                            thisBibInfo.Origin_Info.MARC_DateIssued_End = r.Value;
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    r.Read();
                                                    if (r.NodeType == XmlNodeType.Text)
                                                    {
                                                        thisBibInfo.Origin_Info.MARC_DateIssued = r.Value;
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                r.Read();
                                                if (r.NodeType == XmlNodeType.Text)
                                                {
                                                    thisBibInfo.Origin_Info.Date_Issued = r.Value;
                                                }
                                            }
                                            break;

                                        case "mods:dateCreated":
                                        case "dateCreated":
                                            r.Read();
                                            if (r.NodeType == XmlNodeType.Text)
                                            {
                                                thisBibInfo.Origin_Info.Date_Created = r.Value;
                                            }
                                            break;

                                        case "mods:copyrightDate":
                                        case "copyrightDate":
                                            r.Read();
                                            if (r.NodeType == XmlNodeType.Text)
                                            {
                                                thisBibInfo.Origin_Info.Date_Copyrighted = r.Value;
                                            }
                                            break;

                                        case "mods:dateOther":
                                        case "dateOther":
                                            if ((r.MoveToAttribute("type")) && (r.Value == "reprint"))
                                            {
                                                r.Read();
                                                if (r.NodeType == XmlNodeType.Text)
                                                {
                                                    thisBibInfo.Origin_Info.Date_Reprinted = r.Value;
                                                }
                                            }
                                            break;

                                        case "mods:edition":
                                        case "edition":
                                            r.Read();
                                            if (r.NodeType == XmlNodeType.Text)
                                            {
                                                thisBibInfo.Origin_Info.Edition = r.Value;
                                            }
                                            break;

                                        case "mods:frequency":
                                        case "frequency":
                                            string freq_authority = String.Empty;
                                            if (r.MoveToAttribute("authority"))
                                                freq_authority = r.Value;
                                            r.Read();
                                            if (r.NodeType == XmlNodeType.Text)
                                            {
                                                thisBibInfo.Origin_Info.Add_Frequency(r.Value, freq_authority);
                                            }
                                            break;

                                        case "mods:issuance":
                                        case "issuance":
                                            r.Read();
                                            if (r.NodeType == XmlNodeType.Text)
                                            {
                                                thisBibInfo.Origin_Info.Add_Issuance(r.Value);
                                            }
                                            break;
                                    }
                                }
                            }

                            break;

                        case "mods:physicalDescription":
                        case "physicalDescription":
                            read_physical_description(r, thisBibInfo.Original_Description);
                            break;

                        case "mods:recordInfo":
                        case "recordInfo":
                            while (r.Read())
                            {
                                if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:recordInfo") || (r.Name == "recordInfo")))
                                {
                                    break;
                                }

                                if (r.NodeType == XmlNodeType.Element)
                                {
                                    switch (r.Name)
                                    {
                                        case "mods:recordCreationDate":
                                        case "recordCreationDate":
                                            if ((r.MoveToAttribute("encoding")) && (r.Value == "marc"))
                                            {
                                                r.Read();
                                                thisBibInfo.Record.MARC_Creation_Date = r.Value;
                                            }
                                            break;

                                        case "mods:recordIdentifier":
                                        case "recordIdentifier":
                                            string source = String.Empty;
                                            if (r.MoveToAttribute("source"))
                                            {
                                                thisBibInfo.Record.Main_Record_Identifier.Type = r.Value;
                                            }
                                            r.Read();
                                            thisBibInfo.Record.Main_Record_Identifier.Identifier = r.Value;
                                            break;

                                        case "mods:recordOrigin":
                                        case "recordOrigin":
                                            r.Read();
                                            thisBibInfo.Record.Record_Origin = r.Value;
                                            break;

                                        case "mods:descriptionStandard":
                                        case "descriptionStandard":
                                            r.Read();
                                            thisBibInfo.Record.Description_Standard = r.Value;
                                            break;

                                        case "mods:recordContentSource":
                                        case "recordContentSource":
                                            if (r.MoveToAttribute("authority"))
                                            {
                                                if (r.Value == "marcorg")
                                                {
                                                    r.Read();
                                                    thisBibInfo.Record.Add_MARC_Record_Content_Sources(r.Value);
                                                }
                                            }
                                            else
                                            {
                                                r.Read();
                                                thisBibInfo.Source.Statement = r.Value;
                                            }
                                            break;

                                        case "mods:languageOfCataloging":
                                        case "languageOfCataloging":
                                            string cat_language_text = String.Empty;
                                            string cat_language_rfc_code = String.Empty;
                                            string cat_language_iso_code = String.Empty;
                                            string cat_language_id = String.Empty;
                                            while (r.Read())
                                            {
                                                if ((r.NodeType == XmlNodeType.Element) && ((r.Name == "mods:languageTerm") || (r.Name == "languageTerm")))
                                                {
                                                    if (r.MoveToAttribute("ID"))
                                                        cat_language_id = r.Value;

                                                    if (r.MoveToAttribute("type"))
                                                    {
                                                        switch (r.Value)
                                                        {
                                                            case "code":
                                                                if (r.MoveToAttribute("authority"))
                                                                {
                                                                    if (r.Value == "rfc3066")
                                                                    {
                                                                        r.Read();
                                                                        if (r.NodeType == XmlNodeType.Text)
                                                                        {
                                                                            cat_language_rfc_code = r.Value;
                                                                        }
                                                                    }
                                                                    else if (r.Value == "iso639-2b")
                                                                    {
                                                                        r.Read();
                                                                        if (r.NodeType == XmlNodeType.Text)
                                                                        {
                                                                            cat_language_iso_code = r.Value;
                                                                        }
                                                                    }
                                                                }
                                                                break;

                                                            case "text":
                                                                r.Read();
                                                                if (r.NodeType == XmlNodeType.Text)
                                                                {
                                                                    cat_language_text = r.Value;
                                                                }
                                                                break;

                                                            default:
                                                                r.Read();
                                                                if (r.NodeType == XmlNodeType.Text)
                                                                {
                                                                    cat_language_text = r.Value;
                                                                }
                                                                break;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        r.Read();
                                                        if (r.NodeType == XmlNodeType.Text)
                                                        {
                                                            cat_language_text = r.Value;
                                                        }
                                                    }
                                                }

                                                if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:languageOfCataloging") || (r.Name == "languageOfCataloging")))
                                                {
                                                    break;
                                                }
                                            }

                                            if ((cat_language_text.Length > 0) || (cat_language_rfc_code.Length > 0) || (cat_language_iso_code.Length > 0))
                                            {
                                                Language_Info newCatLanguage = new Language_Info(cat_language_text, cat_language_iso_code, cat_language_rfc_code);
                                                thisBibInfo.Record.Add_Catalog_Language(newCatLanguage);
                                            }
                                            break;
                                    }
                                }
                            }
                            break;

                        case "mods:relatedItem":
                        case "relatedItem":
                            string relatedItemType = String.Empty;
                            if (r.MoveToAttribute("type"))
                                relatedItemType = r.Value.ToLower();

                            switch (relatedItemType)
                            {
                                case "original":
                                    while (r.Read())
                                    {
                                        if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:relatedItem") || (r.Name == "relatedItem")))
                                            break;

                                        if (r.NodeType == XmlNodeType.Element)
                                        {
                                            if ((r.Name == "mods:physicalDescription") || (r.Name == "physicalDescription"))
                                            {
                                                read_physical_description(r, thisBibInfo.Original_Description);
                                            }
                                        }
                                    }
                                    break;

                                case "series":
                                    string part_type = String.Empty;
                                    string part_caption = String.Empty;
                                    string part_number = String.Empty;

                                    while (r.Read())
                                    {
                                        if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:relatedItem") || (r.Name == "mods:relatedItem")))
                                        {
                                            break;
                                        }

                                        if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:detail") || (r.Name == "detail")))
                                        {
                                            try
                                            {
                                                switch (part_type)
                                                {
                                                    case "Enum1":
                                                        thisBibInfo.Series_Part_Info.Enum1 = part_caption;
                                                        thisBibInfo.Series_Part_Info.Enum1_Index = Convert.ToInt32(part_number);
                                                        break;

                                                    case "Enum2":
                                                        thisBibInfo.Series_Part_Info.Enum2 = part_caption;
                                                        thisBibInfo.Series_Part_Info.Enum2_Index = Convert.ToInt32(part_number);
                                                        break;

                                                    case "Enum3":
                                                        thisBibInfo.Series_Part_Info.Enum3 = part_caption;
                                                        thisBibInfo.Series_Part_Info.Enum3_Index = Convert.ToInt32(part_number);
                                                        break;

                                                    case "Enum4":
                                                        thisBibInfo.Series_Part_Info.Enum4 = part_caption;
                                                        thisBibInfo.Series_Part_Info.Enum4_Index = Convert.ToInt32(part_number);
                                                        break;

                                                    case "Year":
                                                        thisBibInfo.Series_Part_Info.Year = part_caption;
                                                        thisBibInfo.Series_Part_Info.Year_Index = Convert.ToInt32(part_number);
                                                        break;

                                                    case "Month":
                                                        thisBibInfo.Series_Part_Info.Month = part_caption;
                                                        thisBibInfo.Series_Part_Info.Month_Index = Convert.ToInt32(part_number);
                                                        break;

                                                    case "Day":
                                                        thisBibInfo.Series_Part_Info.Day = part_caption;
                                                        thisBibInfo.Series_Part_Info.Day_Index = Convert.ToInt32(part_number);
                                                        break;
                                                }
                                            }
                                            catch
                                            {
                                            }

                                            part_type = String.Empty;
                                            part_caption = String.Empty;
                                            part_number = String.Empty;
                                        }

                                        if (r.NodeType == XmlNodeType.Element)
                                        {
                                            switch (r.Name)
                                            {
                                                case "mods:titleInfo":
                                                case "titleInfo":
                                                    thisBibInfo.SeriesTitle = read_title_object(r);
                                                    break;

                                                case "mods:detail":
                                                case "detail":
                                                    if (r.MoveToAttribute("type"))
                                                    {
                                                        part_type = r.Value;
                                                    }
                                                    break;

                                                case "mods:caption":
                                                case "caption":
                                                    r.Read();
                                                    if (r.NodeType == XmlNodeType.Text)
                                                    {
                                                        part_caption = r.Value;
                                                    }
                                                    break;

                                                case "mods:number":
                                                case "number":
                                                    r.Read();
                                                    if (r.NodeType == XmlNodeType.Text)
                                                    {
                                                        part_number = r.Value;
                                                    }
                                                    break;
                                            }
                                        }
                                    }
                                    break;

                                default:
                                    Related_Item_Info newRelated = new Related_Item_Info();
                                    thisBibInfo.Add_Related_Item(newRelated);
                                    switch (relatedItemType)
                                    {
                                        case "preceding":
                                            newRelated.Relationship = Related_Item_Type_Enum.preceding;
                                            break;

                                        case "succeeding":
                                            newRelated.Relationship = Related_Item_Type_Enum.succeeding;
                                            break;

                                        case "otherVersion":
                                            newRelated.Relationship = Related_Item_Type_Enum.otherVersion;
                                            break;

                                        case "otherFormat":
                                            newRelated.Relationship = Related_Item_Type_Enum.otherFormat;
                                            break;

                                        case "host":
                                            newRelated.Relationship = Related_Item_Type_Enum.host;
                                            break;
                                    }
                                    if (r.MoveToAttribute("ID"))
                                        newRelated.ID = r.Value;

                                    while (r.Read())
                                    {
                                        if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:relatedItem") || (r.Name == "relatedItem")))
                                        {
                                            break;
                                        }

                                        if (r.NodeType == XmlNodeType.Element)
                                        {
                                            switch (r.Name)
                                            {
                                                case "mods:titleInfo":
                                                case "titleInfo":
                                                    newRelated.Set_Main_Title(read_title_object(r));
                                                    break;

                                                case "mods:identifier":
                                                case "identifier":
                                                    Identifier_Info thisRIdentifier = new Identifier_Info();
                                                    if (r.MoveToAttribute("type"))
                                                        thisRIdentifier.Type = r.Value;
                                                    if (r.MoveToAttribute("displayLabel"))
                                                        thisRIdentifier.Display_Label = r.Value;
                                                    r.Read();
                                                    if (r.NodeType == XmlNodeType.Text)
                                                    {
                                                        thisRIdentifier.Identifier = r.Value;
                                                        newRelated.Add_Identifier(thisRIdentifier);
                                                    }
                                                    break;

                                                case "mods:name":
                                                case "name":
                                                    newRelated.Add_Name(read_name_object(r));
                                                    break;

                                                case "mods:note":
                                                case "note":
                                                    Note_Info newRNote = new Note_Info();
                                                    if (r.MoveToAttribute("ID"))
                                                        newRNote.ID = r.Value;
                                                    if (r.MoveToAttribute("type"))
                                                        newRNote.Note_Type_String = r.Value;
                                                    if (r.MoveToAttribute("displayLabel"))
                                                        newRNote.Display_Label = r.Value;
                                                    r.Read();
                                                    if (r.NodeType == XmlNodeType.Text)
                                                    {
                                                        newRNote.Note = r.Value;
                                                        newRelated.Add_Note(newRNote);
                                                    }
                                                    break;

                                                case "mods:url":
                                                case "url":
                                                    if (r.MoveToAttribute("displayLabel"))
                                                        newRelated.URL_Display_Label = r.Value;
                                                    r.Read();
                                                    if (r.NodeType == XmlNodeType.Text)
                                                    {
                                                        newRelated.URL = r.Value;
                                                    }
                                                    break;

                                                case "mods:publisher":
                                                case "publisher":
                                                    r.Read();
                                                    if (r.NodeType == XmlNodeType.Text)
                                                    {
                                                        newRelated.Publisher = r.Value;
                                                    }
                                                    break;

                                                case "mods:recordIdentifier":
                                                case "recordIdentifier":
                                                    if (r.MoveToAttribute("source"))
                                                    {
                                                        if ((r.Value == "ufdc") || (r.Value == "dloc") || (r.Value.ToLower() == "sobekcm"))
                                                        {
                                                            r.Read();
                                                            if (r.NodeType == XmlNodeType.Text)
                                                            {
                                                                newRelated.SobekCM_ID = r.Value;
                                                            }
                                                        }
                                                    }
                                                    break;

                                                case "mods:dateIssued":
                                                case "dateIssued":
                                                    if (r.MoveToAttribute("point"))
                                                    {
                                                        if (r.Value == "start")
                                                        {
                                                            r.Read();
                                                            if (r.NodeType == XmlNodeType.Text)
                                                            {
                                                                newRelated.Start_Date = r.Value;
                                                            }
                                                        }
                                                        else if (r.Value == "end")
                                                        {
                                                            r.Read();
                                                            if (r.NodeType == XmlNodeType.Text)
                                                            {
                                                                newRelated.End_Date = r.Value;
                                                            }
                                                        }
                                                    }
                                                    break;
                                            }
                                        }
                                    }
                                    break;
                            }
                            break;

                        case "mods:subject":
                        case "subject":
                            read_subject_object(r, thisBibInfo);
                            break;

                        case "mods:targetAudience":
                        case "targetAudience":
                            TargetAudience_Info newTarget = new TargetAudience_Info();
                            if (r.MoveToAttribute("ID"))
                                newTarget.ID = r.Value;
                            if (r.MoveToAttribute("authority"))
                                newTarget.Authority = r.Value;
                            r.Read();
                            if (r.NodeType == XmlNodeType.Text)
                            {
                                newTarget.Audience = r.Value;
                                thisBibInfo.Add_Target_Audience(newTarget);
                            }
                            break;

                        case "mods:tableOfContents":
                        case "tableOfContents":
                            r.Read();
                            if (r.NodeType == XmlNodeType.Text)
                            {
                                thisBibInfo.TableOfContents = r.Value;
                            }
                            break;

                        case "mods:titleInfo":
                        case "titleInfo":
                            Title_Info thisTitle = read_title_object(r);
                            if (thisTitle.Title_Type == Title_Type_Enum.UNSPECIFIED)
                                thisBibInfo.Main_Title = thisTitle;
                            else
                                thisBibInfo.Add_Other_Title(thisTitle);
                            break;

                        case "mods:typeOfResource":
                        case "typeOfResource":
                            r.Read();
                            if (r.NodeType == XmlNodeType.Text)
                            {
                                thisBibInfo.Type.Add_Uncontrolled_Type(r.Value);
                            }
                            break;

                        case "mods:extension":
                        case "extension":
                            string schema = String.Empty;
                            string alias = String.Empty;
                            if (r.HasAttributes)
                            {
                                for (int i = 0; i < r.AttributeCount; i++)
                                {
                                    r.MoveToAttribute(i);
                                    if (r.Name.IndexOf("xmlns") == 0)
                                    {
                                        alias = r.Name.Replace("xmlns:", "");
                                        schema = r.Value;
                                        break;
                                    }
                                }
                            }
                            if (schema.IndexOf("vra.xsd") > 0)
                            {
                                read_vra_core_extensions(r, thisBibInfo, alias, Return_Item);
                            }
                            break;
                    }
                }
            }
        }
        private static void read_vra_core_extensions(XmlReader r, Bibliographic_Info thisBibInfo, string alias, SobekCM_Item Package)
        {
            if (Package == null)
            {
                while (r.Read())
                {
                    if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:extension") || (r.Name == "extension")))
                    {
                        return;
                    }
                }
                return;
            }

            VRACore_Info vraCoreInfo = Package.Get_Metadata_Module( GlobalVar.VRACORE_METADATA_MODULE_KEY ) as VRACore_Info;
            if (vraCoreInfo == null)
            {
                vraCoreInfo = new VRACore_Info();
                Package.Add_Metadata_Module(GlobalVar.VRACORE_METADATA_MODULE_KEY, vraCoreInfo);
            }

            while (r.Read())
            {
                if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:extension") || (r.Name == "extension")))
                {
                    return;
                }

                if (r.NodeType == XmlNodeType.Element)
                {
                    string nodename = r.Name;
                    if (alias.Length > 0)
                    {
                        nodename = nodename.Replace(alias + ":", "");
                    }
                    switch (nodename)
                    {
                        case "culturalContext":
                            r.Read();
                            if (r.NodeType == XmlNodeType.Text)
                            {
                                if (r.Value.Length > 0)
                                    vraCoreInfo.Add_Cultural_Context(r.Value);
                            }
                            break;

                        case "inscription":
                            r.Read();
                            if (r.NodeType == XmlNodeType.Text)
                            {
                                if (r.Value.Length > 0)
                                    vraCoreInfo.Add_Inscription(r.Value);
                            }
                            break;

                        case "material":
                            string type = String.Empty;
                            if (r.HasAttributes)
                            {
                                if (r.MoveToAttribute("type"))
                                    type = r.Value;
                            }
                            r.Read();
                            if (r.NodeType == XmlNodeType.Text)
                            {
                                if (r.Value.Length > 0)
                                    vraCoreInfo.Add_Material(r.Value, type);
                            }
                            break;

                        case "measurements":
                            string units = String.Empty;
                            if (r.HasAttributes)
                            {
                                if (r.MoveToAttribute("unit"))
                                    units = r.Value;
                            }
                            r.Read();
                            if (r.NodeType == XmlNodeType.Text)
                            {
                                if (r.Value.Length > 0)
                                    vraCoreInfo.Add_Measurement(r.Value, units);
                            }
                            break;

                        case "stateEdition":
                            r.Read();
                            if (r.NodeType == XmlNodeType.Text)
                            {
                                if (r.Value.Length > 0)
                                    vraCoreInfo.Add_State_Edition(r.Value);
                            }
                            break;

                        case "stylePeriod":
                            r.Read();
                            if (r.NodeType == XmlNodeType.Text)
                            {
                                if (r.Value.Length > 0)
                                    vraCoreInfo.Add_Style_Period(r.Value);
                            }
                            break;

                        case "technique":
                            r.Read();
                            if (r.NodeType == XmlNodeType.Text)
                            {
                                if (r.Value.Length > 0)
                                    vraCoreInfo.Add_Technique(r.Value);
                            }
                            break;
                    }
                }
            }
        }
        private static void read_subject_object(XmlReader r, Bibliographic_Info thisBibInfo)
        {
            string language = String.Empty;
            string authority = String.Empty;
            string id = String.Empty;

            if (r.MoveToAttribute("ID"))
                id = r.Value;
            if (r.MoveToAttribute("lang"))
                language = r.Value;
            if (r.MoveToAttribute("authority"))
                authority = r.Value;

            // Move to the next element
            while (r.Read())
            {
                if (r.NodeType == XmlNodeType.Element)
                    break;
            }

            // Determine the subject type
            Subject_Info_Type type = Subject_Info_Type.UNKNOWN;

            // What is the name of this node?
            switch (r.Name)
            {
                case "mods:topic":
                case "mods:geographic":
                case "mods:genre":
                case "mods:temporal":
                case "mods:occupation":
                case "topic":
                case "geographic":
                case "genre":
                case "temporal":
                case "occupation":
                    type = Subject_Info_Type.Standard;
                    break;

                case "mods:hierarchicalGeographic":
                case "hierarchicalGeographic":
                    type = Subject_Info_Type.Hierarchical_Spatial;
                    break;

                case "mods:cartographics":
                case "cartographics":
                    type = Subject_Info_Type.Cartographics;
                    break;

                case "mods:name":
                case "name":
                    type = Subject_Info_Type.Name;
                    break;

                case "mods:titleInfo":
                case "titleInfo":
                    type = Subject_Info_Type.TitleInfo;
                    break;
            }

            // If no type was determined, return null
            if (type == Subject_Info_Type.UNKNOWN)
                return;

            // Was this the standard subject object?
            if (type == Subject_Info_Type.Standard)
            {
                Subject_Info_Standard standardSubject = new Subject_Info_Standard();
                standardSubject.Language = language;
                standardSubject.Authority = authority;
                standardSubject.ID = id;

                do
                {
                    if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:subject") || (r.Name == "subject")))
                    {
                        if ((standardSubject.Topics_Count > 0) || (standardSubject.Geographics_Count > 0) || (standardSubject.Genres_Count > 0) ||
                            (standardSubject.Temporals_Count > 0) || (standardSubject.Occupations_Count > 0))
                        {
                            thisBibInfo.Add_Subject(standardSubject);
                        }
                        return;
                    }

                    if (r.NodeType == XmlNodeType.Element)
                    {
                        switch (r.Name)
                        {
                            case "mods:topic":
                            case "topic":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    standardSubject.Add_Topic(r.Value);
                                break;

                            case "mods:geographic":
                            case "geographic":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    standardSubject.Add_Geographic(r.Value);
                                break;

                            case "mods:genre":
                            case "genre":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    standardSubject.Add_Genre(r.Value);
                                break;

                            case "mods:temporal":
                            case "temporal":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    standardSubject.Add_Temporal(r.Value);
                                break;

                            case "mods:occupation":
                            case "occupation":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    standardSubject.Add_Occupation(r.Value);
                                break;
                        }
                    }
                } while (r.Read());
            }

            // Was this the hierarchical geography subject?
            if (type == Subject_Info_Type.Hierarchical_Spatial)
            {
                Subject_Info_HierarchicalGeographic geoSubject = new Subject_Info_HierarchicalGeographic();
                geoSubject.Language = language;
                geoSubject.Authority = authority;
                geoSubject.ID = id;

                while (r.Read())
                {
                    if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:subject") || (r.Name == "subject")))
                    {
                        thisBibInfo.Add_Subject(geoSubject);
                        return;
                    }

                    if (r.NodeType == XmlNodeType.Element)
                    {
                        switch (r.Name)
                        {
                            case "mods:continent":
                            case "continent":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.Continent = r.Value;
                                break;

                            case "mods:country":
                            case "country":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.Country = r.Value;
                                break;

                            case "mods:province":
                            case "province":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.Province = r.Value;
                                break;

                            case "mods:region":
                            case "region":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.Region = r.Value;
                                break;

                            case "mods:state":
                            case "state":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.State = r.Value;
                                break;

                            case "mods:territory":
                            case "territory":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.Territory = r.Value;
                                break;

                            case "mods:county":
                            case "county":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.County = r.Value;
                                break;

                            case "mods:city":
                            case "city":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.City = r.Value;
                                break;

                            case "mods:citySection":
                            case "citySection":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.CitySection = r.Value;
                                break;

                            case "mods:island":
                            case "island":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.Island = r.Value;
                                break;

                            case "mods:area":
                            case "area":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.Area = r.Value;
                                break;
                        }
                    }
                }
            }

            // Was this the cartographics subject?
            if (type == Subject_Info_Type.Cartographics)
            {
                Subject_Info_Cartographics mapSubject = new Subject_Info_Cartographics();
                mapSubject.Language = language;
                mapSubject.Authority = authority;
                mapSubject.ID = id;

                while (r.Read())
                {
                    if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:subject") || (r.Name == "subject")))
                    {
                        if ((mapSubject.Projection.Length > 0) || (mapSubject.Coordinates.Length > 0) || (mapSubject.Scale.Length > 0))
                        {
                            thisBibInfo.Add_Subject(mapSubject);
                        }
                        return;
                    }

                    if (r.NodeType == XmlNodeType.Element)
                    {
                        switch (r.Name)
                        {
                            case "mods:coordinates":
                            case "coordinates":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    mapSubject.Coordinates = r.Value;
                                break;

                            case "mods:scale":
                            case "scale":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    mapSubject.Scale = r.Value;
                                break;

                            case "mods:projection":
                            case "projection":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    mapSubject.Projection = r.Value;
                                break;
                        }
                    }
                }
            }

            // Was this the name subject?
            if (type == Subject_Info_Type.Name)
            {
                Subject_Info_Name nameSubject = new Subject_Info_Name();
                nameSubject.Language = language;
                nameSubject.Authority = authority;
                nameSubject.ID = id;

                do
                {
                    if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:subject") || (r.Name == "subject")))
                    {
                        thisBibInfo.Add_Subject(nameSubject);
                        return;
                    }

                    if (r.NodeType == XmlNodeType.Element)
                    {
                        switch (r.Name)
                        {
                            case "mods:name":
                            case "name":
                                Name_Info nameInfo = read_name_object(r);
                                nameSubject.Set_Internal_Name(nameInfo);
                                break;

                            case "mods:topic":
                            case "topic":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    nameSubject.Add_Topic(r.Value);
                                break;

                            case "mods:geographic":
                            case "geographic":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    nameSubject.Add_Geographic(r.Value);
                                break;

                            case "mods:genre":
                            case "genre":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    nameSubject.Add_Genre(r.Value);
                                break;

                            case "mods:temporal":
                            case "temporal":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    nameSubject.Add_Temporal(r.Value);
                                break;
                        }
                    }
                } while (r.Read());
            }

            // Was this the title subject?
            if (type == Subject_Info_Type.TitleInfo)
            {
                Subject_Info_TitleInfo titleSubject = new Subject_Info_TitleInfo();
                titleSubject.Language = language;
                titleSubject.Authority = authority;
                titleSubject.ID = id;

                do
                {
                    if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:subject") || (r.Name == "subject")))
                    {
                        thisBibInfo.Add_Subject(titleSubject);
                        return;
                    }

                    if (r.NodeType == XmlNodeType.Element)
                    {
                        switch (r.Name)
                        {
                            case "mods:titleInfo":
                            case "titleInfo":
                                Title_Info titleInfo = read_title_object(r);
                                titleSubject.Set_Internal_Title(titleInfo);
                                break;

                            case "mods:topic":
                            case "topic":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    titleSubject.Add_Topic(r.Value);
                                break;

                            case "mods:geographic":
                            case "geographic":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    titleSubject.Add_Geographic(r.Value);
                                break;

                            case "mods:genre":
                            case "genre":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    titleSubject.Add_Genre(r.Value);
                                break;

                            case "mods:temporal":
                            case "temporal":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    titleSubject.Add_Temporal(r.Value);
                                break;
                        }
                    }
                } while (r.Read());
            }
        }
 /// <summary> This class adds a bib info object to this class </summary>
 public void Add_Bib_Info()
 {
     BIBInfo = new Bibliographic_Info();
 }
        /// <summary> Class writes simple dublin core to an output stream </summary>
        /// <param name="Output"> Output stream to write to </param>
        /// <param name="BibInfo"> Bibliographic information to write </param>
        public static void Write_Simple_Dublin_Core(TextWriter Output, Bibliographic_Info BibInfo)
        {
            // Add all the titles
            Output.WriteLine("<dc:title>" + BibInfo.Main_Title + "</dc:title>");
            List<string> titles = new List<string> {BibInfo.Main_Title.ToString().Trim()};
            if (BibInfo.Other_Titles_Count > 0)
            {
                foreach (Title_Info thisTitle in BibInfo.Other_Titles)
                {
                    if (!titles.Contains(thisTitle.ToString().Trim()))
                    {
                        Output.WriteLine("<dc:title>" + Convert_String_To_XML_Safe_Static(thisTitle.ToString()) + "</dc:title>");
                        titles.Add(thisTitle.ToString().Trim());
                    }
                }
            }

            // Series title maps to dc:relation
            if ((BibInfo.hasSeriesTitle) && (BibInfo.SeriesTitle.Title.Length > 0))
            {
                if (!titles.Contains(BibInfo.SeriesTitle.ToString().Trim()))
                {
                    Output.WriteLine("<dc:relation>" + Convert_String_To_XML_Safe_Static(BibInfo.SeriesTitle.ToString()) + "</dc:relation>");
                }
            }

            // Add all the creators
            List<string> contributors = new List<string>();
            if ((BibInfo.hasMainEntityName) && (BibInfo.Main_Entity_Name.Full_Name.Length > 0))
            {
                if ((BibInfo.Main_Entity_Name.Roles.Count == 0) || (BibInfo.Main_Entity_Name.Roles[0].Role.ToUpper() != "CONTRIBUTOR"))
                    Output.WriteLine("<dc:creator>" + Convert_String_To_XML_Safe_Static(BibInfo.Main_Entity_Name.ToString().Replace("<i>", "").Replace("</i>", "")) + "</dc:creator>");
                else
                    contributors.Add(BibInfo.Main_Entity_Name.ToString(false).Replace("<i>", "").Replace("</i>", ""));
            }
            if (BibInfo.Names_Count > 0)
            {
                foreach (Name_Info thisName in BibInfo.Names)
                {
                    if ((thisName.Roles.Count == 0) || (thisName.Roles[0].Role.ToUpper() != "CONTRIBUTOR"))
                        Output.WriteLine("<dc:creator>" + Convert_String_To_XML_Safe_Static(thisName.ToString().Replace("<i>", "").Replace("</i>", "")) + "</dc:creator>");
                    else
                        contributors.Add(thisName.ToString(false).Replace("<i>", "").Replace("</i>", ""));
                }
            }

            // Add any collected contributors
            if (contributors.Count > 0)
            {
                foreach (string thisContributor in contributors)
                {
                    Output.WriteLine("<dc:contributor>" + Convert_String_To_XML_Safe_Static(thisContributor) + "</dc:contributor>");
                }
            }

            // Add the coverages (hierarchical geographic)
            if (BibInfo.Subjects_Count > 0)
            {
                foreach (Subject_Info thisSubject in BibInfo.Subjects)
                {
                    if (thisSubject.Class_Type == Subject_Info_Type.Hierarchical_Spatial)
                    {
                        string subject_string = thisSubject.ToString();
                        if (subject_string.Length > 0)
                        {
                            Output.WriteLine("<dc:coverage>" + Convert_String_To_XML_Safe_Static(subject_string) + "</dc:coverage>");
                        }
                    }
                }
            }

            // Add the coverages (temporal)
            if (BibInfo.TemporalSubjects_Count > 0)
            {
                foreach (Temporal_Info thisTemporal in BibInfo.TemporalSubjects)
                {
                    if (thisTemporal.TimePeriod.Length > 0)
                    {
                        Output.WriteLine("<dc:coverage>" + Convert_String_To_XML_Safe_Static(thisTemporal.TimePeriod) + "</dc:coverage>");
                    }
                }
            }

            // Add the date issued
            if (BibInfo.Origin_Info.Date_Issued.Length > 0)
            {
                Output.WriteLine("<dc:date>" + Convert_String_To_XML_Safe_Static(BibInfo.Origin_Info.Date_Issued) + "</dc:date>");
            }

            // Add all descriptions/notes
            if ((BibInfo.Original_Description != null) && (BibInfo.Original_Description.Notes_Count > 0))
            {
                foreach (string physicalDescNote in BibInfo.Original_Description.Notes)
                {
                    Output.WriteLine("<dc:description>" + Convert_String_To_XML_Safe_Static(physicalDescNote) + "</dc:description>");
                }
            }
            if (BibInfo.Notes_Count > 0)
            {
                foreach (Note_Info thisNote in BibInfo.Notes)
                {
                    if (thisNote.Note_Type != Note_Type_Enum.source)
                        Output.WriteLine("<dc:description>" + Convert_String_To_XML_Safe_Static(thisNote.ToString().Replace("<b>", "(").Replace("</b>", ") ")) + "</dc:description>");
                }
            }

            // Add the format
            if (BibInfo.Original_Description.Extent.Length > 0)
            {
                Output.WriteLine("<dc:format>" + Convert_String_To_XML_Safe_Static(BibInfo.Original_Description.Extent) + "</dc:format>");
            }

            // Add all the other identifiers
            if (BibInfo.Identifiers_Count > 0)
            {
                foreach (Identifier_Info thisIdentifier in BibInfo.Identifiers)
                {
                    Output.WriteLine("<dc:identifier>" + Convert_String_To_XML_Safe_Static(thisIdentifier.Identifier) + "</dc:identifier>");
                }
            }

            // Add the language information
            if (BibInfo.Languages_Count > 0)
            {
                foreach (Language_Info thisLanguage in BibInfo.Languages)
                {
                    if (thisLanguage.Language_Text.Length > 0)
                    {
                        Output.WriteLine("<dc:language>" + Convert_String_To_XML_Safe_Static(thisLanguage.Language_Text) + "</dc:language>");
                    }
                }
            }

            // Add the subjects
            if (BibInfo.Subjects_Count > 0)
            {
                foreach (Subject_Info thisSubject in BibInfo.Subjects)
                {
                    if (thisSubject.Class_Type != Subject_Info_Type.Hierarchical_Spatial)
                    {
                        if (thisSubject.Class_Type == Subject_Info_Type.Standard)
                        {
                            Subject_Info_Standard standSubj = (Subject_Info_Standard) thisSubject;
                            if (standSubj.Geographics_Count > 0)
                            {
                                string[] geographics = new string[standSubj.Geographics_Count];
                                standSubj.Geographics.CopyTo(geographics, 0);
                                standSubj.Clear_Geographics();
                                string subject_string = thisSubject.ToString();
                                if (subject_string.Length > 0)
                                {
                                    Output.WriteLine("<dc:subject>" + Convert_String_To_XML_Safe_Static(subject_string.Replace("<i>", "").Replace("</i>", "")) + "</dc:subject>");
                                }
                                foreach (string thisGeographic in geographics)
                                {
                                    Output.WriteLine("<dc:coverage>" + Convert_String_To_XML_Safe_Static(thisGeographic) + "</dc:coverage>");
                                    standSubj.Add_Geographic(thisGeographic);
                                }
                            }
                            else
                            {
                                string subject_string = thisSubject.ToString();
                                if (subject_string.Length > 0)
                                {
                                    Output.WriteLine("<dc:subject>" + Convert_String_To_XML_Safe_Static(subject_string.Replace("<i>", "").Replace("</i>", "")) + "</dc:subject>");
                                }
                            }
                        }
                        else
                        {
                            string subject_string = thisSubject.ToString();
                            if (subject_string.Length > 0)
                            {
                                Output.WriteLine("<dc:subject>" + Convert_String_To_XML_Safe_Static(subject_string.Replace("<i>", "").Replace("</i>", "")) + "</dc:subject>");
                            }
                        }
                    }
                }
            }

            // Add all the publishers from the origin info section
            if (BibInfo.Origin_Info.Publishers_Count > 0)
            {
                foreach (string publisher in BibInfo.Origin_Info.Publishers)
                {
                    Output.WriteLine("<dc:publisher>" + Convert_String_To_XML_Safe_Static(publisher) + "</dc:publisher>");
                }
            }

            // Add all publishers held in the more complete custom section
            if (BibInfo.Publishers.Count > 0)
            {
                foreach (Publisher_Info thisPublisher in BibInfo.Publishers)
                {
                    Output.WriteLine("<dc:publisher>" + Convert_String_To_XML_Safe_Static(thisPublisher.ToString()) + "</dc:publisher>");
                }
            }

            // Add the type
            string mods_type = BibInfo.Type.MODS_Type_String;
            if (mods_type.Length > 0)
            {
                Output.WriteLine("<dc:type>" + Convert_String_To_XML_Safe_Static(mods_type) + "</dc:type>");
            }
            if (BibInfo.Type.Uncontrolled_Types_Count > 0)
            {
                foreach (string thisType in BibInfo.Type.Uncontrolled_Types)
                {
                    Output.WriteLine("<dc:type>" + Convert_String_To_XML_Safe_Static(thisType) + "</dc:type>");
                }
            }

            // Add the relations
            if (BibInfo.RelatedItems_Count > 0)
            {
                foreach (Related_Item_Info thisRelatedItem in BibInfo.RelatedItems)
                {
                    if (thisRelatedItem.Main_Title.Title.Trim().Length > 0)
                    {
                        Output.WriteLine("<dc:relation>" + Convert_String_To_XML_Safe_Static(thisRelatedItem.Main_Title.Title) + "</dc:relation>");
                    }
                }
            }

            // Add the rights
            if (BibInfo.Access_Condition.Text.Length > 0)
            {
                Output.WriteLine("<dc:rights>" + Convert_String_To_XML_Safe_Static(BibInfo.Access_Condition.Text) + "</dc:rights>");
            }

            // Add the source note
            if (BibInfo.Notes_Count > 0)
            {
                foreach (Note_Info thisNote in BibInfo.Notes)
                {
                    if (thisNote.Note_Type == Note_Type_Enum.source)
                        Output.WriteLine("<dc:source>" + Convert_String_To_XML_Safe_Static(thisNote.Note) + "</dc:source>");
                }
            }

            //// Add the source information
            //if (BibInfo.Source.Statement.Length > 0)
            //{
            //    Output.WriteLine("<dc:source>" + BibInfo.Source.XML_Safe_Statement + "</dc:source>");
            //}
        }
        private static void Add_Descriptions(Bibliographic_Info thisBibInfo, MARC_Record record)
        {
            // Look for any THESIS note
            foreach (MARC_Field thisRecord in record[502])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.Thesis);
                }
            }

            // Look for any BIBLIORAPHY note
            foreach (MARC_Field thisRecord in record[504])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.Bibliography);
                }
            }

            // Look for any RESTRICTION note
            foreach (MARC_Field thisRecord in record[506])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    thisBibInfo.Access_Condition.Text = thisRecord['a'];
                    // thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.restriction);
                }
            }

            // Look for any CREATION/PRODUCTION CREDITS note
            foreach (MARC_Field thisRecord in record[508])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.CreationCredits);
                }
            }

            // Look for any CREATION/PRODUCTION CREDITS note
            foreach (MARC_Field thisRecord in record[510])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.CitationReference);
                }
            }

            // Look for any PERFORMERS note
            foreach (MARC_Field thisRecord in record[511])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    if (thisRecord.Indicator1 == '1')
                    {
                        thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.Performers, "cast");
                    }
                    else
                    {
                        thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.Performers);
                    }
                }
            }

            // Look for any DATE/VENUE note
            foreach (MARC_Field thisRecord in record[518])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    if (thisRecord.has_Subfield('3'))
                    {
                        thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.DateVenue, thisRecord['3']);
                    }
                    else
                    {
                        thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.DateVenue);
                    }
                }
            }

            // Look for any PREFERRED CITATION note
            foreach (MARC_Field thisRecord in record[524])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    if (thisRecord.has_Subfield('3'))
                    {
                        thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.PreferredCitation, thisRecord['3']);
                    }
                    else
                    {
                        thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.PreferredCitation);
                    }
                }
            }

            // Look for any ADDITIONAL PHYSICAL FORM note
            foreach (MARC_Field thisRecord in record[530])
            {
                StringBuilder builder_530 = new StringBuilder();
                if (thisRecord.has_Subfield('3'))
                {
                    builder_530.Append(thisRecord['3'] + " ");
                }
                if (thisRecord.has_Subfield('a'))
                {
                    builder_530.Append(thisRecord['a'] + " ");
                }
                if (thisRecord.has_Subfield('b'))
                {
                    builder_530.Append(thisRecord['b'] + " ");
                }
                if (thisRecord.has_Subfield('c'))
                {
                    builder_530.Append(thisRecord['c'] + " ");
                }
                string complete_530 = builder_530.ToString().Trim();
                if (complete_530.Length > 0)
                {
                    thisBibInfo.Add_Note(complete_530, Note_Type_Enum.AdditionalPhysicalForm);
                }
            }

            // Look for any ORIGINAL VERSION note
            foreach (MARC_Field thisRecord in record[534])
            {
                StringBuilder builder_534 = new StringBuilder();
                if (thisRecord.has_Subfield('p'))
                {
                    builder_534.Append(thisRecord['p'] + " ");
                }
                if (thisRecord.has_Subfield('k'))
                {
                    builder_534.Append(thisRecord['k'] + " ");
                }
                if (thisRecord.has_Subfield('a'))
                {
                    builder_534.Append(thisRecord['a'] + " ");
                }
                if (thisRecord.has_Subfield('c'))
                {
                    builder_534.Append(thisRecord['c'] + " ");
                }
                if (thisRecord.has_Subfield('e'))
                {
                    builder_534.Append(thisRecord['e'] + " ");
                }
                if (thisRecord.has_Subfield('l'))
                {
                    builder_534.Append(thisRecord['l'] + " ");
                }
                if (thisRecord.has_Subfield('t'))
                {
                    builder_534.Append(thisRecord['t'] + " ");
                }
                if (thisRecord.has_Subfield('b'))
                {
                    builder_534.Append(thisRecord['b'] + " ");
                }
                if (thisRecord.has_Subfield('n'))
                {
                    builder_534.Append(thisRecord['n'] + " ");
                }
                string complete_534 = builder_534.ToString().Trim();
                if (complete_534.Length > 0)
                {
                    thisBibInfo.Add_Note(complete_534, Note_Type_Enum.OriginalVersion);
                }
            }

            // Look for any ORIGINAL LOCATION note
            foreach (MARC_Field thisRecord in record[535])
            {
                StringBuilder builder_535 = new StringBuilder();
                bool possibly_holding_location = true;
                if (thisRecord.has_Subfield('3'))
                {
                    builder_535.Append(thisRecord['3'] + " ");
                    possibly_holding_location = false;
                }
                if (thisRecord.has_Subfield('a'))
                {
                    builder_535.Append(thisRecord['a'] + " ");
                }
                if (thisRecord.has_Subfield('b'))
                {
                    builder_535.Append(thisRecord['b'] + " ");
                    possibly_holding_location = false;
                }
                if (thisRecord.has_Subfield('d'))
                {
                    builder_535.Append(thisRecord['d'] + " ");
                    possibly_holding_location = false;
                }
                string complete_535 = builder_535.ToString().Trim();
                if (complete_535.Length > 0)
                {
                    if ((possibly_holding_location) && (thisRecord.Indicator1 == '1'))
                    {
                        thisBibInfo.Location.Holding_Name = complete_535;
                    }
                    else
                    {
                        thisBibInfo.Add_Note(complete_535, Note_Type_Enum.OriginalLocation);
                    }
                }
            }

            // Look for any FUNDING note
            foreach (MARC_Field thisRecord in record[536])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.Funding);
                }
            }

            // Look for any SYSTEM DETAILS note
            foreach (MARC_Field thisRecord in record[538])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.SystemDetails);
                }
            }

            // Look for any ACQUISITION note
            foreach (MARC_Field thisRecord in record[541])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    if (thisRecord.Indicator1 != '0')
                    {
                        thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.Acquisition);
                    }
                }
            }

            // Look for any BIOGRAPHICAL note
            foreach (MARC_Field thisRecord in record[545])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    if (thisRecord.has_Subfield('b'))
                    {
                        thisBibInfo.Add_Note(thisRecord['a'] + " " + thisRecord['b'], Note_Type_Enum.Biographical);
                    }
                    else
                    {
                        thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.Biographical);
                    }

                }
            }

            // Look for any LANGUAGE note
            foreach (MARC_Field thisRecord in record[546])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    if (thisRecord.has_Subfield('3'))
                    {
                        thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.Language, thisRecord['3']);
                    }
                    else
                    {
                        thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.Language);
                    }
                }
            }

            // Look for any OWNERSHIP note
            foreach (MARC_Field thisRecord in record[561])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    if (thisRecord.has_Subfield('3'))
                    {
                        thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.Ownership, thisRecord['3']);
                    }
                    else
                    {
                        thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.Ownership);
                    }
                }
            }

            // Look for any VERSION IDENTIFICATION note
            foreach (MARC_Field thisRecord in record[562])
            {
                StringBuilder builder_562 = new StringBuilder();
                if (thisRecord.has_Subfield('3'))
                {
                    builder_562.Append(thisRecord['3'] + " ");
                }
                if (thisRecord.has_Subfield('a'))
                {
                    builder_562.Append(thisRecord['a'] + " ");
                }
                if (thisRecord.has_Subfield('c'))
                {
                    builder_562.Append(thisRecord['c'] + " ");
                }
                if (thisRecord.has_Subfield('e'))
                {
                    builder_562.Append(thisRecord['e'] + " ");
                }
                if (thisRecord.has_Subfield('b'))
                {
                    builder_562.Append(thisRecord['b'] + " ");
                }
                string complete_562 = builder_562.ToString().Trim();
                if (complete_562.Length > 0)
                {
                    thisBibInfo.Add_Note(complete_562, Note_Type_Enum.VersionIdentification);
                }
            }

            // Look for any PUBLICATIONS note
            foreach (MARC_Field thisRecord in record[581])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    if (thisRecord.has_Subfield('3'))
                    {
                        thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.Publications, thisRecord['3']);
                    }
                    else
                    {
                        thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.Publications);
                    }
                }
            }

            // Look for any EXHIBITIONS note
            foreach (MARC_Field thisRecord in record[585])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    if (thisRecord.has_Subfield('3'))
                    {
                        thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.Exhibitions, thisRecord['3']);
                    }
                    else
                    {
                        thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.Exhibitions);
                    }
                }
            }

            // Look for statement of responsibility (from TITLE - 245 |c )
            foreach (MARC_Field thisRecord in record[245])
            {
                if (thisRecord.has_Subfield('c'))
                {
                    thisBibInfo.Add_Note(thisRecord['c'], Note_Type_Enum.StatementOfResponsibility);
                }
            }

            // Look for any publication dates or sequential designation note (362)
            foreach (MARC_Field thisRecord in record[362])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    if (thisRecord.has_Subfield('z'))
                    {
                        thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.DatesSequentialDesignation, thisRecord['z']);
                    }
                    else
                    {
                        thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.DatesSequentialDesignation);
                    }
                }
            }

            // Look for any numbering peculiarities note (515)
            foreach (MARC_Field thisRecord in record[515])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.NumberingPeculiarities);
                }
            }

            // Look for any issuing body note (550)
            foreach (MARC_Field thisRecord in record[550])
            {
                if (thisRecord.has_Subfield('a'))
                {
                    thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.IssuingBody);
                }
            }

            // Look for any other NOTES fields ( 500, 501, 513, 522, 525, 563, 567, 586 )
            int[] other_notes = new int[] {500, 501, 513, 522, 525, 563, 567, 586};
            foreach (int tagNumber in other_notes)
            {
                foreach (MARC_Field thisRecord in record[tagNumber])
                {
                    string displayLabel = String.Empty;
                    if (thisRecord.Indicator1 == ' ')
                    {
                        switch (tagNumber)
                        {
                            case 522:
                                displayLabel = "Geographic Coverage";
                                break;

                            case 525:
                                displayLabel = "Supplement Note";
                                break;

                            case 567:
                                displayLabel = "Methodology";
                                break;

                            case 586:
                                displayLabel = "Awards";
                                break;
                        }
                    }
                    if (thisRecord.has_Subfield('a'))
                    {
                        thisBibInfo.Add_Note(thisRecord['a'], Note_Type_Enum.NONE, displayLabel);
                    }
                }
            }
        }
Ejemplo n.º 17
0
        /// <summary> Constructor for a new instance of the SobekCM_Item class, which imports values from a OAI record </summary>
        public SobekCM_Item(OAI_Repository_DublinCore_Record OAI_Record)
        {
            metsInfo = new METS_Header_Info();
            behaviorInfo = new Behaviors_Info();
            divInfo = new Division_Info();
            BIBInfo = new Bibliographic_Info();
            web = new Web_Info(behaviorInfo);
            analyzed_for_complex_content = false;
            contains_complex_content = false;
            using_complex_template = false;
            DiskSize_KB = 0;

            // Copy over all the data
            if (OAI_Record.hasCreators)
            {
                foreach (string thisCreator in OAI_Record.Creators)
                {
                    Bib_Info.Add_Named_Entity(thisCreator);
                }
            }
            if (OAI_Record.hasContributors)
            {
                foreach (string thisContributor in OAI_Record.Contributors)
                {
                    Bib_Info.Add_Named_Entity(thisContributor, "Contributor");
                }
            }
            if (OAI_Record.hasCoverages)
            {
                foreach (string thisCoverage in OAI_Record.Coverages)
                {
                    Subject_Info_Standard thisSubject = new Subject_Info_Standard();
                    thisSubject.Add_Geographic(thisCoverage);
                    Bib_Info.Add_Subject(thisSubject);
                }
            }
            if (OAI_Record.hasDates)
            {
                foreach (string thisDate in OAI_Record.Dates)
                {
                    Bib_Info.Origin_Info.Date_Issued = thisDate;
                }
            }
            if (OAI_Record.hasDescriptions)
            {
                foreach (string thisDescription in OAI_Record.Descriptions)
                {
                    Bib_Info.Add_Note(thisDescription);
                }
            }
            if (OAI_Record.hasFormats)
            {
                foreach (string thisFormat in OAI_Record.Formats)
                {
                    Bib_Info.Original_Description.Extent = thisFormat;
                }
            }
            if (OAI_Record.hasIdentifiers)
            {
                foreach (string thisIdentifier in OAI_Record.Identifiers)
                {
                    if (thisIdentifier.IndexOf("http://") == 0)
                    {
                        Bib_Info.Location.Other_URL = thisIdentifier;
                    }
                    else
                    {
                        Bib_Info.Add_Identifier(thisIdentifier);
                    }
                }
            }
            if (OAI_Record.hasLanguages)
            {
                foreach (string thisLanguage in OAI_Record.Languages)
                {
                    Bib_Info.Add_Language(thisLanguage);
                }
            }
            if (OAI_Record.hasPublishers)
            {
                foreach (string thisPublisher in OAI_Record.Publishers)
                {
                    Bib_Info.Add_Publisher(thisPublisher);
                }
            }
            if (OAI_Record.hasRelations)
            {
                foreach (string thisRelation in OAI_Record.Relations)
                {
                    Related_Item_Info newRelatedItem = new Related_Item_Info();
                    newRelatedItem.Main_Title.Title = thisRelation;
                    Bib_Info.Add_Related_Item(newRelatedItem);
                }
            }
            if (OAI_Record.hasRights)
            {
                foreach (string thisRights in OAI_Record.Rights)
                {
                    Bib_Info.Access_Condition.Text = thisRights;
                }
            }
            //if (OAI_Record.hasSources)
            //{
            //    foreach (string thisSource in OAI_Record.Sources)
            //    {
            //        this.Bib_Info.Source.Statement = r.Value.Trim() = thisSource;
            //    }
            //}
            if (OAI_Record.hasSubjects)
            {
                foreach (string thisSubject in OAI_Record.Subjects)
                {
                    if (thisSubject.IndexOf(";") > 0)
                    {
                        string[] splitter = thisSubject.Split(";".ToCharArray());
                        foreach (string thisSplit in splitter)
                        {
                            Bib_Info.Add_Subject(thisSplit.Trim(), String.Empty);
                        }
                    }
                    else
                    {
                        Bib_Info.Add_Subject(thisSubject, String.Empty);
                    }
                }
            }
            if (OAI_Record.hasTitles)
            {
                foreach (string thistitle in OAI_Record.Titles)
                {
                    if (Bib_Info.Main_Title.ToString().Length > 0)
                    {
                        Bib_Info.Add_Other_Title(thistitle, Title_Type_Enum.Alternative);
                    }
                    else
                    {
                        Bib_Info.Main_Title.Clear();
                        Bib_Info.Main_Title.Title = thistitle;
                    }
                }
            }
            if (OAI_Record.hasTypes)
            {
                foreach (string thisType in OAI_Record.Types)
                {
                    Bib_Info.SobekCM_Type_String = thisType;
                }
            }

            // If there is a metadata configuration which calls for a metadata
            // extension module to always be used, add it now
            if (Metadata_Configuration.Metadata_Modules_To_Include.Count > 0)
            {
                foreach (Additional_Metadata_Module_Config thisConfig in Metadata_Configuration.Metadata_Modules_To_Include)
                {
                    iMetadata_Module toInclude = thisConfig.Get_Module();
                    if (toInclude != null)
                    {
                        Add_Metadata_Module(thisConfig.Key, toInclude);
                    }
                }
            }
        }
        /// <summary> Reads the Dublin Core-compliant section of XML and stores the data in the provided digital resource </summary>
        /// <param name="r"> XmlTextReader from which to read the dublin core data </param>
        /// <param name="thisBibInfo"> Digital resource object to save the data to </param>
        public static void Read_Simple_Dublin_Core_Info(XmlReader r, Bibliographic_Info thisBibInfo)
        {
            while (r.Read())
            {
                if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "METS:mdWrap") || (r.Name == "mdWrap")))
                    return;

                if (r.NodeType == XmlNodeType.Element)
                {
                    switch (r.Name)
                    {
                        case "dc:contributor":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                thisBibInfo.Add_Named_Entity(r.Value.Trim(), "Contributor");
                            }
                            break;

                        case "dc:coverage":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                Subject_Info_Standard thisSubject = new Subject_Info_Standard();
                                thisSubject.Add_Geographic(r.Value.Trim());
                                thisBibInfo.Add_Subject(thisSubject);
                            }
                            break;

                        case "dc:creator":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                if (thisBibInfo.Main_Entity_Name.hasData)
                                {
                                    thisBibInfo.Add_Named_Entity(r.Value.Trim());
                                }
                                else
                                {
                                    thisBibInfo.Main_Entity_Name.Full_Name = r.Value.Trim();
                                }
                            }
                            break;

                        case "dc:date":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                thisBibInfo.Origin_Info.Date_Issued = r.Value.Trim();
                            }
                            break;

                        case "dc:description":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                thisBibInfo.Add_Note(r.Value.Trim());
                            }
                            break;

                        case "dc:format":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                thisBibInfo.Original_Description.Extent = r.Value.Trim();
                            }
                            break;

                        case "dc:identifier":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                thisBibInfo.Add_Identifier(r.Value.Trim());
                            }
                            break;

                        case "dc:language":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                thisBibInfo.Add_Language(r.Value.Trim());
                            }
                            break;

                        case "dc:publisher":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                thisBibInfo.Add_Publisher(r.Value.Trim());
                            }
                            break;

                        case "dc:relation":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                Related_Item_Info newRelatedItem = new Related_Item_Info();
                                newRelatedItem.Main_Title.Title = r.Value.Trim();
                                thisBibInfo.Add_Related_Item(newRelatedItem);
                            }
                            break;

                        case "dc:rights":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                thisBibInfo.Access_Condition.Text = r.Value.Trim();
                            }
                            break;

                        case "dc:source":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                thisBibInfo.Add_Note(r.Value, Note_Type_Enum.source);
                            }
                            break;

                        case "dc:subject":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                if (r.Value.IndexOf(";") > 0)
                                {
                                    string[] splitter = r.Value.Split(";".ToCharArray());
                                    foreach (string thisSplit in splitter)
                                    {
                                        thisBibInfo.Add_Subject(thisSplit.Trim(), String.Empty);
                                    }
                                }
                                else
                                {
                                    thisBibInfo.Add_Subject(r.Value.Trim(), String.Empty);
                                }
                            }
                            break;

                        case "dc:title":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                if (thisBibInfo.Main_Title.Title.Length == 0)
                                {
                                    thisBibInfo.Main_Title.Title = r.Value.Trim();
                                }
                                else
                                {
                                    thisBibInfo.Add_Other_Title(r.Value.Trim(), Title_Type_Enum.alternative);
                                }
                            }
                            break;

                        case "dc:type":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                thisBibInfo.Type.Add_Uncontrolled_Type(r.Value.Trim());
                            }
                            break;
                    }
                }
            }
        }