brokerPool.release(broker);
pool.release(broker);
	public void getContentAsSAX(ContentHandler handler) throws XMLDBException {		DBBroker broker = null;		// case 1: content is an external DOM node		if (root != null && !(root instanceof NodeValue)) {			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);			}					// case 2: content is an atomic value		} 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);			}					// case 3: content is an internal node or a document		} else {			try {				broker = brokerPool.get(user);				Serializer serializer = broker.getSerializer();				serializer.setUser(user);				serializer.setProperties(getProperties());				serializer.setContentHandler(handler);				if (root != null)					serializer.toSAX((NodeValue) root);				else {					DocumentImpl document = getDocument(broker, true);					try {						if (!document.getPermissions().validate(user,								Permission.READ))							throw new XMLDBException(ErrorCodes.PERMISSION_DENIED,							"permission denied to read resource");						String xml;						if (id < 0)							serializer.toSAX(document);						else {							if (proxy == null)								proxy = new NodeProxy(document, id);														serializer.toSAX(proxy);						}					} finally {					    parent.getCollection().releaseDocument(document);						brokerPool.release(broker);					}				}			} catch (EXistException e) {				throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e						.getMessage(), e);			} catch (SAXException e) {				throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e						.getMessage(), e);			}		}	}