int howmany, int start, long queryTime, Properties outputProperties, int enclose)
int howmany, int start, long queryTime, Properties outputProperties, boolean wrap)
	protected String printResults(DBBroker broker, Sequence results,			int howmany, int start, long queryTime, Properties outputProperties, int enclose)			throws BadRequestException {		int rlen = results.getLength();		if (rlen > 0) {			if ((start < 1) || (start > rlen))				throw new BadRequestException("Start parameter out of range");			// FD : correct bound evaluation			if (((howmany + start) > rlen) || (howmany <= 0))				howmany = rlen - start + 1;		} else			howmany = 0;		Serializer serializer = broker.getSerializer();		serializer.reset();		SAXSerializer sax = null;		try {			StringWriter writer = new StringWriter();			sax = SAXSerializerPool.getInstance().borrowSAXSerializer();			sax.setWriter(writer);			sax.setOutputProperties(outputProperties);			serializer.setProperties(outputProperties);			serializer.setSAXHandlers(sax, sax);			LOG.debug(outputProperties.getProperty(EXistOutputKeys.STYLESHEET));						AttributesImpl attrs = new AttributesImpl();			attrs.addAttribute("", "hits", "hits", "CDATA", Integer.toString(rlen));			attrs.addAttribute("", "start", "start", "CDATA", Integer.toString(start));			attrs.addAttribute("", "count", "count", "CDATA", Integer.toString(howmany));						sax.startDocument();						if (enclose == 1) {			sax.startPrefixMapping("exist", NS);			sax.startElement(NS, "result", "exist:result", attrs);	    	} 						Item item;			for (int i = --start; i < start + howmany; i++) {				item = results.itemAt(i);				if (item == null) {					LOG.debug("item " + i + " not found");					continue;				}				if (Type.subTypeOf(item.getType(), Type.NODE)) {					NodeValue node = (NodeValue) item;					serializer.toSAX(node);				} else {					attrs.clear();					attrs.addAttribute("", "type", "type", "CDATA", Type.getTypeName(item.getType()));					sax.startElement(NS, "value", "exist:value", attrs);					item.toSAX(broker, sax);					sax.endElement(NS, "value", "exist:value");				}			}						if (enclose == 1) {			sax.endElement(NS, "result", "exist:result");			sax.endPrefixMapping("exist");            }			sax.endDocument();						return writer.toString();		} catch (SAXException e) {			LOG.warn(e);			throw new BadRequestException("Error while serializing xml: "					+ e.toString(), e);		} catch(Exception e) {			LOG.warn(e.getMessage(), e);			throw new BadRequestException("Error while serializing xml: "					+ e.toString(), e);		}	}