/** * Parse the "declare revalidation" declaration. * Syntax: not allowed unless XQuery update is in use * * @throws XPathException */ protected void parseRevalidationDeclaration() throws XPathException { grumble("declare revalidation is allowed only in XQuery Update"); }
/** * Parse an updating function declaration (allowed in XQuery Update only) */ protected void parseUpdatingFunctionDeclaration() throws XPathException { grumble("Updating functions are allowed only in XQuery Update"); }
/** * 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 + '\''); } }
/** * 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 + '\''); } }
private String analyzeEntityReference(String entity) throws XPathException { if ("lt".equals(entity)) { return "<"; } else if ("gt".equals(entity)) { return ">"; } else if ("amp".equals(entity)) { return "&"; } else if ("quot".equals(entity)) { return "\""; } else if ("apos".equals(entity)) { return "'"; } else if (entity.length() < 2 || entity.charAt(0) != '#') { grumble("invalid character reference &" + entity + ';'); return null; } else { //entity = entity.toLowerCase(); return parseCharacterReference(entity); } }
private String analyzeEntityReference(String entity) throws XPathException { if ("lt".equals(entity)) { return "<"; } else if ("gt".equals(entity)) { return ">"; } else if ("amp".equals(entity)) { return "&"; } else if ("quot".equals(entity)) { return "\""; } else if ("apos".equals(entity)) { return "'"; } else if (entity.length() < 2 || entity.charAt(0) != '#') { grumble("invalid entity reference &" + entity + ';'); return null; } else { //entity = entity.toLowerCase(); return parseCharacterReference(entity); } }
/** * 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 */ private void lookAhead() throws XPathException { try { t.lookAhead(); } catch (XPathException err) { grumble(err.getMessage()); } }
/** * Parse the "declare ordering" declaration. * Syntax: <"declare" "ordering"> ("ordered" | "unordered") * * @throws XPathException */ 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 */ private void lookAhead() throws XPathException { try { t.lookAhead(); } catch (XPathException err) { grumble(err.getMessage()); } }
/** * Parse the "declare xmlspace" declaration. * Syntax: <"declare" "boundary-space"> ("preserve" | "strip") * * @throws XPathException */ private void parseBoundarySpaceDeclaration() throws XPathException { if (foundBoundarySpaceDeclaration) { grumble("'declare boundary-space' appears more than once", "XQST0068"); } foundBoundarySpaceDeclaration = true; nextToken(); expect(Token.NAME); if ("preserve".equals(t.currentTokenValue)) { ((QueryModule)env).setPreserveBoundarySpace(true); } else if ("strip".equals(t.currentTokenValue)) { ((QueryModule)env).setPreserveBoundarySpace(false); } else { grumble("boundary-space must be 'preserve' or 'strip'"); } nextToken(); }
private void applySchemaImport(Import sImport) throws XPathException { // Do the importing Configuration config = env.getConfiguration(); if (!config.isSchemaAvailable(sImport.namespaceURI)) { if (!sImport.locationURIs.isEmpty()) { try { PipelineConfiguration pipe = config.makePipelineConfiguration(); config.readMultipleSchemas(pipe, env.getBaseURI(), sImport.locationURIs, sImport.namespaceURI); namespacesToBeSealed.add(sImport.namespaceURI); } catch (TransformerConfigurationException err) { grumble("Error in schema. " + err.getMessage(), "XQST0059"); } } else { grumble("Unable to locate requested schema", "XQST0059"); } } ((QueryModule)env).addImportedSchema(sImport.namespaceURI); }
/** * parse "declare default order empty (least|greatest)" */ private void parseDefaultOrder() throws XPathException { if (foundEmptyOrderingDeclaration) { grumble("empty ordering declaration appears more than once", "XQST0069"); } foundEmptyOrderingDeclaration = true; nextToken(); if (!isKeyword("empty")) { grumble("After 'declare default order', expected keyword 'empty'"); } nextToken(); if (isKeyword("least")) { ((QueryModule)env).setEmptyLeast(true); } else if (isKeyword("greatest")) { ((QueryModule)env).setEmptyLeast(false); } else { grumble("After 'declare default order empty', expected keyword 'least' or 'greatest'"); } nextToken(); }
private void applySchemaImport(Import sImport) throws XPathException { // Do the importing Configuration config = env.getConfiguration(); if (!config.isSchemaAvailable(sImport.namespaceURI)) { if (!sImport.locationURIs.isEmpty()) { try { PipelineConfiguration pipe = config.makePipelineConfiguration(); config.readMultipleSchemas(pipe, env.getBaseURI(), sImport.locationURIs, sImport.namespaceURI); namespacesToBeSealed.add(sImport.namespaceURI); } catch (TransformerConfigurationException err) { grumble("Error in schema. " + err.getMessage(), "XQST0059"); } } else { grumble("Unable to locate requested schema", "XQST0059"); } } ((QueryModule)env).addImportedSchema(sImport.namespaceURI, env.getBaseURI(), sImport.locationURIs); }
/** * Parse the "default element namespace" declaration. * Syntax: <"declare" "default" "element" "namespace"> StringLiteral * * @throws XPathException to indicate a syntax error */ private void parseDefaultElementNamespace() throws XPathException { if (foundDefaultElementNamespace) { grumble("default element namespace appears more than once", "XQST0066"); } foundDefaultElementNamespace = true; nextToken(); expect(Token.NAME); if (!"namespace".equals(t.currentTokenValue)) { grumble("After 'declare default element', expected 'namespace'"); } nextToken(); expect(Token.STRING_LITERAL); String uri = URILiteral(t.currentTokenValue); ((QueryModule)env).setDefaultElementNamespace(uri); nextToken(); }
/** * Parse the "default element namespace" declaration. * Syntax: <"declare" "default" "element" "namespace"> StringLiteral * * @throws XPathException to indicate a syntax error */ private void parseDefaultElementNamespace() throws XPathException { if (foundDefaultElementNamespace) { grumble("default element namespace appears more than once", "XQST0066"); } foundDefaultElementNamespace = true; nextToken(); expect(Token.NAME); if (!"namespace".equals(t.currentTokenValue)) { grumble("After 'declare default element', expected 'namespace'"); } nextToken(); expect(Token.STRING_LITERAL); String uri = URILiteral(t.currentTokenValue); ((QueryModule)env).setDefaultElementNamespace(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(); }
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 Expression parseCommentConstructor() throws XPathException { try { char c = t.nextChar(); // XML-like comment expectChar(c, '-'); FastStringBuffer comment = new FastStringBuffer(240); 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)), env.getConfiguration()); setLocation(instruction); return instruction; } catch (StringIndexOutOfBoundsException err) { grumble("No closing '-->' found for comment constructor"); return null; } }
/** * Make the instructions for the children of a node with simple content (attribute, text, PI, etc) * * @param content the expression making up the simple content * @param inst the skeletal instruction for creating the node * @param offset the character position of this construct within the source query */ private void makeSimpleContent(Expression content, SimpleNodeConstructor inst, int offset) throws XPathException { try { if (content == null) { inst.setSelect(new StringLiteral(StringValue.EMPTY_STRING), env.getConfiguration()); } else { inst.setSelect(stringify(content, false), env.getConfiguration()); } setLocation(inst, offset); } catch (XPathException e) { grumble(e.getMessage()); } }
/** * Make the instructions for the children of a node with simple content (attribute, text, PI, etc) * * @param content the expression making up the simple content * @param inst the skeletal instruction for creating the node * @param offset the character position of this construct within the source query */ private void makeSimpleContent(Expression content, SimpleNodeConstructor inst, int offset) throws XPathException { try { if (content == null) { inst.setSelect(new StringLiteral(StringValue.EMPTY_STRING), env.getConfiguration()); } else { inst.setSelect(stringify(content, false), env.getConfiguration()); } setLocation(inst, offset); } catch (XPathException e) { grumble(e.getMessage()); } }