if(Type.subTypeOf(p.getType(), Type.DOCUMENT)) {
if(Type.subTypeOf(p.getType(), Type.DOCUMENT) || p.gid < 0) {
    protected void serializeToReceiver(NodeProxy p, boolean generateDocEvent)    throws SAXException {    	if(Type.subTypeOf(p.getType(), Type.DOCUMENT)) {    			serializeToReceiver(p.getDocument(), generateDocEvent);    			return;    	}    	setDocument(p.getDocument());    	if (generateDocEvent) receiver.startDocument();        Iterator domIter = broker.getNodeIterator(p);        serializeToReceiver(null, domIter, p.getDocument(), p.gid, true, p.getMatches(), new TreeSet());        if (generateDocEvent) receiver.endDocument();    }