StoredNode prevNode;
    public void appendChildren(Txn transaction, NodeList nodes, int child) throws DOMException {        final DocumentImpl owner = (DocumentImpl)getOwnerDocument();        // attributes are handled differently. Call checkForAttributes to extract them.        nodes = checkForAttributes(transaction, nodes);        if (nodes == null || nodes.getLength() == 0)            return;        if (children == 0) {            // no children: append a new child            appendChildren(transaction, nodeId.newChild(), firstChildID(), new NodeImplRef(this), getPath(), nodes, true);        } else {            if (child == 1) {                Node firstChild = getFirstChild();                insertBefore(transaction, nodes, firstChild);            }            else {                StoredNode prevNode;                if (child > 0 && child <= children) {                    NodeList cl = getChildNodes();                    StoredNode last = (StoredNode) cl.item(child - 1);                    insertAfter(transaction, nodes, getLastNode(last));                } else {                    NodeList cl = getChildNodes();                    StoredNode last = (StoredNode) cl.item(cl.getLength() - 1);                     appendChildren(transaction, last.getNodeId().nextSibling(), -1,                             new NodeImplRef(getLastNode(last)), getPath(), nodes, true);                }            }        }        getBroker().updateNode(transaction, this);        getBroker().flush();    }