NodeList cl = doc.getDocumentElement().getChildNodes();
org.exist.dom.ElementImpl root = (org.exist.dom.ElementImpl) doc.getDocumentElement(); NodeList cl = root.getChildNodes();
    public Int2ObjectHashMap makePersistent() throws XPathException {        if (size <= 1)            return null;        List oldIds = new ArrayList(20);        int top = 1;        while (top > 0) {            oldIds.add(new Integer(top));            top = getNextSiblingFor(top);        }        DocumentImpl expandedDoc = expandRefs();        org.exist.dom.DocumentImpl doc = context.storeTemporaryDoc(expandedDoc);        NodeList cl = doc.getDocumentElement().getChildNodes();        storedNodes = new Int2ObjectHashMap();        top = 1;        int i = 0;        while(top > 0 && i < cl.getLength()) {            org.exist.dom.NodeImpl node = (org.exist.dom.NodeImpl) cl.item(i);            NodeProxy proxy = new NodeProxy(doc, node.getGID(), node.getInternalAddress());            int old = ((Integer)oldIds.get(i)).intValue();            storedNodes.put(old, proxy);            top = expandedDoc.getNextSiblingFor(top);            i++;        }        return storedNodes;    }