PathExpr expr = new PathExpr(pool); treeParser.xpath(ast, expr); if (treeParser.foundErrors()) { System.err.println(treeParser.getErrorMessage()); return; }
PathExpr expr = new PathExpr(); treeParser.xpath(ast, expr); if (treeParser.foundErrors()) { System.err.println(treeParser.getErrorMessage()); return; }
	public void testQuery() throws XPathException {		//String query = "document()//p[. &= '\uB2E8\uACC4']";		String query = "document()//p[. = '\u4ED6\u4E3A\u8FD9\u9879\u5DE5\u7A0B\u6295" +			"\u5165\u4E86\u5341\u4E09\u5E74\u65F6\u95F4\u3002']";					// get a BrokerPool for access to the database engine		BrokerPool pool = null;		try {			pool = BrokerPool.getInstance();		} catch (EXistException e1) {			e1.printStackTrace();			fail(e1.getMessage());		}		User user = pool.getSecurityManager().getUser("admin");		DBBroker broker = null;		try {				// parse the xml source			broker = pool.get();			Parser parser = new Parser(broker, user, true);			parser.parse(xml, "/db/test/test.xml");						// parse the query into the internal syntax tree			StaticContext context = new StaticContext(user);						XPathLexer2 lexer = new XPathLexer2(new StringReader(query));						XPathParser2 xparser = new XPathParser2(lexer);						XPathTreeParser2 treeParser = new XPathTreeParser2(pool, context);						xparser.xpath();						if (xparser.foundErrors()) {							System.err.println(xparser.getErrorMessage());							return;						}						AST ast = xparser.getAST();						System.out.println("generated AST: " + ast.toStringTree());						PathExpr expr = new PathExpr(pool);						treeParser.xpath(ast, expr);						if (treeParser.foundErrors()) {							System.err.println(treeParser.getErrorMessage());							return;						}						// execute the query			DocumentSet docs = expr.preselect();			Value resultValue = expr.eval(context, docs, null, null);						// check results			NodeSet resultSet = (NodeSet)resultValue.getNodeList();			System.out.println("----------------------------------");			System.out.println("found: " + resultSet.getLength());		} catch (RecognitionException e) {			e.printStackTrace();		} catch (TokenStreamException e) {			e.printStackTrace();		} catch (EXistException e) {			e.printStackTrace();		} catch (PermissionDeniedException e) {			e.printStackTrace();		} catch (SAXException e) {			e.printStackTrace();		} catch (IOException e) {			e.printStackTrace();		} finally {			pool.release(broker);		}		if(localDb)			try {				BrokerPool.stop();			} catch (EXistException e2) {				e2.printStackTrace();			}	}