return result; }
break; }  } } catch (Exception e) { HttpServer.LOG.debug(e.toString(), e); result = formatErrorMsg(e.toString(), UNKNOWN_ERROR); }  return result; }
    protected String search( String query, int howmany, int start,                             boolean printSummary, boolean indent,                             String stylesheet                             ) {        String result = null;        try {        	StaticContext context = new StaticContext(broker);			XPathLexer2 lexer = new XPathLexer2(new StringReader(query));			XPathParser2 parser = new XPathParser2(lexer);			XPathTreeParser2 treeParser = new XPathTreeParser2(context);			parser.xpath();						if(parser.foundErrors()) {							return formatErrorMsg( parser.getErrorMessage(  ), SYNTAX_ERROR );						}						AST ast = parser.getAST();						HttpServer.LOG.debug("generated AST: " + ast.toStringTree());									PathExpr expr = new PathExpr();						treeParser.xpath(ast, expr);						if(treeParser.foundErrors()) {								return formatErrorMsg( treeParser.getErrorMessage(  ), SYNTAX_ERROR );						}												HttpServer.LOG.info("query: " + expr.pprint());            if ( parser.foundErrors(  ) )                return formatErrorMsg( parser.getErrorMessage(  ), SYNTAX_ERROR );            long startTime = System.currentTimeMillis(  );            DocumentSet ndocs = expr.preselect( context );            if ( ndocs.getLength(  ) == 0 )                result = formatErrorMsg( "nothing found", OK );            else {                Sequence resultSequence = expr.eval( context, ndocs, null, null );                long queryTime = System.currentTimeMillis(  ) - startTime;                HttpServer.LOG.debug( "evaluation took " + queryTime + "ms." );                startTime = System.currentTimeMillis(  );                switch ( resultSequence.getItemType(  ) ) {                case Type.NODE:                    if ( printSummary )                        result = printSummary( (NodeSet)resultSequence, queryTime );                    else                        result =                            printAll( (NodeSet)resultSequence, howmany, start, queryTime,                                      indent, stylesheet                                      );                    break;                default:                    result = printValues( resultSequence, howmany, start );                    break;                }            }        } catch ( Exception e ) {            HttpServer.LOG.debug( e.toString(  ), e );            result = formatErrorMsg( e.toString(  ), UNKNOWN_ERROR );        }        return result;    }