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_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> 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; } } } }
/// <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> 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; } } } }