/** * Test whether the current character is the expected character. * * @param actual The character that was read * @param expected The character that was expected * @throws XPathException if they are different */ private void expectChar(char actual, char expected) throws XPathException { if (actual != expected) { grumble("Expected '" + expected + "', found '" + actual + '\''); } }
/** * Parse the "declare revalidation" declaration. * Syntax: not allowed unless XQuery update is in use * * @throws XPathException if the syntax is incorrect, or is not allowed in this XQuery processor */ protected void parseRevalidationDeclaration() throws XPathException { grumble("declare revalidation is allowed only in XQuery Update"); }
/** * Parse the "declare revalidation" declaration. * Syntax: not allowed unless XQuery update is in use * * @throws XPathException if the syntax is incorrect, or is not allowed in this XQuery processor */ protected void parseRevalidationDeclaration() throws XPathException { grumble("declare revalidation is allowed only in XQuery Update"); }
@Override protected void testPermittedAxis(byte axis, String errorCode) throws XPathException { if (axis == AxisInfo.NAMESPACE && language == XQUERY) { grumble("The namespace axis is not available in XQuery", errorCode); } }
@Override protected void testPermittedAxis(byte axis, String errorCode) throws XPathException { if (axis == AxisInfo.NAMESPACE && language == XQUERY) { grumble("The namespace axis is not available in XQuery", errorCode); } }
/** * Test whether the current character is the expected character. * * @param actual The character that was read * @param expected The character that was expected * @throws XPathException if they are different */ private void expectChar(char actual, char expected) throws XPathException { if (actual != expected) { grumble("Expected '" + expected + "', found '" + actual + '\''); } }
/** * Parse a default decimal format declaration * "declare" "default" "decimal-format" (property "=" string-literal)* * * @throws XPathException if parsing fails */ private void parseDefaultDecimalFormat() throws XPathException { if (foundDefaultDecimalFormat) { grumble("Duplicate declaration of default decimal-format", "XQST0111"); } foundDefaultDecimalFormat = true; parseDecimalFormatProperties(null); }
/** * Parse a default decimal format declaration * "declare" "default" "decimal-format" (property "=" string-literal)* * * @throws XPathException if parsing fails */ private void parseDefaultDecimalFormat() throws XPathException { if (foundDefaultDecimalFormat) { grumble("Duplicate declaration of default decimal-format", "XQST0111"); } foundDefaultDecimalFormat = true; parseDecimalFormatProperties(null); }
/** * Parse the "declare ordering" declaration. * Syntax: <"declare" "ordering"> ("ordered" | "unordered") * * @throws XPathException if parsing fails */ private void parseOrderingDeclaration() throws XPathException { if (foundOrderingDeclaration) { grumble("ordering mode declaration appears more than once", "XQST0065"); } foundOrderingDeclaration = true; nextToken(); expect(Token.NAME); if ("ordered".equals(t.currentTokenValue)) { // no action } else if ("unordered".equals(t.currentTokenValue)) { // no action } else { grumble("ordering mode must be 'ordered' or 'unordered'"); } nextToken(); }
/** * Lookahead one token, catching any exception thrown by the tokenizer. This * method is only called from the query parser when switching from character-at-a-time * mode to tokenizing mode * * @throws XPathException if parsing fails */ protected void lookAhead() throws XPathException { try { t.lookAhead(); } catch (XPathException err) { grumble(err.getMessage()); } }
/** * Lookahead one token, catching any exception thrown by the tokenizer. This * method is only called from the query parser when switching from character-at-a-time * mode to tokenizing mode * * @throws XPathException if parsing fails */ protected void lookAhead() throws XPathException { try { t.lookAhead(); } catch (XPathException err) { grumble(err.getMessage()); } }
protected String readCollationName() throws XPathException { nextToken(); expect(Token.STRING_LITERAL); String collationName = uriLiteral(t.currentTokenValue); URI collationURI; try { collationURI = new URI(collationName); if (!collationURI.isAbsolute()) { URI base = new URI(env.getStaticBaseURI()); collationURI = base.resolve(collationURI); collationName = collationURI.toString(); } } catch (URISyntaxException err) { grumble("Collation name '" + collationName + "' is not a valid URI", "XQST0046"); collationName = NamespaceConstant.CODEPOINT_COLLATION_URI; } nextToken(); return collationName; }
protected String readCollationName() throws XPathException { nextToken(); expect(Token.STRING_LITERAL); String collationName = uriLiteral(t.currentTokenValue); URI collationURI; try { collationURI = new URI(collationName); if (!collationURI.isAbsolute()) { URI base = new URI(env.getStaticBaseURI()); collationURI = base.resolve(collationURI); collationName = collationURI.toString(); } } catch (URISyntaxException err) { grumble("Collation name '" + collationName + "' is not a valid URI", "XQST0046"); collationName = NamespaceConstant.CODEPOINT_COLLATION_URI; } nextToken(); return collationName; }
private void parseDefaultCollation() throws XPathException { // <"default" "collation"> StringLiteral if (foundDefaultCollation) { grumble("default collation appears more than once", "XQST0038"); } foundDefaultCollation = true; nextToken(); expect(Token.STRING_LITERAL); String uri = uriLiteral(t.currentTokenValue); ((QueryModule) env).setDefaultCollationName(uri); nextToken(); }
private void parseDefaultCollation() throws XPathException { // <"default" "collation"> StringLiteral if (foundDefaultCollation) { grumble("default collation appears more than once", "XQST0038"); } foundDefaultCollation = true; nextToken(); expect(Token.STRING_LITERAL); String uri = uriLiteral(t.currentTokenValue); ((QueryModule) env).setDefaultCollationName(uri); nextToken(); }
/** * Check a ForClause for an "outer for" * * @throws net.sf.saxon.trans.XPathException * if invalid */ private void checkForClauseAllowingEmpty(FLWORExpression flwor, ForClause clause) throws XPathException { if (!allowXPath30Syntax) { grumble("The 'allowing empty' option requires XQuery 3.0"); } SequenceType type = clause.getRangeVariable().getRequiredType(); if (!Cardinality.allowsZero(type.getCardinality())) { warning("When 'allowing empty' is specified, the occurrence indicator on the range variable type should be '?'"); } }
/** * Check a ForClause for an "outer for" * * @throws net.sf.saxon.trans.XPathException * if invalid */ private void checkForClauseAllowingEmpty(FLWORExpression flwor, ForClause clause) throws XPathException { if (!allowXPath30Syntax) { grumble("The 'allowing empty' option requires XQuery 3.0"); } SequenceType type = clause.getRangeVariable().getRequiredType(); if (!Cardinality.allowsZero(type.getCardinality())) { warning("When 'allowing empty' is specified, the occurrence indicator on the range variable type should be '?'"); } }
private Expression parseCommentConstructor() throws XPathException { try { char c = t.nextChar(); // XML-like comment expectChar(c, '-'); FastStringBuffer comment = new FastStringBuffer(FastStringBuffer.C256); while (!comment.toString().endsWith("--")) { comment.append(t.nextChar()); } if (t.nextChar() != '>') { grumble("'--' is not permitted in an XML comment"); } CharSequence commentText = comment.subSequence(0, comment.length() - 2); Comment instruction = new Comment(); instruction.setSelect(new StringLiteral(new StringValue(commentText))); setLocation(instruction); return instruction; } catch (StringIndexOutOfBoundsException err) { grumble("No closing '-->' found for comment constructor"); return null; } }
/** * Parse a named decimal format declaration. * "declare" "decimal-format" QName (property "=" string-literal)* * * @throws XPathException if parsing fails */ private void parseDecimalFormatDeclaration() throws XPathException { nextToken(); expect(Token.NAME); StructuredQName formatName = makeStructuredQName(t.currentTokenValue, ""); if (env.getDecimalFormatManager().getNamedDecimalFormat(formatName) != null) { grumble("Duplicate declaration of decimal-format " + formatName.getDisplayName(), "XQST0111"); } nextToken(); parseDecimalFormatProperties(formatName); }
/** * Parse a named decimal format declaration. * "declare" "decimal-format" QName (property "=" string-literal)* * * @throws XPathException if parsing fails */ private void parseDecimalFormatDeclaration() throws XPathException { nextToken(); expect(Token.NAME); StructuredQName formatName = makeStructuredQName(t.currentTokenValue, ""); if (env.getDecimalFormatManager().getNamedDecimalFormat(formatName) != null) { grumble("Duplicate declaration of decimal-format " + formatName.getDisplayName(), "XQST0111"); } nextToken(); parseDecimalFormatProperties(formatName); }