public static List <Key> BuildKeys(MarcRecord record, string strBiblioRecPath, string xpath, string type) { List <string> values = new List <string>(); foreach (MarcSubfield subfield in record.select(xpath)) { values.Add(subfield.Content); } // TODO: SQL Server 无法区分大小写 key 字符串,会认为重复 values.Sort((a, b) => string.Compare(a, b, true)); _removeDup(ref values); StringUtil.RemoveBlank(ref values); List <Key> results = new List <Key>(); int index = 0; foreach (string class_string in values) { Key key = new Key { Text = class_string, Type = type, BiblioRecPath = strBiblioRecPath, Index = index++, }; results.Add(key); } return(results); }
public static int ScriptUnimarc( string strRecPath, string strMARC, out List <NameValueLine> results, out string strError) { strError = ""; results = new List <NameValueLine>(); MarcRecord record = new MarcRecord(strMARC); if (record.ChildNodes.count == 0) { return(0); } // 010 MarcNodeList fields = record.select("field[@name='010' or @name='011' or @name='091']"); if (fields.count > 0) { results.Add(new NameValueLine("获得方式", BuildFields(fields))); } return(0); }
// 从 dp2library 服务器获得全部 isbn 和 title 字符串 IsbnResult GetIsbnStrings() { LibraryChannel channel = _channelPool.GetChannel(this.textBox_dp2libraryUrl.Text, "public"); try { // TODO: <全部UNIMARC> long lRet = channel.SearchBiblio("<全部>", "", -1, "isbn", "left", "zh", "default", "", "", "", out string strQueryXml, out string strError); if (lRet == -1) { return new IsbnResult { Value = -1, ErrorInfo = strError } } ; ResultSetLoader loader = new ResultSetLoader(channel, "default", "id,xml"); IsbnResult result = new IsbnResult(); result.IsbnList = new List <string>(); foreach (Record record in loader) { // XML 转换为 MARC int nRet = MarcUtil.Xml2Marc(record.RecordBody.Xml, false, "", out string strMarcSyntax, out string strMARC, out strError); if (nRet != 0) { continue; } // 从 MARC 中取 010$a var marc_record = new MarcRecord(strMARC); string xpath = "field[@name='010']/subfield[@name='a']"; if (strMarcSyntax == "usmarc") { xpath = "field[@name='020']/subfield[@name='a']"; } var nodes = marc_record.select(xpath); foreach (MarcSubfield subfield in nodes) { result.IsbnList.Add(subfield.Content); } } return(result); } finally { _channelPool.ReturnChannel(channel); } }
// parameters: // subfieldList 字符串数组。每个单元格式如下: "a; " 第一字符表示子字段名,后面若干字符表示要插入的前置符号。 static string BuildContent(MarcRecord record, string fieldName, string[] subfieldList, bool trimStart) { List <char> chars = new List <char>() { ' ' }; // 用于 TrimStart 的字符 Hashtable prefix_table = new Hashtable(); // name -> prefix StringBuilder xpath = new StringBuilder(); xpath.Append("field[@name='200']/subfield["); int i = 0; foreach (string s in subfieldList) { string name = s.Substring(0, 1); string prefix = s.Substring(1); prefix_table[name] = prefix; string strChar = prefix.Trim(); if (string.IsNullOrEmpty(strChar) == false) { chars.Add(strChar[0]); } if (i > 0) { xpath.Append(" or "); } xpath.Append("@name='" + name + "'"); i++; } xpath.Append("]"); MarcNodeList subfields = record.select(xpath.ToString()); StringBuilder text = new StringBuilder(); foreach (MarcSubfield subfield in subfields) { string prefix = (string)prefix_table[subfield.Name]; if (string.IsNullOrEmpty(prefix) == false) { text.Append(prefix + subfield.Content); } else { text.Append(" " + subfield.Content); } } if (trimStart) { return(text.ToString().TrimStart(chars.ToArray())); } return(text.ToString()); }
static int Count6XX(string strXml) { string strError = ""; string strMarc = ""; string strOutMarcSyntax = ""; // 将MARCXML格式的xml记录转换为marc机内格式字符串 // parameters: // bWarning ==true, 警告后继续转换,不严格对待错误; = false, 非常严格对待错误,遇到错误后不继续转换 // strMarcSyntax 指示marc语法,如果=="",则自动识别 // strOutMarcSyntax out参数,返回marc,如果strMarcSyntax == "",返回找到marc语法,否则返回与输入参数strMarcSyntax相同的值 int nRet = MarcUtil.Xml2Marc(strXml, true, // 2013/1/12 修改为true "", // strMarcSyntax out strOutMarcSyntax, out strMarc, out strError); if (nRet == -1) { return(0); } int nCount = 0; if (strOutMarcSyntax == "unimarc") { MarcRecord record = new MarcRecord(strMarc); nCount += record.select("field[@name='606']").count; nCount += record.select("field[@name='690']").count; return(nCount); } if (strOutMarcSyntax == "usmarc") { MarcRecord record = new MarcRecord(strMarc); nCount += record.select("field[@name='600' or @name='610' or @name='630' or @name='650' or @name='651']").count; nCount += record.select("field[@name='093']").count; return(nCount); } return(0); }
// 创建 table 中的对象资源局部 XML。这是一个 <table> 片段 // 前导语 $3 // 链接文字 $y $f // URL $u // 格式类型 $q // 对象ID $8 // 对象尺寸 $s // 公开注释 $z public static string BuildObjectXmlTable(string strMARC, // string strRecPath, BuildObjectHtmlTableStyle style = BuildObjectHtmlTableStyle.None) { // Debug.Assert(false, ""); MarcRecord record = new MarcRecord(strMARC); MarcNodeList fields = record.select("field[@name='856']"); if (fields.count == 0) { return(""); } XmlDocument dom = new XmlDocument(); dom.LoadXml("<table/>"); int nCount = 0; foreach (MarcField field in fields) { string x = field.select("subfield[@name='x']").FirstContent; Hashtable table = StringUtil.ParseParameters(x, ';', ':'); string strType = (string)table["type"]; if (string.IsNullOrEmpty(strType) == false && (style & BuildObjectHtmlTableStyle.FrontCover) == 0 && (strType == "FrontCover" || strType.StartsWith("FrontCover.") == true)) { continue; } string strSize = (string)table["size"]; string s_q = field.select("subfield[@name='q']").FirstContent; // 注意, FirstContent 可能会返回 null string u = field.select("subfield[@name='u']").FirstContent; // string strUri = MakeObjectUrl(strRecPath, u); string strSaveAs = ""; if (string.IsNullOrEmpty(s_q) == true || // 2016/9/4 StringUtil.MatchMIME(s_q, "text") == true || StringUtil.MatchMIME(s_q, "image") == true) { } else { strSaveAs = "true"; } string y = field.select("subfield[@name='y']").FirstContent; string f = field.select("subfield[@name='f']").FirstContent; string urlLabel = ""; if (string.IsNullOrEmpty(y) == false) { urlLabel = y; } else { urlLabel = f; } if (string.IsNullOrEmpty(urlLabel) == true) { urlLabel = strType; } // 2015/11/26 string s_z = field.select("subfield[@name='z']").FirstContent; if (string.IsNullOrEmpty(urlLabel) == true && string.IsNullOrEmpty(s_z) == false) { urlLabel = s_z; s_z = ""; } if (string.IsNullOrEmpty(urlLabel) == true) { urlLabel = u; } #if NO string urlTemp = ""; if (String.IsNullOrEmpty(strObjectUrl) == false) { urlTemp += "<a href='" + strObjectUrl + "'>"; urlTemp += urlLabel; urlTemp += "</a>"; } else { urlTemp = urlLabel; } #endif string s_3 = field.select("subfield[@name='3']").FirstContent; string s_s = field.select("subfield[@name='s']").FirstContent; XmlElement line = dom.CreateElement("line"); dom.DocumentElement.AppendChild(line); string strTypeString = (s_3 + " " + strType).Trim(); if (string.IsNullOrEmpty(strTypeString) == false) { line.SetAttribute("type", strTypeString); } if (string.IsNullOrEmpty(urlLabel) == false) { line.SetAttribute("urlLabel", urlLabel); } if (string.IsNullOrEmpty(u) == false) { line.SetAttribute("uri", u); } if (string.IsNullOrEmpty(s_q) == false) { line.SetAttribute("mime", s_q); } if (string.IsNullOrEmpty(strSize) == false) { line.SetAttribute("size", strSize); } if (string.IsNullOrEmpty(s_s) == false) { line.SetAttribute("bytes", s_s); } if (string.IsNullOrEmpty(strSaveAs) == false) { line.SetAttribute("saveAs", strSaveAs); } if (string.IsNullOrEmpty(s_z) == false) { line.SetAttribute("comment", s_z); } nCount++; } if (nCount == 0) { return(""); } return(dom.DocumentElement.OuterXml); }
/// <summary> /// 获得封面图像 URL /// 优先选择中等大小的图片 /// </summary> /// <param name="strMARC">MARC机内格式字符串</param> /// <param name="strPreferredType">优先使用何种大小类型</param> /// <returns>返回封面图像 URL。空表示没有找到</returns> public static string GetCoverImageUrl(string strMARC, string strPreferredType = "MediumImage") { string strLargeUrl = ""; string strMediumUrl = ""; // type:FrontCover.MediumImage string strUrl = ""; // type:FronCover string strSmallUrl = ""; MarcRecord record = new MarcRecord(strMARC); MarcNodeList fields = record.select("field[@name='856']"); foreach (MarcField field in fields) { string x = field.select("subfield[@name='x']").FirstContent; if (string.IsNullOrEmpty(x) == true) { continue; } Hashtable table = StringUtil.ParseParameters(x, ';', ':'); string strType = (string)table["type"]; if (string.IsNullOrEmpty(strType) == true) { continue; } string u = field.select("subfield[@name='u']").FirstContent; // if (string.IsNullOrEmpty(u) == true) // u = field.select("subfield[@name='8']").FirstContent; // . 分隔 FrontCover.MediumImage if (StringUtil.HasHead(strType, "FrontCover." + strPreferredType) == true) { return(u); } if (StringUtil.HasHead(strType, "FrontCover.SmallImage") == true) { strSmallUrl = u; } else if (StringUtil.HasHead(strType, "FrontCover.MediumImage") == true) { strMediumUrl = u; } else if (StringUtil.HasHead(strType, "FrontCover.LargeImage") == true) { strLargeUrl = u; } else if (StringUtil.HasHead(strType, "FrontCover") == true) { strUrl = u; } } if (string.IsNullOrEmpty(strLargeUrl) == false) { return(strLargeUrl); } if (string.IsNullOrEmpty(strMediumUrl) == false) { return(strMediumUrl); } if (string.IsNullOrEmpty(strUrl) == false) { return(strUrl); } return(strSmallUrl); }
void GetVolume(string strBiblioRecPath, out string strVolume, out string strPrice) { strVolume = ""; strPrice = ""; string strXml = (string)this._biblioXmlTable[strBiblioRecPath]; if (string.IsNullOrEmpty(strXml) == true) { return; } string strOutMarcSyntax = ""; string strMARC = ""; string strError = ""; int nRet = MarcUtil.Xml2Marc(strXml, false, "", out strOutMarcSyntax, out strMARC, out strError); if (nRet == -1) { return; } if (string.IsNullOrEmpty(strMARC) == true) { return; } MarcRecord record = new MarcRecord(strMARC); if (strOutMarcSyntax == "unimarc") { string h = record.select("field[@name='200']/subfield[@name='h']").FirstContent; string i = record.select("field[@name='200']/subfield[@name='i']").FirstContent; if (string.IsNullOrEmpty(h) == false && string.IsNullOrEmpty(i) == false) { strVolume = h + " . " + i; } else { if (h == null) { h = ""; } strVolume = h + i; } strPrice = record.select("field[@name='010']/subfield[@name='d']").FirstContent; } else if (strOutMarcSyntax == "usmarc") { string n = record.select("field[@name='200']/subfield[@name='n']").FirstContent; string p = record.select("field[@name='200']/subfield[@name='p']").FirstContent; if (string.IsNullOrEmpty(n) == false && string.IsNullOrEmpty(p) == false) { strVolume = n + " . " + p; } else { if (n == null) { n = ""; } strVolume = n + p; } strPrice = record.select("field[@name='020']/subfield[@name='c']").FirstContent; } else { } }
// 创建 OPAC 详细页面中的对象资源显示局部 HTML。这是一个 <table> 片段 // 前导语 $3 // 链接文字 $y $f // URL $u // 格式类型 $q // 对象ID $8 // 对象尺寸 $s // 公开注释 $z public static string BuildObjectHtmlTable(string strMARC, string strRecPath, BuildObjectHtmlTableStyle style = BuildObjectHtmlTableStyle.HttpUrlHitCount) { // Debug.Assert(false, ""); MarcRecord record = new MarcRecord(strMARC); MarcNodeList fields = record.select("field[@name='856']"); if (fields.count == 0) { return(""); } StringBuilder text = new StringBuilder(); text.Append("<table class='object_table'>"); text.Append("<tr class='column_title'>"); text.Append("<td class='type' style='word-break:keep-all;'>名称</td>"); text.Append("<td class='hitcount'></td>"); text.Append("<td class='link' style='word-break:keep-all;'>链接</td>"); text.Append("<td class='mime' style='word-break:keep-all;'>媒体类型</td>"); text.Append("<td class='size' style='word-break:keep-all;'>尺寸</td>"); text.Append("<td class='bytes' style='word-break:keep-all;'>字节数</td>"); text.Append("</tr>"); int nCount = 0; foreach (MarcField field in fields) { string x = field.select("subfield[@name='x']").FirstContent; Hashtable table = StringUtil.ParseParameters(x, ';', ':'); string strType = (string)table["type"]; if (string.IsNullOrEmpty(strType) == false && (style & BuildObjectHtmlTableStyle.FrontCover) == 0 && (strType == "FrontCover" || strType.StartsWith("FrontCover.") == true)) { continue; } string strSize = (string)table["size"]; string s_q = field.select("subfield[@name='q']").FirstContent; // 注意, FirstContent 可能会返回 null string u = field.select("subfield[@name='u']").FirstContent; string strUri = MakeObjectUrl(strRecPath, u); string strSaveAs = ""; if (string.IsNullOrEmpty(s_q) == true || StringUtil.MatchMIME(s_q, "text") == true || StringUtil.MatchMIME(s_q, "image") == true) { } else { strSaveAs = "&saveas=true"; } string strHitCountImage = ""; string strObjectUrl = strUri; if (StringUtil.IsHttpUrl(strUri) == false) { // 内部对象 strObjectUrl = "./getobject.aspx?uri=" + HttpUtility.UrlEncode(strUri) + strSaveAs; strHitCountImage = "<img src='" + strObjectUrl + "&style=hitcount' alt='hitcount'></img>"; } else { // http: 或 https: 的情形,即外部 URL if ((style & BuildObjectHtmlTableStyle.HttpUrlHitCount) != 0) { strObjectUrl = "./getobject.aspx?uri=" + HttpUtility.UrlEncode(strUri) + strSaveAs + "&biblioRecPath=" + HttpUtility.UrlEncode(strRecPath); strHitCountImage = "<img src='" + strObjectUrl + "&style=hitcount&biblioRecPath=" + HttpUtility.UrlEncode(strRecPath) + "' alt='hitcount'></img>"; } } string y = field.select("subfield[@name='y']").FirstContent; string f = field.select("subfield[@name='f']").FirstContent; string urlLabel = ""; if (string.IsNullOrEmpty(y) == false) { urlLabel = y; } else { urlLabel = f; } if (string.IsNullOrEmpty(urlLabel) == true) { urlLabel = strType; } // 2015/11/26 string s_z = field.select("subfield[@name='z']").FirstContent; if (string.IsNullOrEmpty(urlLabel) == true && string.IsNullOrEmpty(s_z) == false) { urlLabel = s_z; s_z = ""; } if (string.IsNullOrEmpty(urlLabel) == true) { urlLabel = strObjectUrl; } string urlTemp = ""; if (String.IsNullOrEmpty(strObjectUrl) == false) { urlTemp += "<a href='" + strObjectUrl + "'>"; urlTemp += urlLabel; urlTemp += "</a>"; } else { urlTemp = urlLabel; } string s_3 = field.select("subfield[@name='3']").FirstContent; string s_s = field.select("subfield[@name='s']").FirstContent; text.Append("<tr class='content'>"); text.Append("<td class='type'>" + HttpUtility.HtmlEncode(s_3 + " " + strType) + "</td>"); text.Append("<td class='hitcount' style='text-align: right;'>" + strHitCountImage + "</td>"); text.Append("<td class='link' style='word-break:break-all;'>" + urlTemp + "</td>"); text.Append("<td class='mime'>" + HttpUtility.HtmlEncode(s_q) + "</td>"); text.Append("<td class='size'>" + HttpUtility.HtmlEncode(strSize) + "</td>"); text.Append("<td class='bytes'>" + HttpUtility.HtmlEncode(s_s) + "</td>"); text.Append("</tr>"); if (string.IsNullOrEmpty(s_z) == false) { text.Append("<tr class='comment'>"); text.Append("<td colspan='6'>" + HttpUtility.HtmlEncode(s_z) + "</td>"); text.Append("</tr>"); } nCount++; } if (nCount == 0) { return(""); } text.Append("</table>"); return(text.ToString()); }
// 开始转bdf private void button_tobdf_Click(object sender, EventArgs e) { if (textBox_isofilename.Text.Trim() == "") { MessageBox.Show(this, "尚未选择iso数据文件"); return; } if (comboBox_source.Text.Trim() == "") { MessageBox.Show(this, "尚未选择数据来源系统"); return; } if (this.comboBox_source.Text.ToUpper() == "DT1000") { if (this.Location == "") { MessageBox.Show(this, "请输入馆藏地"); return; } if (this.BookType == "") { MessageBox.Show(this, "请输入图书类型"); return; } } // 选择保存的bdf文件 SaveFileDialog dlg = new SaveFileDialog() { Title = "书目转储文件名", Filter = "书目转储文件(*.bdf)|*.bdf", RestoreDirectory = true }; if (dlg.ShowDialog(this) != DialogResult.OK) { return; } // bdf文件是一个xml结构 string bdfFile = dlg.FileName; XmlTextWriter _writer = null; _writer = new XmlTextWriter(bdfFile, Encoding.UTF8) { Formatting = Formatting.Indented, Indentation = 4 }; _writer.WriteStartDocument(); _writer.WriteStartElement("dprms", "collection", DpNs.dprms); _writer.WriteAttributeString("xmlns", "dprms", null, DpNs.dprms); // 输出一个错误信息文件 FileInfo fileInfo = new FileInfo(bdfFile); string strSourceDir = fileInfo.DirectoryName; string errorFilename = strSourceDir + "\\~error.txt"; long errorCount1 = 0; StreamWriter sw_error = new StreamWriter(errorFilename, false, // append Encoding.UTF8); // 源iso文件 string isoFileName = this.textBox_isofilename.Text.Trim(); // 用当前日期作为批次号 string strBatchNo = DateTime.Now.ToString("yyyyMMdd"); int nIndex = 0; string strError = ""; MarcLoader loader = new MarcLoader(isoFileName, this.Encoding, "marc", null); foreach (string marc in loader) { MarcRecord record = new MarcRecord(marc); string strISBN = record.select("field[@name='010']/subfield[@name='a']").FirstContent; strISBN = string.IsNullOrEmpty(strISBN) ? "" : strISBN; string strTitle = record.select("field[@name='200']/subfield[@name='a']").FirstContent; strTitle = string.IsNullOrEmpty(strTitle) ? "" : strTitle; string strSummary = strISBN + "\t" + strTitle; // 转换回XML XmlDocument domMarc = null; int nRet = MarcUtil.Marc2Xml(marc, this.MarcSyntax,//this.m_strBiblioSyntax, out domMarc, out strError); if (nRet == -1) { errorCount1++; sw_error.WriteLine("!!!异常Marc2Xml()" + strError); return; } // 写<record> _writer.WriteStartElement("dprms", "record", DpNs.dprms); // 写<biblio> _writer.WriteStartElement("dprms", "biblio", DpNs.dprms); // 把marc xml写入<biblio>下级 domMarc.WriteTo(_writer); // </<biblio>> _writer.WriteEndElement(); #region 关于价格 bool bPriceError = false; // *** 从010$d中取得价格 string strErrorPrice = ""; string strCataPrice = record.select("field[@name='010']/subfield[@name='d']").FirstContent; string strOldPrice = strCataPrice; // marc中不存在010$d价格 if (string.IsNullOrEmpty(strCataPrice) == true) { strCataPrice = "CNY0"; sw_error.WriteLine(nIndex + "\t" + strSummary + "\t不存在010$d价格子字段。"); bPriceError = true; } else { // 如果不在合法的价格格式 if (!Regex.IsMatch(strCataPrice, @"^(CNY)?\d+\.?\d{0,2}$")) { //将价格中含有的汉字型数值替换为数字 strCataPrice = ParsePrice(strCataPrice); if (strCataPrice != strOldPrice) { strErrorPrice = strOldPrice; sw_error.WriteLine(nIndex + "\t" + strSummary + "\t价格字符串 '" + strOldPrice + "' 被自动修改为 '" + strCataPrice + "'"); bPriceError = true; } //已知格式价格内容转换 string temp1 = strCataPrice; strCataPrice = CorrectPrice(strCataPrice); if (strCataPrice != temp1) { strErrorPrice = strOldPrice; sw_error.WriteLine(nIndex + "\t" + strSummary + "\t价格字符串 '" + strOldPrice + "' 被自动修改为 '" + strCataPrice + "'"); bPriceError = true; } } List <string> temp = VerifyPrice(strCataPrice); if (temp.Count > 0) { string temp1 = strCataPrice; CorrectPrice(ref strCataPrice); if (temp1 != strCataPrice) { if (IsPriceCorrect(strCataPrice) == true) { sw_error.WriteLine(nIndex + "\t" + strSummary + "\t价格字符串 '" + strOldPrice + "' 被自动修改为 '" + strCataPrice + "'"); bPriceError = true; } else { strCataPrice = "CNY0"; strErrorPrice = strOldPrice; sw_error.WriteLine(nIndex + "\t" + strSummary + "\t价格字符串 '" + strOldPrice + "' 无法被自动修改,默认为 CNY0"); bPriceError = true; } } else { strCataPrice = "CNY0"; strErrorPrice = strOldPrice; sw_error.WriteLine(nIndex + "\t" + strSummary + "\t价格字符串 '" + strOldPrice + "' 无法被自动修改,默认为 CNY0"); bPriceError = true; } } // 如果不是CNY开头的,加CNY if (!strCataPrice.StartsWith("CNY")) { strCataPrice = "CNY" + strCataPrice; sw_error.WriteLine(nIndex + ":" + strSummary + "*** 价格字符串 '" + strCataPrice + "' 不含有币种前缀,自动添加为'CNY'\r\n"); bPriceError = true; } } // 如果价格经过修复,错误记录数增加1 if (bPriceError == true) { errorCount1++; } #endregion #region 从905$d$e取得索书号 // 905$d 中图法大类 string str905d = record.select("field[@name='905']/subfield[@name='d']").FirstContent; if (String.IsNullOrEmpty(str905d) == true) { strError = nIndex + "\t" + strSummary + "\t905字段不存在$d子字段"; sw_error.WriteLine(strError); } // 905$e 种次号 string str905e = record.select("field[@name='905']/subfield[@name='e']").FirstContent; if (String.IsNullOrEmpty(str905e) == true) { strError = nIndex + "\t" + strSummary + "\t905字段不存在$e子字段"; sw_error.WriteLine(strError); } // 如果缺索取号记一笔 if (bPriceError == false) { if (string.IsNullOrEmpty(str905d) == true || string.IsNullOrEmpty(str905e) == true) { errorCount1++; } } #endregion // 册条码是放在906$h字段的 MarcNodeList subfield_690h = record.select("field[@name='906']/subfield[@name='h']"); int index = 0; // <itemCollection> _writer.WriteStartElement("dprms", "itemCollection", DpNs.dprms); foreach (MarcNode node in subfield_690h) { index++; string strBarcode = node.Content; // 册条码号为空,则不创建册信息元素 if (string.IsNullOrEmpty(strBarcode)) { continue; } _writer.WriteStartElement("dprms", "item", DpNs.dprms); strBarcode = strBarcode.Trim(); _writer.WriteElementString("barcode", strBarcode); string strLocation = this.Location; //DT1000使用界面输入的值 _writer.WriteElementString("location", strLocation); if (!string.IsNullOrEmpty(strCataPrice)) { _writer.WriteElementString("price", strCataPrice); } if (!string.IsNullOrEmpty(strErrorPrice)) { _writer.WriteElementString("comment", "原价格:" + strErrorPrice); } string strBookType = this.BookType;//DT1000使用界面输入的值 _writer.WriteElementString("bookType", strBookType); if (!string.IsNullOrEmpty(str905d) && !string.IsNullOrEmpty(str905e)) { _writer.WriteElementString("accessNo", str905d + "/" + str905e); } else { //strError = nIndex + "\t" + strSummary + "\t册记录'" + strBarcode + "'不含有 索取号 内容"; //sw_error.WriteLine(strError); } _writer.WriteElementString("batchNo", strBatchNo);// _writer.WriteEndElement(); } //</itemCollection> _writer.WriteEndElement(); //</record> _writer.WriteEndElement(); nIndex++; this._mainForm.SetStatusMessage(nIndex.ToString() + " " + strSummary); Application.DoEvents(); } //</collection> _writer.WriteEndElement(); _writer.WriteEndDocument(); _writer.Close(); _writer = null; this._mainForm.SetStatusMessage("处理完成,共处理" + nIndex.ToString() + "条。"); string strMsg = "数据转换处理结束。请到dp2内务使用【批处理】-【从书目转储文件导入】功能将转换的 书目转储文件 导入到目标书目库。"; MessageBox.Show(this, strMsg); if (sw_error != null) { strMsg = "共处理'" + nIndex + "'条MARC记录,其中有 " + errorCount1.ToString() + " 条记录中有错误信息。"; sw_error.WriteLine(strMsg); sw_error.Close(); sw_error = null; } }
public override void OnRecord(object sender, StatisEventArgs e) { MarcNodeList nodes = null; string strContent = ""; MarcNodeList nodes1 = null; MarcRecord record = this.MarcRecord; string strClc = ""; string strNumber = ""; nodes = record.select("field[@name='690']/subfield[@name='a']"); foreach (MarcNode node in nodes) { strClc = node.Content; break; } nodes = record.select("field[@name='905']/subfield[@name='f']"); if (nodes.count == 0) { string strError = ""; string strAuthor = ""; List <string> results = null; nodes1 = record.select("field[@name='701']/subfield[@name='a']"); if (nodes1.count > 0) { goto FOUND; } nodes1 = record.select("field[@name='711']/subfield[@name='a']"); if (nodes1.count > 0) { goto FOUND; } nodes1 = record.select("field[@name='200']/subfield[@name='a']"); if (nodes1.count > 0) { goto FOUND; } FOUND: foreach (MarcNode node in nodes1) { strContent = node.Content; if (BiblioItemsHost.ContainHanzi(strContent)) { strAuthor = strContent; // 获得四角号码著者号 // return: // -1 error // 0 canceled // 1 succeed int nRet = GetSjhmAuthorNumber( strAuthor, out strNumber, out strError); if (nRet != 1) { } } break; } } else { return; } nodes = record.select("field[@name='905']/subfield[@name='a']"); // strStartEnd = String.Format("{0:000000}", intAutoNo); // intAutoNo = intAutoNo + 1; if (nodes.count > 0) { nodes[0].after(MarcQuery.SUBFLD + "d" + strClc + "/" + strNumber); } nodes = record.select("field[@name='906']/subfield[@name='a']"); if (nodes.count > 0) { foreach (MarcNode node in nodes) { node.after(MarcQuery.SUBFLD + "d" + strClc + "/" + strNumber); } } this.Changed = true; }
public override void OnRecord(object sender, StatisEventArgs e) { MarcNodeList nodes = null; string strContent = ""; MarcNodeList nodes1 = null; MarcNode node2 = null; MarcRecord record = this.MarcRecord; if (record.Header[5, 4] == "nam ") { record.Header[5, 4] = "oam2"; } //有010的 nodes = record.select("field[@name='010']/subfield[@name='b']"); foreach (MarcNode node in nodes) { strContent = node.Content; if (String.IsNullOrEmpty(strContent)) { continue; } if (strContent == "光盘") { node2 = node.Parent; if (node2.FirstChild.Name == "a") { strContent = node2.FirstChild.Content; //node2.Content = "{cr:CALIS}" + node2.Content; node2.after("307 " + MarcQuery.SUBFLD + "a附光盘:ISBN " + strContent); node2.detach(); this.Changed = true; } } } //有016的 nodes = record.select("field[@name='016']/subfield[@name='b']"); foreach (MarcNode node in nodes) { strContent = node.Content; if (String.IsNullOrEmpty(strContent)) { continue; } if (strContent == "磁带") { node2 = node.Parent; if (node2.FirstChild.Name == "a") { strContent = node2.FirstChild.Content; //node2.Content = "{cr:CALIS}" + node2.Content; node2.after("307 {cr:NLC}" + MarcQuery.SUBFLD + "a附磁带:" + strContent); node2.detach(); this.Changed = true; } } } //有100的 nodes = record.select("field[@name='100']"); foreach (MarcNode node in nodes) { strContent = node.Content; if (String.IsNullOrEmpty(strContent)) { continue; } if (strContent.Substring(28, 4) == "0120") { node.Content = strContent.Substring(0, 28) + "0110" + strContent.Substring(32, strContent.Length - 32); this.Changed = true; } } //都存在的拼音 nodes = record.select("field[@name='200' or @name='512' or @name='513' or @name='514' or @name='515' or @name='516' or @name='517' or @name='518' or @name='540' or @name='541' or @name='545' or @name='701' or @name='702' or @name='711' or @name='712' or @name='730']/subfield[@name='A']"); foreach (MarcNode node in nodes) { strContent = node.Content; if (String.IsNullOrEmpty(strContent)) { continue; } node.Name = "9"; node.Content = node.Content.ToLower(); this.Changed = true; } //国图不存在的拼音 nodes = record.select("field[@name='225' or @name='600' or @name='601' or @name='604' or @name='605' or @name='606' or @name='607' or @name='610']/subfield[@name='A']"); foreach (MarcNode node in nodes) { strContent = node.Content; if (String.IsNullOrEmpty(strContent)) { continue; } node.detach(); this.Changed = true; } //有200$d的 nodes = record.select("field[@name='200']/subfield[@name='d']"); foreach (MarcNode node in nodes) { strContent = node.Content; if (String.IsNullOrEmpty(strContent)) { continue; } if (strContent.StartsWith("= ")) { node.Content = strContent.Remove(0, 2); this.Changed = true; } } //有200$f$g的 nodes = record.select("field[@name='200']/subfield[@name='f' or @name='g']"); foreach (MarcNode node in nodes) { strContent = node.Content; if (String.IsNullOrEmpty(strContent)) { continue; } if (BiblioItemsHost.ContainHanzi(strContent)) { string strRight = strContent.Replace(",", ","); strRight = strRight.Replace(" ", ""); node.Content = strRight.Replace("...", ""); this.Changed = true; } } //有205的 nodes = record.select("field[@name='205']/subfield[@name='a']"); foreach (MarcNode node in nodes) { strContent = node.Content; if (String.IsNullOrEmpty(strContent)) { continue; } if (strContent.IndexOf("第") >= 0) { string strRight = strContent.Replace("第", ""); node.Content = strRight; this.Changed = true; } } //有215$a的 nodes = record.select("field[@name='215']/subfield[@name='a']"); foreach (MarcNode node in nodes) { strContent = node.Content; if (String.IsNullOrEmpty(strContent)) { continue; } if (strContent.IndexOf(" ") >= 0) { string strRight = strContent.Replace(" ", ""); node.Content = strRight; this.Changed = true; } } //有215$e的 nodes = record.select("field[@name='215']/subfield[@name='e']"); foreach (MarcNode node in nodes) { strContent = node.Content; if (String.IsNullOrEmpty(strContent)) { continue; } if (strContent.IndexOf("光盘") >= 0) { string strRight = strContent.Replace("光盘", ""); node.Content = strRight.Replace("片", "光盘"); this.Changed = true; } } //有215$d的 nodes = record.select("field[@name='215']/subfield[@name='d']"); foreach (MarcNode node in nodes) { strContent = node.Content; if (String.IsNullOrEmpty(strContent)) { continue; } if (strContent.IndexOf("x") >= 0) { string strRight = strContent.Replace("x", "×"); node.Content = strRight; this.Changed = true; } } //有410的 nodes = record.select("field[@name='410']"); foreach (MarcNode node in nodes) { strContent = node.Content; if (String.IsNullOrEmpty(strContent)) { continue; } if (strContent.IndexOf(MarcQuery.SUBFLD + "i") >= 0) { node.Name = "462"; } else { node.Name = "461"; } this.Changed = true; } //有605$a的 nodes = record.select("field[@name='605']/subfield[@name='a']"); foreach (MarcNode node in nodes) { strContent = node.Content; if (String.IsNullOrEmpty(strContent)) { continue; } if (strContent.IndexOf("《") < 0) { node.Content = "《" + strContent + "》"; this.Changed = true; } } //有600/701/702的 nodes = record.select("field[@name='600' or @name='701' or @name='702']"); foreach (MarcNode node in nodes) { strContent = node.Content; if (String.IsNullOrEmpty(strContent)) { continue; } MarcNodeList subfields = node.select("subfield[@name='g' or @name='f']"); if (subfields.count > 0) { foreach (MarcNode node3 in node.ChildNodes) { if (node3.Name == "g") { node3.Name = "c"; } if (node3.Name == "f") { node3.Content = "(" + node3.Content + ")"; } } for (int i = node.ChildNodes.count - 1; i >= 0; i--) { MarcNode node3 = node.ChildNodes[i]; strContent = node3.Content; bool prefix = false; if (node3.Name == "f") { prefix = true; } else { if (prefix) { if (strContent.Substring(strContent.Length - 1, 1) == ",") { node3.Content = strContent.Remove(strContent.Length - 1, 1); } } prefix = false; } } for (int i = 0; i < node.ChildNodes.count; i++) { MarcNode node3 = node.ChildNodes[i]; strContent = node3.Content; bool prefix = false; if (strContent.StartsWith("(")) { if (prefix) { node3.Content = strContent.Remove(0, 1); strContent = node.ChildNodes[i - 1].Content; node.ChildNodes[i - 1].Content = strContent.Substring(0, strContent.Length - 1); } prefix = true; } else { prefix = false; } } this.Changed = true; } } record.Fields.sort(); this.Changed = true; }
/// <summary> /// 获取记录详细信息 /// </summary> /// <param name="channel"></param> /// <param name="strRecord"></param> /// <param name="cols"></param> /// <param name="strError"></param> /// <returns></returns> int GetDetailInfo(RestChannel channel, string recPath, string strRecordXml, out ReservationItem reserItem, out string strError) { strError = ""; reserItem = new ReservationItem(); reserItem.RecPath = recPath; XmlDocument dom = new XmlDocument(); dom.LoadXml(strRecordXml); XmlNode nodeRoot = dom.DocumentElement; reserItem.RecPath = recPath; reserItem.State = DomUtil.GetElementText(nodeRoot, "state"); reserItem.ItemBarcode = DomUtil.GetElementText(nodeRoot, "itemBarcode"); reserItem.ItemRefID = DomUtil.GetElementText(nodeRoot, "itemRefID"); reserItem.PatronBarcode = DomUtil.GetElementText(nodeRoot, "readerBarcode"); reserItem.LibraryCode = DomUtil.GetElementText(nodeRoot, "libraryCode"); reserItem.OnShelf = DomUtil.GetElementText(nodeRoot, "onShelf"); reserItem.NotifyTime = DateTimeUtil.ToLocalTime(DomUtil.GetElementText(nodeRoot, "notifyDate"), "yyyy-MM-dd HH:mm:ss"); reserItem.Location = DomUtil.GetElementText(nodeRoot, "location"); reserItem.AccessNo = DomUtil.GetElementText(nodeRoot, "accessNo"); // 以下字段为图书信息 reserItem.ISBN = ""; reserItem.Title = ""; reserItem.Author = ""; // 以下字段是读者信息 reserItem.PatronName = ""; reserItem.Department = ""; reserItem.PatronTel = ""; reserItem.RequestTime = ""; reserItem.ArrivedTime = ""; // 备书产生的字段 reserItem.PrintState = DomUtil.GetElementText(nodeRoot, "printState"); reserItem.CheckResult = "";// 是否找到图书,值为:找到/未找到 // 过了保留期的数据,不再获取详细数据 if (reserItem.State == C_State_outof) { strError = "因为过了保留期,不必再获取详细数据了。"; return(0); } // 获取册信息以及书目信息 if (!string.IsNullOrEmpty(reserItem.ItemBarcode)) { GetItemInfoResponse response = channel.GetItemInfo(reserItem.ItemBarcode, "xml", "xml"); if (response.GetItemInfoResult.Value == -1) { strError = "获取册记录'" + reserItem.ItemBarcode + "'出错:" + response.GetItemInfoResult.ErrorInfo; return(-1); } if (response.GetItemInfoResult.Value == 0) { strError = "获取册记录'" + reserItem.ItemBarcode + "未命中"; return(-1); } string strOutMarcSyntax = ""; string strMARC = ""; string strMarcXml = response.strBiblio; int nRet = MarcUtil.Xml2Marc(strMarcXml, false, "", // 自动识别 MARC 格式 out strOutMarcSyntax, out strMARC, out strError); if (nRet == -1) { return(-1); } MarcRecord marcRecord = new MarcRecord(strMARC); reserItem.ISBN = marcRecord.select("field[@name='010']/subfield[@name='a']").FirstContent; reserItem.Title = marcRecord.select("field[@name='200']/subfield[@name='a']").FirstContent; reserItem.Author = marcRecord.select("field[@name='200']/subfield[@name='f']").FirstContent; } // 获取读者信息 if (string.IsNullOrEmpty(reserItem.PatronBarcode) == false) { GetReaderInfoResponse readerRet = channel.GetReaderInfo(reserItem.PatronBarcode, "xml:noborrowhistory"); if (readerRet.GetReaderInfoResult.Value == -1) { strError = "获取册记录'" + reserItem.ItemBarcode + "'出错:" + readerRet.GetReaderInfoResult.ErrorInfo; return(-1); } if (readerRet.GetReaderInfoResult.Value == 0) { strError = "获取册记录'" + reserItem.ItemBarcode + "'未命中。";// + readerRet.GetReaderInfoResult.ErrorInfo; return(-1); } string strPatronXml = readerRet.results[0]; dom.LoadXml(strPatronXml); XmlNode rootNode = dom.DocumentElement; reserItem.PatronName = DomUtil.GetElementText(rootNode, "name"); reserItem.Department = DomUtil.GetElementText(rootNode, "department"); reserItem.PatronTel = DomUtil.GetElementText(rootNode, "tel"); /* * - <root expireDate=""> * <barcode>XZP10199</barcode> * <readerType>学生</readerType> * <name>李明</name> * <overdues /> * - <reservations> * <request items="XZ000101" requestDate="Tue, 11 Feb 2020 00:30:27 +0800" * operator="XZP10199" state="arrived" arrivedDate="Tue, 11 Feb 2020 00:31:45 +0800" * arrivedItemBarcode="XZ000101" notifyID="59abfc23-f44f-4b34-a22c-f8a8aa5e289e" * accessNo="K825.6=76/Z780" location="星洲学校/图书馆,#reservation" /> * </reservations> * </root> */ XmlNodeList nodeList = rootNode.SelectNodes("reservations/request"); foreach (XmlNode node in nodeList) { string arrivedItemBarcode = DomUtil.GetAttr(node, "arrivedItemBarcode"); if (arrivedItemBarcode == reserItem.ItemBarcode) { reserItem.RequestTime = DateTimeUtil.ToLocalTime(DomUtil.GetAttr(node, "requestDate"), "yyyy-MM-dd HH:mm:ss"); reserItem.ArrivedTime = DateTimeUtil.ToLocalTime(DomUtil.GetAttr(node, "arrivedDate"), "yyyy-MM-dd HH:mm:ss"); break; } } } return(0); }
// 创建 OPAC 详细页面中的对象资源显示局部 HTML。这是一个 <table> 片段 // 前导语 $3 // 链接文字 $y $f // URL $u // 格式类型 $q // 对象ID $8 // 对象尺寸 $s // 公开注释 $z public static string BuildObjectHtmlTable(string strMARC, string strRecPath, XmlElement maps_container, BuildObjectHtmlTableStyle style = BuildObjectHtmlTableStyle.HttpUrlHitCount | BuildObjectHtmlTableStyle.Template, string strMarcSyntax = "unimarc") { // Debug.Assert(false, ""); MarcRecord record = new MarcRecord(strMARC); MarcNodeList fields = record.select("field[@name='856']"); if (fields.count == 0) { return(""); } StringBuilder text = new StringBuilder(); text.Append("<table class='object_table'>"); text.Append("<tr class='column_title'>"); text.Append("<td class='type' style='word-break:keep-all;'>材料</td>"); text.Append("<td class='hitcount'></td>"); text.Append("<td class='link' style='word-break:keep-all;'>链接</td>"); text.Append("<td class='mime' style='word-break:keep-all;'>媒体类型</td>"); text.Append("<td class='size' style='word-break:keep-all;'>尺寸</td>"); text.Append("<td class='bytes' style='word-break:keep-all;'>字节数</td>"); text.Append("</tr>"); int nCount = 0; foreach (MarcField field in fields) { string x = field.select("subfield[@name='x']").FirstContent; Hashtable table = StringUtil.ParseParameters(x, ';', ':'); string strType = (string)table["type"]; // TODO: if (strType == null) { strType = ""; } if (string.IsNullOrEmpty(strType) == false && (style & BuildObjectHtmlTableStyle.FrontCover) == 0 && (strType == "FrontCover" || strType.StartsWith("FrontCover.") == true)) { continue; } string strSize = (string)table["size"]; string s_q = field.select("subfield[@name='q']").FirstContent; // 注意, FirstContent 可能会返回 null List <Map856uResult> u_list = new List <Map856uResult>(); { string u = field.select("subfield[@name='u']").FirstContent; // Hashtable parameters = new Hashtable(); if (maps_container != null && (style & BuildObjectHtmlTableStyle.Template) != 0) { // return: // -1 出错 // 0 没有发生宏替换 // 1 发生了宏替换 int nRet = Map856u(u, strRecPath, maps_container, // parameters, style, out u_list, // strUri, out string strError); //if (nRet == -1) // strUri = "!error:" + strError; if (nRet == -1) { u_list.Add(new Map856uResult { Result = "!error: 对 858$u 内容 '" + u + "' 进行映射变换时出错: " + strError }); } } else { u_list.Add(new Map856uResult { Result = u }); // WrapUrl == true ? } } foreach (Map856uResult result in u_list) { string strUri = MakeObjectUrl(strRecPath, result.Result); Hashtable parameters = result.Parameters; string strSaveAs = ""; if (string.IsNullOrEmpty(s_q) == true // || StringUtil.MatchMIME(s_q, "text") == true || StringUtil.MatchMIME(s_q, "image") == true) { } else { strSaveAs = "&saveas=true"; } string strHitCountImage = ""; string strObjectUrl = strUri; string strPdfUrl = ""; string strThumbnailUrl = ""; if (result.WrapUrl == true) { if (StringUtil.IsHttpUrl(strUri) == false) { // 内部对象 strObjectUrl = "./getobject.aspx?uri=" + HttpUtility.UrlEncode(strUri) + strSaveAs; strHitCountImage = "<img src='" + strObjectUrl + "&style=hitcount' alt='hitcount'></img>"; if (s_q == "application/pdf") { strPdfUrl = "./viewpdf.aspx?uri=" + HttpUtility.UrlEncode(strUri); strThumbnailUrl = "./getobject.aspx?uri=" + HttpUtility.UrlEncode(strUri + "/page:1,format=jpeg,dpi:24"); } } else { // http: 或 https: 的情形,即外部 URL if ((style & BuildObjectHtmlTableStyle.HttpUrlHitCount) != 0) { strObjectUrl = "./getobject.aspx?uri=" + HttpUtility.UrlEncode(strUri) + strSaveAs + "&biblioRecPath=" + HttpUtility.UrlEncode(strRecPath); strHitCountImage = "<img src='" + strObjectUrl + "&style=hitcount&biblioRecPath=" + HttpUtility.UrlEncode(strRecPath) + "' alt='hitcount'></img>"; } } } else { strObjectUrl = strUri; strHitCountImage = ""; } string linkText = ""; if (strMarcSyntax == "unimarc") { linkText = field.select("subfield[@name='2']").FirstContent; } else { linkText = field.select("subfield[@name='y']").FirstContent; } string f = field.select("subfield[@name='f']").FirstContent; string urlLabel = ""; if (string.IsNullOrEmpty(linkText) == false) { urlLabel = linkText; } else { urlLabel = f; } if (string.IsNullOrEmpty(urlLabel) == true) { urlLabel = strType; } // 2015/11/26 string s_z = field.select("subfield[@name='z']").FirstContent; if (string.IsNullOrEmpty(urlLabel) == true && string.IsNullOrEmpty(s_z) == false) { urlLabel = s_z; s_z = ""; } if (string.IsNullOrEmpty(urlLabel) == true) { urlLabel = strObjectUrl; } // if (StringUtil.StartsWith(strUri, "!error:")) { urlLabel += strUri; } // 2018/11/5 urlLabel = Map856uResult.MacroAnchorText(result.AnchorText, urlLabel); if (string.IsNullOrEmpty(strPdfUrl) == false && string.IsNullOrEmpty(urlLabel) == false) { strPdfUrl += "&title=" + HttpUtility.UrlEncode(urlLabel); } string urlTemp = ""; if (String.IsNullOrEmpty(strObjectUrl) == false) { string strParameters = ""; if (parameters != null) { foreach (string name in parameters.Keys) { strParameters += HttpUtility.HtmlAttributeEncode(name) + "='" + HttpUtility.HtmlAttributeEncode(parameters[name] as string) + "' "; // 注意,内容里面是否有单引号? } } urlTemp += "<a class='link' href='" + strObjectUrl + "' " + strParameters.Trim() + " >"; urlTemp += HttpUtility.HtmlEncode( (string.IsNullOrEmpty(strSaveAs) == false ? "下载 " : "") + urlLabel); urlTemp += "</a>"; if (string.IsNullOrEmpty(strPdfUrl) == false) { #if NO // 预览 按钮 urlTemp += "<br/><a href='" + strPdfUrl + "' target='_blank'>"; urlTemp += HttpUtility.HtmlEncode("预览 " + urlLabel); urlTemp += "</a>"; #endif // 缩略图 点按和预览按钮效果相同 urlTemp += "<br/><a class='thumbnail' href='" + strPdfUrl + "' target='_blank' alt='" + HttpUtility.HtmlEncode("在线阅读 " + urlLabel) + "'>"; urlTemp += "<img src='" + strThumbnailUrl + "' alt='" + HttpUtility.HtmlEncode("在线阅读 " + urlLabel) + "'></img>"; urlTemp += "</a>"; } } else { urlTemp = urlLabel; } // Different parts of the item are electronic, using subfield $3 to indicate the part (e.g., table of contents accessible in one file and an abstract in another) // 意思就是,如果有多种部分是电子资源,用 $3 指明当前 856 针对的哪个部分。这时候有多个 856,每个 856 中的 $3 各不相同 string s_3 = field.select("subfield[@name='3']").FirstContent; string s_s = field.select("subfield[@name='s']").FirstContent; text.Append("<tr class='content'>"); text.Append("<td class='type'>" + HttpUtility.HtmlEncode(s_3 + " " + strType) + "</td>"); text.Append("<td class='hitcount' style='text-align: right;'>" + strHitCountImage + "</td>"); text.Append("<td class='link' style='word-break:break-all;'>" + urlTemp + "</td>"); text.Append("<td class='mime'>" + HttpUtility.HtmlEncode(s_q) + "</td>"); text.Append("<td class='size'>" + HttpUtility.HtmlEncode(strSize) + "</td>"); text.Append("<td class='bytes'>" + HttpUtility.HtmlEncode(s_s) + "</td>"); text.Append("</tr>"); if (string.IsNullOrEmpty(s_z) == false) { text.Append("<tr class='comment'>"); text.Append("<td colspan='6'>" + HttpUtility.HtmlEncode(s_z) + "</td>"); text.Append("</tr>"); } nCount++; } } if (nCount == 0) { return(""); } text.Append("</table>"); return(text.ToString()); }
string[] FillListViewItem(LibraryChannel channel, Record record) { string strErrorInfo = ""; string strError = ""; string[] cols = new string[11]; long lRet = 0; string strXML = record.RecordBody.Xml; XmlDocument dom = new XmlDocument(); dom.LoadXml(strXML); string strState = DomUtil.GetElementText(dom.DocumentElement, "state"); if ("arrived" == strState) { strState = "图书在馆"; } else if ("outof" == strState) { strState = "超过保留期"; } string strLocation = DomUtil.GetElementText(dom.DocumentElement, "location"); string strAccessNo = DomUtil.GetElementText(dom.DocumentElement, "accessNo"); string strItemBarcode = DomUtil.GetElementText(dom.DocumentElement, "itemBarcode"); if (!string.IsNullOrEmpty(strItemBarcode)) { GetItemInfoResponse itemInfoResponse = channel.GetItemInfo(strItemBarcode, "xml", // "xml:noborrowhistory", // resultType (itemType) "xml"); lRet = itemInfoResponse.GetItemInfoResult.Value; strErrorInfo = itemInfoResponse.GetItemInfoResult.ErrorInfo; if (lRet == 1) { string strOutMarcSyntax = ""; string strMARC = ""; string strMarcXml = itemInfoResponse.strBiblio; int nRet = MarcUtil.Xml2Marc(strMarcXml, false, "", // 自动识别 MARC 格式 out strOutMarcSyntax, out strMARC, out strError); if (nRet != -1) { MarcRecord marcRecord = new MarcRecord(strMARC); string strISBN = marcRecord.select("field[@name='010']/subfield[@name='a']").FirstContent; string strTitle = marcRecord.select("field[@name='200']/subfield[@name='a']").FirstContent; string strAuthor = marcRecord.select("field[@name='200']/subfield[@name='f']").FirstContent; cols[1] = strISBN; cols[2] = strTitle; cols[3] = strAuthor; } } } string strReaderBarcode = DomUtil.GetElementText(dom.DocumentElement, "readerBarcode"); GetReaderInfoResponse readerInfoResponse = channel.GetReaderInfo(strReaderBarcode, "xml:noborrowhistory"); lRet = readerInfoResponse.GetReaderInfoResult.Value; strErrorInfo = readerInfoResponse.GetReaderInfoResult.ErrorInfo; if (lRet == 1) { string strReaderXml = readerInfoResponse.results[0]; dom.LoadXml(strReaderXml); string strName = DomUtil.GetElementText(dom.DocumentElement, "name"); string strDept = DomUtil.GetElementText(dom.DocumentElement, "department"); cols[6] = strReaderBarcode; cols[7] = strName; cols[8] = strDept; } cols[0] = strItemBarcode; cols[4] = strAccessNo; cols[5] = strLocation; cols[9] = strState; cols[10] = "未打印"; return(cols); }
private void button_search_Click(object sender, EventArgs e) { string strError = ""; this.listView_results.Items.Clear(); MainForm mainForm = null; if (this.MdiParent is MainForm) { mainForm = this.MdiParent as MainForm; } Debug.Assert(mainForm != null, "MdiParent 父窗口为 null"); mainForm.SetMessage(""); string strQueryWord = this.textBox_queryWord.Text; string strFrom = "读者证条码号"; string strMatchStyle = "exact"; if (string.IsNullOrEmpty(strQueryWord)) { strFrom = "__id"; strMatchStyle = "left"; } string strQueryXml = "<target list='" + mainForm.ArrivedDbName + ":" + strFrom + "'>" + "<item>" + "<word>" + strQueryWord + "</word>" + "<match>" + strMatchStyle + "</match>" + "<relation>=</relation>" + "<dataType>string</dataType>" + "</item>" + "<lang>zh</lang>" + "</target>"; LibraryChannel channel = mainForm.GetChannel(); try { string strOutputStyle = ""; SearchResponse searchResponse = channel.Search(strQueryXml, "", strOutputStyle); long lRet = searchResponse.SearchResult.Value; if (lRet == -1) { strError = "检索发生错误:" + strError; goto ERROR1; } else if (lRet == 0) { strError = "读者'" + strQueryWord + "'没有到书信息"; goto ERROR1; } long lHitCount = lRet; long lStart = 0; long lCount = lHitCount; Record[] searchresults = null; for (; ;) { Application.DoEvents(); lRet = channel.GetSearchResult("", lStart, lCount, "id,xml",// cols, "zh", out searchresults, out strError); if (lRet == -1) { strError = "获得检索结果发生错误:" + strError; goto ERROR1; } else if (lRet == 0) { strError = "没有获得到 0 条检索结果"; goto ERROR1; } int i = 0; foreach (Record record in searchresults) { // string[] cols = record.Cols; string strPath = record.Path; string strXML = record.RecordBody.Xml; XmlDocument dom = new XmlDocument(); dom.LoadXml(strXML); string strState = DomUtil.GetElementText(dom.DocumentElement, "state"); if ("arrived" == strState) { strState = "图书在馆"; } else if ("outof" == strState) { strState = "超过保留期"; } string strLocation = DomUtil.GetElementText(dom.DocumentElement, "location"); string strAccessNo = DomUtil.GetElementText(dom.DocumentElement, "accessNo"); string strItemBarcode = DomUtil.GetElementText(dom.DocumentElement, "itemBarcode"); if (string.IsNullOrEmpty(strItemBarcode)) { continue; } GetItemInfoResponse itemInfoResponse = channel.GetItemInfo(strItemBarcode, "xml", // "xml:noborrowhistory", // resultType (itemType) "xml" // biblioType ); lRet = itemInfoResponse.GetItemInfoResult.Value; string strErrorInfo = itemInfoResponse.GetItemInfoResult.ErrorInfo; if (lRet != 1) { MessageBox.Show(strErrorInfo); continue; } string strOutMarcSyntax = ""; string strMARC = ""; string strMarcXml = itemInfoResponse.strBiblio; int nRet = MarcUtil.Xml2Marc(strMarcXml, false, "", // 自动识别 MARC 格式 out strOutMarcSyntax, out strMARC, out strError); if (nRet == -1) { continue; } MarcRecord marcRecord = new MarcRecord(strMARC); string strISBN = marcRecord.select("field[@name='010']/subfield[@name='a']").FirstContent; string strTitle = marcRecord.select("field[@name='200']/subfield[@name='a']").FirstContent; string strAuthor = marcRecord.select("field[@name='200']/subfield[@name='f']").FirstContent; string strReaderBarcode = DomUtil.GetElementText(dom.DocumentElement, "readerBarcode"); GetReaderInfoResponse readerInfoResponse = channel.GetReaderInfo(strReaderBarcode, "xml:noborrowhistory"); lRet = readerInfoResponse.GetReaderInfoResult.Value; strErrorInfo = readerInfoResponse.GetReaderInfoResult.ErrorInfo; if (lRet != 1) { MessageBox.Show(strErrorInfo); continue; } string strReaderXml = readerInfoResponse.results[0]; dom.LoadXml(strReaderXml); string strName = DomUtil.GetElementText(dom.DocumentElement, "name"); string strDept = DomUtil.GetElementText(dom.DocumentElement, "department"); // MessageBox.Show(strXML); string[] cols = new string[this.listView_results.Columns.Count]; cols[0] = strItemBarcode; cols[1] = strISBN; cols[2] = strTitle; cols[3] = strAuthor; cols[4] = strAccessNo; cols[5] = strLocation; cols[6] = strReaderBarcode; cols[7] = strName; cols[8] = strDept; cols[9] = strState; cols[10] = "未打印"; AppendNewLine(this.listView_results, strPath, cols); mainForm.SetMessage((lStart + i + 1).ToString() + " / " + lHitCount); i++; } lStart += searchresults.Length; lCount -= searchresults.Length; if (lStart >= lHitCount || lCount <= 0) { break; } } // this.listView_results.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); } finally { mainForm.ReturnChannel(channel); } return; ERROR1: MessageBox.Show(strError); }
// 构建集合对象 // parameters: // strDef 定义字符串。分为若干行,每行定义一个对照关系。行之间用分号间隔。 // 行格式为 dbname=数据库名,source=源字段名子字段名,target=目标字段名子字段名,color=#000000 public int Build(string strMARC, string strDef, out string strError) { strError = ""; this.MARC = strMARC; MarcRecord record = new MarcRecord(strMARC); string[] lines = strDef.Split(new char[] { ';' }); foreach (string line in lines) { Hashtable table = StringUtil.ParseParameters(line, ',', '='); string strDbName = (string)table["dbname"]; string strSource = (string)table["source"]; string strTarget = (string)table["target"]; string strColor = (string)table["color"]; if (string.IsNullOrEmpty(strSource) == true || strSource.Length != 4) { strError = "行 '" + line + "' 中 source 参数值 '" + strSource + "' 格式错误,应为 4 字符"; return(-1); } if (string.IsNullOrEmpty(strTarget) == true || strTarget.Length != 4) { strError = "行 '" + line + "' 中 target 参数值 '" + strTarget + "' 格式错误,应为 4 字符"; return(-1); } string fieldname = strSource.Substring(0, 3); string subfieldname = strSource.Substring(3, 1); MarcNodeList subfields = record.select("field[@name='" + fieldname + "']/subfield[@name='" + subfieldname + "']"); if (subfields.count == 0) { continue; } List <string> keys = new List <string>(); foreach (MarcSubfield subfield in subfields) { if (string.IsNullOrEmpty(subfield.Content) == true) { continue; } keys.Add(subfield.Content); } if (keys.Count == 0) { continue; } Relation relation = new Relation(strDbName, strSource, strTarget, keys, strColor); this._collection.Add(relation); } return(0); }
// TODO: 实现简略格式和详细格式提供。简略格式可以理解为略去一些分类号主题词字段,最好用一段用户定制的脚本来进行过滤 // 获得MARC记录 // parameters: // elementSetNames 元素集列表。每个元素集为 'B' 或 'F',表示简略和详细格式 // bAddField901 是否加入901字段? // return: // -1 error // 0 not found // 1 found static int GetIso2709Record( DigitalPlatform.LibraryClient.localhost.Record dp2library_record, List <string> elementSetNames, bool bAddField901, string strRemoveFields, Encoding marcRecordEncoding, out string strMarcSyntaxOID, out byte[] baIso2709, out string strError) { baIso2709 = null; strError = ""; strMarcSyntaxOID = ""; // 转换为机内格式 int nRet = MarcUtil.Xml2Marc(dp2library_record.RecordBody.Xml, true, "", out string strMarcSyntax, out string strMarc, out strError); if (nRet == -1) { strError = "XML转换到MARC记录时出错: " + strError; return(-1); } // 去掉记录中的 997/998 MarcRecord record = new MarcRecord(strMarc); if (string.IsNullOrEmpty(strRemoveFields) == false) { List <string> field_names = StringUtil.SplitList(strRemoveFields); foreach (string field_name in field_names) { if (field_name.Length != 3) { strError = "removeFields 定义里面出现了不是 3 字符的字段名('" + strRemoveFields + "')"; return(-1); } record.select("field[@name='" + field_name + "']").detach(); } } if (bAddField901 == true) { // 901 $p记录路径$t时间戳 string strContent = "$p" + dp2library_record.Path + "$t" + ByteArray.GetHexTimeStampString(dp2library_record.RecordBody.Timestamp); record.setFirstField("901", " ", strContent.Replace("$", MarcQuery.SUBFLD), " "); } strMarc = record.Text; // 转换为ISO2709 nRet = MarcUtil.CvtJineiToISO2709( strMarc, strMarcSyntax, marcRecordEncoding, out baIso2709, out strError); if (nRet == -1) { return(-1); } if (strMarcSyntax == "unimarc") { strMarcSyntaxOID = "1.2.840.10003.5.1"; } if (strMarcSyntax == "usmarc") { strMarcSyntaxOID = "1.2.840.10003.5.10"; } return(1); }
// 创建 table 中的对象资源局部 XML。这是一个 <table> 片段 // 前导语 $3 // 链接文字 $y $f // URL $u // 格式类型 $q // 对象ID $8 // 对象尺寸 $s // 公开注释 $z public static string BuildObjectXmlTable(string strMARC, // string strRecPath, BuildObjectHtmlTableStyle style = BuildObjectHtmlTableStyle.None, string strMarcSyntax = "unimarc", string strRecPath = null, XmlElement maps_container = null) { // Debug.Assert(false, ""); MarcRecord record = new MarcRecord(strMARC); MarcNodeList fields = record.select("field[@name='856']"); if (fields.count == 0) { return(""); } XmlDocument dom = new XmlDocument(); dom.LoadXml("<table/>"); int nCount = 0; foreach (MarcField field in fields) { string x = field.select("subfield[@name='x']").FirstContent; Hashtable table = StringUtil.ParseParameters(x, ';', ':'); string strType = (string)table["type"]; if (strType == null) { strType = ""; } if (string.IsNullOrEmpty(strType) == false && (style & BuildObjectHtmlTableStyle.FrontCover) == 0 && (strType == "FrontCover" || StringUtil.StartsWith(strType, "FrontCover.") == true)) { continue; } string strSize = (string)table["size"]; string s_q = field.select("subfield[@name='q']").FirstContent; // 注意, FirstContent 可能会返回 null List <Map856uResult> u_list = new List <Map856uResult>(); { string u = field.select("subfield[@name='u']").FirstContent; // 2018/10/24 // Hashtable parameters = new Hashtable(); if (maps_container != null && (style & BuildObjectHtmlTableStyle.Template) != 0) { // string strUri = MakeObjectUrl(strRecPath, u); // return: // -1 出错 // 0 没有发生宏替换 // 1 发生了宏替换 int nRet = Map856u(u, strRecPath, maps_container, style, // parameters, out u_list, out string strError); if (nRet == -1) { u_list.Add(new Map856uResult { Result = "!error: 对 858$u 内容 '" + u + "' 进行映射变换时出错: " + strError }); } } else { u_list.Add(new Map856uResult { Result = u }); // WrapUrl == true ? } } string strSaveAs = ""; if (string.IsNullOrEmpty(s_q) == true || // 2016/9/4 StringUtil.MatchMIME(s_q, "text") == true || StringUtil.MatchMIME(s_q, "image") == true) { } else { strSaveAs = "true"; } #if NO string y = field.select("subfield[@name='y']").FirstContent; string f = field.select("subfield[@name='f']").FirstContent; string urlLabel = ""; if (string.IsNullOrEmpty(y) == false) { urlLabel = y; } else { urlLabel = f; } if (string.IsNullOrEmpty(urlLabel) == true) { urlLabel = strType; } #endif string linkText = ""; if (strMarcSyntax == "unimarc") { linkText = field.select("subfield[@name='2']").FirstContent; } else { linkText = field.select("subfield[@name='y']").FirstContent; } string f = field.select("subfield[@name='f']").FirstContent; string urlLabel = ""; if (string.IsNullOrEmpty(linkText) == false) { urlLabel = linkText; } else { urlLabel = f; } if (string.IsNullOrEmpty(urlLabel) == true) { urlLabel = strType; } // 2015/11/26 string s_z = field.select("subfield[@name='z']").FirstContent; if (string.IsNullOrEmpty(urlLabel) == true && string.IsNullOrEmpty(s_z) == false) { urlLabel = s_z; s_z = ""; } #if NO string urlTemp = ""; if (String.IsNullOrEmpty(strObjectUrl) == false) { urlTemp += "<a href='" + strObjectUrl + "'>"; urlTemp += urlLabel; urlTemp += "</a>"; } else { urlTemp = urlLabel; } #endif string s_3 = field.select("subfield[@name='3']").FirstContent; string s_s = field.select("subfield[@name='s']").FirstContent; foreach (Map856uResult u in u_list) { XmlElement line = dom.CreateElement("line"); dom.DocumentElement.AppendChild(line); string strTypeString = (s_3 + " " + strType).Trim(); if (string.IsNullOrEmpty(strTypeString) == false) { line.SetAttribute("type", strTypeString); } string currentUrlLabel = urlLabel; if (string.IsNullOrEmpty(currentUrlLabel) == true) { if (u.AnchorText != null) { currentUrlLabel = Map856uResult.MacroAnchorText(u.AnchorText, currentUrlLabel); } else { currentUrlLabel = u.Result; } } else { if (u.AnchorText != null) { currentUrlLabel = Map856uResult.MacroAnchorText(u.AnchorText, urlLabel); } } if (string.IsNullOrEmpty(currentUrlLabel) == false) { line.SetAttribute("urlLabel", currentUrlLabel); } if (string.IsNullOrEmpty(u.Result) == false) { line.SetAttribute("uri", u.Result); } if (u.Parameters != null && u.Parameters.Count > 0) { line.SetAttribute("uriEnv", StringUtil.BuildParameterString(u.Parameters, ',', '=', "url")); } if (string.IsNullOrEmpty(s_q) == false) { line.SetAttribute("mime", s_q); } if (string.IsNullOrEmpty(strSize) == false) { line.SetAttribute("size", strSize); } if (string.IsNullOrEmpty(s_s) == false) { line.SetAttribute("bytes", s_s); } if (string.IsNullOrEmpty(strSaveAs) == false) { line.SetAttribute("saveAs", strSaveAs); } if (string.IsNullOrEmpty(s_z) == false) { line.SetAttribute("comment", s_z); } nCount++; } } if (nCount == 0) { return(""); } return(dom.DocumentElement.OuterXml); }
public static int ScriptMarc21( string strRecPath, string strMARC, out List <NameValueLine> results, out string strError) { strError = ""; results = new List <NameValueLine>(); MarcRecord record = new MarcRecord(strMARC); if (record.ChildNodes.count == 0) { return(0); } string strImageUrl = ScriptUtil.GetCoverImageUrl(strMARC, "LargeImage"); // LargeImage if (string.IsNullOrEmpty(strImageUrl) == false) { results.Add(new NameValueLine("_coverImage", strImageUrl)); } // LC control no. MarcNodeList nodes = record.select("field[@name='010']/subfield[@name='a']"); if (nodes.count > 0) { results.Add(new NameValueLine("LC control no.", nodes[0].Content.Trim())); } // Type of material results.Add(new NameValueLine("Type of material", GetMaterialType(record))); // Personal name MarcNodeList fields = record.select("field[@name='100']"); foreach (MarcNode field in fields) { nodes = field.select("subfield"); if (nodes.count > 0) { results.Add(new NameValueLine("Personal name", ConcatSubfields(nodes), "author")); } } // Corporate name fields = record.select("field[@name='110']"); if (fields.count > 0) { results.Add(new NameValueLine("Corporate name", BuildFields(fields))); } // Uniform title fields = record.select("field[@name='240']"); if (fields.count > 0) { results.Add(new NameValueLine("Uniform title", BuildFields(fields))); } // Main title fields = record.select("field[@name='245']"); if (fields.count > 0) { results.Add(new NameValueLine("Main title", BuildFields(fields), "title")); } #if NO foreach (MarcNode field in fields) { nodes = field.select("subfield"); if (nodes.count > 0) { results.Add(new OneLine("Main title", ConcatSubfields(nodes))); } } #endif // Portion of title fields = record.select("field[@name='246' and @indicator2='0']"); if (fields.count > 0) { results.Add(new NameValueLine("Portion of title", BuildFields(fields))); } // Spine title fields = record.select("field[@name='246' and @indicator2='8']"); if (fields.count > 0) { results.Add(new NameValueLine("Spine title", BuildFields(fields))); } // Edition fields = record.select("field[@name='250']"); if (fields.count > 0) { results.Add(new NameValueLine("Edition", BuildFields(fields))); } // Published/Created fields = record.select("field[@name='260']"); foreach (MarcNode field in fields) { nodes = field.select("subfield"); if (nodes.count > 0) { results.Add(new NameValueLine("Published / Created", ConcatSubfields(nodes), "publisher")); // 附加的空格便于在 HTML 中自然折行 } } // Related names fields = record.select("field[@name='700' or @name='710' or @name='711']"); if (fields.count > 0) { results.Add(new NameValueLine("Related names", BuildFields(fields))); } // Related titles fields = record.select("field[@name='730' or @name='740']"); if (fields.count > 0) { results.Add(new NameValueLine("Related titles", BuildFields(fields))); } // Description fields = record.select("field[@name='300' or @name='362']"); if (fields.count > 0) { results.Add(new NameValueLine("Description", BuildFields(fields))); } // ISBN fields = record.select("field[@name='020']"); if (fields.count > 0) { results.Add(new NameValueLine("ISBN", BuildFields(fields), "isbn")); } // Current frequency fields = record.select("field[@name='310']"); if (fields.count > 0) { results.Add(new NameValueLine("Current frequency", BuildFields(fields))); } // Former title fields = record.select("field[@name='247']"); if (fields.count > 0) { results.Add(new NameValueLine("Former title", BuildFields(fields))); } // Former frequency fields = record.select("field[@name='321']"); if (fields.count > 0) { results.Add(new NameValueLine("Former frequency", BuildFields(fields))); } // Continues fields = record.select("field[@name='780']"); if (fields.count > 0) { results.Add(new NameValueLine("Continues", BuildFields(fields))); } // ISSN MarcNodeList subfields = record.select("field[@name='022']/subfield[@name='a']"); if (subfields.count > 0) { results.Add(new NameValueLine("ISSN", ConcatSubfields(subfields), "issn")); } // Linking ISSN subfields = record.select("field[@name='022']/subfield[@name='l']"); if (subfields.count > 0) { results.Add(new NameValueLine("Linking ISSN", ConcatSubfields(subfields))); } // Invalid LCCN subfields = record.select("field[@name='010']/subfield[@name='z']"); if (subfields.count > 0) { results.Add(new NameValueLine("Invalid LCCN", ConcatSubfields(subfields))); } // Contents fields = record.select("field[@name='505' and @indicator1='0']"); if (fields.count > 0) { results.Add(new NameValueLine("Contents", BuildFields(fields))); } // Partial contents fields = record.select("field[@name='505' and @indicator1='2']"); if (fields.count > 0) { results.Add(new NameValueLine("Partial contents", BuildFields(fields))); } // Computer file info fields = record.select("field[@name='538']"); if (fields.count > 0) { results.Add(new NameValueLine("Computer file info", BuildFields(fields))); } // Notes fields = record.select("field[@name='500' or @name='501' or @name='504' or @name='561' or @name='583' or @name='588' or @name='590']"); if (fields.count > 0) { results.Add(new NameValueLine("Notes", BuildFields(fields))); } // References fields = record.select("field[@name='510']"); if (fields.count > 0) { results.Add(new NameValueLine("References", BuildFields(fields))); } // Additional formats fields = record.select("field[@name='530' or @name='533' or @name='776']"); if (fields.count > 0) { results.Add(new NameValueLine("Additional formats", BuildFields(fields))); } // Subjects fields = record.select("field[@name='600' or @name='610' or @name='630' or @name='650' or @name='651']"); if (fields.count > 0) { results.Add(new NameValueLine("Subjects", BuildSubjects(fields))); } // Form/Genre fields = record.select("field[@name='655']"); if (fields.count > 0) { results.Add(new NameValueLine("Form/Genre", BuildSubjects(fields))); } // Series fields = record.select("field[@name='440' or @name='490' or @name='830']"); if (fields.count > 0) { results.Add(new NameValueLine("Series", BuildFields(fields))); } // LC classification fields = record.select("field[@name='050']"); if (fields.count > 0) { results.Add(new NameValueLine("LC classification", BuildFields(fields))); } #if NO foreach (MarcNode field in fields) { nodes = field.select("subfield"); if (nodes.count > 0) { results.Add(new OneLine("LC classification", ConcatSubfields(nodes))); } } #endif // NLM class no. fields = record.select("field[@name='060']"); if (fields.count > 0) { results.Add(new NameValueLine("NLM class no.", BuildFields(fields))); } // Dewey class no. // 不要 $2 fields = record.select("field[@name='082']"); if (fields.count > 0) { results.Add(new NameValueLine("Dewey class no.", BuildFields(fields, "a"))); } // NAL class no. fields = record.select("field[@name='070']"); if (fields.count > 0) { results.Add(new NameValueLine("NAL class no.", BuildFields(fields))); } // National bib no. fields = record.select("field[@name='015']"); if (fields.count > 0) { results.Add(new NameValueLine("National bib no.", BuildFields(fields, "a"))); } // National bib agency no. fields = record.select("field[@name='016']"); if (fields.count > 0) { results.Add(new NameValueLine("National bib agency no.", BuildFields(fields, "a"))); } // LC copy fields = record.select("field[@name='051']"); if (fields.count > 0) { results.Add(new NameValueLine("LC copy", BuildFields(fields))); } // Other system no. fields = record.select("field[@name='035'][subfield[@name='a']]"); if (fields.count > 0) { results.Add(new NameValueLine("Other system no.", BuildFields(fields, "a"))); } #if NO fields = record.select("field[@name='035']"); foreach (MarcNode field in fields) { nodes = field.select("subfield[@name='a']"); if (nodes.count > 0) { results.Add(new OneLine("Other system no.", ConcatSubfields(nodes))); } } #endif // Reproduction no./Source fields = record.select("field[@name='037']"); if (fields.count > 0) { results.Add(new NameValueLine("Reproduction no./Source", BuildFields(fields))); } // Geographic area code fields = record.select("field[@name='043']"); if (fields.count > 0) { results.Add(new NameValueLine("Geographic area code", BuildFields(fields))); } // Quality code fields = record.select("field[@name='042']"); if (fields.count > 0) { results.Add(new NameValueLine("Quality code", BuildFields(fields))); } /* * // Links * fields = record.select("field[@name='856'or @name='859']"); * if (fields.count > 0) * { * results.Add(new NameValueLine("Links", BuildLinks(fields))); * } * */ // Content type fields = record.select("field[@name='336']"); if (fields.count > 0) { results.Add(new NameValueLine("Content type", BuildFields(fields, "a"))); } // Media type fields = record.select("field[@name='337']"); if (fields.count > 0) { results.Add(new NameValueLine("Media type", BuildFields(fields, "a"))); } // Carrier type fields = record.select("field[@name='338']"); if (fields.count > 0) { results.Add(new NameValueLine("Carrier type", BuildFields(fields, "a"))); } fields = record.select("field[@name='856' or @name='859']"); if (fields.count > 0) { string strXml = ScriptUtil.BuildObjectXmlTable(strMARC); if (string.IsNullOrEmpty(strXml) == false) { var line = new NameValueLine("Digital Resource", "", "object"); line.Xml = strXml; results.Add(line); } } return(0); }