prefixes.remove(prefix);
	public void toSAX(		ContentHandler contentHandler,		LexicalHandler lexicalHandler,		boolean first,		ArrayList prefixes)		throws SAXException {		NodeList childNodes = getChildNodes();		NodeImpl child = null;		DBBroker broker = ownerDocument.getBroker();		AttributesImpl attributes = new AttributesImpl();		ArrayList myPrefixes = null;		String defaultNS = null;		if (declaresNamespacePrefixes()) {			// declare namespaces used by this element			String prefix;			myPrefixes = new ArrayList();			for (Iterator i = getNamespacePrefixes(); i.hasNext();) {				prefix = (String) i.next();				if (!prefixes.contains(prefix)) {					if (prefix.startsWith("#")) {						defaultNS = broker.getNamespaceURI(prefix);						contentHandler.startPrefixMapping("", defaultNS);					} else						contentHandler.startPrefixMapping(prefix, broker.getNamespaceURI(prefix));					prefixes.add(prefix);					myPrefixes.add(prefix);				}			}		}		if (first) {			attributes.addAttribute(				"http://exist.sourceforge.net/NS/exist",				"id",				"exist:id",				"CDATA",				Long.toString(gid));			attributes.addAttribute(				"http://exist.sourceforge.net/NS/exist",				"source",				"exist:source",				"CDATA",				ownerDocument.getFileName());		}		int i = 0;		while (i < childNodes.getLength()) {			child = (NodeImpl) childNodes.item(i);			if (child.getNodeType() == Node.ATTRIBUTE_NODE) {				attributes.addAttribute(					child.getNamespaceURI(),					child.getLocalName(),					child.getNodeName(),					"CDATA",					((AttrImpl) child).getValue());				i++;			} else				break;		}		String ns = defaultNS == null ? getNamespaceURI() : defaultNS;		contentHandler.startElement(ns, getLocalName(), getNodeName(), attributes);		while (i < childNodes.getLength()) {			child.toSAX(contentHandler, lexicalHandler, false, prefixes);			i++;			if (i < childNodes.getLength())				child = (NodeImpl) childNodes.item(i);			else				break;		}		contentHandler.endElement(ns, getLocalName(), getNodeName());		if (declaresNamespacePrefixes() && myPrefixes != null) {			String prefix;			for (Iterator pi = myPrefixes.iterator(); pi.hasNext();) {				prefix = (String) pi.next();				contentHandler.endPrefixMapping(prefix);				prefixes.remove(prefix);			}		}	}