Node node = null;
    public Node appendChildren(NodeList nodes, int child)            throws DOMException {    	// attributes are handled differently. Call checkForAttributes to extract them.        nodes = checkForAttributes(nodes);        if (nodes == null || nodes.getLength() == 0)            return null;        DocumentImpl prevDoc = new DocumentImpl(ownerDocument);        Node node = null;        if (children == 0) {            // no children: append a new child            node = appendChildren(firstChildID(), this, getPath(), nodes, true);        }        else {            if (child == 1) {                Node firstChild = getFirstChild();                insertBefore(nodes, firstChild);            }            else {                NodeImpl prevNode;                long pos = firstChildID();                if (0 < child && child <= children) {                    pos = firstChildID() + child - 2;                    prevNode = getLastNode((NodeImpl) ownerDocument.getNode(pos));                    node = insertAfter(nodes, prevNode);                }                else {                    prevNode = getLastNode((NodeImpl) ownerDocument.getNode(lastChildID()));                    node = appendChildren(lastChildID() + 1, prevNode, getPath(), nodes, true);                }            }        }        ownerDocument.broker.update(this);        ownerDocument.broker.reindex(prevDoc, ownerDocument, null);        return node;    }