internal virtual void AfterEvent(XmlNodeChangedEventArgs args)
 {
     if (args != null)
     {
         this.OwnerDocument.AfterEvent(args);
     }
 }
        private void AttributeChange(Object src, XmlNodeChangedEventArgs args)
        {
            XmlAttribute attribute = src as XmlAttribute;

            if(attribute.LocalName == "externalResourcesRequired")
            {
                externalResourcesRequired = null;
            }
        }
Exemplo n.º 3
0
 private void OnListChanged( object sender, XmlNodeChangedEventArgs args ) {
     if( atomized == false ) {
         this.localName = this.rootNode.Document.NameTable.Add( this.localName );
         this.namespaceURI = this.rootNode.Document.NameTable.Add( this.namespaceURI );
         this.atomized = true;
     }                
     if ( IsMatch( args.Node ) ) {
         this.changeCount++ ;
         this.curInd = -1;
         this.curElem = rootNode;
         if( args.Action == XmlNodeChangedAction.Insert )
             this.empty = false;
     }
 }
Exemplo n.º 4
0
 internal void ConcurrencyCheck(XmlNodeChangedEventArgs args){
     if( atomized == false ) {
         XmlNameTable nameTable = this.rootNode.Document.NameTable;
         this.localName = nameTable.Add( this.localName );
         this.namespaceURI = nameTable.Add( this.namespaceURI );
         this.atomized = true;
     }                
     if ( IsMatch( args.Node ) ) {
         this.changeCount++ ;
         this.curInd = -1;
         this.curElem = rootNode;
         if( args.Action == XmlNodeChangedAction.Insert )
             this.empty = false;
     }
     this.matchCount = -1;
 }
Exemplo n.º 5
0
        private void AttributeChange(Object src, XmlNodeChangedEventArgs args)
        {
            XmlAttribute attribute = src as XmlAttribute;

            if(attribute.NamespaceURI.Length == 0)
            {
                switch(attribute.LocalName)
                {
                    case "viewBox":
                        viewBox = null;
                        break;
                    case "preserveAspectRatio":
                        preserveAspectRatio = null;
                        break;
                }
            }
        }
Exemplo n.º 6
0
		private void HandleNodeChanged(object sender, XmlNodeChangedEventArgs ea)
		{
			if (ea.Action == XmlNodeChangedAction.Change && ea.NewValue == ea.OldValue)
			{
				// A void change can be ignored.
				//
				return;
			}

			if (_changedNodes == null)
				_changedNodes = new Stack();

			_changedNodes.Push(new XmlNodeTrackBack(ea));

			// Propagate changes to parent object, if set.
			//
			if (_parent != null)
				_parent.OnPropertyChanged(_propertyInfo);
		}
Exemplo n.º 7
0
 internal void ConcurrencyCheck(XmlNodeChangedEventArgs args)
 {
     if (_atomized == false)
     {
         XmlNameTable nameTable = _rootNode.Document.NameTable;
         _localName = nameTable.Add(_localName);
         _namespaceURI = nameTable.Add(_namespaceURI);
         _atomized = true;
     }
     if (IsMatch(args.Node))
     {
         _changeCount++;
         _curInd = -1;
         _curElem = _rootNode;
         if (args.Action == XmlNodeChangedAction.Insert)
             _empty = false;
     }
     _matchCount = -1;
 }
 private void OnListChanged(object sender, XmlNodeChangedEventArgs args)
 {
     lock (this)
     {
         if (this.elemList != null)
         {
             XmlElementList target = (XmlElementList) this.elemList.Target;
             if (target != null)
             {
                 target.ConcurrencyCheck(args);
             }
             else
             {
                 this.doc.NodeInserted -= this.nodeChangeHandler;
                 this.doc.NodeRemoved -= this.nodeChangeHandler;
                 this.elemList = null;
             }
         }
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Called when any attribute is changing. This is typically triggered by calls to 
        /// setAttribute() and should only be called from the CssXmlDocument.
        /// </summary>
        /// <see cref="CssXmlDocument"/>
        public virtual void AttributeChange(Object src, XmlNodeChangedEventArgs args)
        {
            // Invalidate the CSS, the cascade for the CSS heirarchy will need to be recomputed
              // We do this before and after the change because we need to invalidate the old and new locations
              CssInvalidate();

              XmlAttribute attribute = src as XmlAttribute;

              if(attribute != null)
              {
            HandleAttributeChange(attribute);
              }

              // Notify any listeners
              FireAttributeChange(src, args);
              FireParentNodeChange(src, args, false);
              FireChildNodeChange(src, args, false);

              // Invalidate the CSS, the cascade for the CSS heirarchy will need to be recomputed
              CssInvalidate();
        }
Exemplo n.º 10
0
 void OnPIChange(XmlNodeChangedEventArgs e)
 {
     XmlProcessingInstruction pi = (XmlProcessingInstruction)e.Node;
     if (pi.Name == "xml-stylesheet") {
         if (e.Action == XmlNodeChangedAction.Remove) {
             // see if there's another!
             pi = (XmlProcessingInstruction)this.doc.SelectSingleNode("processing-instruction('xml-stylesheet')");
         }
         if (pi != null) {
             this.xsltFilename = DomLoader.ParseXsltArgs(pi.Data);
         }
     }
 }
Exemplo n.º 11
0
        private void OnDocumentChanged(object sender, XmlNodeChangedEventArgs e)
        {
            // initialize t
            ModelChangeType t = ModelChangeType.NodeChanged;
            if (e.Node is XmlProcessingInstruction) {
                OnPIChange(e);
            }

            if (XmlHelpers.IsXmlnsNode(e.NewParent) || XmlHelpers.IsXmlnsNode(e.Node)) {

                // we flag a namespace change whenever an xmlns attribute changes.
                t = ModelChangeType.NamespaceChanged;
                XmlNode node = e.Node;
                if (e.Action == XmlNodeChangedAction.Remove) {
                    node = e.OldParent; // since node.OwnerElement link has been severed!
                }
                this.dirty = true;
                FireModelChanged(t, node);
            } else {
                switch (e.Action) {
                    case XmlNodeChangedAction.Change:
                        t = ModelChangeType.NodeChanged;
                        break;
                    case XmlNodeChangedAction.Insert:
                        t = ModelChangeType.NodeInserted;
                        break;
                    case XmlNodeChangedAction.Remove:
                        t = ModelChangeType.NodeRemoved;
                        break;
                }
                this.dirty = true;
                FireModelChanged(t, e.Node);
            }
        }
 public override void NodeUpdateEvent(object src, System.Xml.XmlNodeChangedEventArgs args)
 {
     //throw new NotImplementedException();
 }
Exemplo n.º 13
0
        private XmlAttribute GetAttributeFromEvent(XmlNodeChangedEventArgs e)
        {
            if ( e.Node.NodeType == XmlNodeType.Attribute )
                // node attribute direct
                return (XmlAttribute) e.Node;
            else if ( e.NewParent != null && e.NewParent.NodeType == XmlNodeType.Attribute )
                // text under node attribute
                return (XmlAttribute) e.NewParent;

            // not attribute
            return null;
        }
Exemplo n.º 14
0
        protected void NodeRemoved(object sender, XmlNodeChangedEventArgs e)
        {
            XmlAttribute attr=GetAttributeFromEvent(e);
            if ( attr != null )
            {
                if ( e.OldParent != null && XmlUtil.HasAncestor(e.OldParent, attr.OwnerDocument.DocumentElement) )
                {
                    ValidateRemovedAttribute((XmlElement) e.OldParent, attr);
                    RemoveIdOrIdRef((XmlElement) e.OldParent, attr);
                }
                return;
            }

            switch ( e.Node.NodeType )
            {
                case XmlNodeType.Element:
                case XmlNodeType.EntityReference:
                    // remove this node and any child nodes
                    RecursiveRemove(e.Node);
                    XmlElement p=e.OldParent as XmlElement;
                    if ( p == null )
                        // go up dealing with entity references
                        p=XmlUtil.GetParentNode(e.Node) as XmlElement;

                    if ( p != null )
                        Validate(p);

                    break;

                default:
                    // any other cases?
                    break;
            }
        }
Exemplo n.º 15
0
        // Adds the specified node to the end of the list of children of this node.
        public virtual XmlNode AppendChild(XmlNode newChild)
        {
            XmlDocument thisDoc = OwnerDocument;

            if (thisDoc == null)
            {
                thisDoc = this as XmlDocument;
            }
            if (!IsContainer)
            {
                throw new InvalidOperationException(SR.Xdom_Node_Insert_Contain);
            }

            if (this == newChild || AncestorNode(newChild))
            {
                throw new ArgumentException(SR.Xdom_Node_Insert_Child);
            }

            if (newChild.ParentNode != null)
            {
                newChild.ParentNode.RemoveChild(newChild);
            }

            XmlDocument childDoc = newChild.OwnerDocument;

            if (childDoc != null && childDoc != thisDoc && childDoc != this)
            {
                throw new ArgumentException(SR.Xdom_Node_Insert_Context);
            }

            // special case for doc-fragment.
            if (newChild.NodeType == XmlNodeType.DocumentFragment)
            {
                XmlNode first = newChild.FirstChild;
                XmlNode node  = first;
                while (node != null)
                {
                    XmlNode next = node.NextSibling;
                    newChild.RemoveChild(node);
                    AppendChild(node);
                    node = next;
                }
                return(first);
            }

            if (!(newChild is XmlLinkedNode) || !IsValidChildType(newChild.NodeType))
            {
                throw new InvalidOperationException(SR.Xdom_Node_Insert_TypeConflict);
            }


            if (!CanInsertAfter(newChild, LastChild))
            {
                throw new InvalidOperationException(SR.Xdom_Node_Insert_Location);
            }

            string newChildValue         = newChild.Value;
            XmlNodeChangedEventArgs args = GetEventArgs(newChild, newChild.ParentNode, this, newChildValue, newChildValue, XmlNodeChangedAction.Insert);

            if (args != null)
            {
                BeforeEvent(args);
            }

            XmlLinkedNode refNode = LastNode;
            XmlLinkedNode newNode = (XmlLinkedNode)newChild;

            if (refNode == null)
            {
                newNode.next = newNode;
                LastNode     = newNode;
                newNode.SetParent(this);
            }
            else
            {
                newNode.next = refNode.next;
                refNode.next = newNode;
                LastNode     = newNode;
                newNode.SetParent(this);

                if (refNode.IsText)
                {
                    if (newNode.IsText)
                    {
                        NestTextNodes(refNode, newNode);
                    }
                }
            }

            if (args != null)
            {
                AfterEvent(args);
            }

            return(newNode);
        }
Exemplo n.º 16
0
Arquivo: Undo.cs Projeto: mnisl/OD
		static internal object PreviousState(XmlNodeChangedEventArgs e)
		{
			return null;
		}
Exemplo n.º 17
0
        private void AttributeChange(Object src, XmlNodeChangedEventArgs args)
        {
            XmlAttribute attribute = src as XmlAttribute;

            if (attribute.NamespaceURI == SvgDocument.XLinkNamespace &&
                attribute.LocalName == "href")
            {
                href = null;
                absoluteUri = null;
            }
        }
Exemplo n.º 18
0
Arquivo: Undo.cs Projeto: mnisl/OD
		static internal object PreviousState(XmlNodeChangedEventArgs e)
		{
			return e.Node.Value;
		}
Exemplo n.º 19
0
Arquivo: Undo.cs Projeto: mnisl/OD
		static internal object PreviousState(XmlNodeChangedEventArgs e)
		{
			return e.Node.NextSibling;
		}
		private void EventNodeChanging (Object sender, XmlNodeChangedEventArgs e)
		{
			changing = true;
		}
Exemplo n.º 21
0
        //
        //  Private Methods
        //

        // event handler for XmlNodeChanged event
        private void OnXmlNodeChanged(object sender, XmlNodeChangedEventArgs args)
        {
            DeliverEvent(sender, args);
        }
Exemplo n.º 22
0
        // Removes specified child node.
        public virtual XmlNode RemoveChild(XmlNode oldChild)
        {
            if (!IsContainer)
            {
                throw new InvalidOperationException(SR.Xdom_Node_Remove_Contain);
            }

            if (oldChild.ParentNode != this)
            {
                throw new ArgumentException(SR.Xdom_Node_Remove_Child);
            }

            XmlLinkedNode oldNode = (XmlLinkedNode)oldChild;

            string oldNodeValue          = oldNode.Value;
            XmlNodeChangedEventArgs args = GetEventArgs(oldNode, this, null, oldNodeValue, oldNodeValue, XmlNodeChangedAction.Remove);

            if (args != null)
            {
                BeforeEvent(args);
            }

            XmlLinkedNode lastNode = LastNode;

            if (oldNode == FirstChild)
            {
                if (oldNode == lastNode)
                {
                    LastNode     = null;
                    oldNode.next = null;
                    oldNode.SetParent(null);
                }
                else
                {
                    XmlLinkedNode nextNode = oldNode.next;

                    if (nextNode.IsText)
                    {
                        if (oldNode.IsText)
                        {
                            UnnestTextNodes(oldNode, nextNode);
                        }
                    }

                    lastNode.next = nextNode;
                    oldNode.next  = null;
                    oldNode.SetParent(null);
                }
            }
            else
            {
                if (oldNode == lastNode)
                {
                    XmlLinkedNode prevNode = (XmlLinkedNode)oldNode.PreviousSibling;
                    prevNode.next = oldNode.next;
                    LastNode      = prevNode;
                    oldNode.next  = null;
                    oldNode.SetParent(null);
                }
                else
                {
                    XmlLinkedNode prevNode = (XmlLinkedNode)oldNode.PreviousSibling;
                    XmlLinkedNode nextNode = oldNode.next;

                    if (nextNode.IsText)
                    {
                        if (prevNode.IsText)
                        {
                            NestTextNodes(prevNode, nextNode);
                        }
                        else
                        {
                            if (oldNode.IsText)
                            {
                                UnnestTextNodes(oldNode, nextNode);
                            }
                        }
                    }

                    prevNode.next = nextNode;
                    oldNode.next  = null;
                    oldNode.SetParent(null);
                }
            }

            if (args != null)
            {
                AfterEvent(args);
            }

            return(oldChild);
        }
Exemplo n.º 23
0
Arquivo: Undo.cs Projeto: mnisl/OD
		private void NodeChanged(object sender, XmlNodeChangedEventArgs e)
		{
			if (this._Undoing)
			{
				// if we're undoing ignore the event since it is the result of an undo
				_pState = null;
				_Undoing = false;
				return;
			}

			UndoItem undo = null;
			switch (e.Action)
			{
				case XmlNodeChangedAction.Insert:
					undo = new NodeInsertedUndo(e, _pState);
					break;
				case XmlNodeChangedAction.Remove:
					undo = new NodeRemovedUndo(e, _pState);
					break;
				case XmlNodeChangedAction.Change:
					undo = new NodeChangedUndo(e, _pState);
					break;
				default:
					throw new Exception("Unknown Action");
			}
			_pState = null;
			if (_currentUndoGroup != null)
			{
				_currentUndoGroup.AddUndoItem(undo);
			}
			else if (GroupsOnly)
			{
				_pState = null;
			}
			else
			{
				_actions.Push(undo);
			}
		}
Exemplo n.º 24
0
Arquivo: Undo.cs Projeto: mnisl/OD
 public NodeInsertedUndo(XmlNodeChangedEventArgs e, object previous)
 {
     iNode = e.Node;
 }
Exemplo n.º 25
0
 internal virtual void BeforeEvent(XmlNodeChangedEventArgs args)
 {
     if (args != null)
         OwnerDocument.BeforeEvent(args);
 }
Exemplo n.º 26
0
Arquivo: Undo.cs Projeto: mnisl/OD
 internal NodeRemovedUndo(XmlNodeChangedEventArgs e, object previous)
 {
     removedNode = e.Node;
     parentNode = e.OldParent;
     nextSibling = previous as XmlNode;
 }
Exemplo n.º 27
0
        // Inserts the specified node immediately before the specified reference node.
        public virtual XmlNode InsertBefore(XmlNode newChild, XmlNode refChild)
        {
            if (this == newChild || AncestorNode(newChild))
            {
                throw new ArgumentException(SR.Xdom_Node_Insert_Child);
            }

            if (refChild == null)
            {
                return(AppendChild(newChild));
            }

            if (!IsContainer)
            {
                throw new InvalidOperationException(SR.Xdom_Node_Insert_Contain);
            }

            if (refChild.ParentNode != this)
            {
                throw new ArgumentException(SR.Xdom_Node_Insert_Path);
            }

            if (newChild == refChild)
            {
                return(newChild);
            }

            XmlDocument childDoc = newChild.OwnerDocument;
            XmlDocument thisDoc  = OwnerDocument;

            if (childDoc != null && childDoc != thisDoc && childDoc != this)
            {
                throw new ArgumentException(SR.Xdom_Node_Insert_Context);
            }

            if (!CanInsertBefore(newChild, refChild))
            {
                throw new InvalidOperationException(SR.Xdom_Node_Insert_Location);
            }

            if (newChild.ParentNode != null)
            {
                newChild.ParentNode.RemoveChild(newChild);
            }

            // special case for doc-fragment.
            if (newChild.NodeType == XmlNodeType.DocumentFragment)
            {
                XmlNode first = newChild.FirstChild;
                XmlNode node  = first;
                if (node != null)
                {
                    newChild.RemoveChild(node);
                    InsertBefore(node, refChild);
                    // insert the rest of the children after this one.
                    InsertAfter(newChild, node);
                }
                return(first);
            }

            if (!(newChild is XmlLinkedNode) || !IsValidChildType(newChild.NodeType))
            {
                throw new InvalidOperationException(SR.Xdom_Node_Insert_TypeConflict);
            }

            XmlLinkedNode newNode = (XmlLinkedNode)newChild;
            XmlLinkedNode refNode = (XmlLinkedNode)refChild;

            string newChildValue         = newChild.Value;
            XmlNodeChangedEventArgs args = GetEventArgs(newChild, newChild.ParentNode, this, newChildValue, newChildValue, XmlNodeChangedAction.Insert);

            if (args != null)
            {
                BeforeEvent(args);
            }

            if (refNode == FirstChild)
            {
                newNode.next  = refNode;
                LastNode.next = newNode;
                newNode.SetParent(this);

                if (newNode.IsText)
                {
                    if (refNode.IsText)
                    {
                        NestTextNodes(newNode, refNode);
                    }
                }
            }
            else
            {
                XmlLinkedNode prevNode = (XmlLinkedNode)refNode.PreviousSibling;

                newNode.next  = refNode;
                prevNode.next = newNode;
                newNode.SetParent(this);

                if (prevNode.IsText)
                {
                    if (newNode.IsText)
                    {
                        NestTextNodes(prevNode, newNode);
                        if (refNode.IsText)
                        {
                            NestTextNodes(newNode, refNode);
                        }
                    }
                    else
                    {
                        if (refNode.IsText)
                        {
                            UnnestTextNodes(prevNode, refNode);
                        }
                    }
                }
                else
                {
                    if (newNode.IsText)
                    {
                        if (refNode.IsText)
                        {
                            NestTextNodes(newNode, refNode);
                        }
                    }
                }
            }

            if (args != null)
            {
                AfterEvent(args);
            }

            return(newNode);
        }
Exemplo n.º 28
0
Arquivo: Undo.cs Projeto: mnisl/OD
        internal NodeChangedUndo(XmlNodeChangedEventArgs e, object pValue)
        {
			oldValue = pValue as string;
            node = e.Node;		
        }
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// xmlnodechangedeventhandler.BeginInvoke(sender, e, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this XmlNodeChangedEventHandler xmlnodechangedeventhandler, Object sender, XmlNodeChangedEventArgs e, AsyncCallback callback)
        {
            if(xmlnodechangedeventhandler == null) throw new ArgumentNullException("xmlnodechangedeventhandler");

            return xmlnodechangedeventhandler.BeginInvoke(sender, e, callback, null);
        }
Exemplo n.º 30
0
Arquivo: Undo.cs Projeto: mnisl/OD
		private void NodeChanging(object sender, XmlNodeChangedEventArgs e)
		{
			if (this._Undoing)
				return;

			switch (e.Action)
			{
				case XmlNodeChangedAction.Insert:
					_pState = NodeInsertedUndo.PreviousState(e);
					break;
				case XmlNodeChangedAction.Remove:
					_pState = NodeRemovedUndo.PreviousState(e);
					break;
				case XmlNodeChangedAction.Change:
					_pState = NodeChangedUndo.PreviousState(e);
					break;
				default:
					throw new Exception("Unknown Action");
			}
		}
Exemplo n.º 31
0
        protected void NodeChanged(object sender, XmlNodeChangedEventArgs e)
        {
            // Fired when XmlNode.Value is changed
            // The only types that have non-null Value are:
            //	- Attribute (special case)
            //	- CDATASection (not significant for validation)
            //	- Comment (not significant for validation)
            //	- ProcessingInstruction (not significant for validation)
            //	- Text (not significant for validation when changed)
            //	- [Significant]Whitespace (not significant for validation)
            //	- XmlDeclaration (not significant for validation)

            Console.WriteLine("Node {0} changed", e.Node.Name);

            XmlAttribute attr=GetAttributeFromEvent(e);

            if ( attr == null || !XmlUtil.HasAncestor(attr.OwnerElement, attr.OwnerDocument.DocumentElement) )
                // attribute's parent is not part of the document
                return;

            ValidateAttributeAddOrChange(attr);
        }
Exemplo n.º 32
0
 private void ReferencedNodeChange(Object src, XmlNodeChangedEventArgs args)
 {
     if (NodeChanged != null)
     {
         NodeChanged(src, args);
     }
 }
Exemplo n.º 33
0
        protected void NodeChanging(object sender, XmlNodeChangedEventArgs e)
        {
            // we're only interested in attribute nodes
            XmlAttribute attr=GetAttributeFromEvent(e);
            if ( attr == null || !XmlUtil.HasAncestor(attr.OwnerElement, attr.OwnerDocument.DocumentElement) )
                // attribute's parent is not part of the document
                return;

            RemoveIdOrIdRef(attr.OwnerElement, attr);
        }
Exemplo n.º 34
0
        protected void NodeInserted(object sender, XmlNodeChangedEventArgs e)
        {
            XmlAttribute attr=GetAttributeFromEvent(e);
            if ( attr != null )
            {
                // we deal with attributes differently
                if ( attr.OwnerElement != null && XmlUtil.HasAncestor(attr.OwnerElement, attr.OwnerDocument.DocumentElement) )
                    // owner element is part of doc, so validate
                    ValidateAttributeAddOrChange(attr);

                return;
            }

            Console.WriteLine("Node {0} inserted", e.Node.Name);

            if ( !XmlUtil.HasAncestor(e.NewParent, e.NewParent.OwnerDocument.DocumentElement) )
            {
                Console.WriteLine("Insert of {0} under {1}, is not part of doc", e.Node.Name, e.NewParent.Name);
                // new parent is not part of doc
                return;
            }

            XmlElement p=e.NewParent as XmlElement;
            if ( p == null )
                // must be entity reference
                p=(XmlElement) XmlUtil.GetParentNode(e.NewParent);

            RemoveValidationErrors(new ContextErrorFilter(e.Node));
            Console.WriteLine("Validating parent node {0}", e.NewParent.Name);
            Validate(p);

            XmlElement elem=e.Node as XmlElement;
            if ( elem != null )
                RecursiveInsert(elem);

            if ( e.OldParent != null )
                Validate((XmlElement) e.OldParent);
        }
Exemplo n.º 35
0
        private void OnNodeInserted(object sender, XmlNodeChangedEventArgs args)
        {
            if (!raiseDocumentEvents)
            {
                return;
            }
            bool escapedRaiseDataSetEvents = raiseDataSetEvents;

            raiseDataSetEvents = false;

            // If the parent node is mapped to a DataTable, then
            // add a DataRow and map the parent element to it.
            //
            // AND If the child node is mapped to a DataTable, then
            // 1. if it is mapped to a DataTable and relation, add
            // a new DataRow and map the child element to it.
            // 2. if it is mapped to a DataColumn, set the column
            // value of the parent DataRow as the child

            try {
                if (!(args.NewParent is XmlElement))
                {
                    // i.e. adding document element
                    foreach (XmlNode table in args.Node.ChildNodes)
                    {
                        CheckDescendantRelationship(table);
                    }
                    return;
                }

                DataRow row = GetRowFromElement(args.NewParent as XmlElement);
                if (row == null)
                {
                    // That happens only when adding table to existing DocumentElement (aka DataSet element)
                    if (args.NewParent == DocumentElement)
                    {
                        CheckDescendantRelationship(args.Node);
                    }
                    return;
                }

                XmlAttribute attr = args.Node as XmlAttribute;
                if (attr != null)                   // fill attribute value
                {
                    DataColumn col = row.Table.Columns [XmlHelper.Decode(attr.LocalName)];
                    if (col != null)
                    {
                        row [col] = StringToObject(col.DataType, args.Node.Value);
                    }
                }
                else
                {
                    DataRow childRow = GetRowFromElement(args.Node as XmlElement);
                    if (childRow != null)
                    {
                        // child might be a table row.
                        // I might be impossible to set parent
                        // since either of them might be detached
                        if (childRow.RowState != DataRowState.Detached && row.RowState != DataRowState.Detached)
                        {
                            FillRelationship(row, childRow, args.NewParent, args.Node);
                        }
                    }
                    else if (args.Node.NodeType == XmlNodeType.Element)
                    {
                        // child element might be a column
                        DataColumn col = row.Table.Columns [XmlHelper.Decode(args.Node.LocalName)];
                        if (col != null)
                        {
                            row [col] = StringToObject(col.DataType, args.Node.InnerText);
                        }
                    }
                    else if (args.Node is XmlCharacterData)
                    {
                        if (args.Node.NodeType != XmlNodeType.Comment)
                        {
                            for (int i = 0; i < row.Table.Columns.Count; i++)
                            {
                                DataColumn col = row.Table.Columns [i];
                                if (col.ColumnMapping == MappingType.SimpleContent)
                                {
                                    row [col] = StringToObject(col.DataType, args.Node.Value);
                                }
                            }
                        }
                    }
                }
            } finally {
                raiseDataSetEvents = escapedRaiseDataSetEvents;
            }
        }