コード例 #1
0
ファイル: MarcNodeList.cs プロジェクト: yinjuan1123/chord
        // 在当前集合中每个元素的DOM位置 下级末尾 插入新元素
        // 参见 MarcQuery::append() 函数的注释
        // 最后返回当前集合
        /// <summary>
        /// 在当前集合中每个元素的 DOM 位置的下级末尾 追加根据源字符串构造的新元素
        /// </summary>
        /// <param name="strSourceText">源字符串</param>
        /// <returns>当前集合</returns>
        public MarcNodeList append(string strSourceText)
        {
            if (this.count == 0 || string.IsNullOrEmpty(strSourceText))
            {
                return(this);
            }

            if (this[0].NodeType == NodeType.None)
            {
                throw new ArgumentException("不允许在 None 节点的 下级末尾 添加任何节点");
            }
            if (this[0].NodeType == NodeType.Subfield)
            {
                throw new ArgumentException("不允许在 子字段 节点的 下级末尾添加任何节点。因为子字段本身就是末级节点,不允许出现下级节点");
            }

            MarcNodeList source_nodes = null;
            string       strLeading   = "";

            if (this[0].NodeType == NodeType.Record)
            {
                source_nodes = MarcQuery.createFields(strSourceText);
            }
            else if (this[0].NodeType == NodeType.Field)
            {
                source_nodes = MarcQuery.createSubfields(strSourceText, out strLeading);
                // leading要追加到目标集合的最后一个元素的Content末尾
                if (string.IsNullOrEmpty(strLeading) == false)
                {
                    this.last()[0].Content += strLeading;
                }
            }
            else
            {
                throw new Exception("未知的对象类型 '" + this[0].NodeType.ToString() + "'");
            }

            MarcQuery.append(source_nodes, this);
            return(this);
        }
コード例 #2
0
ファイル: MarcNodeList.cs プロジェクト: yinjuan1123/chord
 /// <summary>
 /// 将当前集合内的每个元素追加到指定的目标集合的 DOM 位置下级末尾
 /// </summary>
 /// <param name="target_nodes">目标集合</param>
 /// <returns>当前集合</returns>
 public MarcNodeList appendTo(MarcNodeList target_nodes)
 {
     MarcQuery.append(this, target_nodes);
     return(this);
 }
コード例 #3
0
ファイル: MarcNodeList.cs プロジェクト: yinjuan1123/chord
 // 在当前集合中每个元素的DOM位置 下级末尾 插入源集合内的元素
 // 参见 MarcQuery::append() 函数的注释
 // 最后返回当前集合
 /// <summary>
 /// 在当前集合中每个元素的 DOM 位置的下级末尾 追加来自源集合内的元素
 /// </summary>
 /// <param name="source_nodes">源集合</param>
 /// <returns>当前集合</returns>
 public MarcNodeList append(MarcNodeList source_nodes)
 {
     MarcQuery.append(source_nodes, this);
     return(this);
 }