public Show_MARC_Form(SobekCM_Item item) { InitializeComponent(); Marc21_File_ReaderWriter writer = new Marc21_File_ReaderWriter(); MARC_Record tags = item.To_MARC_Record(); // writer.Save_As_MARC_XML("test.xml", item, writer.UFDC_Standard_Tags( item, "World Map Collection" )); richTextBox1.AppendText("LDR " + tags.Leader + "\n"); foreach (MARC_Field tag in tags.Sorted_MARC_Tag_List) { richTextBox1.AppendText(tag.Tag.ToString().PadLeft(3, '0') + " "); richTextBox1.SelectionColor = Color.Green; richTextBox1.AppendText(tag.Indicators); richTextBox1.SelectionColor = Color.Black; if ((tag.Tag == 8) || (tag.Tag == 7) || (tag.Tag == 6) || (tag.Tag == 5) || (tag.Tag == 1)) { richTextBox1.AppendText(" " + tag.Control_Field_Value.Replace(" ", "^") + "\n"); } else { richTextBox1.AppendText(" "); string[] splitter = tag.Control_Field_Value.Split("|".ToCharArray()); foreach (string thisSplit in splitter) { if (thisSplit.Length > 2) { richTextBox1.SelectionColor = Color.Blue; richTextBox1.AppendText("|" + thisSplit.Substring(0, 2)); richTextBox1.SelectionColor = Color.Black; richTextBox1.AppendText(thisSplit.Substring(2)); } } richTextBox1.AppendText("\n"); } } }
/// <summary> Writes the formatted metadata from the provided item to a TextWriter (usually to an output stream) </summary> /// <param name="Output_Stream"></param> /// <param name="Item_To_Save"> Package with all the metadata to save </param> /// <param name="Options"> Dictionary of any options which this metadata reader/writer may utilize </param> /// <param name="Error_Message">[OUTPUT] Explanation of the error, if an error occurs during write </param> /// <returns>TRUE if successful, otherwise FALSE </returns> /// <remarks>This writer accepts one option value. 'MarcXML_File_ReaderWriter:Additional_Tags' is a List of additional /// <see cref="MARC_Field"/> tags which should be added to the standard tags written (Default is NULL).</remarks> public bool Write_Metadata(TextWriter Output_Stream, SobekCM_Item Item_To_Save, Dictionary<string, object> Options, out string Error_Message) { // Set default error outpt message Error_Message = String.Empty; // Get all the standard tags MARC_Record tags = Item_To_Save.To_MARC_Record(); // Look for extra tags to add in the OPTIONS if (Options.ContainsKey("MarcXML_File_ReaderWriter:Additional_Tags")) { object add_tags_obj = Options["MarcXML_File_ReaderWriter:Additional_Tags"]; if (add_tags_obj != null) { try { List<MARC_Field> add_tags = (List<MARC_Field>) add_tags_obj; foreach (MARC_Field thisTag in add_tags) { tags.Add_Field(thisTag); } } catch { Error_Message = "Unable to cast provided option ( MarcXML_File_ReaderWriter:Additional_Tags ) to List<MARC_Field> object"; return false; } } } // Start to build the XML result Output_Stream.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); Output_Stream.WriteLine("<collection xmlns=\"http://www.loc.gov/MARC21/slim\">"); Output_Stream.WriteLine(" <record>"); // Add the leader Output_Stream.WriteLine(" <leader>" + tags.Leader + "</leader>"); foreach (MARC_Field thisTag in tags.Sorted_MARC_Tag_List) { if ((thisTag.Tag >= 1) && (thisTag.Tag <= 8)) { Output_Stream.WriteLine(" <controlfield tag=\"" + thisTag.Tag.ToString().PadLeft(3, '0') + "\">" + base.Convert_String_To_XML_Safe(thisTag.Control_Field_Value).Replace("&bar;", "|") + "</controlfield>"); } else { Output_Stream.WriteLine(" <datafield tag=\"" + thisTag.Tag.ToString().PadLeft(3, '0') + "\" ind1=\"" + thisTag.Indicators[0] + "\" ind2=\"" + thisTag.Indicators[1] + "\">"); string[] splitter = thisTag.Control_Field_Value.Split("|".ToCharArray()); foreach (string subfield in splitter) { if (subfield.Length > 2) { Output_Stream.WriteLine(" <subfield code=\"" + subfield[0] + "\">" + base.Convert_String_To_XML_Safe(subfield.Substring(2).Trim()).Replace("&bar;", "|") + "</subfield>"); } } Output_Stream.WriteLine(" </datafield>"); } } Output_Stream.WriteLine(" </record>"); Output_Stream.WriteLine("</collection>"); return true; }
/// <summary> Add the bibliographic information as MARC21 slim XML to the output stream for a given digital resource </summary> /// <param name="Output"> Output stream for this metadata to be written to </param> /// <param name="thisBib"> Source digital resource </param> /// <param name="Include_Schema"> Flag indicates whether the schema information should be included in the record tag </param> public static void Write_MarcXML(TextWriter Output, SobekCM_Item thisBib, bool Include_Schema) { // Get all the standard tags MARC_Record tags = thisBib.To_MARC_Record(); // Start to build the XML result if (Include_Schema) { Output.Write("<record xmlns=\"http://www.loc.gov/MARC21/slim\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd\">\r\n"); } else { Output.Write("<record>\r\n"); } // Add the leader Output.Write("<leader>" + tags.Leader + "</leader>\r\n"); foreach (MARC_Field thisTag in tags.Sorted_MARC_Tag_List) { if ((thisTag.Tag == 1) || (thisTag.Tag == 3) || (thisTag.Tag == 5) || (thisTag.Tag == 6) || (thisTag.Tag == 7) || (thisTag.Tag == 8)) { Output.Write("<controlfield tag=\"" + thisTag.Tag.ToString().PadLeft(3, '0') + "\">" + Convert_String_To_XML_Safe_Static(thisTag.Control_Field_Value) + "</controlfield>\r\n"); } else { Output.Write("<datafield tag=\"" + thisTag.Tag.ToString().PadLeft(3, '0') + "\" ind1=\"" + thisTag.Indicators[0] + "\" ind2=\"" + thisTag.Indicators[1] + "\">\r\n"); string[] splitter = thisTag.Control_Field_Value.Split("|".ToCharArray()); foreach (string subfield in splitter) { if ((subfield.Length > 2) && ((Char.IsLetter(subfield[0])) || (Char.IsNumber(subfield[0])))) { Output.Write("<subfield code=\"" + subfield[0] + "\">" + Convert_String_To_XML_Safe_Static(subfield.Substring(2).Trim()) + "</subfield>\r\n"); } } Output.Write("</datafield>\r\n"); } } Output.Write("</record>\r\n"); }
/// <summary> Returns the OAI-PMH metadata in MarcXML (OAI-flavored) for this item </summary> /// <param name="Item_To_Save"> Package with all the metadata to save </param> /// <param name="Options"> Dictionary of any options which this metadata reader/writer may utilize </param> /// <param name="Error_Message">[OUTPUT] Explanation of the error, if an error occurs during write </param> /// <returns> Metadata for a OAI-PMH record of a particular metadata format/type </returns> public override string Create_OAI_PMH_Metadata(SobekCM_Item Item_To_Save, Dictionary<string, object> Options, out string Error_Message) { // Look for options string CatalogingSourceCode = null; string LocationCode = null; string ReproductionAgency = null; string ReproductionPlace = null; string SystemName = null; string SystemAbbreviation = null; string ThumbnailBase = null; string XlstFile = null; if (Options != null) { if (Options.ContainsKey("MarcXML_File_ReaderWriter:MARC Cataloging Source Code")) CatalogingSourceCode = Options["MarcXML_File_ReaderWriter:MARC Cataloging Source Code"].ToString(); if (Options.ContainsKey("MarcXML_File_ReaderWriter:MARC Location Code")) LocationCode = Options["MarcXML_File_ReaderWriter:MARC Location Code"].ToString(); if (Options.ContainsKey("MarcXML_File_ReaderWriter:MARC Reproduction Agency")) ReproductionAgency = Options["MarcXML_File_ReaderWriter:MARC Reproduction Agency"].ToString(); if (Options.ContainsKey("MarcXML_File_ReaderWriter:MARC Reproduction Place")) ReproductionPlace = Options["MarcXML_File_ReaderWriter:MARC Reproduction Place"].ToString(); if (Options.ContainsKey("MarcXML_File_ReaderWriter:MARC XSLT File")) XlstFile = Options["MarcXML_File_ReaderWriter:MARC XSLT File"].ToString(); if (Options.ContainsKey("MarcXML_File_ReaderWriter:System Name")) SystemName = Options["MarcXML_File_ReaderWriter:System Name"].ToString(); if (Options.ContainsKey("MarcXML_File_ReaderWriter:System Abbreviation")) SystemAbbreviation = Options["MarcXML_File_ReaderWriter:System Abbreviation"].ToString(); if (Options.ContainsKey("MarcXML_File_ReaderWriter:Image_Base")) ThumbnailBase = Options["MarcXML_File_ReaderWriter:Image_Base"].ToString(); } // Set default error outpt message Error_Message = String.Empty; StringBuilder results = new StringBuilder(); results.AppendLine("<marc:record xmlns:marc=\"http://www.loc.gov/MARC21/slim\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd\" type=\"Bibliographic\">"); // Get all the standard tags MARC_Record tags = Item_To_Save.To_MARC_Record(CatalogingSourceCode, LocationCode, ReproductionAgency, ReproductionPlace, SystemName, SystemAbbreviation, ThumbnailBase); // St // Add the leader results.Append("<marc:leader>" + tags.Leader + "</marc:leader>\r\n"); foreach (MARC_Field thisTag in tags.Sorted_MARC_Tag_List) { if ((thisTag.Tag == 1) || (thisTag.Tag == 3) || (thisTag.Tag == 5) || (thisTag.Tag == 6) || (thisTag.Tag == 7) || (thisTag.Tag == 8)) { results.Append("<marc:controlfield tag=\"" + thisTag.Tag.ToString().PadLeft(3, '0') + "\">" + Convert_String_To_XML_Safe_Static(thisTag.Control_Field_Value) + "</marc:controlfield>\r\n"); } else { results.Append("<marc:datafield tag=\"" + thisTag.Tag.ToString().PadLeft(3, '0') + "\" ind1=\"" + thisTag.Indicators[0] + "\" ind2=\"" + thisTag.Indicators[1] + "\">\r\n"); string[] splitter = thisTag.Control_Field_Value.Split("|".ToCharArray()); foreach (string subfield in splitter) { if ((subfield.Length > 2) && ((Char.IsLetter(subfield[0])) || (Char.IsNumber(subfield[0])))) { results.Append("<marc:subfield code=\"" + subfield[0] + "\">" + Convert_String_To_XML_Safe_Static(subfield.Substring(2).Trim()) + "</marc:subfield>\r\n"); } } results.Append("</marc:datafield>\r\n"); } } // Finish this OAI results.AppendLine("</marc:record>"); return results.ToString(); }
/// <summary> Writes the formatted metadata from the provided item to a TextWriter (usually to an output stream) </summary> /// <param name="Output_Stream"></param> /// <param name="Item_To_Save"> Package with all the metadata to save </param> /// <param name="Options"> Dictionary of any options which this metadata reader/writer may utilize </param> /// <param name="Error_Message">[OUTPUT] Explanation of the error, if an error occurs during write </param> /// <returns>TRUE if successful, otherwise FALSE </returns> /// <remarks>This writer accepts one option value. 'MarcXML_File_ReaderWriter:Additional_Tags' is a List of additional /// <see cref="MARC_Field"/> tags which should be added to the standard tags written (Default is NULL).</remarks> public bool Write_Metadata(TextWriter Output_Stream, SobekCM_Item Item_To_Save, Dictionary <string, object> Options, out string Error_Message) { // Set default error outpt message Error_Message = String.Empty; // Try to pull some values from the options string cataloging_source_code = String.Empty; if ((Options.ContainsKey("MarcXML_File_ReaderWriter:MARC Cataloging Source Code")) && (Options["MarcXML_File_ReaderWriter:MARC Cataloging Source Code"] != null)) { cataloging_source_code = Options["MarcXML_File_ReaderWriter:MARC Cataloging Source Code"].ToString(); } string location_code = String.Empty; if ((Options.ContainsKey("MarcXML_File_ReaderWriter:MARC Location Code")) && (Options["MarcXML_File_ReaderWriter:MARC Location Code"] != null)) { location_code = Options["MarcXML_File_ReaderWriter:MARC Location Code"].ToString(); } string reproduction_agency = String.Empty; if ((Options.ContainsKey("MarcXML_File_ReaderWriter:MARC Reproduction Agency")) && (Options["MarcXML_File_ReaderWriter:MARC Reproduction Agency"] != null)) { reproduction_agency = Options["MarcXML_File_ReaderWriter:MARC Reproduction Agency"].ToString(); } string reproduction_place = String.Empty; if ((Options.ContainsKey("MarcXML_File_ReaderWriter:MARC Reproduction Place")) && (Options["MarcXML_File_ReaderWriter:MARC Reproduction Place"] != null)) { reproduction_place = Options["MarcXML_File_ReaderWriter:MARC Reproduction Place"].ToString(); } string system_name = String.Empty; if ((Options.ContainsKey("MarcXML_File_ReaderWriter:System Name")) && (Options["MarcXML_File_ReaderWriter:System Name"] != null)) { system_name = Options["MarcXML_File_ReaderWriter:System Name"].ToString(); } string system_abbreviation = String.Empty; if ((Options.ContainsKey("MarcXML_File_ReaderWriter:System Abbreviation")) && (Options["MarcXML_File_ReaderWriter:System Abbreviation"] != null)) { system_abbreviation = Options["MarcXML_File_ReaderWriter:System Abbreviation"].ToString(); } string thumbnail_base = String.Empty; if ((Options.ContainsKey("MarcXML_File_ReaderWriter:Image_Base")) && (Options["MarcXML_File_ReaderWriter:Image_Base"] != null)) { thumbnail_base = Options["MarcXML_File_ReaderWriter:Image_Base"].ToString(); } // Get all the standard tags MARC_Record tags = Item_To_Save.To_MARC_Record(cataloging_source_code, location_code, reproduction_agency, reproduction_place, system_name, system_abbreviation, thumbnail_base); // Look for extra tags to add in the OPTIONS if (Options.ContainsKey("MarcXML_File_ReaderWriter:Additional_Tags")) { object add_tags_obj = Options["MarcXML_File_ReaderWriter:Additional_Tags"]; if (add_tags_obj != null) { try { List <MARC_Field> add_tags = (List <MARC_Field>)add_tags_obj; foreach (MARC_Field thisTag in add_tags) { tags.Add_Field(thisTag); } } catch { Error_Message = "Unable to cast provided option ( MarcXML_File_ReaderWriter:Additional_Tags ) to List<MARC_Field> object"; return(false); } } } // Start to build the XML result Output_Stream.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); Output_Stream.WriteLine("<collection xmlns=\"http://www.loc.gov/MARC21/slim\">"); Output_Stream.WriteLine(" <record>"); // Add the leader Output_Stream.WriteLine(" <leader>" + tags.Leader + "</leader>"); foreach (MARC_Field thisTag in tags.Sorted_MARC_Tag_List) { if ((thisTag.Tag >= 1) && (thisTag.Tag <= 8)) { Output_Stream.WriteLine(" <controlfield tag=\"" + thisTag.Tag.ToString().PadLeft(3, '0') + "\">" + Convert_String_To_XML_Safe(thisTag.Control_Field_Value).Replace("&bar;", "|") + "</controlfield>"); } else { Output_Stream.WriteLine(" <datafield tag=\"" + thisTag.Tag.ToString().PadLeft(3, '0') + "\" ind1=\"" + thisTag.Indicators[0] + "\" ind2=\"" + thisTag.Indicators[1] + "\">"); string[] splitter = thisTag.Control_Field_Value.Split("|".ToCharArray()); foreach (string subfield in splitter) { if (subfield.Length > 2) { Output_Stream.WriteLine(" <subfield code=\"" + subfield[0] + "\">" + Convert_String_To_XML_Safe(subfield.Substring(2).Trim()).Replace("&bar;", "|") + "</subfield>"); } } Output_Stream.WriteLine(" </datafield>"); } } Output_Stream.WriteLine(" </record>"); Output_Stream.WriteLine("</collection>"); return(true); }
/// <summary> Returns the OAI-PMH metadata in MarcXML (OAI-flavored) for this item </summary> /// <param name="Item_To_Save"> Package with all the metadata to save </param> /// <param name="Options"> Dictionary of any options which this metadata reader/writer may utilize </param> /// <param name="Error_Message">[OUTPUT] Explanation of the error, if an error occurs during write </param> /// <returns> Metadata for a OAI-PMH record of a particular metadata format/type </returns> public override string Create_OAI_PMH_Metadata(SobekCM_Item Item_To_Save, Dictionary <string, object> Options, out string Error_Message) { // Look for options string CatalogingSourceCode = null; string LocationCode = null; string ReproductionAgency = null; string ReproductionPlace = null; string SystemName = null; string SystemAbbreviation = null; string ThumbnailBase = null; string XlstFile = null; if (Options != null) { if (Options.ContainsKey("MarcXML_File_ReaderWriter:MARC Cataloging Source Code")) { CatalogingSourceCode = Options["MarcXML_File_ReaderWriter:MARC Cataloging Source Code"].ToString(); } if (Options.ContainsKey("MarcXML_File_ReaderWriter:MARC Location Code")) { LocationCode = Options["MarcXML_File_ReaderWriter:MARC Location Code"].ToString(); } if (Options.ContainsKey("MarcXML_File_ReaderWriter:MARC Reproduction Agency")) { ReproductionAgency = Options["MarcXML_File_ReaderWriter:MARC Reproduction Agency"].ToString(); } if (Options.ContainsKey("MarcXML_File_ReaderWriter:MARC Reproduction Place")) { ReproductionPlace = Options["MarcXML_File_ReaderWriter:MARC Reproduction Place"].ToString(); } if (Options.ContainsKey("MarcXML_File_ReaderWriter:MARC XSLT File")) { XlstFile = Options["MarcXML_File_ReaderWriter:MARC XSLT File"].ToString(); } if (Options.ContainsKey("MarcXML_File_ReaderWriter:System Name")) { SystemName = Options["MarcXML_File_ReaderWriter:System Name"].ToString(); } if (Options.ContainsKey("MarcXML_File_ReaderWriter:System Abbreviation")) { SystemAbbreviation = Options["MarcXML_File_ReaderWriter:System Abbreviation"].ToString(); } if (Options.ContainsKey("MarcXML_File_ReaderWriter:Image_Base")) { ThumbnailBase = Options["MarcXML_File_ReaderWriter:Image_Base"].ToString(); } } // Set default error outpt message Error_Message = String.Empty; StringBuilder results = new StringBuilder(); results.AppendLine("<marc:record xmlns:marc=\"http://www.loc.gov/MARC21/slim\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd\" type=\"Bibliographic\">"); // Get all the standard tags MARC_Record tags = Item_To_Save.To_MARC_Record(CatalogingSourceCode, LocationCode, ReproductionAgency, ReproductionPlace, SystemName, SystemAbbreviation, ThumbnailBase); // St // Add the leader results.Append("<marc:leader>" + tags.Leader + "</marc:leader>\r\n"); foreach (MARC_Field thisTag in tags.Sorted_MARC_Tag_List) { if ((thisTag.Tag == 1) || (thisTag.Tag == 3) || (thisTag.Tag == 5) || (thisTag.Tag == 6) || (thisTag.Tag == 7) || (thisTag.Tag == 8)) { results.Append("<marc:controlfield tag=\"" + thisTag.Tag.ToString().PadLeft(3, '0') + "\">" + Convert_String_To_XML_Safe_Static(thisTag.Control_Field_Value) + "</marc:controlfield>\r\n"); } else { results.Append("<marc:datafield tag=\"" + thisTag.Tag.ToString().PadLeft(3, '0') + "\" ind1=\"" + thisTag.Indicators[0] + "\" ind2=\"" + thisTag.Indicators[1] + "\">\r\n"); string[] splitter = thisTag.Control_Field_Value.Split("|".ToCharArray()); foreach (string subfield in splitter) { if ((subfield.Length > 2) && ((Char.IsLetter(subfield[0])) || (Char.IsNumber(subfield[0])))) { results.Append("<marc:subfield code=\"" + subfield[0] + "\">" + Convert_String_To_XML_Safe_Static(subfield.Substring(2).Trim()) + "</marc:subfield>\r\n"); } } results.Append("</marc:datafield>\r\n"); } } // Finish this OAI results.AppendLine("</marc:record>"); return(results.ToString()); }
/// <summary> Writes a digital resource in MARC format, with additional considerations for displaying within a HTML page </summary> /// <param name="package"> Digital resource to write in MARC format </param> /// <param name="Width"> Width of the resulting HTML-formatted MARC record </param> /// <param name="add_tags"> Any additional MARC tags which should be included besides the standard MARC tags </param> /// <returns> MARC record formatted for HTML, returned as a string </returns> public string MARC_HTML(SobekCM_Item package, string Width, List <MARC_Field> add_tags) { // Get all the standard tags MARC_Record tags = package.To_MARC_Record(); // Add any additional tags included here if (add_tags != null) { foreach (MARC_Field thisTag in add_tags) { tags.Add_Field(thisTag); } } // Start to build the HTML result StringBuilder results = new StringBuilder(); results.Append("<table border=\"0\" align=\"center\" width=\"" + Width + "\">\n"); // Add the LEADER results.Append(" <tr class=\"trGenContent\">\n"); results.Append(" <td width=\"33\" valign=\"top\">LDR</td>\n"); results.Append(" <td width=\"26\" valign=\"top\"> </td>\n"); results.Append(" <td>" + tags.Leader.Replace(" ", "^") + "</td>\n"); results.Append(" </tr>"); // Add all the FIELDS foreach (MARC_Field thisTag in tags.Sorted_MARC_Tag_List) { results.Append(" <tr class=\"trGenContent\">\n"); results.Append(" <td width=\"33\" valign=\"top\">" + thisTag.Tag.ToString().PadLeft(3, '0') + "</td>\n"); results.Append(" <td width=\"26\" valign=\"top\"><font color=\"green\">" + thisTag.Indicators.Replace(" ", " ") + "</font></td>\n"); results.Append(" <td>"); if ((thisTag.Tag == 8) || (thisTag.Tag == 7) || (thisTag.Tag == 6)) { results.Append(base.Convert_String_To_XML_Safe(thisTag.Control_Field_Value.Replace(" ", "^"))); } else { results.Append(base.Convert_String_To_XML_Safe(thisTag.Control_Field_Value).Replace("|a", "<font color=\"blue\">|a</font>"). Replace("|b", "<font color=\"blue\">|b</font>"). Replace("|c", "<font color=\"blue\">|c</font>"). Replace("|d", "<font color=\"blue\">|d</font>"). Replace("|e", "<font color=\"blue\">|e</font>"). Replace("|g", "<font color=\"blue\">|g</font>"). Replace("|x", "<font color=\"blue\">|x</font>"). Replace("|y", "<font color=\"blue\">|y</font>"). Replace("|z", "<font color=\"blue\">|z</font>"). Replace("|v", "<font color=\"blue\">|v</font>"). Replace("|h", "<font color=\"blue\">|h</font>"). Replace("|u", "<font color=\"blue\">|u</font>"). Replace("|f", "<font color=\"blue\">|f</font>"). Replace("|n", "<font color=\"blue\">|n</font>"). Replace("|2", "<font color=\"blue\">|2</font>"). Replace("|3", "<font color=\"blue\">|3</font>"). Replace("|w", "<font color=\"blue\">|w</font>"). Replace("|t", "<font color=\"blue\">|t</font>"). Replace("|q", "<font color=\"blue\">|q</font>"). Replace("|o", "<font color=\"blue\">|o</font>"). Replace("|i", "<font color=\"blue\">|i</font>"). Replace("|4", "<font color=\"blue\">|4</font>")); } results.Append("</td>\n"); results.Append(" </tr>"); } results.Append("</table>\n"); return(results.ToString().Replace("&bar;", "|")); }
/// <summary> Writes a digital resource in MARC format, with additional considerations for displaying within a HTML page </summary> /// <param name="Package"> Digital resource to write in MARC format </param> /// <param name="Width"> Width of the resulting HTML-formatted MARC record </param> /// <param name="Options"> Dictionary of any options which this metadata reader/writer may utilize </param> /// <returns> MARC record formatted for HTML, returned as a string </returns> public string MARC_HTML(SobekCM_Item Package, string Width, Dictionary <string, object> Options) { // Try to pull some values from the options string cataloging_source_code = String.Empty; if ((Options.ContainsKey("MarcXML_File_ReaderWriter:MARC Cataloging Source Code")) && (Options["MarcXML_File_ReaderWriter:MARC Cataloging Source Code"] != null)) { cataloging_source_code = Options["MarcXML_File_ReaderWriter:MARC Cataloging Source Code"].ToString(); } string location_code = String.Empty; if ((Options.ContainsKey("MarcXML_File_ReaderWriter:MARC Location Code")) && (Options["MarcXML_File_ReaderWriter:MARC Location Code"] != null)) { location_code = Options["MarcXML_File_ReaderWriter:MARC Location Code"].ToString(); } string reproduction_agency = String.Empty; if ((Options.ContainsKey("MarcXML_File_ReaderWriter:MARC Reproduction Agency")) && (Options["MarcXML_File_ReaderWriter:MARC Reproduction Agency"] != null)) { reproduction_agency = Options["MarcXML_File_ReaderWriter:MARC Reproduction Agency"].ToString(); } string reproduction_place = String.Empty; if ((Options.ContainsKey("MarcXML_File_ReaderWriter:MARC Reproduction Place")) && (Options["MarcXML_File_ReaderWriter:MARC Reproduction Place"] != null)) { reproduction_place = Options["MarcXML_File_ReaderWriter:MARC Reproduction Place"].ToString(); } string system_name = String.Empty; if ((Options.ContainsKey("MarcXML_File_ReaderWriter:System Name")) && (Options["MarcXML_File_ReaderWriter:System Name"] != null)) { system_name = Options["MarcXML_File_ReaderWriter:System Name"].ToString(); } string system_abbreviation = String.Empty; if ((Options.ContainsKey("MarcXML_File_ReaderWriter:System Abbreviation")) && (Options["MarcXML_File_ReaderWriter:System Abbreviation"] != null)) { system_abbreviation = Options["MarcXML_File_ReaderWriter:System Abbreviation"].ToString(); } string thumbnail_base = String.Empty; if ((Options.ContainsKey("MarcXML_File_ReaderWriter:Image_Base")) && (Options["MarcXML_File_ReaderWriter:Image_Base"] != null)) { thumbnail_base = Options["MarcXML_File_ReaderWriter:Image_Base"].ToString(); } // Get all the standard tags MARC_Record tags = Package.To_MARC_Record(cataloging_source_code, location_code, reproduction_agency, reproduction_place, system_name, system_abbreviation, thumbnail_base); // Look for extra tags to add in the OPTIONS if (Options.ContainsKey("MarcXML_File_ReaderWriter:Additional_Tags")) { object add_tags_obj = Options["MarcXML_File_ReaderWriter:Additional_Tags"]; if (add_tags_obj != null) { try { List <MARC_Field> add_tags = (List <MARC_Field>)add_tags_obj; foreach (MARC_Field thisTag in add_tags) { tags.Add_Field(thisTag); } } catch { // Do nothing in this case } } } // Start to build the HTML result StringBuilder results = new StringBuilder(); results.Append("<table style=\"border:none; text-align:left; width:" + Width + ";\">\n"); // Add the LEADER results.Append(" <tr class=\"trGenContent\">\n"); results.Append(" <td style=\"width:33px;vertical-align:top;\">LDR</td>\n"); results.Append(" <td style=\"width:26px;vertical-align:top;\"> </td>\n"); results.Append(" <td>" + tags.Leader.Replace(" ", "^") + "</td>\n"); results.Append(" </tr>"); // Add all the FIELDS foreach (MARC_Field thisTag in tags.Sorted_MARC_Tag_List) { results.Append(" <tr class=\"trGenContent\">\n"); results.Append(" <td>" + thisTag.Tag.ToString().PadLeft(3, '0') + "</td>\n"); results.Append(" <td style=\"color: green;\">" + thisTag.Indicators.Replace(" ", " ") + "</td>\n"); results.Append(" <td>"); if ((thisTag.Tag == 8) || (thisTag.Tag == 7) || (thisTag.Tag == 6)) { results.Append(Convert_String_To_XML_Safe(thisTag.Control_Field_Value.Replace(" ", "^"))); } else { results.Append(Convert_String_To_XML_Safe(thisTag.Control_Field_Value).Replace("|a", "<span style=\"color:blue;\">|a</span>"). Replace("|b", "<span style=\"color:blue;\">|b</span>"). Replace("|c", "<span style=\"color:blue;\">|c</span>"). Replace("|d", "<span style=\"color:blue;\">|d</span>"). Replace("|e", "<span style=\"color:blue;\">|e</span>"). Replace("|g", "<span style=\"color:blue;\">|g</span>"). Replace("|x", "<span style=\"color:blue;\">|x</span>"). Replace("|y", "<span style=\"color:blue;\">|y</span>"). Replace("|z", "<span style=\"color:blue;\">|z</span>"). Replace("|v", "<span style=\"color:blue;\">|v</span>"). Replace("|h", "<span style=\"color:blue;\">|h</span>"). Replace("|u", "<span style=\"color:blue;\">|u</span>"). Replace("|f", "<span style=\"color:blue;\">|f</span>"). Replace("|n", "<span style=\"color:blue;\">|n</span>"). Replace("|2", "<span style=\"color:blue;\">|2</span>"). Replace("|3", "<span style=\"color:blue;\">|3</span>"). Replace("|w", "<span style=\"color:blue;\">|w</span>"). Replace("|t", "<span style=\"color:blue;\">|t</span>"). Replace("|q", "<span style=\"color:blue;\">|q</span>"). Replace("|o", "<span style=\"color:blue;\">|o</span>"). Replace("|i", "<span style=\"color:blue;\">|i</span>"). Replace("|4", "<span style=\"color:blue;\">|4</span>")); } results.Append("</td>\n"); results.Append(" </tr>"); } results.Append("</table>\n"); return(results.ToString().Replace("&bar;", "|")); }