XQueryParser parser = new XQueryParser(lexer, false);
XQueryParser parser = new XQueryParser(lexer);
	protected String search(DBBroker broker, String query, String path,			int howmany, int start, Properties outputProperties)	throws BadRequestException, PermissionDeniedException {		String result = null;		try {			XQueryContext context = new XQueryContext(broker);			DocumentSet docs = new DocumentSet();			Collection collection = broker.getCollection(path);			if (collection != null) {				collection.allDocs(broker, docs, true);			} else {				DocumentImpl doc = (DocumentImpl) broker.getDocument(path);				if (doc != null)					docs.add(doc);				else					broker.getAllDocuments(docs);			}			context.setStaticallyKnownDocuments(docs);			XQueryLexer lexer = new XQueryLexer(new StringReader(query));			XQueryParser parser = new XQueryParser(lexer, false);			XQueryTreeParser treeParser = new XQueryTreeParser(context);			parser.xpath();			if (parser.foundErrors()) {				throw new BadRequestException(parser.getErrorMessage());			}			AST ast = parser.getAST();			PathExpr expr = new PathExpr(context);			treeParser.xpath(ast, expr);			if (treeParser.foundErrors()) {				throw new BadRequestException(treeParser.getErrorMessage());			}			LOG.info("query: " + expr.pprint());			if (parser.foundErrors())				throw new BadRequestException(parser.getErrorMessage());			long startTime = System.currentTimeMillis();			Sequence resultSequence = expr.eval(null, null);			long queryTime = System.currentTimeMillis() - startTime;			LOG.debug("evaluation took " + queryTime + "ms.");			startTime = System.currentTimeMillis();			return printResults(broker, resultSequence, howmany, start,					queryTime, outputProperties);		} catch (RecognitionException e) {			throw new BadRequestException(e.getMessage(), e);		} catch (TokenStreamException e) {			throw new BadRequestException(e.getMessage(), e);		} catch (XPathException e) {			throw new BadRequestException(e.getMessage(), e);		}	}