Insert the node newChild before the existing child node refChild. If refChild is null, insert newChild at the end og the child's list. If newChild is an object DocumentFragment, all its childs are inserted, in the same order, before the refChild. If the newChild already exist in the tree is deleted.

1 dom.node.insertBefore

    <newChild /> !
    <refChild /> !



Appears if this node is of a type that not allow childs of the newChild node, if the type of the node to put is one of the ancestors of the node itself or the node itself, also if the node is of the Document type ans the result of the substitution operation adds a second DocumentType or Element in the Document node.


Appears if newChild has been created of a different document than the one created by this node.


Appears if this node is readonly or if the previous parent of the node being inserted is readonly.


Appears if refChild is not a child of this node.


If this node is of the Document type, this exception may appear if the DOM implementation does not support the replacement of the DocumentType child or Element child.


If the node to be added does not belong to the document to which the node in which it is to be added belongs, is necessary perform first a import of the node that will be added to decontextualize it, it means, unlink it of its owner document and in this way can use it in a different document. This operation should be performed when adding ( dom.node.insertBefore), moving ( dom.node.replaceChild) or inserting ( dom.node.insertBefore).


Inserting a node of a document below another node of a different document.

<xsql-script name='dom_node_insertBefore'>
        <set name='root_ori'><dom.parse><file name='data1.xml' type='absolute' /></dom.parse></set>
        <set name='root_rpl'><dom.parse><file name='data2.xml' type='absolute' /></dom.parse></set>

        <!-- The node should be imported to unlink it of its                       -->
        <!-- owner document, and be able to use it in a new document.              -->
        <set name='node_rpl'>

        <!-- Replace the first element of the original document   -->
        <!-- with the node of the remplaced document.             -->
            <dom.element.getFirstChildElement><root_ori /></dom.element.getFirstChildElement>

<xsql-script name="print">
        <string>HELLO ECHO</string>

            <socket.print host="dbsrv1" port="7301">
            <string>HELLO ECHO</string></socket.print>