* @return QName describing the module namespace or null if the source is not
* a module.
*/
protected final static QName getModuleDecl(InputStream is) {
final XQueryLexer lexer = new XQueryLexer(null, new InputStreamReader(is));
final DeclScanner scanner = new DeclScanner(lexer);
try {
scanner.versionDecl();
} catch (final RecognitionException e) {
//Nothing to do
} catch (final TokenStreamException e) {
//Nothing to do
} catch (final XPathException e) {
//Nothing to do
}
if (scanner.getNamespace() != null) {
return new QName(scanner.getPrefix(), scanner.getNamespace());
}
return null;
}