com.saxonica.query11
Class Query11Parser

java.lang.Object
  extended by net.sf.saxon.expr.ExpressionParser
      extended by net.sf.saxon.query.QueryParser
          extended by com.saxonica.query11.Query11Parser

public class Query11Parser
extends QueryParser

Parser extension for new syntax in XQuery 1.1. Note this cannot currently be used at the same time as the XQuery Update extensions.


Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.saxon.query.QueryParser
QueryParser.LetClause
 
Nested classes/interfaces inherited from class net.sf.saxon.expr.ExpressionParser
ExpressionParser.FLWORClause, ExpressionParser.ForClause, ExpressionParser.TemporaryContainer
 
Field Summary
 
Fields inherited from class net.sf.saxon.query.QueryParser
executable, importedModules, queryVersion
 
Fields inherited from class net.sf.saxon.expr.ExpressionParser
compileWithTracing, defaultContainer, env, language, nameChecker, rangeVariables, scanOnly, SEQUENCE_TYPE, t, XPATH, XQUERY, XSLT_PATTERN
 
Constructor Summary
Query11Parser()
           
 
Method Summary
protected  Binding findRangeVariable(StructuredQName qName)
          Locate a range variable with a given name.
 int getPermittedFunctions()
          Get the permitted set of standard functions in this environment
protected  boolean isNamespaceTestAllowed()
          Ask whether the syntax namespace-node() is allowed in a node kind test.
 QueryParser newParser()
          Create a new parser of the same kind
protected  void parseContextItemDeclaration()
          Parse a context item declaration.
protected  void parseDecimalFormatDeclaration()
          Parse a named decimal format declaration.
protected  void parseDefaultDecimalFormat()
          Parse a default decimal format declaration "declare" "default" "decimal-format" (property "=" string-literal)*
protected  Expression parseDynamicFunctionCall(Expression functionItem)
          Parse a dynamic function call
 ItemType parseFunctionItemType()
          Parse the item type used for function items (XQuery 1.1 higher order functions) Syntax: function '(' (SeqType (',' SeqType)*)? ')' ('as' SeqType)?
protected  void parseGroupByClause(List clauseList)
          Parse a Group By clause.
protected  Expression parseInlineFunction()
          Parse an inline function "function" "(" ParamList? ")" ("as" SequenceType)? EnclosedExpr On entry, "function (" has already been read
protected  Expression parseLiteralFunctionItem()
          Parse a literal function item (introduced in XQuery 1.1) Syntax: QName # integer The QName and # have already been read
protected  Expression parseNamedNamespaceConstructor(int offset)
          Parse a namespace node constructor of the form namespace name { expr }
protected  Expression parseNamespaceConstructor(int offset)
          Parse a computed namespace constructor of the form namespace {expr}{expr}
protected  void parseOuterForClause(List clauseList)
          Parse an Outer ForClause.
protected  ItemType parseParenthesizedItemType()
          Parse a parenthesized item type (allowed in XQuery 1.1 only)
protected  Expression parseTryCatchExpression()
          Parse a Try/Catch Expression.
protected  Expression processGroupingExpression(List<ExpressionParser.FLWORClause> clauseList, Expression action)
          Process a grouping expression
 
Methods inherited from class net.sf.saxon.query.QueryParser
applyModuleImport, getExecutable, getLanguage, grumble, lookAhead, makeSimpleContent, makeStringJoin, makeStringLiteral, makeXQueryExpression, parseConstructor, parseExtensionExpression, parseForExpression, parseFunctionDeclaration, parseLibraryModule, parseRevalidationDeclaration, parseTypeswitchExpression, parseUpdatingFunctionDeclaration, parseValidateExpression, readCollationName, setDefaultValue, setDisableCycleChecks, setExecutable
 
Methods inherited from class net.sf.saxon.expr.ExpressionParser
currentTokenDisplay, declareRangeVariable, expect, getRangeVariableStack, getTokenizer, grumble, grumble, isCompileWithTracing, isKeyword, makeLocalNameTest, makeNameCode, makeNameCodeSilently, makeNamespaceTest, makeNameTest, makeStructuredQName, makeTracer, nextToken, parse, parseExpression, parseExprSingle, parseFunctionCall, parseItemType, parseMappingExpression, parseNodeTest, parsePattern, parseRelativePath, parseRemainingPath, parseSequenceType, parseSequenceType, parseStepExpression, setCompileWithTracing, setLocation, setLocation, setRangeVariableStack, setScanOnly, undeclareRangeVariable, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Query11Parser

public Query11Parser()
Method Detail

newParser

public QueryParser newParser()
Create a new parser of the same kind

Overrides:
newParser in class QueryParser

getPermittedFunctions

public int getPermittedFunctions()
Get the permitted set of standard functions in this environment

Overrides:
getPermittedFunctions in class QueryParser

parseLiteralFunctionItem

protected Expression parseLiteralFunctionItem()
                                       throws XPathException
Parse a literal function item (introduced in XQuery 1.1) Syntax: QName # integer The QName and # have already been read

Overrides:
parseLiteralFunctionItem in class ExpressionParser
Returns:
an ExternalObject representing the function item
Throws:
XPathException

parseFunctionItemType

public ItemType parseFunctionItemType()
                               throws XPathException
Parse the item type used for function items (XQuery 1.1 higher order functions) Syntax: function '(' (SeqType (',' SeqType)*)? ')' ('as' SeqType)?

Overrides:
parseFunctionItemType in class ExpressionParser
Throws:
XPathException

parseParenthesizedItemType

protected ItemType parseParenthesizedItemType()
                                       throws XPathException
Parse a parenthesized item type (allowed in XQuery 1.1 only)

Overrides:
parseParenthesizedItemType in class ExpressionParser
Throws:
XPathException

parseDynamicFunctionCall

protected Expression parseDynamicFunctionCall(Expression functionItem)
                                       throws XPathException
Parse a dynamic function call

Overrides:
parseDynamicFunctionCall in class ExpressionParser
Returns:
the expression that results from the parsing
Throws:
XPathException

parseInlineFunction

protected Expression parseInlineFunction()
                                  throws XPathException
Parse an inline function "function" "(" ParamList? ")" ("as" SequenceType)? EnclosedExpr On entry, "function (" has already been read

Overrides:
parseInlineFunction in class ExpressionParser
Throws:
XPathException - if a syntax error is found

findRangeVariable

protected Binding findRangeVariable(StructuredQName qName)
Locate a range variable with a given name. (By "range variable", we mean a variable declared within the expression where it is used.)

Overrides:
findRangeVariable in class ExpressionParser
Parameters:
qName - identifies the name of the range variable
Returns:
null if not found (this means the variable is probably a context variable); otherwise the relevant RangeVariable

parseTryCatchExpression

protected Expression parseTryCatchExpression()
                                      throws XPathException
Parse a Try/Catch Expression. This construct is XQuery-1.1 only. The syntax allows: try { Expr } catch NameTest ('|' NameTest)* { Expr } We don't currently implement the CatchVars

Overrides:
parseTryCatchExpression in class ExpressionParser
Returns:
the parsed expression; except that this version of the method always throws an exception
Throws:
XPathException

parseGroupByClause

protected void parseGroupByClause(List clauseList)
                           throws XPathException
Parse a Group By clause. Currently only a subset of the XQuery 1.1 syntax is supported: "group by" $varname ("collation" URILiteral).

There are also constraints on the structure of a FLWOR expression that contains a group-by clause, but these are imposed at a different level. For the moment, we just parse the clause as it comes.

Overrides:
parseGroupByClause in class QueryParser
Throws:
XPathException

processGroupingExpression

protected Expression processGroupingExpression(List<ExpressionParser.FLWORClause> clauseList,
                                               Expression action)
                                        throws XPathException
Process a grouping expression

Overrides:
processGroupingExpression in class QueryParser
Parameters:
clauseList - the list of clauses (for, let, group by)
action - the return clause, optionally wrapped with if-then-else to reflect the where clause
Throws:
XPathException

parseOuterForClause

protected void parseOuterForClause(List clauseList)
                            throws XPathException
Parse an Outer ForClause.

[42] OuterForClause ::= <"outer" "for" "$"> VarName TypeDeclaration? PositionalVar? "in" ExprSingle ("," "$" VarName TypeDeclaration? PositionalVar? "in" ExprSingle)*

Overrides:
parseOuterForClause in class QueryParser
Parameters:
clauseList - - the components of the parsed ForClause are appended to the supplied list
Throws:
XPathException

parseNamespaceConstructor

protected Expression parseNamespaceConstructor(int offset)
                                        throws XPathException
Parse a computed namespace constructor of the form namespace {expr}{expr}

Overrides:
parseNamespaceConstructor in class QueryParser
Parameters:
offset -
Returns:
the compiled Namespace instruction
Throws:
XPathException

parseNamedNamespaceConstructor

protected Expression parseNamedNamespaceConstructor(int offset)
                                             throws XPathException
Parse a namespace node constructor of the form namespace name { expr }

Overrides:
parseNamedNamespaceConstructor in class QueryParser
Parameters:
offset -
Returns:
the compiled instruction
Throws:
XPathException

isNamespaceTestAllowed

protected boolean isNamespaceTestAllowed()
Ask whether the syntax namespace-node() is allowed in a node kind test.

Overrides:
isNamespaceTestAllowed in class ExpressionParser
Returns:
true (currently allowed only in XQuery 1.1)

parseContextItemDeclaration

protected void parseContextItemDeclaration()
                                    throws XPathException
Parse a context item declaration. "declare" "context" "item" TypeDeclaration? ((":=" ExprSingle ) | ("external" (":=" ExprSingle ))

Overrides:
parseContextItemDeclaration in class QueryParser
Throws:
XPathException

parseDecimalFormatDeclaration

protected void parseDecimalFormatDeclaration()
                                      throws XPathException
Parse a named decimal format declaration. "declare" "decimal-format" QName (property "=" string-literal)*

Overrides:
parseDecimalFormatDeclaration in class QueryParser
Throws:
XPathException

parseDefaultDecimalFormat

protected void parseDefaultDecimalFormat()
                                  throws XPathException
Parse a default decimal format declaration "declare" "default" "decimal-format" (property "=" string-literal)*

Overrides:
parseDefaultDecimalFormat in class QueryParser
Throws:
XPathException


Copyright (c) Saxonica Limited. All rights reserved.