Exemplo n.º 1
0
        /// <summary> Adds a new language to the list of catalog languages  </summary>
        /// <param name="New_Catalog_Language"> New catalog language to add </param>
        public void Add_Catalog_Language(Language_Info New_Catalog_Language)
        {
            if (catalog_languages == null)
            {
                catalog_languages = new List <Language_Info>();
            }

            catalog_languages.Add(New_Catalog_Language);
        }
        /// <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;
                    }
                }
            }
        }
        /// <summary> Indicate another language associated with this material </summary>
        /// <param name="Language_Text">Language term for this language</param>
        /// <param name="Language_ISO_Code">Iso639-2b code for this language</param>
        /// <param name="Language_RFC_Code">Rfc3066 code for this language</param>       
        public Language_Info Add_Language(string Language_Text, string Language_ISO_Code, string Language_RFC_Code)
        {
            if (languages == null)
                languages = new List<Language_Info>();

            Language_Info newLanguage = new Language_Info(Language_Text, Language_ISO_Code, Language_RFC_Code);
            if (!languages.Contains(newLanguage))
            {
                languages.Add(newLanguage);
                return newLanguage;
            }
            else
            {
                Language_Info returnLanguage = languages.Find(newLanguage.Equals);
                if (newLanguage.Language_Text.Length > 0)
                    returnLanguage.Language_Text = newLanguage.Language_Text;
                if (newLanguage.Language_ISO_Code.Length > 0)
                    returnLanguage.Language_ISO_Code = newLanguage.Language_ISO_Code;
                if (newLanguage.Language_RFC_Code.Length > 0)
                    returnLanguage.Language_RFC_Code = newLanguage.Language_RFC_Code;
                return returnLanguage;
            }
        }
 /// <summary> Removes an existing language object from this item </summary>
 /// <param name="Language"> Language to remove </param>
 public void Remove_Language(Language_Info Language)
 {
     if ((languages != null) && (languages.Contains(Language)))
         languages.Remove(Language);
 }
Exemplo n.º 5
0
        /// <summary> Adds a new language to the list of catalog languages  </summary>
        /// <param name="New_Catalog_Language"> New catalog language to add </param>
        public void Add_Catalog_Language(Language_Info New_Catalog_Language)
        {
            if (catalog_languages == null)
                catalog_languages = new List<Language_Info>();

            catalog_languages.Add(New_Catalog_Language);
        }
Exemplo n.º 6
0
        /// <summary> Prepares the bib object for the save, by clearing the
        /// existing data in this element's related field. </summary>
        /// <param name="Bib"> Existing Bib object </param>
        public override void Prepare_For_Save(SobekCM_Item Bib)
        {
            Origin_Info_Place deletePlace = null;

            foreach (Origin_Info_Place thisPlace in Bib.Bib_Info.Origin_Info.Places)
            {
                if (thisPlace.Place_MarcCountry.Length > 0)
                {
                    deletePlace = thisPlace;
                    break;
                }
            }
            if (deletePlace != null)
            {
                Bib.Bib_Info.Origin_Info.Remove_Place(deletePlace);
            }

            Language_Info deleteLanguage = null;

            foreach (Language_Info thisLanguage in Bib.Bib_Info.Languages)
            {
                if (thisLanguage.Language_ISO_Code.Length > 0)
                {
                    deleteLanguage = thisLanguage;
                    break;
                }
            }
            if (deleteLanguage != null)
            {
                Bib.Bib_Info.Remove_Language(deleteLanguage);
            }

            List <Origin_Info_Frequency> deleteFrequencies = new List <Origin_Info_Frequency>();

            foreach (Origin_Info_Frequency thisFrequency in Bib.Bib_Info.Origin_Info.Frequencies)
            {
                if (thisFrequency.Authority == "marcfrequency")
                {
                    deleteFrequencies.Add(thisFrequency);
                }
            }
            foreach (Origin_Info_Frequency deleteFrequency in deleteFrequencies)
            {
                Bib.Bib_Info.Origin_Info.Remove_Frequency(deleteFrequency);
            }

            List <Genre_Info> deleteGenres = new List <Genre_Info>();

            foreach (Genre_Info thisGenre in Bib.Bib_Info.Genres)
            {
                if ((thisGenre.Authority == "marcgt") || (thisGenre.Authority == "sobekcm"))
                {
                    deleteGenres.Add(thisGenre);
                }
            }
            foreach (Genre_Info deleteGenre in deleteGenres)
            {
                Bib.Bib_Info.Remove_Genre(deleteGenre);
            }

            List <TargetAudience_Info> deleteAudiences = new List <TargetAudience_Info>();

            foreach (TargetAudience_Info thisAudience in Bib.Bib_Info.Target_Audiences)
            {
                if (thisAudience.Authority == "marctarget")
                {
                    deleteAudiences.Add(thisAudience);
                }
            }
            foreach (TargetAudience_Info deleteAudience in deleteAudiences)
            {
                Bib.Bib_Info.Remove_Target_Audience(deleteAudience);
            }

            List <Subject_Info> deleteCartographics = new List <Subject_Info>();

            foreach (Subject_Info thisSubject in Bib.Bib_Info.Subjects)
            {
                if (thisSubject.Class_Type == Subject_Info_Type.Cartographics)
                {
                    deleteCartographics.Add(thisSubject);
                }
            }
            foreach (Subject_Info deleteSubject in deleteCartographics)
            {
                Bib.Bib_Info.Remove_Subject(deleteSubject);
            }
        }