if (root != null) {
if (root != null && !(root instanceof NodeValue)) {
	public void getContentAsSAX(ContentHandler handler) throws XMLDBException {		DBBroker broker = null;        if (root != null) {			try {				String option = parent.properties.getProperty(Serializer.GENERATE_DOC_EVENTS, "false");                DOMStreamer streamer = DOMStreamerPool.getInstance().borrowDOMStreamer();                streamer.setContentHandler(handler);                streamer.serialize(root, option.equalsIgnoreCase("true"));                DOMStreamerPool.getInstance().returnDOMStreamer(streamer);			} catch (Exception e) {				throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, e.getMessage(), e);			}        } else if(value != null) {        	try {        		broker = brokerPool.get(user);        		value.toSAX(broker, handler);        	} catch (EXistException e) {				throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e);			} catch (SAXException e) {				throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e);			} finally {        		brokerPool.release(broker);        	}        } else {            try {                broker = brokerPool.get(user);                if (document == null)                    getDocument(broker);                if (!document.getPermissions().validate(user, Permission.READ))                    throw new XMLDBException(                        ErrorCodes.PERMISSION_DENIED,                        "permission denied to read resource");                Serializer serializer = broker.getSerializer();                serializer.setUser(user);                                String xml;                try {					serializer.setProperties(parent.properties);					serializer.setContentHandler(handler);                    if (id < 0)                        serializer.toSAX(document);                    else {                        if (proxy == null)                            proxy = new NodeProxy(document, id);                            serializer.toSAX(proxy);                    }                } catch (SAXException saxe) {                    saxe.printStackTrace();                    throw new XMLDBException(ErrorCodes.VENDOR_ERROR, saxe.getMessage(), saxe);                }            } catch (EXistException e) {                throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e);            } finally {                brokerPool.release(broker);            }        }	}