if (doc==null) { continue; }
	public NodeSet toNodeSet() throws XPathException {		if(size == UNSET_SIZE)			return NodeSet.EMPTY_SET;        // for this method to work, all items have to be nodes		if(itemType != Type.ANY_TYPE && Type.subTypeOf(itemType, Type.NODE)) {			NodeSet set = new ExtArrayNodeSet();			NodeValue v;			for (int i = 0; i <= size; i++) {				v = (NodeValue)values[i];				if(v.getImplementationType() != NodeValue.PERSISTENT_NODE) {                    // found an in-memory document                    DocumentImpl doc = ((NodeImpl)v).getDocument();                    // make this document persistent: doc.makePersistent()                    // returns a map of all root node ids mapped to the corresponding                    // persistent node. We scan the current sequence and replace all                    // in-memory nodes with their new persistent node objects.                    Int2ObjectHashMap newRoots = doc.makePersistent();                    for (int j = i; j <= size; j++) {                        v = (NodeValue) values[j];                        if(v.getImplementationType() != NodeValue.PERSISTENT_NODE) {                            NodeImpl node = (NodeImpl) v;                            if (node.getDocument() == doc) {                                NodeProxy p = (NodeProxy) newRoots.get(node.getNodeNumber());                                if (p != null) {                                    // replace the node by the NodeProxy                                    values[j] = p;                                }                            }                        }                    }                    set.add((NodeProxy) values[i]);				} else {					set.add((NodeProxy)v);				}			}			return set;		} else			throw new XPathException("Type error: the sequence cannot be converted into" +				" a node set. Item type is " + Type.getTypeName(itemType));	}