Exemple #1
0
        /// <summary>
        /// 由xml格式的marc生成record对象,marc的xml格式方案来自于TopEnginge
        /// </summary>
        /// <param name="xmlMarc"></param>
        /// <returns></returns>
        public static MarcRecord LoadFromXMlString(string xmlMarc)
        {
            XElement xe = XElement.Parse(xmlMarc);

            string strldr = xe.Element("header").Value;
            LDR ldr = new LDR(strldr);

            MarcRecord record = new MarcRecord(ldr);

            foreach(XElement fldxml in xe.Elements("field"))
            {
                Field fld;

                string tag = fldxml.Attribute("name").Value;

                if (tag.Equals("-01") || tag.Equals("001") || tag.Equals("005"))
                {
                    fld = new ControlField(tag, fldxml.Value);
                }
                else
                {
                    fld = new DataField(tag);

                    string indicator = fldxml.Attribute("indicator") == null ? string.Empty : fldxml.Attribute("indicator").Value;

                    foreach (XElement sfxml in fldxml.Elements("sf"))
                    {

                        ((DataField)fld).AddSubField(sfxml.Attribute("name").Value[0], sfxml.Value);
                    }

                }

                record.AddField(fld);
            }

            return record;
        }
Exemple #2
0
        /// <summary>
        /// 生成新的Marc的record记录
        /// </summary>
        /// <param name="newLDR"></param>
        /// <returns></returns>
        public static MarcRecord NewRecord(string newLDR)
        {
            if (string.IsNullOrEmpty(newLDR))
                return null;
            if (newLDR.Length < LDR.LDRLength)
                return null;

            LDR ldr = new LDR(newLDR);
            MarcRecord record = new MarcRecord(ldr);

            return record;
        }
Exemple #3
0
        /// <summary>
        /// 由标准marc生成record对象
        /// </summary>
        /// <param name="strMarc"></param>
        /// <returns></returns>
        public static MarcRecord LoadFromString(string strMarc)
        {
            if (string.IsNullOrEmpty(strMarc))
                return null;
            if (strMarc.Length < LDR.LDRLength)
                return null;
            //if (!strMarc.EndsWith(RecordEnd.ToString()))
            //    return null;

            MarcRecord record = new MarcRecord(strMarc);

            return record;
        }