コード例 #1
0
        // 创建书目摘要
        public static string CreateSummary(
            string strRecPath,
            string strMARC,
            string syntax)
        {
            string strError = "";
            int    nRet     = 0;
            List <NameValueLine> results = null;

            if (syntax == "usmarc")
            {
                nRet = MarcTable.ScriptMarc21(
                    strRecPath,
                    strMARC,
                    "areas",
                    null,
                    out results,
                    out strError);
            }
            else
            {
                nRet = MarcTable.ScriptUnimarc(
                    strRecPath,
                    strMARC,
                    "areas",
                    null,
                    out results,
                    out strError);
            }
            if (nRet == -1)
            {
                return("error:" + strError);
            }

            StringBuilder text = new StringBuilder();

            foreach (var line in results)
            {
                if (text.Length > 0)
                {
                    text.Append(". -- ");
                }
                text.Append(line.Value);
            }

            return(text.ToString());
        }
コード例 #2
0
ファイル: TestDp2Library.cs プロジェクト: pxmarc/dp2
        public static void VerifyTableXml(string strWorksheet,
                                          string strStyle,
                                          string strTableXml)
        {
            MarcRecord           record         = MarcRecord.FromWorksheet(strWorksheet);
            List <NameValueLine> expect_results = NameValueLine.FromTableXml(strTableXml);

            int nRet = MarcTable.ScriptUnimarc(
                "中文图书/1",
                record.Text,
                strStyle,
                out List <NameValueLine> results,
                out string strError);

            if (nRet == -1)
            {
                throw new Exception(strError);
            }

            CompareResults(results, expect_results);
        }
コード例 #3
0
        // 填充浏览列表
        void FillBrowseList(string xml)
        {
            this.listView_browse.Items.Clear();

            // "http://www.loc.gov/MARC21/slim"
            XmlDocument dom = new XmlDocument();

            dom.LoadXml(xml);

            XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());

            nsmgr.AddNamespace("srw", "http://www.loc.gov/zing/srw/");
            nsmgr.AddNamespace("marc21", "http://www.loc.gov/MARC21/slim");

            /*
             *
             *  <recordIdentifier>9910523143603961</recordIdentifier>
             *  <recordPosition>1</recordPosition>
             * */
            XmlNodeList records = dom.DocumentElement.SelectNodes("//srw:record", nsmgr);

            foreach (XmlElement record in records)
            {
                string id      = record.SelectSingleNode("srw:recordIdentifier", nsmgr)?.InnerText;
                string pos     = record.SelectSingleNode("srw:recordPosition", nsmgr)?.InnerText;
                string marcxml = record.SelectSingleNode("//marc21:record", nsmgr).OuterXml;

                XmlDocument marcxml_dom = new XmlDocument();
                marcxml_dom.LoadXml(marcxml);

                int nRet = MarcUtil.Xml2Marc(marcxml_dom,
                                             true,
                                             null,
                                             out string marcSyntax,
                                             out string strMARC,
                                             out string strError);
                if (nRet == -1)
                {
                    throw new Exception(strError);
                }

                List <DigitalPlatform.Marc.NameValueLine> results = null;

                if (marcSyntax == "usmarc")
                {
                    nRet = MarcTable.ScriptMarc21("",
                                                  strMARC,
                                                  "",
                                                  null,
                                                  out results,
                                                  out strError);
                }
                else if (marcSyntax == "unimarc")
                {
                    nRet = MarcTable.ScriptUnimarc("",
                                                   strMARC,
                                                   "",
                                                   null,
                                                   out results,
                                                   out strError);
                }
                else
                {
                    throw new Exception($"未知的 MARC 格式 '{marcSyntax}'");
                }

                if (nRet == -1)
                {
                    throw new Exception(strError);
                }

                ListViewItem item = new ListViewItem();
                ListViewUtil.ChangeItemText(item, 0, pos);

                FillColumns(item, results);

                this.listView_browse.Items.Add(item);
            }
        }