public class QueryParser extends ExpressionParser
| Modifier and Type | Class and Description |
|---|---|
protected static class |
QueryParser.LetClause |
ExpressionParser.FLWORClause, ExpressionParser.ForClause, ExpressionParser.TemporaryContainer| Modifier and Type | Field and Description |
|---|---|
protected Executable |
executable |
protected static int |
FUNCTION_IS_NONDETERMINISTIC |
protected static int |
FUNCTION_IS_PRIVATE |
protected static int |
FUNCTION_IS_UPDATING |
Set |
importedModules |
(package private) List |
moduleImports |
(package private) List |
namespacesToBeSealed |
protected String |
queryVersion |
(package private) List |
schemaImports |
static String |
XQUERY10 |
static String |
XQUERY30 |
allowXPath30Syntax, compileWithTracing, defaultContainer, env, language, languageVersion, nameChecker, rangeVariables, scanOnly, SEQUENCE_TYPE, t, XPATH, XQUERY, XSLT_PATTERN| Constructor and Description |
|---|
QueryParser()
Constructor for internal use: this class should be instantiated via the QueryModule
|
| Modifier and Type | Method and Description |
|---|---|
void |
applyModuleImport(net.sf.saxon.query.QueryParser.Import mImport) |
protected boolean |
atStartOfRelativePath()
Test whether the current token is one that can start a RelativePathExpression
|
protected void |
checkForClauseAllowingEmpty(ExpressionParser.ForClause clause)
Check a ForClause for an "outer for"
|
Executable |
getExecutable()
Get the executable containing this expression.
|
protected String |
getLanguage()
Get the current language (XPath or XQuery)
|
int |
getPermittedFunctions()
Get the permitted set of standard functions in this environment
|
protected void |
grumble(String message,
StructuredQName errorCode,
int offset)
Report a static error
|
protected void |
lookAhead()
Lookahead one token, catching any exception thrown by the tokenizer.
|
protected LetExpression |
makeLetExpression()
Make a LetExpression.
|
protected void |
makeSimpleContent(Expression content,
SimpleNodeConstructor inst,
int offset)
Make the instructions for the children of a node with simple content (attribute, text, PI, etc)
|
static Expression |
makeStringJoin(Expression exp,
StaticContext env)
Make a string-join expression that concatenates the string-values of items in
a sequence with intervening spaces.
|
protected Literal |
makeStringLiteral(String token)
Method to make a string literal from a token identified as a string
literal.
|
XQueryExpression |
makeXQueryExpression(String query,
QueryModule mainModule,
Configuration config)
Create an XQueryExpression
|
QueryParser |
newParser()
Create a new parser of the same kind
|
protected String |
normalizeEQName(String s)
Convert a QName in expanded-name format "uri":local into Clark format
|
protected Expression |
parseConstructor()
Parse a node constructor.
|
protected void |
parseContextItemDeclaration()
Parse a context item declaration.
|
protected void |
parseDecimalFormatDeclaration()
Parse the "declare decimal-format" declaration.
|
protected void |
parseDefaultDecimalFormat() |
protected Expression |
parseExtensionExpression()
Parse an Extension Expression.
|
protected ForExpression |
parseForClauseAllowingVersion(ExpressionParser.ForClause clause,
StructuredQName varQName)
Parse an "outer for" clause - XQuery 1.1 only
|
protected Expression |
parseForExpression()
Parse a FLWOR expression.
|
protected void |
parseFunctionDeclaration(int functionOptions)
Parse a function declaration.
|
protected void |
parseGroupByClause(List clauseList)
Parse a Group By clause.
|
void |
parseLibraryModule(String queryString,
QueryModule env)
Parse a library module.
|
protected Expression |
parseNamedNamespaceConstructor(int offset) |
protected Expression |
parseNamespaceConstructor(int offset) |
protected void |
parseRevalidationDeclaration()
Parse the "declare revalidation" declaration.
|
protected Expression |
parseTypeswitchExpression()
Parse a Typeswitch Expression.
|
protected void |
parseUpdatingFunctionDeclaration()
Parse an updating function declaration (allowed in XQuery Update only)
|
protected Expression |
parseValidateExpression()
Parse a Validate Expression.
|
protected Expression |
processGroupingExpression(List<ExpressionParser.FLWORClause> clauseList,
Expression action)
Process a grouping expression
Not supported in 1.0; subclassed in the XQuery 1.1 parser
|
protected String |
readCollationName() |
Expression |
setDefaultValue(String exp)
Parse the expression (inside a string literal) used to define default values
for external variables.
|
void |
setDisableCycleChecks(boolean disable)
Disable checks for certain kinds of cycle.
|
void |
setExecutable(Executable exec)
Set the executable used for this query expression
|
static Expression |
stringify(Expression exp,
boolean noNodeIfEmpty)
Convert an expression so it generates a space-separated sequence of strings
|
String |
URILiteral(String in)
Handle a URI literal.
|
currentTokenDisplay, declareRangeVariable, disallowedAtStartOfRelativePath, expect, findRangeVariable, getDefaultContainer, getNameChecker, getRangeVariables, getStaticContext, getTokenizer, grumble, grumble, grumble, isCompileWithTracing, isKeyword, isNamespaceTestAllowed, makeCurriedFunction, makeLocalNameTest, makeNameCode, makeNameCodeSilently, makeNamespaceTest, makeNameTest, makeStructuredQName, makeTracer, nextToken, parse, parseBasicStep, parseDynamicFunctionCall, parseExpression, parseExprSingle, parseFunctionArgument, parseFunctionCall, parseFunctionItemType, parseInlineFunction, parseItemType, parseLiteralFunctionItem, parseNodeTest, parseNumericLiteral, parseParenthesizedItemType, parsePathExpression, parsePredicate, parseRelativePath, parseRemainingPath, parseSequenceType, parseSequenceType, parseStepExpression, parseStringLiteral, parseSwitchExpression, parseTryCatchExpression, parseUnionExpression, parseVariableReference, resolveFunctionName, setCompileWithTracing, setDefaultContainer, setLanguage, setLocation, setLocation, setRangeVariables, setRangeVariableStack, setScanOnly, undeclareRangeVariable, warningpublic static String XQUERY10
public static String XQUERY30
protected String queryVersion
protected Executable executable
public Set importedModules
List namespacesToBeSealed
List schemaImports
List moduleImports
protected static final int FUNCTION_IS_UPDATING
protected static final int FUNCTION_IS_PRIVATE
protected static final int FUNCTION_IS_NONDETERMINISTIC
public QueryParser()
public QueryParser newParser()
public XQueryExpression makeXQueryExpression(String query, QueryModule mainModule, Configuration config) throws XPathException
query - the source text of the querymainModule - the static context of the queryconfig - the Saxon configurationXPathExceptionpublic int getPermittedFunctions()
public Executable getExecutable()
public void setExecutable(Executable exec)
exec - the executablepublic void setDisableCycleChecks(boolean disable)
declare option saxon:allow-cycles "true"
disable - true if checks for import cycles are to be suppressed, that is,
if cycles should be allowedpublic final void parseLibraryModule(String queryString, QueryModule env) throws XPathException
queryString - The text of the library module.env - The static context. The result of parsing
a library module is that the static context is populated with a set of function
declarations and variable declarations. Each library module must have its own
static context objext.XPathException - if the expression contains a syntax errorprotected void grumble(String message, StructuredQName errorCode, int offset) throws XPathException
grumble in class ExpressionParsermessage - the error messageoffset - errorCode - the error codeXPathException - always thrown: an exception containing the
supplied messageprotected void parseRevalidationDeclaration()
throws XPathException
XPathExceptionpublic void applyModuleImport(net.sf.saxon.query.QueryParser.Import mImport)
throws XPathException
XPathExceptionprotected void parseDecimalFormatDeclaration()
throws XPathException
XPathExceptionprotected void parseDefaultDecimalFormat()
throws XPathException
XPathExceptionprotected void parseContextItemDeclaration()
throws XPathException
XPathExceptionprotected void parseFunctionDeclaration(int functionOptions)
throws XPathException
Syntax:
<"declare" "function"> QName "(" ParamList? ")" ("as" SequenceType)?
(EnclosedExpr | "external")
On entry, the "define function" has already been recognized
XPathException - if a syntax error is foundprotected void parseUpdatingFunctionDeclaration()
throws XPathException
XPathExceptionpublic Expression setDefaultValue(String exp)
exp - holds the expression used to define a default valueprotected Expression parseForExpression() throws XPathException
parseForExpression in class ExpressionParserXPathException - if any error is encounteredprotected LetExpression makeLetExpression()
protected ForExpression parseForClauseAllowingVersion(ExpressionParser.ForClause clause, StructuredQName varQName) throws XPathException
clause - the "for clause"varQName - XPathExceptionprotected void checkForClauseAllowingEmpty(ExpressionParser.ForClause clause) throws XPathException
XPathException - if invalidprotected void parseGroupByClause(List clauseList) throws XPathException
XPathExceptionprotected Expression processGroupingExpression(List<ExpressionParser.FLWORClause> clauseList, Expression action) throws XPathException
clauseList - the list of clauses (for, let, group by)action - the return clause, optionally wrapped with if-then-else to reflect the where clauseXPathExceptionpublic static Expression makeStringJoin(Expression exp, StaticContext env)
exp - the base expression, evaluating to a sequenceenv - the static contextprotected String readCollationName() throws XPathException
XPathExceptionprotected Expression parseTypeswitchExpression() throws XPathException
parseTypeswitchExpression in class ExpressionParserXPathExceptionprotected Expression parseValidateExpression() throws XPathException
parseValidateExpression in class ExpressionParserXPathExceptionprotected Expression parseExtensionExpression() throws XPathException
parseExtensionExpression in class ExpressionParserXPathExceptionprotected Expression parseConstructor() throws XPathException
parseConstructor in class ExpressionParserXPathException - in the event of a syntax error.protected Expression parseNamespaceConstructor(int offset) throws XPathException
XPathExceptionprotected Expression parseNamedNamespaceConstructor(int offset) throws XPathException
XPathExceptionprotected void makeSimpleContent(Expression content, SimpleNodeConstructor inst, int offset) throws XPathException
content - the expression making up the simple contentinst - the skeletal instruction for creating the nodeoffset - the character position of this construct within the source queryXPathExceptionpublic static Expression stringify(Expression exp, boolean noNodeIfEmpty) throws XPathException
exp - the expression that calculates the contentnoNodeIfEmpty - if true, no node is produced when the value of the content
expression is an empty sequence. If false, the effect of supplying an empty sequence
is that a node is created whose string-value is a zero-length string. Set to true for
text node constructors, false for other kinds of node.XPathExceptionprotected Literal makeStringLiteral(String token) throws XPathException
makeStringLiteral in class ExpressionParsertoken - the string as written (or as returned by the tokenizer)XPathExceptionpublic String URILiteral(String in) throws XPathException
in - the string as writtenXPathExceptionprotected String normalizeEQName(String s) throws XPathException
normalizeEQName in class ExpressionParsers - the QName in expanded-name formatXPathExceptionprotected void lookAhead()
throws XPathException
XPathExceptionprotected boolean atStartOfRelativePath()
ExpressionParseratStartOfRelativePath in class ExpressionParserprotected String getLanguage()
getLanguage in class ExpressionParser