if(nextRef == 0) { return; } MemTreeBuilder builder = new MemTreeBuilder(context); DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(builder); try { builder.startDocument(); NodeImpl node = (NodeImpl) getFirstChild(); while(node != null) { copyTo(node, receiver, true); node = (NodeImpl) node.getNextSibling(); } receiver.endDocument(); } catch (SAXException e) { throw new DOMException(DOMException.INVALID_STATE_ERR, e.getMessage()); } DocumentImpl newDoc = builder.getDocument();
DocumentImpl newDoc = expandRefs();
    public void expand() throws DOMException {        if(nextRef == 0) {            return;        }        MemTreeBuilder builder = new MemTreeBuilder(context);        DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(builder);        try {            builder.startDocument();            NodeImpl node = (NodeImpl) getFirstChild();            while(node != null) {                copyTo(node, receiver, true);                node = (NodeImpl) node.getNextSibling();            }            receiver.endDocument();        } catch (SAXException e) {            throw new DOMException(DOMException.INVALID_STATE_ERR, e.getMessage());        }        DocumentImpl newDoc = builder.getDocument();        copyDocContents(newDoc);    }