return; }
	protected void startForEach(Attributes attribs) throws SAXException {		if(collection == null) {			reportError(FATAL_ERROR, "no collection selected");			return;		}		ForEach each = new ForEach();		nesting++;		XMLResource resource = null;		boolean nested = !commandStack.isEmpty();		if (nested) {			ForEach last = (ForEach) commandStack.peek();			resource = last.currentResource;		}		commandStack.push(each);		// process attributes		xpath = attribs.getValue("query");		if (xpath == null) {			reportError(FATAL_ERROR, "attribute 'query' is missing");			return;		}		each.query = xpath;		String pFrom = attribs.getValue("from");		if (pFrom != null)			try {				each.from = Integer.parseInt(pFrom);			} catch (NumberFormatException e) {				reportError(WARNING, "attribute 'from' requires numeric value");			}		String pTo = attribs.getValue("to");		if (pTo != null)			try {				each.to = Integer.parseInt(pTo);			} catch (NumberFormatException e) {				reportError(WARNING, "attribute 'to' requires numeric value");			}		String pSession = attribs.getValue("use-session");		boolean createSession = false;		if (pSession != null)			createSession = pSession.equals("true");		Session session = null;		if (createSession)			session = request.getSession(true);		final long start = System.currentTimeMillis();		try {			ResourceSet queryResult = null;			XPathQueryServiceImpl service =				(XPathQueryServiceImpl) collection.getService("XPathQueryService", "1.0");			service.setProperty("sax-document-events", "false");			service.setProperty("create-container-elements", "false");			// check if query result is already stored in the session			if (createSession && resource == null)				queryResult = (ResourceSet) session.getAttribute(xpath);			if (queryResult == null) {				queryResult =					(resource == null) ? service.query(xpath) : service.query(resource, xpath);				if (createSession)					session.setAttribute(xpath, queryResult);			}			if (queryResult == null)				reportError(WARNING, "query returned null");			each.queryResult = queryResult;			int size = (int) each.queryResult.getSize();			if (each.from < 0)				each.from = 0;			if (each.to < 0 || each.to > size)				each.to = size;			if (!nested) {				AttributesImpl atts = new AttributesImpl();				atts.addAttribute(					"",					"count",					"count",					"CDATA",					queryResult == null ? "0" : Long.toString(queryResult.getSize()));				atts.addAttribute("", "xpath", "xpath", "CDATA", xpath);				atts.addAttribute(					"",					"query-time",					"query-time",					"CDATA",					Long.toString((System.currentTimeMillis() - start)));				atts.addAttribute("", "from", "from", "CDATA", Integer.toString(each.from));				atts.addAttribute("", "to", "to", "CDATA", Integer.toString(each.to));				super.startElement(					NAMESPACE,					RESULT_SET_ELEMENT,					PREFIX + RESULT_SET_ELEMENT,					atts);			}		} catch (XMLDBException e) {			reportError(FATAL_ERROR, e.getMessage(), e);			return;		}		isRecording = true;		startRecording();	}