set { throw new NotImplementedException (); }
}
- private void AppendChildValues(XmlNode parent, StringBuilder builder)
+ private void AppendChildValues (XmlNode parent, StringBuilder builder)
{
XmlNode node = parent.FirstChild;
while (node != null) {
- builder.Append (node.Value);
+ if (node.NodeType == XmlNodeType.Text)
+ builder.Append (node.Value);
AppendChildValues (node, builder);
node = node.NextSibling;
}
public virtual XmlNode AppendChild (XmlNode newChild)
{
- if (NodeType == XmlNodeType.Document
- || NodeType == XmlNodeType.Element
- || NodeType == XmlNodeType.Attribute) {
+ XmlDocument ownerDoc = (NodeType == XmlNodeType.Document) ? (XmlDocument)this : OwnerDocument;
+
+ ownerDoc.onNodeInserting (newChild, this);
+
+ if (NodeType == XmlNodeType.Document || NodeType == XmlNodeType.Element || NodeType == XmlNodeType.Attribute) {
+
+ if (newChild.OwnerDocument != ownerDoc)
+ throw new ArgumentException ("Can't append a node created by another document.");
+
XmlLinkedNode newLinkedChild = (XmlLinkedNode) newChild;
XmlLinkedNode lastLinkedChild = LastLinkedChild;
LastLinkedChild = newLinkedChild;
+ ownerDoc.onNodeInserted (newChild, newChild.ParentNode);
+
return newChild;
} else
throw new InvalidOperationException();
public abstract XmlNode CloneNode (bool deep);
[MonoTODO]
- public virtual XPathNavigator CreateNavigator ()
+ public XPathNavigator CreateNavigator ()
{
return new XmlDocumentNavigator(this);
}
public virtual void RemoveAll ()
{
+ XmlDocument ownerDoc = (NodeType == XmlNodeType.Document) ? (XmlDocument)this : OwnerDocument;
+
+ ownerDoc.onNodeRemoving (this, this.ParentNode);
LastLinkedChild = null;
+ ownerDoc.onNodeRemoved (this, this.ParentNode);
}
public virtual XmlNode RemoveChild (XmlNode oldChild)
{
+ OwnerDocument.onNodeRemoving (oldChild, oldChild.ParentNode);
+
if (NodeType == XmlNodeType.Document || NodeType == XmlNodeType.Element || NodeType == XmlNodeType.Attribute)
{
if (IsReadOnly)
oldLinkedChild.NextLinkedSibling = null;
}
+ OwnerDocument.onNodeRemoved (oldChild, oldChild.ParentNode);
+
return oldChild;
}
else