node = new ElementImpl(0, qn);
node = new ElementImpl(qn);
	public void startElement(		String namespace,		String name,		String qname,		Attributes attributes) throws SAXException {		// calculate number of real attributes:		// don't store namespace declarations		int attrLength = attributes.getLength();		String attrQName;		String attrNS;		for (int i = 0; i < attributes.getLength(); i++) {			attrNS = attributes.getURI(i);			attrQName = attributes.getQName(i);			if (attrQName.startsWith("xmlns") || attrNS.equals(Serializer.EXIST_NS))				--attrLength;		}		ElementImpl last = null;		ElementImpl node = null;		int p = qname.indexOf(':');		String prefix = (p != Constants.STRING_NOT_FOUND) ? qname.substring(0, p) : "";		QName qn = broker.getSymbols().getQName(Node.ELEMENT_NODE, namespace, name, prefix);		if (!stack.empty()) {			last = (ElementImpl) stack.peek();			if (charBuf != null) {				if(charBuf.isWhitespaceOnly()) {					if (suppressWSmixed) {						if(charBuf.length() > 0 && last.getChildCount() > 0) {							text.setData(charBuf);							text.setOwnerDocument(document);							last.appendChildInternal(prevNode, text);                         prevNode = text;							if (!validate)								storeText();							text.clear();					   }					}									} else if(charBuf.length() > 0) {					// mixed element content: don't normalize the text node, just check					// if there is any text at all					text.setData(charBuf);					text.setOwnerDocument(document);					last.appendChildInternal(prevNode, text);                  prevNode = text;					if (!validate)						storeText();					text.clear();				}				charBuf.reset();			}			if (!usedElements.isEmpty()) {				node = (ElementImpl) usedElements.pop();				node.setNodeName(qn);			} else				node = new ElementImpl(qn);			// copy xml:space setting			node.setPreserveSpace(last.preserveSpace());			// append the node to its parent 			// (computes the node id and updates the parent's child count)			last.appendChildInternal(prevNode, node);			prevNode = null;			node.setOwnerDocument(document);			node.setAttributes((short) attrLength);			if (nsMappings != null && nsMappings.size() > 0) {				node.setNamespaceMappings(nsMappings);				nsMappings.clear();			}			stack.push(node);			currentPath.addComponent(qn);            node.setPosition(elementCnt++);			if (!validate) {                if (childCnt != null)                    node.setChildCount(childCnt[node.getPosition()]);				storeElement(node);			}		} else {			if (validate)				node = new ElementImpl(0, qn);			else				node = new ElementImpl(1, qn);			rootNode = node;           prevNode = null;           node.setNodeId(broker.getBrokerPool().getNodeFactory().createInstance());			node.setOwnerDocument(document);			node.setAttributes((short) attrLength);			if (nsMappings != null && nsMappings.size() > 0) {				node.setNamespaceMappings(nsMappings);				nsMappings.clear();			}			stack.push(node);			currentPath.addComponent(qn);            node.setPosition(elementCnt++);			if (!validate) {                if (childCnt != null)                    node.setChildCount(childCnt[node.getPosition()]);				storeElement(node);			}			document.appendChild(node);		}		level++;		if (document.getMaxDepth() < level)			document.setMaxDepth(level);		String attrPrefix;		String attrLocalName;		for (int i = 0; i < attributes.getLength(); i++) {			attrNS = attributes.getURI(i);			attrLocalName = attributes.getLocalName(i);			attrQName = attributes.getQName(i);			// skip xmlns-attributes and attributes in eXist's namespace			if (attrQName.startsWith("xmlns") || attrNS.equals(Serializer.EXIST_NS))				--attrLength;			else {				p = attrQName.indexOf(':');				attrPrefix = (p != Constants.STRING_NOT_FOUND) ? attrQName.substring(0, p) : null;				final AttrImpl attr = (AttrImpl)NodeObjectPool.getInstance().borrowNode(AttrImpl.class);				attr.setNodeName(document.getSymbols().getQName(Node.ATTRIBUTE_NODE, attrNS, attrLocalName, attrPrefix));				attr.setValue(attributes.getValue(i));				attr.setOwnerDocument(document);				if (attributes.getType(i).equals(ATTR_ID_TYPE)) {					attr.setType(AttrImpl.ID);				} else if (attr.getQName().equalsSimple(Namespaces.XML_ID_QNAME)) {					// an xml:id attribute. Normalize the attribute and set its type to ID					attr.setValue(StringValue.trimWhitespace(StringValue.collapseWhitespace(attr.getValue())));					if (!XMLChar.isValidNCName(attr.getValue()))						throw new SAXException("Value of xml:id attribute is not a valid NCName: " + attr.getValue());					attr.setType(AttrImpl.ID);				} else if (attr.getQName().equalsSimple(Namespaces.XML_SPACE_QNAME)) {					node.setPreserveSpace("preserve".equals(attr.getValue()));				}				node.appendChildInternal(prevNode, attr);               prevNode = attr;				if (!validate)					broker.storeNode(transaction, attr, currentPath);				attr.release();			}		}		if (attrLength > 0)			node.setAttributes((short) attrLength);		// notify observers about progress every 100 lines		if (locator != null) {			currentLine = locator.getLineNumber();			if (!validate) {				progress.setValue(currentLine);				if (progress.changed()) {					setChanged();					notifyObservers(progress);				}			}		}	}