*/
    private void parseVersionDeclaration() throws XPathException {
        if (t.currentToken == Token.XQUERY_VERSION) {
            nextToken();
            expect(Token.STRING_LITERAL);
            queryVersion = t.currentTokenValue;
            if ("1.0".equals(queryVersion)) {
                // no action
            } else if ("1.1".equals(queryVersion)) {
                if (!env.getConfiguration().isLicensedFeature(Configuration.LicenseFeature.SCHEMA_AWARE_XQUERY)) {
                    grumble("XQuery 1.1 is not supported in this version of Saxon", "XQST0031");
                    queryVersion = "1.0";
                }
                if (!"1.1".equals(((QueryModule)env).getLanguageVersion())) {
                    grumble("XQuery 1.1 was not enabled when invoking Saxon", "XQST0031");
                    queryVersion = "1.0";
                }
            } else {
                grumble("Unsupported XQuery version " + queryVersion, "XQST0031");
                queryVersion = "1.0";
            }
            nextToken();
            if ("encoding".equals(t.currentTokenValue)) {
                nextToken();
                expect(Token.STRING_LITERAL);
                if (!encNamePattern.matcher(t.currentTokenValue).matches()) {
                    grumble("Encoding name contains invalid characters", "XQST0087");
                }
                // we ignore the encoding now: it was handled earlier, while decoding the byte stream
                nextToken();
            }
            expect(Token.SEMICOLON);
            nextToken();
        }
    }