XQueryParser parser = new XQueryParser(lexer, false);
XQueryParser parser = new XQueryParser(lexer);
	public void importModule(String namespaceURI, String prefix, String location)		throws XPathException {		if(location == null)			location = namespaceURI;		if(location.startsWith("java:")) {			location = location.substring("java:".length());			loadBuiltInModule(namespaceURI, location);			if(prefix != null)				declareNamespace(prefix, namespaceURI);			return;		}		if(location.indexOf(':') < 0) {			File f = new File(moduleLoadPath + File.separatorChar + location);			if(!f.canRead()) {				f = new File(location);				if(!f.canRead())					throw new XPathException("cannot read module source from file at " + f.getAbsolutePath());			}			location = f.toURI().toASCIIString();		}		LOG.debug("Loading module from " + location);		InputStreamReader reader;		try {			URL url = new URL(location);			reader = new InputStreamReader(url.openStream(), "UTF-8");		} catch (MalformedURLException e) {			throw new XPathException("source location for module " + namespaceURI + " should be a valid URL");		} catch (UnsupportedEncodingException e) {			throw new XPathException("unsupported source encoding");		} catch (IOException e) {			throw new XPathException("IO exception while loading module " + namespaceURI, e);		}		XQueryContext context = new XQueryContext(broker);		context.setStaticallyKnownDocuments(getStaticallyKnownDocuments());				XQueryLexer lexer = new XQueryLexer(reader);		XQueryParser parser = new XQueryParser(lexer, false);		XQueryTreeParser astParser = new XQueryTreeParser(context);		try {			parser.xpath();			if (parser.foundErrors()) {				LOG.debug(parser.getErrorMessage());				throw new XPathException(					"error found while loading module from " + location + ": "						+ parser.getErrorMessage());			}			AST ast = parser.getAST();			PathExpr path = new PathExpr(context);			astParser.xpath(ast, path);			if (astParser.foundErrors()) {				throw new XPathException(					"error found while loading module from " + location + ": "						+ astParser.getErrorMessage(),					astParser.getLastException());			}						ExternalModule module = astParser.getModule();			if(module == null)				throw new XPathException("source at " + location + " is not a valid module");			if(!module.getNamespaceURI().equals(namespaceURI))				throw new XPathException("namespace URI declared by module (" + module.getNamespaceURI() + 					") does not match namespace URI in import statement, which was: " + namespaceURI);			if(prefix == null)				prefix = module.getDefaultPrefix();			declareNamespace(prefix, namespaceURI);			modules.put(module.getNamespaceURI(), module);			context.modules.put(module.getNamespaceURI(), module);		} catch (RecognitionException e) {			throw new XPathException(				"error found while loading module from " + location + ": " + e.getMessage(),				e);		} catch (TokenStreamException e) {			throw new XPathException(				"error found while loading module from " + location + ": " + e.getMessage(),				e);		}	}