code: public void setNextSibling(Node nextSibling) {
  
          // does the corrent parent/child relationship exist?
          if (nextSibling != null) {
              // cannot be a sibling of a null node
              if (node == null) {
                  throw new IllegalStateException("Cannot create a DOMResult when the nextSibling is contained by the \"null\" node.");
              }
  
              // nextSibling contained by node?
              if ((node.compareDocumentPosition(nextSibling)&Node.DOCUMENT_POSITION_CONTAINED_BY)==0) {
                  throw new IllegalArgumentException("Cannot create a DOMResult when the nextSibling is not contained by the node.");
              }
          }
  
          this.nextSibling = nextSibling;
      }
docs: <p>Set the child node before which the result nodes will be inserted.</p>
  
  <p>Use <code>nextSibling</code> to specify the child node
  before which the result nodes should be inserted.
  If <code>nextSibling</code> is not a descendant of <code>node</code>,
  then an <code>IllegalArgumentException</code> is thrown.
  If <code>node</code> is <code>null</code> and <code>nextSibling</code> is not <code>null</code>,
  then an <code>IllegalStateException</code> is thrown.
  If <code>nextSibling</code> is <code>null</code>,
  then the behavior is the same as calling {@link #DOMResult(Node node)},
  i.e. append the result nodes as the last child of the specified <code>node</code>.</p>
  
  @param nextSibling The child node before which the result nodes will be inserted.
  
  @throws IllegalArgumentException If <code>nextSibling</code> is not a descendant of <code>node</code>.
  @throws IllegalStateException If <code>node</code> is <code>null</code> and <code>nextSibling</code> is not <code>null</code>.
  
  @since 1.5