public class XQueryParser extends XPathParser
Modifier and Type | Class and Description |
---|---|
static class |
XQueryParser.Unescaper |
XPathParser.Accelerator, XPathParser.NestedLocation
Modifier and Type | Field and Description |
---|---|
protected Executable |
executable |
java.util.Set<java.lang.String> |
importedModules |
static StructuredQName |
SAXON_MEMO_FUNCTION |
static java.lang.String |
XQUERY10 |
static java.lang.String |
XQUERY30 |
static java.lang.String |
XQUERY31 |
allowSaxonExtensions, allowXPath30Syntax, allowXPath30XSLTExtensions, allowXPath31Syntax, catchDepth, charChecker, codeInjector, env, EXTENDED_ITEM_TYPE, language, languageVersion, parserExtension, qNameParser, rangeVariables, scanOnly, SEQUENCE_TYPE, t, XPATH, XQUERY, XSLT_PATTERN
Constructor and Description |
---|
XQueryParser()
Constructor for internal use: this class should be instantiated via the QueryModule
|
Modifier and Type | Method and Description |
---|---|
void |
applyModuleImport(net.sf.saxon.query.XQueryParser.Import mImport) |
protected boolean |
atStartOfRelativePath()
Test whether the current token is one that can start a RelativePathExpression
|
void |
checkStreamability(Expression exp,
ContextItemStaticInfo contextInfo)
Check that an expression is streamable
|
protected static boolean |
containsLoopingClause(java.util.List<Clause> clauseList) |
protected void |
customizeTokenizer(Tokenizer t)
Callback to tailor the tokenizer
|
protected void |
ensureSchemaAware(java.lang.String featureName) |
Executable |
getExecutable()
Get the executable containing this expression.
|
protected java.lang.String |
getLanguage()
Get the current language (XPath or XQuery)
|
int |
getPermittedFunctions()
Get the permitted set of standard functions in this environment
|
boolean |
isStreaming()
Ask whether the streaming option has been set, that is, whether
subsequent calls on parseQuery() will compile queries to be capable
of executing in streaming mode.
|
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(java.lang.String token)
Method to make a string literal from a token identified as a string
literal.
|
XQueryExpression |
makeXQueryExpression(java.lang.String query,
QueryModule mainModule,
Configuration config)
Create an XQueryExpression
|
XQueryParser |
newParser()
Create a new parser of the same kind
|
protected AnnotationList |
parseAnnotationsList()
Parse the annotations that can appear in a variable or function declaration
|
protected Expression |
parseConstructor()
Parse a node constructor.
|
protected Expression |
parseExtensionExpression()
Parse an Extension Expression.
|
protected Expression |
parseFLWORExpression()
Parse a FLWOR expression.
|
void |
parseFunctionDeclaration(AnnotationList annotations)
Parse a function declaration.
|
void |
parseLibraryModule(java.lang.String queryString,
QueryModule env)
Parse a library module.
|
protected void |
parseOutputDeclaration(StructuredQName varName,
java.lang.String value) |
protected void |
parseRevalidationDeclaration()
Parse the "declare revalidation" declaration.
|
Expression |
parseStringTemplate(boolean complete)
Parse a string constructor: introduced in XQuery 3.1
|
protected Expression |
parseSwitchExpression()
Parse a Switch Expression.
|
protected Expression |
parseTryCatchExpression()
Parse a Try/Catch Expression.
|
protected void |
parseTypeAliasDeclaration()
Parse a type alias declaration.
|
protected Expression |
parseTypeswitchExpression()
Parse a Typeswitch Expression.
|
protected Expression |
parseValidateExpression()
Parse a Validate Expression.
|
protected java.lang.String |
readCollationName() |
void |
setExecutable(Executable exec)
Set the executable used for this query expression
|
void |
setStreaming(boolean option)
Say whether the query should be compiled and evaluated to use streaming.
|
static Expression |
stringify(Expression exp,
boolean noNodeIfEmpty,
StaticContext env)
Convert an expression so it generates a space-separated sequence of strings
|
protected void |
testPermittedAxis(byte axis,
java.lang.String errorCode) |
protected java.lang.CharSequence |
unescape(java.lang.String token)
Unescape character references and built-in entity references in a string
|
java.lang.String |
uriLiteral(java.lang.String in)
Handle a URI literal.
|
checkHofFeature, checkLanguageVersion30, checkLanguageVersion31, checkMapExtensions, checkSyntaxExtensions, currentTokenDisplay, declareRangeVariable, disallowedAtStartOfRelativePath, expect, findRangeVariable, generateApplyCall, getCodeInjector, getMissingFunctionExplanation, getPlainType, getQNameParser, getRangeVariables, getStaticContext, getTokenizer, grumble, grumble, grumble, grumble, isAllowAbsentExpression, isAllowXPath31Syntax, isKeyword, isNamespaceTestAllowed, isReservedFunctionName30, isReservedFunctionName31, isReservedInQuery, makeCurriedFunction, makeFingerprint, makeLocalNameTest, makeLocation, makeNamespaceTest, makeNameTest, makeNestedLocation, makeNodeName, makeStructuredQName, makeStructuredQNameSilently, makeTracer, nextToken, operatorPrecedence, parse, parseArrayCurlyConstructor, parseArrayItemType, parseArraySquareConstructor, parseArrowPostfix, parseBasicStep, parseBinaryExpression, parseDynamicFunctionCall, parseExpression, parseExprSingle, parseExtendedItemType, parseExtendedSequenceType, parseFunctionArgument, parseFunctionCall, parseFunctionItemType, parseInlineFunction, parseItemType, parseLookup, parseMapExpression, parseMapItemType, parseNamedFunctionReference, parseNodeTest, parseNumericLiteral, parseParenthesizedExpression, parsePathExpression, parsePredicate, parsePredicate, parseRelativePath, parseRemainingPath, parseSequenceType, parseSequenceType, parseSimpleMappingExpression, parseStepExpression, parseStringLiteral, parseVariableReference, reportMissingFunction, resolveFunctionName, setAccelerator, setAllowAbsentExpression, setCatchDepth, setCodeInjector, setLanguage, setLocation, setLocation, setLocation, setParserExtension, setQNameParser, setRangeVariables, setRangeVariableStack, setScanOnly, undeclareRangeVariable, warning, whyDisallowedType
public static final java.lang.String XQUERY10
public static final java.lang.String XQUERY30
public static final java.lang.String XQUERY31
protected Executable executable
public final java.util.Set<java.lang.String> importedModules
public static final StructuredQName SAXON_MEMO_FUNCTION
public XQueryParser()
public XQueryParser newParser()
public XQueryExpression makeXQueryExpression(java.lang.String query, QueryModule mainModule, Configuration config) throws XPathException
query
- the source text of the querymainModule
- the static context of the queryconfig
- the Saxon configurationXPathException
- if the expression contains static errorspublic int getPermittedFunctions()
public void checkStreamability(Expression exp, ContextItemStaticInfo contextInfo) throws XPathException
exp
- the expression to be checkedcontextInfo
- information about the context itemXPathException
- if the expression is not streamablepublic Executable getExecutable()
public void setExecutable(Executable exec)
exec
- the executableprotected void customizeTokenizer(Tokenizer t)
customizeTokenizer
in class XPathParser
t
- the Tokenizer to be customizedpublic void setStreaming(boolean option)
option
- if true, the compiler will attempt to compile a query to be
capable of executing in streaming mode. If the query cannot be streamed,
a compile-time exception is reported. In streaming mode, the source
document is supplied as a stream, and no tree is built in memory. The default
is false.public boolean isStreaming()
public final void parseLibraryModule(java.lang.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 AnnotationList parseAnnotationsList() throws XPathException
parseAnnotationsList
in class XPathParser
XPathException
- in the event of a syntax errorprotected void parseRevalidationDeclaration() throws XPathException
XPathException
- if the syntax is incorrect, or is not allowed in this XQuery processorprotected void ensureSchemaAware(java.lang.String featureName) throws XPathException
XPathException
public void applyModuleImport(net.sf.saxon.query.XQueryParser.Import mImport) throws XPathException
XPathException
public void parseFunctionDeclaration(AnnotationList annotations) throws XPathException
Syntax:
<"declare" "function"> QName "(" ParamList? ")" ("as" SequenceType)?
(EnclosedExpr | "external")
On entry, the "declare function" has already been recognized
annotations
- the list of annotations that have been encountered for this function declarationXPathException
- if a syntax error is foundprotected void parseTypeAliasDeclaration() throws XPathException
XPathException
- if parsing failsprotected void parseOutputDeclaration(StructuredQName varName, java.lang.String value) throws XPathException
XPathException
protected Expression parseFLWORExpression() throws XPathException
[41] FLWORExpr ::= (ForClause | LetClause)+
WhereClause? OrderByClause?
"return" ExprSingle
[42] ForClause ::= <"for" "$"> VarName TypeDeclaration? PositionalVar? "in" ExprSingle
("," "$" VarName TypeDeclaration? PositionalVar? "in" ExprSingle)*
[43] PositionalVar ::= "at" "$" VarName
[44] LetClause ::= <"let" "$"> VarName TypeDeclaration? ":=" ExprSingle
("," "$" VarName TypeDeclaration? ":=" ExprSingle)*
[45] WhereClause ::= "where" Expr
[46] OrderByClause ::= (<"order" "by"> | <"stable" "order" "by">) OrderSpecList
[47] OrderSpecList ::= OrderSpec ("," OrderSpec)*
[48] OrderSpec ::= ExprSingle OrderModifier
[49] OrderModifier ::= ("ascending" | "descending")?
(<"empty" "greatest"> | <"empty" "least">)?
("collation" StringLiteral)?
parseFLWORExpression
in class XPathParser
XPathException
- if any error is encounteredprotected LetExpression makeLetExpression()
protected static boolean containsLoopingClause(java.util.List<Clause> clauseList)
public static Expression makeStringJoin(Expression exp, StaticContext env)
exp
- the base expression, evaluating to a sequenceenv
- the static contextprotected java.lang.String readCollationName() throws XPathException
XPathException
protected Expression parseTypeswitchExpression() throws XPathException
parseTypeswitchExpression
in class XPathParser
XPathException
- if parsing failsprotected Expression parseSwitchExpression() throws XPathException
parseSwitchExpression
in class XPathParser
XPathException
- in the event of a syntax errorprotected Expression parseValidateExpression() throws XPathException
parseValidateExpression
in class XPathParser
XPathException
- if parsing failsprotected Expression parseExtensionExpression() throws XPathException
parseExtensionExpression
in class XPathParser
XPathException
- if parsing failsprotected Expression parseConstructor() throws XPathException
parseConstructor
in class XPathParser
XPathException
- in the event of a syntax error.protected Expression parseTryCatchExpression() throws XPathException
parseTryCatchExpression
in class XPathParser
XPathException
- if a static error is foundprotected void makeSimpleContent(Expression content, SimpleNodeConstructor inst, int offset)
content
- the expression making up the simple contentinst
- the skeletal instruction for creating the nodeoffset
- the character position of this construct within the source querypublic static Expression stringify(Expression exp, boolean noNodeIfEmpty, StaticContext env)
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.env
- the static contextprotected Literal makeStringLiteral(java.lang.String token) throws XPathException
makeStringLiteral
in class XPathParser
token
- the string as written (or as returned by the tokenizer)XPathException
- if parsing failsprotected java.lang.CharSequence unescape(java.lang.String token) throws XPathException
unescape
in class XPathParser
token
- the input string, which may include XML-style character references or built-in
entity referencesXPathException
- if a malformed character or entity reference is foundpublic Expression parseStringTemplate(boolean complete) throws XPathException
parseStringTemplate
in class XPathParser
XPathException
public java.lang.String uriLiteral(java.lang.String in) throws XPathException
in
- the string as writtenXPathException
- if an error is found while unescaping the URIprotected void lookAhead() throws XPathException
XPathException
- if parsing failsprotected boolean atStartOfRelativePath()
XPathParser
atStartOfRelativePath
in class XPathParser
protected void testPermittedAxis(byte axis, java.lang.String errorCode) throws XPathException
testPermittedAxis
in class XPathParser
XPathException
protected java.lang.String getLanguage()
getLanguage
in class XPathParser
Copyright (c) 2004-2020 Saxonica Limited. All rights reserved.