public class XQueryParser extends XPathParser
XPathParser.TemporaryContainer
Modifier and Type | Field and Description |
---|---|
protected Executable |
executable |
Set |
importedModules |
protected String |
queryVersion |
static String |
XQUERY10 |
static String |
XQUERY30 |
allowXPath30Syntax, catchDepth, charChecker, codeInjector, defaultContainer, env, language, languageVersion, 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
|
protected void |
customizeTokenizer(Tokenizer t)
Callback to tailor the tokenizer
|
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
|
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(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
|
XQueryParser |
newParser()
Create a new parser of the same kind
|
protected String |
normalizeEQName(String s)
Convert a QName in expanded-name format Q{uri}local into Clark format
|
protected Map<StructuredQName,Annotation> |
parseAnnotations()
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.
|
protected void |
parseFunctionDeclaration(Map<StructuredQName,Annotation> annotations)
Parse a function declaration.
|
void |
parseLibraryModule(String queryString,
QueryModule env)
Parse a library module.
|
protected void |
parseOutputDeclaration(StructuredQName varName,
String value) |
protected void |
parseRevalidationDeclaration()
Parse the "declare revalidation" declaration.
|
protected Expression |
parseSwitchExpression()
Parse a Switch Expression.
|
protected Expression |
parseTryCatchExpression()
Parse a Try/Catch Expression.
|
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 String |
readCollationName() |
void |
setDisableCycleChecks(boolean disable)
Disable checks for certain kinds of cycle.
|
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,
Configuration config)
Convert an expression so it generates a space-separated sequence of strings
|
protected void |
testPermittedAxis(byte axis) |
String |
URILiteral(String in)
Handle a URI literal.
|
currentTokenDisplay, declareRangeVariable, disallowedAtStartOfRelativePath, expect, findRangeVariable, getCodeInjector, getDefaultContainer, getMissingFunctionExplanation, getRangeVariables, getStaticContext, getTokenizer, grumble, grumble, grumble, isKeyword, isNamespaceTestAllowed, isReservedInQuery, makeCurriedFunction, makeLocalNameTest, makeNameCode, makeNamespaceTest, makeNameTest, makeNodeName, makeStructuredQName, makeStructuredQNameSilently, makeTracer, nextToken, parse, parseBasicStep, parseBinaryExpression, parseDynamicFunctionCall, parseExpression, parseExprSingle, parseFunctionArgument, parseFunctionCall, parseFunctionItemType, parseInlineFunction, parseItemType, parseLiteralFunctionItem, parseMapExpression, parseMapItemType, parseNodeTest, parseNumericLiteral, parsePathExpression, parsePredicate, parseRelativePath, parseRemainingPath, parseSequenceType, parseSequenceType, parseSimpleMappingExpression, parseStepExpression, parseStringLiteral, parseVariableReference, reportMissingFunction, resolveFunctionName, setCodeInjector, setDefaultContainer, setLanguage, setLocation, setLocation, setLocation, setRangeVariables, setRangeVariableStack, setScanOnly, undeclareRangeVariable, warning
public static final String XQUERY10
public static final String XQUERY30
protected String queryVersion
protected Executable executable
public Set importedModules
public XQueryParser()
public XQueryParser 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 configurationXPathException
- if the expression contains static errorspublic 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 allowedprotected 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(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 XPathParser
message
- the error messageoffset
- the location in the source queryerrorCode
- the error codeXPathException
- always thrown: an exception containing the
supplied messageprotected Map<StructuredQName,Annotation> parseAnnotations() throws XPathException
parseAnnotations
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 processorpublic void applyModuleImport(net.sf.saxon.query.XQueryParser.Import mImport) throws XPathException
XPathException
protected void parseFunctionDeclaration(Map<StructuredQName,Annotation> 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 parseUpdatingFunctionDeclaration() throws XPathException
XPathException
- if parsing fails or if updating functions are not allowedprotected void parseOutputDeclaration(StructuredQName varName, String value) throws XPathException
XPathException
protected Expression parseFLWORExpression() throws XPathException
parseFLWORExpression
in class XPathParser
XPathException
- if any error is encounteredprotected LetExpression makeLetExpression()
public static Expression makeStringJoin(Expression exp, StaticContext env)
exp
- the base expression, evaluating to a sequenceenv
- the static contextprotected 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) 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 queryXPathException
- if a static error is encounteredpublic static Expression stringify(Expression exp, boolean noNodeIfEmpty, Configuration config) 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.config
- the Saxon configurationXPathException
- if parsing failsprotected Literal makeStringLiteral(String token) throws XPathException
makeStringLiteral
in class XPathParser
token
- the string as written (or as returned by the tokenizer)XPathException
- if parsing failspublic String URILiteral(String in) throws XPathException
in
- the string as writtenXPathException
- if an error is found while unescaping the URIprotected String normalizeEQName(String s) throws XPathException
normalizeEQName
in class XPathParser
s
- the QName in expanded-name formatXPathException
protected void lookAhead() throws XPathException
XPathException
- if parsing failsprotected boolean atStartOfRelativePath()
XPathParser
atStartOfRelativePath
in class XPathParser
protected void testPermittedAxis(byte axis) throws XPathException
testPermittedAxis
in class XPathParser
XPathException
protected String getLanguage()
getLanguage
in class XPathParser
Copyright (c) 2004-2014 Saxonica Limited. All rights reserved.