Пример #1
0
 // 用node初始化本对象和下级
 // parameters:
 //		node	XmlNode节点
 //		allocator	对象创建器。用来构造下级元素对象
 //		style	状态,展开 收缩等 仅对ElementItem有意义
 // return:
 //		-1  出错
 //		-2  中途cancel;
 //		0   successed
 public virtual int Initial(XmlNode node,
                            ItemAllocator allocator,
                            object style,
                            bool bConnect)
 {
     return(0);
 }
Пример #2
0
		// 用node初始化本对象和下级
		// parameters:
		//		style	暂不使用
		// return:
		//		-1  出错
		//		-2  中途cancel
		//		0   成功
		public override int Initial(XmlNode node, 
			ItemAllocator allocator,
			object style,
            bool bConnect)
		{
			// 初始化数据,从node中获取
			this.InitialData(node);

			// 搞清楚是不是namespace类型节点
			string strName = node.Name;
			if (strName.Length >= 5)
			{
				if (strName.Substring(0,5) == "xmlns")	// 大小写敏感
				{
					if (strName.Length == 5)	// 特殊属性,定义了无前缀字符串的名字空间
					{
						this.IsNamespace = true;
						this.Prefix = "xmlns";
						this.LocalName = "";

						// 如果要和.net dom兼容的话
						//this.Prefix = "";	// 本应是"xmlns",但是.net的dom为"";
						//this.LocalName = "xmlns";	// 本应是"",但是.net的dom为"xmlns";
					}
					else if (strName[5] == ':')	// 特殊属性,定义了有前缀字符串的名字空间
					{
						this.IsNamespace = true;
						this.Prefix = "xmlns";
						this.LocalName = strName.Substring(6);
						if (this.LocalName == "")
						{
							throw(new Exception("冒号后面应还有内容"));
							// return -1;
						}
					}
					else // 普通属性
					{
						this.IsNamespace = false;
					}
				}
			}

			// 处理普通属性
			if (this.IsNamespace == false)
			{
				int nRet = strName.IndexOf(":");
				if (nRet == -1) 
				{
					this.Prefix = "";
					this.LocalName = strName;
				}
				else 
				{
					this.Prefix = strName.Substring(0, nRet);
					this.LocalName = strName.Substring(nRet + 1);
				}
			}

			return 0;
		}
Пример #3
0
        // parameters:
        //		style	Ôݲ»Ê¹ÓÃ.
        public override int Initial(XmlNode node,
                                    ItemAllocator allocator,
                                    object style,
                                    bool bConnect)
        {
            this.Name = node.Name;
            this.SetValue(((XmlDocumentType)node).InternalSubset);

            return(0);
        }
Пример #4
0
		// parameters:
		//		style	Ôݲ»Ê¹ÓÃ.
		public override int Initial(XmlNode node, 
			ItemAllocator allocator,
			object style,
            bool bConnect)
		{
			this.Name = node.Name;
			this.SetValue(((XmlDocumentType)node).InternalSubset);

			return 0;
		}
Пример #5
0
		// parameters:
		//		style	Ôݲ»Ê¹ÓÃ.
		public override int Initial(XmlNode node, 
			ItemAllocator allocator,
            object style,
            bool bConnect)
		{
			this.Name = node.Name;
			this.SetValue(node.InnerText);

			//this.ReadOnly = true;

			return 0;
		}
Пример #6
0
        // parameters:
        //		style	Ôݲ»Ê¹ÓÃ.
        public override int Initial(XmlNode node,
                                    ItemAllocator allocator,
                                    object style,
                                    bool bConnect)
        {
            this.Name = node.Name;
            this.SetValue(node.InnerText);

            //this.ReadOnly = true;

            return(0);
        }
Пример #7
0
		// parameters:
		//		style	暂不使用.
		public override int Initial(XmlNode node, 
			ItemAllocator allocator,
            object style,
            bool bConnect)
		{
			this.Name = node.Name;
			if (node.Value != null)
			{
				this.SetValue(node.Value);
			}
			else
			{
				Debug.Assert(false,"node节点的Value竟然为null");
			}

			return 0;
		}
Пример #8
0
        // parameters:
        //		style	暂不使用.
        public override int Initial(XmlNode node,
                                    ItemAllocator allocator,
                                    object style,
                                    bool bConnect)
        {
            this.Name = node.Name;
            if (node.Value != null)
            {
                this.SetValue(node.Value);
            }
            else
            {
                Debug.Assert(false, "node节点的Value竟然为null");
            }

            return(0);
        }
Пример #9
0
		// 用node初始化本对象和下级
		// return:
		//		-1  出错
		//		-2  中途cancel
		//		0   成功
		public override int Initial(XmlNode node, 
			ItemAllocator allocator,
			object style,
            bool bConnect)
		{
			// this.m_bConnected = true;
            this.m_bConnected = bConnect;   // new change

			if (!(style is ElementInitialStyle))
			{
				Debug.Assert(false,"style必须为ElementInitialStyle类型");
				return -1;
			}

			if ((node.NodeType != XmlNodeType.Element)
				&& node.NodeType != XmlNodeType.Document)
			{
				Debug.Assert(false, "'" + node.NodeType.ToString() + "'不是合适的节点类型");
				return 0;
			}

			// 设状态
			this.SetStyle((ElementInitialStyle)style);

			// 参数传进的新状态
			ElementInitialStyle elementStyle = (ElementInitialStyle)style;
			ExpandStyle newAttrsExpand = elementStyle.attrsExpandStyle;
			ExpandStyle newChildExpand = elementStyle.childrenExpandStyle;

			// 初始化数据,从node中获取
			this.InitialData(node);

			// 处理属性
			if (this.m_bWantAttrsInitial == 1) 
			{
				if (node.Attributes == null
					|| node.Attributes.Count == 0)
				{
					this.m_attrsExpand = ExpandStyle.None;
					goto SKIPATTRS;
				}

				// 本次希望属性展开
				if (newAttrsExpand == ExpandStyle.Expand)
				{
					this.ClearAttrs();
					foreach(XmlNode attrXmlNode in node.Attributes )
					{
						AttrItem attr = null;

						attr = (AttrItem)allocator.newItem(attrXmlNode,
							this.m_document);
						if (attr != null) 
						{
							int nRet = attr.Initial(attrXmlNode, 
								allocator,
								null,
                                true);
							if (nRet == -1)
								return -1;

							this.AppendAttrInternal(attr,false,true);


						}

						attr.m_bConnected = true;
					}

					this.m_objAttrsTimestamp ++ ;
					this.m_attrsExpand = ExpandStyle.Expand;
				}
				else if (newAttrsExpand == ExpandStyle.Collapse)
				{
					// 注,收缩时不要把属性毁掉

					// 本次希望属性收缩
					this.m_attrsExpand = ExpandStyle.Collapse;
				}
				else
				{
					this.m_attrsExpand = ExpandStyle.None;
				}
			}

			SKIPATTRS:

				// 处理下级
				if (this.m_bWantChildInitial == 1)
				{
					if (node.ChildNodes.Count == 0)  //没有null的情况
					{
						this.m_childrenExpand = ExpandStyle.None;
						goto SKIPCHILDREN;
					}

					// 希望下级展开
					if (newChildExpand == ExpandStyle.Expand)
					{
						if (elementStyle.bReinitial == false
							|| this.m_xmlChildrenTimestamp > this.m_objChildrenTimestmap)
						{
							this.ClearChildren();

							// 处理下级
							foreach(XmlNode child in node.ChildNodes) 
							{
								Item item;
								item = allocator.newItem(child,
									this.m_document);

								if (item == null)
									continue;


								ElementInitialStyle childStyle = 
									new ElementInitialStyle();
								childStyle.attrsExpandStyle = ExpandStyle.Expand;
								childStyle.childrenExpandStyle = ExpandStyle.Expand;
								childStyle.bReinitial = false;
								int nRet = item.Initial(child,
									allocator,
									childStyle,
                                    bConnect);  // 继承外面传入的参数
								if (nRet == -2)
									return -2;
								if (nRet <= -1)
								{
									return nRet;
								}

								// 这里不在AppendChildInternal里做flush的原因是
								// Initial()阶段表示只修改的一次,不是每个元素修改父亲一次
								this.AppendChildInternal(item,false,true);

								//item.m_bConnected = true;
							}
							this.m_objChildrenTimestmap ++;
						}
						this.m_childrenExpand = ExpandStyle.Expand;
					
					}
					else if (newChildExpand == ExpandStyle.Collapse)
					{
						this.m_childrenExpand = ExpandStyle.Collapse;
					}
					else
					{
						this.m_childrenExpand = ExpandStyle.None;
					}
				}

			SKIPCHILDREN:
				/*
							// end
							ItemCreatedEventArgs args = new ItemCreatedEventArgs();
							args.item = this;
							args.bInitial = true;
							this.m_document.fireItemCreated(this,args);
				*/

				return 0;
		}
Пример #10
0
		// 用node初始化本对象和下级
		// parameters:
		//		node	XmlNode节点
		//		allocator	对象创建器。用来构造下级元素对象
		//		style	状态,展开 收缩等 仅对ElementItem有意义
		// return:
		//		-1  出错
		//		-2  中途cancel;
		//		0   successed
		public virtual int Initial(XmlNode node, 
			ItemAllocator allocator,
            object style,
            bool bConnect)
		{
			return 0;
		}
Пример #11
0
        // 用node初始化本对象和下级
        // parameters:
        //		style	暂不使用
        // return:
        //		-1  出错
        //		-2  中途cancel
        //		0   成功
        public override int Initial(XmlNode node,
                                    ItemAllocator allocator,
                                    object style,
                                    bool bConnect)
        {
            // 初始化数据,从node中获取
            this.InitialData(node);

            // 搞清楚是不是namespace类型节点
            string strName = node.Name;

            if (strName.Length >= 5)
            {
                if (strName.Substring(0, 5) == "xmlns")                 // 大小写敏感
                {
                    if (strName.Length == 5)                            // 特殊属性,定义了无前缀字符串的名字空间
                    {
                        this.IsNamespace = true;
                        this.Prefix      = "xmlns";
                        this.LocalName   = "";

                        // 如果要和.net dom兼容的话
                        //this.Prefix = "";	// 本应是"xmlns",但是.net的dom为"";
                        //this.LocalName = "xmlns";	// 本应是"",但是.net的dom为"xmlns";
                    }
                    else if (strName[5] == ':')                         // 特殊属性,定义了有前缀字符串的名字空间
                    {
                        this.IsNamespace = true;
                        this.Prefix      = "xmlns";
                        this.LocalName   = strName.Substring(6);
                        if (this.LocalName == "")
                        {
                            throw(new Exception("冒号后面应还有内容"));
                            // return -1;
                        }
                    }
                    else                     // 普通属性
                    {
                        this.IsNamespace = false;
                    }
                }
            }

            // 处理普通属性
            if (this.IsNamespace == false)
            {
                int nRet = strName.IndexOf(":");
                if (nRet == -1)
                {
                    this.Prefix    = "";
                    this.LocalName = strName;
                }
                else
                {
                    this.Prefix    = strName.Substring(0, nRet);
                    this.LocalName = strName.Substring(nRet + 1);
                }
            }

            return(0);
        }