[DOMCore]

I would like to submit to you a possible addition to the DOM specification
based on discoveries I made while developing a new protocol named XRDOM.

The addition is a method named takeChildNodes which should be added to the
Node interface. This method makes it more possible to easily move data
around the document with linear code that does not require any flow control
statements (loops). One example would be to move a nodes children to its
parent node and then remove the node itself. I have been using this method
to replace an element with another element, including the attributes while
not affecting the position of the hostNodes child nodes in the document.
The takeChildNodes method can also be used in conjunction with the cloneNode
function to copy attribute values or to provide more easily cut,copy, and
paste functionality.  The takeChildNodes method returns the node itself for
convenience and must remove the nodes from the hostNode, as cloneNode can be
used in conjunction for the purpose of copying only the child nodes.

See related XRDOM Notes:
http://wiki.vnetpublishing.com/XRDOM_(XML_Rest_Dom_API)#Notes

<http://wiki.vnetpublishing.com/XRDOM_%28XML_Rest_Dom_API%29#Notes>

Recommendation:

  interface Node
<http://dev.w3.org/2006/webapi/DOM4Core/DOM4Core.html#interface-node>
{

    ...

    Node <http://dev.w3.org/2006/webapi/DOM4Core/DOM4Core.html#interface-node>
                           takeChildNodes(Node
<http://dev.w3.org/2006/webapi/DOM4Core/DOM4Core.html#interface-node>
hostNode);

    ...
  };


takeChildNodes
This method removes all child nodes from the provided hostNode and appends
them to the end of the list of children of this node in the same order they
were in the original hostNode. This method does not remove Attr nodes and
does not move Attr nodes to the current node.

*Parameters*
hostNode of type NodeThe Node to remove children from.
*Return Value*

Node

The current Node which now has the child nodes from the hostNode.
*Exceptions*
*

DOMException <http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-17189187>

HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow
children of the type of the node(s) received from the hostNode, or if the
node to append is one of this node's
ancestors<http://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-ancestor>
or
this node itself, or if this node is of type
Document<http://www.w3.org/TR/DOM-Level-3-Core/core.html#i-Document>
and
the DOM application attempts to append a second
DocumentType<http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-412266927>
 or Element <http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-745549614>
 node.

WRONG_DOCUMENT_ERR: Raised if a hostNode was created from a different
document than the one that created this node.

NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if the
previous parent of the node being inserted is readonly.

NOT_SUPPORTED_ERR: this exception might be raised if the DOM implementation
doesn't support the moving of the
DocumentType<http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-412266927>
child
or Element <http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-745549614>
 child.
*

---

Please send any issues related to this suggestion to rritoch@gmail.com .

Best Regards,
 Ralph Ritoch
 http://www.vnetpublishing.com

Received on Sunday, 23 January 2011 13:39:37 UTC