public object removeChild(DOMNode oldNode) { // check for readonly node if (XmlNode.IsReadOnly) { DOMException.Throw(ExceptionCode.DomModificationNotAllowed); return(false); } try { XmlNode.RemoveChild(oldNode.XmlNode); } catch (ArgumentException) { DOMException.Throw(ExceptionCode.NotFound); return(false); } return(oldNode); }
public object getElementsByTagName(string name) { DOMNodeList list = new DOMNodeList(); if (IsAssociated) { // enumerate elements in the default namespace foreach (XmlNode node in XmlElement.GetElementsByTagName(name)) { IXmlDomNode dom_node = DOMNode.Create(node); if (dom_node != null) { list.AppendNode(dom_node); } } // enumerate all namespaces XPathNavigator navigator = XmlElement.CreateNavigator(); XPathNodeIterator iterator = navigator.Select("//namespace::*[not(. = ../../namespace::*)]"); while (iterator.MoveNext()) { string prefix = iterator.Current.Name; if (!String.IsNullOrEmpty(prefix) && prefix != "xml") { // enumerate elements in this namespace foreach (XmlNode node in XmlElement.GetElementsByTagName(name, iterator.Current.Value)) { IXmlDomNode dom_node = DOMNode.Create(node); if (dom_node != null) { list.AppendNode(dom_node); } } } } } return(list); }
public object appendChild(DOMNode newNode) { bool is_fragment; if (newNode is DOMDocumentFragment) { if (!newNode.IsAssociated || !newNode.XmlNode.HasChildNodes) { PhpException.Throw(PhpError.Warning, Resources.DocumentFragmentEmpty); return(false); } is_fragment = true; } else { is_fragment = false; } XmlNode result = CheckedChildOperation(newNode, null, delegate(DOMNode _newNode, DOMNode _) { return(XmlNode.AppendChild(_newNode.XmlNode)); }); if (result == null) { return(false); } if (is_fragment) { return(Create(result)); } else { return(newNode); } }
public object query(string expr, [Optional] DOMNode context) { XPathNavigator navigator = GetNavigator(context); if (navigator == null) { return(false); } XPathNodeIterator iterator; try { iterator = navigator.Select(expr, XmlNamespaceManager); } catch (Exception ex) { DOMException.Throw(ExceptionCode.SyntaxError, ex.Message); return(false); } // create the resulting node list return(IteratorToList(iterator)); }
public object insertBefore(DOMNode newNode, [Optional][Nullable] DOMNode refNode) { bool is_fragment; if (newNode is DOMDocumentFragment) { if (!newNode.IsAssociated || !newNode.XmlNode.HasChildNodes) { PhpException.Throw(PhpError.Warning, Resources.DocumentFragmentEmpty); return(false); } is_fragment = true; } else { is_fragment = false; } XmlNode result = CheckedChildOperation(newNode, refNode, delegate(DOMNode _newNode, DOMNode _refNode) { return(XmlNode.InsertBefore(_newNode.XmlNode, (_refNode == null ? null : _refNode.XmlNode))); }); if (result == null) { return(false); } if (is_fragment) { return(Create(result)); } else { return(newNode); } }
public object insertBefore(DOMNode newNode, [Optional][Nullable] DOMNode refNode) { bool is_fragment; if (newNode is DOMDocumentFragment) { if (!newNode.IsAssociated || !newNode.XmlNode.HasChildNodes) { PhpException.Throw(PhpError.Warning, Resources.DocumentFragmentEmpty); return false; } is_fragment = true; } else is_fragment = false; XmlNode result = CheckedChildOperation(newNode, refNode, delegate(DOMNode _newNode, DOMNode _refNode) { return XmlNode.InsertBefore(_newNode.XmlNode, (_refNode == null ? null : _refNode.XmlNode)); }); if (result == null) return false; if (is_fragment) return Create(result); else return newNode; }
public void handle(int operation, string key, object data, DOMNode src, DOMNode dst) { PhpException.Throw(PhpError.Warning, Resources.NotYetImplemented); }
public void isEqualNode(DOMNode anotherNode) { PhpException.Throw(PhpError.Warning, Resources.NotYetImplemented); }
public void compareDocumentPosition(DOMNode anotherNode) { PhpException.Throw(PhpError.Warning, Resources.NotYetImplemented); }
public void renameNode(DOMNode node, string namespaceUri, string qualifiedName) { PhpException.Throw(PhpError.Warning, Resources.NotYetImplemented); }
public void renameNode(DOMNode node, string namespaceUri, string qualifiedName) { PhpException.Throw(PhpError.Warning, Resources.NotYetImplemented); }
public object expand([Optional] DOMNode basenode) { return(false); }
public object importNode(DOMNode importedNode, bool deep) { if (importedNode.IsAssociated) { return DOMNode.Create(XmlDocument.ImportNode(importedNode.XmlNode, deep)); } else { importedNode.Associate(XmlDocument); return importedNode; } }
/// <summary> /// Performs a child-adding action with error checks. /// </summary> private XmlNode CheckedChildOperation(DOMNode/*!*/ newNode, DOMNode auxNode, NodeAction/*!*/ action) { newNode.Associate(XmlNode.OwnerDocument != null ? XmlNode.OwnerDocument : (XmlDocument)XmlNode); // check for readonly node if (XmlNode.IsReadOnly || (newNode.XmlNode.ParentNode != null && newNode.XmlNode.ParentNode.IsReadOnly)) { DOMException.Throw(ExceptionCode.DomModificationNotAllowed); return null; } // check for owner document mismatch if (XmlNode.OwnerDocument != null ? XmlNode.OwnerDocument != newNode.XmlNode.OwnerDocument : XmlNode != newNode.XmlNode.OwnerDocument) { DOMException.Throw(ExceptionCode.WrongDocument); return null; } XmlNode result; try { result = action(newNode, auxNode); } catch (InvalidOperationException) { // the current node is of a type that does not allow child nodes of the type of the newNode node // or the newNode is an ancestor of this node. DOMException.Throw(ExceptionCode.BadHierarchy); return null; } catch (ArgumentException) { // check for newNode == this which System.Xml reports as ArgumentException if (newNode.XmlNode == XmlNode) DOMException.Throw(ExceptionCode.BadHierarchy); else { // the refNode is not a child of this node DOMException.Throw(ExceptionCode.NotFound); } return null; } return result; }
private XPathNavigator GetNavigator(DOMNode context) { if (context == null) return XPathNavigator; else { XmlNode node = context.XmlNode; if (node.OwnerDocument != (XmlDocument)XPathNavigator.UnderlyingObject) { DOMException.Throw(ExceptionCode.WrongDocument); return null; } return node.CreateNavigator(); } }
public void isEqualNode(DOMNode anotherNode) { PhpException.Throw(PhpError.Warning, Resources.NotYetImplemented); }
public void compareDocumentPosition(DOMNode anotherNode) { PhpException.Throw(PhpError.Warning, Resources.NotYetImplemented); }
public object isSameNode(DOMNode anotherNode) { return(XmlNode == anotherNode.XmlNode); }
public void handle(int operation, string key, object data, DOMNode src, DOMNode dst) { PhpException.Throw(PhpError.Warning, Resources.NotYetImplemented); }
public object replaceChild(DOMNode newNode, DOMNode oldNode) { XmlNode result = CheckedChildOperation(newNode, oldNode, delegate(DOMNode _newNode, DOMNode _oldNode) { return XmlNode.ReplaceChild(_newNode.XmlNode, _oldNode.XmlNode); }); if (result == null) return false; if (newNode is DOMDocumentFragment) return Create(result); else return newNode; }
public void adoptNode(DOMNode source) { PhpException.Throw(PhpError.Warning, Resources.NotYetImplemented); }
public object appendChild(DOMNode newNode) { bool is_fragment; if (newNode is DOMDocumentFragment) { if (!newNode.IsAssociated || !newNode.XmlNode.HasChildNodes) { PhpException.Throw(PhpError.Warning, Resources.DocumentFragmentEmpty); return false; } is_fragment = true; } else is_fragment = false; XmlNode result = CheckedChildOperation(newNode, null, delegate(DOMNode _newNode, DOMNode _) { return XmlNode.AppendChild(_newNode.XmlNode); }); if (result == null) return false; if (is_fragment) return Create(result); else return newNode; }
public void adoptNode(DOMNode source) { PhpException.Throw(PhpError.Warning, Resources.NotYetImplemented); }
public object removeChild(DOMNode oldNode) { // check for readonly node if (XmlNode.IsReadOnly) { DOMException.Throw(ExceptionCode.DomModificationNotAllowed); return false; } try { XmlNode.RemoveChild(oldNode.XmlNode); } catch (ArgumentException) { DOMException.Throw(ExceptionCode.NotFound); return false; } return oldNode; }
public void setNamedItemNS(DOMNode item) { PhpException.Throw(PhpError.Warning, Resources.NotYetImplemented); }
public object isSameNode(DOMNode anotherNode) { return (XmlNode == anotherNode.XmlNode); }