当前位置: 首页>>代码示例>>C#>>正文


C# SobekCM_Item.To_MARC_Record方法代码示例

本文整理汇总了C#中SobekCM_Item.To_MARC_Record方法的典型用法代码示例。如果您正苦于以下问题:C# SobekCM_Item.To_MARC_Record方法的具体用法?C# SobekCM_Item.To_MARC_Record怎么用?C# SobekCM_Item.To_MARC_Record使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SobekCM_Item的用法示例。


在下文中一共展示了SobekCM_Item.To_MARC_Record方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Write_MarcXML

        /// <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");
        }
开发者ID:MarkVSullivan,项目名称:SobekCM-Web-Application,代码行数:47,代码来源:MarcXML_METS_dmdSec_ReaderWriter.cs

示例2: Write_Metadata

        /// <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("&amp;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("&amp;bar;", "|") + "</subfield>");
                        }
                    }

                    Output_Stream.WriteLine("    </datafield>");
                }
            }

            Output_Stream.WriteLine("  </record>");
            Output_Stream.WriteLine("</collection>");

            return true;
        }
开发者ID:randomyed,项目名称:SobekCM-Web-Application,代码行数:74,代码来源:MarcXML_File_ReaderWriter.cs

示例3: Create_OAI_PMH_Metadata

        /// <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();
        }
开发者ID:Elkolt,项目名称:SobekCM-Web-Application,代码行数:72,代码来源:MarcXML_OAI_PMH_Metadata_Type_Writer.cs


注:本文中的SobekCM_Item.To_MARC_Record方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。