Ejemplo n.º 1
0
 internal void LoadChildNodes(XmlDiffParentNode parent, XmlNode parentDomNode)
 {
         var curLastChild = this._curLastChild;
   this._curLastChild = (XmlDiffNode) null;
         var attributes = (XmlNamedNodeMap) parentDomNode.Attributes;
   if (attributes != null && attributes.Count > 0)
   {
     foreach (XmlAttribute xmlAttribute in attributes)
     {
       if (xmlAttribute.Prefix == "xmlns")
       {
         if (!this._XmlDiff.IgnoreNamespaces)
         {
                         var xmlDiffNamespace = new XmlDiffNamespace(xmlAttribute.LocalName, xmlAttribute.Value);
           xmlDiffNamespace.ComputeHashValue(this._xmlHash);
           this.InsertAttributeOrNamespace((XmlDiffElement) parent, (XmlDiffAttributeOrNamespace) xmlDiffNamespace);
         }
       }
       else if (xmlAttribute.Prefix == string.Empty && xmlAttribute.LocalName == "xmlns")
       {
         if (!this._XmlDiff.IgnoreNamespaces)
         {
                         var xmlDiffNamespace = new XmlDiffNamespace(string.Empty, xmlAttribute.Value);
           xmlDiffNamespace.ComputeHashValue(this._xmlHash);
           this.InsertAttributeOrNamespace((XmlDiffElement) parent, (XmlDiffAttributeOrNamespace) xmlDiffNamespace);
         }
       }
       else
       {
         var str = this._XmlDiff.IgnoreWhitespace ? XmlDiff.NormalizeText(xmlAttribute.Value) : xmlAttribute.Value;
                     var xmlDiffAttribute = new XmlDiffAttribute(xmlAttribute.LocalName, xmlAttribute.Prefix, xmlAttribute.NamespaceURI, str);
         xmlDiffAttribute.ComputeHashValue(this._xmlHash);
         this.InsertAttributeOrNamespace((XmlDiffElement) parent, (XmlDiffAttributeOrNamespace) xmlDiffAttribute);
       }
     }
   }
         var childNodes = parentDomNode.ChildNodes;
   if (childNodes.Count != 0)
   {
     var childPosition = 0;
             var enumerator = childNodes.GetEnumerator();
     while (enumerator.MoveNext())
     {
       if (((XmlNode) enumerator.Current).NodeType != XmlNodeType.Whitespace)
       {
                     var newChild = this.LoadNode((XmlNode) enumerator.Current, ref childPosition);
         if (newChild != null)
           this.InsertChild(parent, newChild);
       }
     }
   }
   this._curLastChild = curLastChild;
 }
Ejemplo n.º 2
0
// Methods
        internal override void WriteTo(XmlWriter xmlWriter, XmlDiff xmlDiff)
        {
            xmlWriter.WriteStartElement(XmlDiff.Prefix, "add", XmlDiff.NamespaceUri);

            switch (_targetNode.NodeType)
            {
            case XmlDiffNodeType.Element:
            {
                xmlWriter.WriteAttributeString("type", ((int)XmlNodeType.Element).ToString());

                XmlDiffElement el = _targetNode as XmlDiffElement;
                xmlWriter.WriteAttributeString("name", el.LocalName);
                if (el.NamespaceURI != string.Empty)
                {
                    xmlWriter.WriteAttributeString("ns", el.NamespaceURI);
                }
                if (el.Prefix != string.Empty)
                {
                    xmlWriter.WriteAttributeString("prefix", el.Prefix);
                }
                if (_operationID != 0)
                {
                    xmlWriter.WriteAttributeString("opid", _operationID.ToString());
                }

                WriteChildrenTo(xmlWriter, xmlDiff);
                break;
            }

            case XmlDiffNodeType.Attribute:
            {
                xmlWriter.WriteAttributeString("type", ((int)XmlNodeType.Attribute).ToString());

                XmlDiffAttribute at = _targetNode as XmlDiffAttribute;
                xmlWriter.WriteAttributeString("name", at.LocalName);
                if (at.NamespaceURI != string.Empty)
                {
                    xmlWriter.WriteAttributeString("ns", at.NamespaceURI);
                }
                if (at.Prefix != string.Empty)
                {
                    xmlWriter.WriteAttributeString("prefix", at.Prefix);
                }
                if (_operationID != 0)
                {
                    xmlWriter.WriteAttributeString("opid", _operationID.ToString());
                }
                xmlWriter.WriteString(at.Value);
                break;
            }

            case XmlDiffNodeType.Namespace:
            {
                xmlWriter.WriteAttributeString("type", ((int)XmlNodeType.Attribute).ToString());

                XmlDiffNamespace ns = _targetNode as XmlDiffNamespace;
                if (ns.Prefix != string.Empty)
                {
                    xmlWriter.WriteAttributeString("prefix", "xmlns");
                    xmlWriter.WriteAttributeString("name", ns.Prefix);
                }
                else
                {
                    xmlWriter.WriteAttributeString("name", "xmlns");
                }
                if (_operationID != 0)
                {
                    xmlWriter.WriteAttributeString("opid", _operationID.ToString());
                }

                xmlWriter.WriteString(ns.NamespaceURI);
                break;
            }

            case XmlDiffNodeType.CDATA:
            {
                Debug.Assert(false, "CDATA nodes should be added with DiffgramAddSubtrees class.");

                xmlWriter.WriteAttributeString("type", ((int)_targetNode.NodeType).ToString());

                if (_operationID != 0)
                {
                    xmlWriter.WriteAttributeString("opid", _operationID.ToString());
                }
                xmlWriter.WriteCData((_targetNode as XmlDiffCharData).Value);
                break;
            }

            case XmlDiffNodeType.Comment:
            {
                Debug.Assert(false, "Comment nodes should be added with DiffgramAddSubtrees class.");

                xmlWriter.WriteAttributeString("type", ((int)_targetNode.NodeType).ToString());

                if (_operationID != 0)
                {
                    xmlWriter.WriteAttributeString("opid", _operationID.ToString());
                }
                xmlWriter.WriteComment((_targetNode as XmlDiffCharData).Value);
                break;
            }

            case XmlDiffNodeType.Text:
            {
                Debug.Assert(false, "Text nodes should be added with DiffgramAddSubtrees class.");

                xmlWriter.WriteAttributeString("type", ((int)_targetNode.NodeType).ToString());

                if (_operationID != 0)
                {
                    xmlWriter.WriteAttributeString("opid", _operationID.ToString());
                }
                xmlWriter.WriteString((_targetNode as XmlDiffCharData).Value);
                break;
            }

            case XmlDiffNodeType.ProcessingInstruction:
            {
                Debug.Assert(false, "Processing instruction nodes should be added with DiffgramAddSubtrees class.");

                xmlWriter.WriteAttributeString("type", ((int)_targetNode.NodeType).ToString());

                if (_operationID != 0)
                {
                    xmlWriter.WriteAttributeString("opid", _operationID.ToString());
                }
                XmlDiffPI pi = _targetNode as XmlDiffPI;
                xmlWriter.WriteProcessingInstruction(pi.Name, pi.Value);
                break;
            }

            case XmlDiffNodeType.EntityReference:
            {
                xmlWriter.WriteAttributeString("type", ((int)XmlNodeType.EntityReference).ToString());

                if (_operationID != 0)
                {
                    xmlWriter.WriteAttributeString("opid", _operationID.ToString());
                }

                xmlWriter.WriteAttributeString("name", ((XmlDiffER)_targetNode).Name);
                break;
            }

            case XmlDiffNodeType.SignificantWhitespace:
            {
                Debug.Assert(false, "Significant whitespace nodes should be added with DiffgramAddSubtrees class.");

                xmlWriter.WriteAttributeString("type", ((int)_targetNode.NodeType).ToString());

                if (_operationID != 0)
                {
                    xmlWriter.WriteAttributeString("opid", _operationID.ToString());
                }
                xmlWriter.WriteString(((XmlDiffCharData)_targetNode).Value);
                break;
            }

            case XmlDiffNodeType.XmlDeclaration:
            {
                xmlWriter.WriteAttributeString("type", ((int)XmlNodeType.XmlDeclaration).ToString());

                if (_operationID != 0)
                {
                    xmlWriter.WriteAttributeString("opid", _operationID.ToString());
                }
                xmlWriter.WriteString(((XmlDiffXmlDeclaration)_targetNode).Value);
                break;
            }

            case XmlDiffNodeType.DocumentType:
            {
                xmlWriter.WriteAttributeString("type", ((int)XmlNodeType.DocumentType).ToString());

                XmlDiffDocumentType docType = (XmlDiffDocumentType)_targetNode;

                if (_operationID != 0)
                {
                    xmlWriter.WriteAttributeString("opid", _operationID.ToString());
                }
                xmlWriter.WriteAttributeString("name", docType.Name);
                if (docType.PublicId != string.Empty)
                {
                    xmlWriter.WriteAttributeString("publicId", docType.PublicId);
                }
                if (docType.SystemId != string.Empty)
                {
                    xmlWriter.WriteAttributeString("systemId", docType.SystemId);
                }
                if (docType.Subset != string.Empty)
                {
                    xmlWriter.WriteCData(docType.Subset);
                }
                break;
            }

            default:
                Debug.Assert(false);
                break;
            }

            xmlWriter.WriteEndElement();
        }
Ejemplo n.º 3
0
        internal void InsertAttributeOrNamespace(XmlDiffAttributeOrNamespace newAttrOrNs)
        {
            Debug.Assert(newAttrOrNs != null);

            newAttrOrNs._parent = this;

            XmlDiffAttributeOrNamespace curAttr  = _attributes;
            XmlDiffAttributeOrNamespace prevAttr = null;

            while (curAttr != null &&
                   XmlDiffDocument.OrderAttributesOrNamespaces(curAttr, newAttrOrNs) <= 0)
            {
                prevAttr = curAttr;
                curAttr  = (XmlDiffAttributeOrNamespace)curAttr._nextSibling;
            }

            if (prevAttr == null)
            {
                newAttrOrNs._nextSibling = _attributes;
                _attributes = newAttrOrNs;
            }
            else
            {
                newAttrOrNs._nextSibling = prevAttr._nextSibling;
                prevAttr._nextSibling    = newAttrOrNs;
            }

            // hash
            Debug.Assert(newAttrOrNs.HashValue != 0);
            _allAttributesHash += newAttrOrNs.HashValue;

            char firstLetter;

            if (newAttrOrNs.NodeType == XmlDiffNodeType.Attribute)
            {
                firstLetter = ((XmlDiffAttribute)newAttrOrNs).LocalName[0];
            }
            else
            {
                XmlDiffNamespace nsNode = (XmlDiffNamespace)newAttrOrNs;
                firstLetter = (nsNode.Prefix == string.Empty) ? 'A' : nsNode.Prefix[0];
            }

            firstLetter = char.ToUpper(firstLetter);

            if (firstLetter >= 'R')
            {
                _attributesHashRZ += newAttrOrNs.HashValue;
            }
            else if (firstLetter >= 'I')
            {
                _attributesHashIQ += newAttrOrNs.HashValue;
            }
            else
            {
                _attributesHashAH += newAttrOrNs.HashValue;
            }

            if (newAttrOrNs.NodeType == XmlDiffNodeType.Namespace)
            {
                _bDefinesNamespaces = true;
            }
        }
Ejemplo n.º 4
0
        // Loads child nodes of the 'parent' node
        internal void LoadChildNodes(XmlDiffParentNode parent, XmlNode parentDomNode)
        {
            XmlDiffNode savedLastChild = _curLastChild;

            _curLastChild = null;

            // load attributes & namespace nodes
            XmlNamedNodeMap attribs = parentDomNode.Attributes;

            if (attribs != null && attribs.Count > 0)
            {
                IEnumerator attrEnum = attribs.GetEnumerator();
                while (attrEnum.MoveNext())
                {
                    XmlAttribute attr = (XmlAttribute)attrEnum.Current;
                    if (attr.Prefix == "xmlns")
                    {
                        if (!_XmlDiff.IgnoreNamespaces)
                        {
                            XmlDiffNamespace nsNode = new XmlDiffNamespace(attr.LocalName, attr.Value);
                            nsNode.ComputeHashValue(_xmlHash);
                            InsertAttributeOrNamespace((XmlDiffElement)parent, nsNode);
                        }
                    }
                    else if (attr.Prefix == string.Empty && attr.LocalName == "xmlns")
                    {
                        if (!_XmlDiff.IgnoreNamespaces)
                        {
                            XmlDiffNamespace nsNode = new XmlDiffNamespace(string.Empty, attr.Value);
                            nsNode.ComputeHashValue(_xmlHash);
                            InsertAttributeOrNamespace((XmlDiffElement)parent, nsNode);
                        }
                    }
                    else
                    {
                        string           attrValue = _XmlDiff.IgnoreWhitespace ? XmlDiff.NormalizeText(attr.Value) : attr.Value;
                        XmlDiffAttribute newAttr   = new XmlDiffAttribute(attr.LocalName, attr.Prefix, attr.NamespaceURI, attrValue);
                        newAttr.ComputeHashValue(_xmlHash);
                        InsertAttributeOrNamespace((XmlDiffElement)parent, newAttr);
                    }
                }
            }

            // load children
            XmlNodeList children = parentDomNode.ChildNodes;

            if (children.Count == 0)
            {
                goto End;
            }

            int         childPosition = 0;
            IEnumerator childEnum     = children.GetEnumerator();

            while (childEnum.MoveNext())
            {
                XmlNode node = (XmlNode)childEnum.Current;

                // ignore whitespaces between nodes
                if (node.NodeType == XmlNodeType.Whitespace)
                {
                    continue;
                }

                XmlDiffNode newDiffNode = LoadNode((XmlNode)childEnum.Current, ref childPosition);
                if (newDiffNode != null)
                {
                    InsertChild(parent, newDiffNode);
                }
            }

End:
            _curLastChild = savedLastChild;
        }
Ejemplo n.º 5
0
        // Loads child nodes of the 'parent' node
        internal void LoadChildNodes(XmlDiffParentNode parent, XmlReader reader, bool bEmptyElement)
        {
            XmlDiffNode savedLastChild = _curLastChild;

            _curLastChild = null;

            // load attributes & namespace nodes
            while (reader.MoveToNextAttribute())
            {
                if (reader.Prefix == "xmlns")
                {
                    if (!_XmlDiff.IgnoreNamespaces)
                    {
                        XmlDiffNamespace nsNode = new XmlDiffNamespace(reader.LocalName, reader.Value);
                        nsNode.ComputeHashValue(_xmlHash);
                        InsertAttributeOrNamespace((XmlDiffElement)parent, nsNode);
                    }
                }
                else if (reader.Prefix == string.Empty && reader.LocalName == "xmlns")
                {
                    if (!_XmlDiff.IgnoreNamespaces)
                    {
                        XmlDiffNamespace nsNode = new XmlDiffNamespace(string.Empty, reader.Value);
                        nsNode.ComputeHashValue(_xmlHash);
                        InsertAttributeOrNamespace((XmlDiffElement)parent, nsNode);
                    }
                }
                else
                {
                    string           attrValue = _XmlDiff.IgnoreWhitespace ? XmlDiff.NormalizeText(reader.Value) : reader.Value;
                    XmlDiffAttribute attr      = new XmlDiffAttribute(reader.LocalName, reader.Prefix, reader.NamespaceURI, attrValue);
                    attr.ComputeHashValue(_xmlHash);
                    InsertAttributeOrNamespace((XmlDiffElement)parent, attr);
                }
            }

            // empty element -> return, do not load chilren
            if (bEmptyElement)
            {
                goto End;
            }

            int childPosition = 0;

            // load children
            if (!reader.Read())
            {
                goto End;
            }

            do
            {
                // ignore whitespaces between nodes
                if (reader.NodeType == XmlNodeType.Whitespace)
                {
                    continue;
                }

                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                {
                    bool           bEmptyEl = reader.IsEmptyElement;
                    XmlDiffElement elem     = new XmlDiffElement(++childPosition, reader.LocalName, reader.Prefix, reader.NamespaceURI);

                    LoadChildNodes(elem, reader, bEmptyEl);

                    elem.ComputeHashValue(_xmlHash);
                    InsertChild(parent, elem);
                    break;
                }

                case XmlNodeType.Attribute:
                {
                    Debug.Assert(false, "We should never get to this point, attributes should be read at the beginning of thid method.");
                    break;
                }

                case XmlNodeType.Text:
                {
                    string          textValue    = (_XmlDiff.IgnoreWhitespace) ? XmlDiff.NormalizeText(reader.Value) : reader.Value;
                    XmlDiffCharData charDataNode = new XmlDiffCharData(++childPosition, textValue, XmlDiffNodeType.Text);
                    charDataNode.ComputeHashValue(_xmlHash);
                    InsertChild(parent, charDataNode);
                    break;
                }

                case XmlNodeType.CDATA:
                {
                    XmlDiffCharData charDataNode = new XmlDiffCharData(++childPosition, reader.Value, XmlDiffNodeType.CDATA);
                    charDataNode.ComputeHashValue(_xmlHash);
                    InsertChild(parent, charDataNode);
                    break;
                }

                case XmlNodeType.EntityReference:
                {
                    XmlDiffER er = new XmlDiffER(++childPosition, reader.Name);
                    er.ComputeHashValue(_xmlHash);
                    InsertChild(parent, er);
                    break;
                }

                case XmlNodeType.Comment:
                {
                    ++childPosition;
                    if (!_XmlDiff.IgnoreComments)
                    {
                        XmlDiffCharData charDataNode = new XmlDiffCharData(childPosition, reader.Value, XmlDiffNodeType.Comment);
                        charDataNode.ComputeHashValue(_xmlHash);
                        InsertChild(parent, charDataNode);
                    }
                    break;
                }

                case XmlNodeType.ProcessingInstruction:
                {
                    ++childPosition;
                    if (!_XmlDiff.IgnorePI)
                    {
                        XmlDiffPI pi = new XmlDiffPI(childPosition, reader.Name, reader.Value);
                        pi.ComputeHashValue(_xmlHash);
                        InsertChild(parent, pi);
                    }
                    break;
                }

                case XmlNodeType.SignificantWhitespace:
                {
                    if (reader.XmlSpace == XmlSpace.Preserve)
                    {
                        ++childPosition;
                        if (!_XmlDiff.IgnoreWhitespace)
                        {
                            XmlDiffCharData charDataNode = new XmlDiffCharData(childPosition, reader.Value, XmlDiffNodeType.SignificantWhitespace);
                            charDataNode.ComputeHashValue(_xmlHash);
                            InsertChild(parent, charDataNode);
                        }
                    }
                    break;
                }

                case XmlNodeType.XmlDeclaration:
                {
                    ++childPosition;
                    if (!_XmlDiff.IgnoreXmlDecl)
                    {
                        XmlDiffXmlDeclaration xmlDecl = new XmlDiffXmlDeclaration(childPosition, XmlDiff.NormalizeXmlDeclaration(reader.Value));
                        xmlDecl.ComputeHashValue(_xmlHash);
                        InsertChild(parent, xmlDecl);
                    }
                    break;
                }

                case XmlNodeType.EndElement:
                    goto End;

                case XmlNodeType.DocumentType:
                    childPosition++;
                    if (!_XmlDiff.IgnoreDtd)
                    {
                        XmlDiffDocumentType docType = new XmlDiffDocumentType(childPosition,
                                                                              reader.Name,
                                                                              reader.GetAttribute("PUBLIC"),
                                                                              reader.GetAttribute("SYSTEM"),
                                                                              reader.Value);
                        docType.ComputeHashValue(_xmlHash);
                        InsertChild(parent, docType);
                    }
                    break;

                default:
                    Debug.Assert(false);
                    break;
                }
            } while (reader.Read());

End:
            _curLastChild = savedLastChild;
        }
Ejemplo n.º 6
0
    internal void LoadChildNodes(XmlDiffParentNode parent, XmlReader reader, bool bEmptyElement)
    {
            var curLastChild = this._curLastChild;
      this._curLastChild = (XmlDiffNode) null;
      while (reader.MoveToNextAttribute())
      {
        if (reader.Prefix == "xmlns")
        {
          if (!this._XmlDiff.IgnoreNamespaces)
          {
                        var xmlDiffNamespace = new XmlDiffNamespace(reader.LocalName, reader.Value);
            xmlDiffNamespace.ComputeHashValue(this._xmlHash);
            this.InsertAttributeOrNamespace((XmlDiffElement) parent, (XmlDiffAttributeOrNamespace) xmlDiffNamespace);
          }
        }
        else if (reader.Prefix == string.Empty && reader.LocalName == "xmlns")
        {
          if (!this._XmlDiff.IgnoreNamespaces)
          {
                        var xmlDiffNamespace = new XmlDiffNamespace(string.Empty, reader.Value);
            xmlDiffNamespace.ComputeHashValue(this._xmlHash);
            this.InsertAttributeOrNamespace((XmlDiffElement) parent, (XmlDiffAttributeOrNamespace) xmlDiffNamespace);
          }
        }
        else
        {
          var str = this._XmlDiff.IgnoreWhitespace ? XmlDiff.NormalizeText(reader.Value) : reader.Value;
                    var xmlDiffAttribute = new XmlDiffAttribute(reader.LocalName, reader.Prefix, reader.NamespaceURI, str);
          xmlDiffAttribute.ComputeHashValue(this._xmlHash);
          this.InsertAttributeOrNamespace((XmlDiffElement) parent, (XmlDiffAttributeOrNamespace) xmlDiffAttribute);
        }
      }
      if (!bEmptyElement)
      {
        var position = 0;
        if (reader.Read())
        {
          do
          {
            if (reader.NodeType != XmlNodeType.Whitespace)
            {
              switch (reader.NodeType)
              {
                case XmlNodeType.Element:
                  var isEmptyElement = reader.IsEmptyElement;
                                    var xmlDiffElement = new XmlDiffElement(++position, reader.LocalName, reader.Prefix, reader.NamespaceURI);
                  this.LoadChildNodes((XmlDiffParentNode) xmlDiffElement, reader, isEmptyElement);
                  xmlDiffElement.ComputeHashValue(this._xmlHash);
                  this.InsertChild(parent, (XmlDiffNode) xmlDiffElement);
                  break;
                case XmlNodeType.Text:
                  var str = this._XmlDiff.IgnoreWhitespace ? XmlDiff.NormalizeText(reader.Value) : reader.Value;
                                    var xmlDiffCharData1 = new XmlDiffCharData(++position, str, XmlDiffNodeType.Text);
                  xmlDiffCharData1.ComputeHashValue(this._xmlHash);
                  this.InsertChild(parent, (XmlDiffNode) xmlDiffCharData1);
                  break;
                case XmlNodeType.CDATA:
                                    var xmlDiffCharData2 = new XmlDiffCharData(++position, reader.Value, XmlDiffNodeType.CDATA);
                  xmlDiffCharData2.ComputeHashValue(this._xmlHash);
                  this.InsertChild(parent, (XmlDiffNode) xmlDiffCharData2);
                  break;
                case XmlNodeType.EntityReference:
                                    var xmlDiffEr = new XmlDiffER(++position, reader.Name);
                  xmlDiffEr.ComputeHashValue(this._xmlHash);
                  this.InsertChild(parent, (XmlDiffNode) xmlDiffEr);
                  break;
                case XmlNodeType.ProcessingInstruction:
                  ++position;
                  if (!this._XmlDiff.IgnorePI)
                  {
                                        var xmlDiffPi = new XmlDiffPI(position, reader.Name, reader.Value);
                    xmlDiffPi.ComputeHashValue(this._xmlHash);
                    this.InsertChild(parent, (XmlDiffNode) xmlDiffPi);
                    break;
                  }
                  break;
                case XmlNodeType.Comment:
                  ++position;
                  if (!this._XmlDiff.IgnoreComments)
                  {
                                        var xmlDiffCharData3 = new XmlDiffCharData(position, reader.Value, XmlDiffNodeType.Comment);
                    xmlDiffCharData3.ComputeHashValue(this._xmlHash);
                    this.InsertChild(parent, (XmlDiffNode) xmlDiffCharData3);
                    break;
                  }
                  break;
                case XmlNodeType.DocumentType:
                  ++position;
                  if (!this._XmlDiff.IgnoreDtd)
                  {
                                        var diffDocumentType = new XmlDiffDocumentType(position, reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value);
                    diffDocumentType.ComputeHashValue(this._xmlHash);
                    this.InsertChild(parent, (XmlDiffNode) diffDocumentType);
                    break;
                  }
                  break;
                case XmlNodeType.SignificantWhitespace:
                  if (reader.XmlSpace == XmlSpace.Preserve)
                  {
                    ++position;
                    if (!this._XmlDiff.IgnoreWhitespace)
                    {
                                            var xmlDiffCharData3 = new XmlDiffCharData(position, reader.Value, XmlDiffNodeType.SignificantWhitespace);
                      xmlDiffCharData3.ComputeHashValue(this._xmlHash);
                      this.InsertChild(parent, (XmlDiffNode) xmlDiffCharData3);
                      break;
                    }
                    break;
                  }
                  break;
                case XmlNodeType.EndElement:
                  goto label_29;
                case XmlNodeType.XmlDeclaration:
                  ++position;
                  if (!this._XmlDiff.IgnoreXmlDecl)
                  {
                                        var diffXmlDeclaration = new XmlDiffXmlDeclaration(position, XmlDiff.NormalizeXmlDeclaration(reader.Value));
                    diffXmlDeclaration.ComputeHashValue(this._xmlHash);
                    this.InsertChild(parent, (XmlDiffNode) diffXmlDeclaration);
                    break;
                  }
                  break;
              }
            }
          }
          while (reader.Read());
        }
      }
label_29:
      this._curLastChild = curLastChild;
    }
    // Loads child nodes of the 'parent' node
    internal void LoadChildNodes( XmlDiffParentNode parent, XmlNode parentDomNode ) 
    {
        XmlDiffNode savedLastChild = _curLastChild;
        _curLastChild = null;

        // load attributes & namespace nodes
        XmlNamedNodeMap attribs = parentDomNode.Attributes;
        if ( attribs != null && attribs.Count > 0 ) 
        {
            IEnumerator attrEnum = attribs.GetEnumerator();
            while ( attrEnum.MoveNext() ) 
            {
                XmlAttribute attr = (XmlAttribute)attrEnum.Current;
                if ( attr.Prefix == "xmlns" )
                {
                    if ( !_XmlDiff.IgnoreNamespaces ) 
                    {
                        XmlDiffNamespace nsNode = new XmlDiffNamespace( attr.LocalName, attr.Value );
                        nsNode.ComputeHashValue( _xmlHash );
                        InsertAttributeOrNamespace( (XmlDiffElement)parent, nsNode );
                    }
                }
                else if ( attr.Prefix == string.Empty && attr.LocalName == "xmlns" )
                {
                    if ( !_XmlDiff.IgnoreNamespaces ) 
                    {
                        XmlDiffNamespace nsNode = new XmlDiffNamespace( string.Empty, attr.Value );
                        nsNode.ComputeHashValue( _xmlHash );
                        InsertAttributeOrNamespace( (XmlDiffElement)parent, nsNode );
                    }
                }
                else
                {
                    string attrValue = _XmlDiff.IgnoreWhitespace ? XmlDiff.NormalizeText( attr.Value ) : attr.Value;
                    XmlDiffAttribute newAttr = new XmlDiffAttribute( attr.LocalName, attr.Prefix, attr.NamespaceURI, attrValue );
                    newAttr.ComputeHashValue( _xmlHash );
                    InsertAttributeOrNamespace( (XmlDiffElement)parent, newAttr );
                }
            }
        }

        // load children
        XmlNodeList children = parentDomNode.ChildNodes;
        if ( children.Count == 0 )
            goto End;

        int childPosition = 0;
        IEnumerator childEnum = children.GetEnumerator();
        while ( childEnum.MoveNext() )
        {
            XmlNode node = (XmlNode)childEnum.Current;

            // ignore whitespaces between nodes
            if ( node.NodeType == XmlNodeType.Whitespace )
                continue;

            XmlDiffNode newDiffNode = LoadNode( (XmlNode)childEnum.Current, ref childPosition );
            if ( newDiffNode != null )
                InsertChild( parent, newDiffNode );
        }

        End:
        _curLastChild = savedLastChild;
    }
    // Loads child nodes of the 'parent' node
    internal void LoadChildNodes ( XmlDiffParentNode parent, XmlReader reader, bool bEmptyElement ) 
    {
        XmlDiffNode savedLastChild = _curLastChild;
        _curLastChild = null;

        // load attributes & namespace nodes
        while ( reader.MoveToNextAttribute() )
        {
            if ( reader.Prefix == "xmlns" )
            {
                if ( !_XmlDiff.IgnoreNamespaces ) 
                {
                    XmlDiffNamespace nsNode = new XmlDiffNamespace( reader.LocalName, reader.Value );
                    nsNode.ComputeHashValue( _xmlHash );
                    InsertAttributeOrNamespace( (XmlDiffElement)parent, nsNode );
                }
            }
            else if ( reader.Prefix == string.Empty  && reader.LocalName == "xmlns" )
            {
                if ( !_XmlDiff.IgnoreNamespaces ) 
                {
                    XmlDiffNamespace nsNode = new XmlDiffNamespace( string.Empty, reader.Value );
                    nsNode.ComputeHashValue( _xmlHash );
                    InsertAttributeOrNamespace( (XmlDiffElement)parent, nsNode );
                }
            }
            else
            {
                string attrValue = _XmlDiff.IgnoreWhitespace ? XmlDiff.NormalizeText( reader.Value ) : reader.Value;
                XmlDiffAttribute attr = new XmlDiffAttribute( reader.LocalName, reader.Prefix, reader.NamespaceURI, attrValue );
                attr.ComputeHashValue( _xmlHash );
                InsertAttributeOrNamespace( (XmlDiffElement)parent, attr );
            }
        }

        // empty element -> return, do not load chilren
        if ( bEmptyElement ) 
            goto End;

        int childPosition = 0;

        // load children
        if ( !reader.Read()) 
            goto End;

        do {
            // ignore whitespaces between nodes
            if ( reader.NodeType == XmlNodeType.Whitespace )
                continue;

            switch ( reader.NodeType ) 
            {
                case XmlNodeType.Element:
                {
                    bool bEmptyEl = reader.IsEmptyElement;
                    XmlDiffElement elem = new XmlDiffElement( ++childPosition, reader.LocalName, reader.Prefix, reader.NamespaceURI );

                    LoadChildNodes( elem, reader, bEmptyEl );

                    elem.ComputeHashValue( _xmlHash );
                    InsertChild( parent, elem );
                    break;
                }
                case XmlNodeType.Attribute:
                {
                    Debug.Assert( false, "We should never get to this point, attributes should be read at the beginning of thid method." );
                    break;
                }
                case XmlNodeType.Text:
                {
                    string textValue = ( _XmlDiff.IgnoreWhitespace ) ? XmlDiff.NormalizeText( reader.Value ) : reader.Value;
                    XmlDiffCharData charDataNode = new XmlDiffCharData( ++childPosition, textValue, XmlDiffNodeType.Text );
                    charDataNode.ComputeHashValue( _xmlHash );
                    InsertChild( parent, charDataNode );
                    break;
                }
                case XmlNodeType.CDATA:
                {
                    XmlDiffCharData charDataNode = new XmlDiffCharData( ++childPosition, reader.Value, XmlDiffNodeType.CDATA );
                    charDataNode.ComputeHashValue( _xmlHash );
                    InsertChild( parent, charDataNode );
                    break;
                }
                case XmlNodeType.EntityReference:
                {
                    XmlDiffER er = new XmlDiffER( ++childPosition, reader.Name );
                    er.ComputeHashValue( _xmlHash );
                    InsertChild( parent, er );
                    break;
                }
                case XmlNodeType.Comment:
                {
                    ++childPosition;
                    if ( !_XmlDiff.IgnoreComments ) 
                    {
                        XmlDiffCharData charDataNode = new XmlDiffCharData( childPosition, reader.Value, XmlDiffNodeType.Comment );
                        charDataNode.ComputeHashValue( _xmlHash );
                        InsertChild( parent, charDataNode );
                    }
                    break;
                }
                case XmlNodeType.ProcessingInstruction:
                {
                    ++childPosition;
                    if ( !_XmlDiff.IgnorePI )
                    {
                        XmlDiffPI pi = new XmlDiffPI( childPosition, reader.Name, reader.Value );
                        pi.ComputeHashValue( _xmlHash );
                        InsertChild( parent, pi );
                    }
                    break;
                }
                case XmlNodeType.SignificantWhitespace:
                {
                    if( reader.XmlSpace == XmlSpace.Preserve )
                    {
                        ++childPosition;
                        if (!_XmlDiff.IgnoreWhitespace ) 
                        {
                            XmlDiffCharData charDataNode = new XmlDiffCharData( childPosition, reader.Value, XmlDiffNodeType.SignificantWhitespace );
                            charDataNode.ComputeHashValue( _xmlHash );
                            InsertChild( parent, charDataNode );
                        }
                    }
                    break;
                }
                case XmlNodeType.XmlDeclaration:
                {
                    ++childPosition;
                    if ( !_XmlDiff.IgnoreXmlDecl ) 
                    {
                        XmlDiffXmlDeclaration xmlDecl = new XmlDiffXmlDeclaration( childPosition, XmlDiff.NormalizeXmlDeclaration( reader.Value ) );
                        xmlDecl.ComputeHashValue( _xmlHash );
						InsertChild( parent, xmlDecl );
                    }
                    break;
                }
                case XmlNodeType.EndElement:
                    goto End;

                case XmlNodeType.DocumentType:
                    childPosition++;
                    if ( !_XmlDiff.IgnoreDtd ) {
                        
                        XmlDiffDocumentType docType = new XmlDiffDocumentType( childPosition, 
                                                                               reader.Name,
                                                                               reader.GetAttribute("PUBLIC"),
                                                                               reader.GetAttribute("SYSTEM"),
                                                                               reader.Value );
                        docType.ComputeHashValue( _xmlHash );
                        InsertChild( parent, docType );
                    }
                    break;

                default:
                    Debug.Assert( false );
                    break;
            }
        } while ( reader.Read() );

    End:
        _curLastChild = savedLastChild;
    }