com.saxonica.expr

## Class ExtendedXQueryParser

- java.lang.Object
- - net.sf.saxon.expr.parser.ExpressionParser
  - - net.sf.saxon.query.QueryParser
    - - com.saxonica.expr.ExtendedXQueryParser

-     public class ExtendedXQueryParser
      extends QueryParser

  Parser extension for new syntax in XQuery Update and/or XQuery 3.0.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class net.sf.saxon.expr.parser.ExpressionParser

      `ExpressionParser.TemporaryContainer`

  - ### Field Summary

    - ### Fields inherited from class net.sf.saxon.query.QueryParser

      `executable, importedModules, queryVersion, XQUERY10, XQUERY30`

    - ### Fields inherited from class net.sf.saxon.expr.parser.ExpressionParser

      `allowXPath30Syntax, catchDepth, codeInjector, defaultContainer, env, language, languageVersion, nameChecker, rangeVariables, scanOnly, SEQUENCE_TYPE, t, XPATH, XQUERY, XSLT_PATTERN`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExtendedXQueryParser(String queryVersion, boolean updating)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `checkForClauseAllowingEmpty(ForClause clause)` Check a ForClause for an "outer for"
    `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.
    `protected boolean` | `isReservedInQuery(String uri)`
    `protected Expression` | `makeCurriedFunction(int offset, StructuredQName name, Expression[] args, IntSet placeMarkers)` Process a function call in which one or more of the argument positions are represented as "?" placemarkers (indicating partial application or currying)
    `QueryParser` | `newParser()` Create a new parser of the same kind
    `protected Map<StructuredQName,Annotation>` | `parseAnnotations()` Parse the annotations that can appear in a variable or function declaration
    `protected void` | `parseContextItemDeclaration()` Parse a context item declaration.
    `protected void` | `parseCountClause(List<Clause> clauseList)` Parse a LetClause.
    `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
    `Expression` | `parseExprSingle()` Parse an ExprSingle
    `Expression` | `parseFunctionArgument()` Parse a function argument.
    `ItemType` | `parseFunctionItemType()` Parse the item type used for function items (XQuery 3.0 higher order functions) Syntax (changed by WG decision on 2009-09-22): function '(' '*' ') | function '(' (SeqType (',' SeqType)*)? ')' 'as' SeqType The "function(" has already been read
    `protected void` | `parseGroupByClause(List<Clause> clauseList)` Parse a Group By clause.
    `protected Expression` | `parseInlineFunction(Map<StructuredQName,Annotation> annotations)` 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 3.0) Syntax: QName # integer The QName and # have already been read
    `protected Expression` | `parseMapExpression()` Parse a map expression.
    `ItemType` | `parseMapItemType()` Parse the item type used for function items (XPath 3.0) Syntax: map '(' '*' ') | map '(' ItemType ',' SeqType ')' 'as' SeqType For backwards compatibility with Saxon 9.2 we allow the "*" to be omitted for the time being The "map(" has 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` | `parseOutputDeclaration(StructuredQName varName, String value)`
    `protected ItemType` | `parseParenthesizedItemType()` Parse a parenthesized item type (allowed in XQuery 3.0 and XPath 3.0 only)
    `protected void` | `parseRevalidationDeclaration()` Parse the "declare revalidation" declaration (XQuery Update).
    `protected Expression` | `parseSwitchExpression()` Parse a Switch Expression.
    `protected Expression` | `parseTryCatchExpression()` Parse a Try/Catch Expression.
    `protected void` | `parseUpdatingFunctionDeclaration()` Parse an updating function declaration (allowed in XQuery Update only)
    `protected void` | `parseWindowClause(List<Clause> clauseList)` Parse a tumbling or sliding window clause.

    - ### Methods inherited from class net.sf.saxon.query.QueryParser

      `applyModuleImport, atStartOfRelativePath, customizeTokenizer, getExecutable, getLanguage, grumble, isReservedFunctionName, lookAhead, makeLetExpression, makeSimpleContent, makeStringJoin, makeStringLiteral, makeXQueryExpression, normalizeEQName, parseConstructor, parseExtensionExpression, parseFLWORExpression, parseFunctionDeclaration, parseLibraryModule, parseTypeswitchExpression, parseValidateExpression, readCollationName, setDefaultValue, setDisableCycleChecks, setExecutable, stringify, testPermittedAxis, URILiteral`

    - ### Methods inherited from class net.sf.saxon.expr.parser.ExpressionParser

      `currentTokenDisplay, declareRangeVariable, disallowedAtStartOfRelativePath, expect, getCodeInjector, getDefaultContainer, getNameChecker, getRangeVariables, getStaticContext, getTokenizer, grumble, grumble, grumble, isKeyword, makeLocalNameTest, makeNameCode, makeNamespaceTest, makeNameTest, makeNodeName, makeStructuredQName, makeStructuredQNameSilently, makeTracer, nextToken, parse, parseBasicStep, parseBinaryExpression, parseExpression, parseFunctionCall, parseItemType, parseNodeTest, parseNumericLiteral, parsePathExpression, parsePredicate, parseRelativePath, parseRemainingPath, parseSequenceType, parseSequenceType, parseSimpleMappingExpression, parseStepExpression, parseStringLiteral, parseTypePattern, parseVariableReference, reportMissingFunction, resolveFunctionName, setCodeInjector, setDefaultContainer, setLanguage, setLocation, setLocation, setLocation, setRangeVariables, setRangeVariableStack, setScanOnly, undeclareRangeVariable, warning`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ExtendedXQueryParser

          public ExtendedXQueryParser(String queryVersion,
                              boolean updating)

  - ### Method Detail

    - #### newParser

          public QueryParser newParser()

      Create a new parser of the same kind
      Overrides:
        `newParser` in class `QueryParser`
      Returns:
        a new parser of the same kind as this one

    - #### getPermittedFunctions

          public int getPermittedFunctions()

      Get the permitted set of standard functions in this environment
      Overrides:
        `getPermittedFunctions` in class `QueryParser`
      Returns:
        a code indicating which system library functions are supported in this version of the language

    - #### isReservedInQuery

          protected boolean isReservedInQuery(String uri)

      Overrides:
        `isReservedInQuery` in class `ExpressionParser`

    - #### parseAnnotations

          protected Map<StructuredQName,Annotation> parseAnnotations()
                                                              throws XPathException

      Parse the annotations that can appear in a variable or function declaration
      Overrides:
        `parseAnnotations` in class `ExpressionParser`
      Returns:
        the annotations as a map, indexed by annotation name
      Throws:
        `XPathException`

    - #### parseOutputDeclaration

          protected void parseOutputDeclaration(StructuredQName varName,
                                    String value)
                                         throws XPathException

      Overrides:
        `parseOutputDeclaration` in class `QueryParser`
      Throws:
        `XPathException`

    - #### parseLiteralFunctionItem

          protected Expression parseLiteralFunctionItem()
                                                 throws XPathException

      Parse a literal function item (introduced in XQuery 3.0) Syntax: QName # integer The QName and # have already been read
      Overrides:
        `parseLiteralFunctionItem` in class `ExpressionParser`
      Returns:
        an ExternalObject representing the function item
      Throws:
        `XPathException` - if a static error is encountered

    - #### parseFunctionItemType

          public ItemType parseFunctionItemType()
                                         throws XPathException

      Parse the item type used for function items (XQuery 3.0 higher order functions) Syntax (changed by WG decision on 2009-09-22): function '(' '*' ') | function '(' (SeqType (',' SeqType)*)? ')' 'as' SeqType The "function(" has already been read
      Overrides:
        `parseFunctionItemType` in class `ExpressionParser`
      Returns:
        the item type representing a function item
      Throws:
        `XPathException` - if a static error occurs (including the case where XPath 3.0 syntax is not enabled)

    - #### parseFunctionArgument

          public Expression parseFunctionArgument()
                                           throws XPathException

      Parse a function argument. The special marker "?" is allowed and causes "null" to be returned
      Overrides:
        `parseFunctionArgument` in class `ExpressionParser`
      Returns:
        the Expression used as the argument, or null if the argument is the place-holder "?"
      Throws:
        `XPathException` - if the argument expression does not parse correctly

    - #### parseMapItemType

          public ItemType parseMapItemType()
                                    throws XPathException

      Parse the item type used for function items (XPath 3.0) Syntax: map '(' '*' ') | map '(' ItemType ',' SeqType ')' 'as' SeqType For backwards compatibility with Saxon 9.2 we allow the "*" to be omitted for the time being The "map(" has already been read
      Overrides:
        `parseMapItemType` in class `ExpressionParser`
      Returns:
        the item type of the map
      Throws:
        `XPathException` - if a parsing error occurs or if the map syntax is not available

    - #### parseParenthesizedItemType

          protected ItemType parseParenthesizedItemType()
                                                 throws XPathException

      Parse a parenthesized item type (allowed in XQuery 3.0 and XPath 3.0 only)
      Overrides:
        `parseParenthesizedItemType` in class `ExpressionParser`
      Returns:
        the item type
      Throws:
        `XPathException` - if a syntax error is found

    - #### parseDynamicFunctionCall

          protected Expression parseDynamicFunctionCall(Expression functionItem)
                                                 throws XPathException

      Parse a dynamic function call
      Overrides:
        `parseDynamicFunctionCall` in class `ExpressionParser`
      Parameters:
        `functionItem` - the expression that determines the function to be called
      Returns:
        the expression that results from the parsing
      Throws:
        `XPathException` - if a static error is found

    - #### parseInlineFunction

          protected Expression parseInlineFunction(Map<StructuredQName,Annotation> annotations)
                                            throws XPathException

      Parse an inline function "function" "(" ParamList? ")" ("as" SequenceType)? EnclosedExpr On entry, "function (" has already been read
      Overrides:
        `parseInlineFunction` in class `ExpressionParser`
      Parameters:
        `annotations` - the function annotations, which have already been read, or null if there are none
      Returns:
        the parsed inline function
      Throws:
        `XPathException` - if a syntax error is found

    - #### makeCurriedFunction

          protected Expression makeCurriedFunction(int offset,
                                       StructuredQName name,
                                       Expression[] args,
                                       IntSet placeMarkers)
                                            throws XPathException

      Process a function call in which one or more of the argument positions are represented as "?" placemarkers (indicating partial application or currying)
      Overrides:
        `makeCurriedFunction` in class `ExpressionParser`
      Parameters:
        `offset` - the location of the expression in the query source
        `name` - the function name (as if there were no currying)
        `args` - the arguments (with EmptySequence in the placemarker positions)
        `placeMarkers` - the positions of the placemarkers @return the curried function
      Returns:
        the curried function
      Throws:
        `XPathException` - if the syntax is incorrect

    - #### parseMapExpression

          protected Expression parseMapExpression()
                                           throws XPathException

      Parse a map expression. Requires XPath/XQuery 3.0 Provisional syntax map { expr := expr (, expr := expr )*} }
      Overrides:
        `parseMapExpression` in class `ExpressionParser`
      Returns:
        the map expression
      Throws:
        `XPathException`

    - #### 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-3.0 only. The syntax allows: try { Expr } catch NameTest ('|' NameTest)* { Expr } We don't currently implement the CatchVars
      Overrides:
        `parseTryCatchExpression` in class `QueryParser`
      Returns:
        the parsed expression; except that this version of the method always throws an exception
      Throws:
        `XPathException` - if a static error is found

    - #### checkForClauseAllowingEmpty

          protected void checkForClauseAllowingEmpty(ForClause clause)
                                              throws XPathException

      Check a ForClause for an "outer for"
      Overrides:
        `checkForClauseAllowingEmpty` in class `QueryParser`
      Parameters:
        `clause` - the clause to be checked
      Throws:
        `XPathException` - if invalid

    - #### parseCountClause

          protected void parseCountClause(List<Clause> clauseList)
                                   throws XPathException

      Parse a LetClause.

      [44] LetClause ::= <"let" "$"> VarName TypeDeclaration? ":=" ExprSingle ("," "$" VarName TypeDeclaration? ":=" ExprSingle)*
      Overrides:
        `parseCountClause` in class `QueryParser`
      Parameters:
        `clauseList` - - the components of the parsed LetClause are appended to the supplied list
      Throws:
        `XPathException`

    - #### parseGroupByClause

          protected void parseGroupByClause(List<Clause> clauseList)
                                     throws XPathException

      Parse a Group By clause. Handles the full XQuery 3.0 syntax: "group by" ($varname ["collation" URILiteral]) [,...]
      Overrides:
        `parseGroupByClause` in class `QueryParser`
      Parameters:
        `clauseList` - the list of clauses for the expression, to which this clause will be added
      Throws:
        `XPathException`

    - #### parseWindowClause

          protected void parseWindowClause(List<Clause> clauseList)
                                    throws XPathException

      Parse a tumbling or sliding window clause.
      Overrides:
        `parseWindowClause` in class `QueryParser`
      Parameters:
        `clauseList` - the list of clauses for the expression, to which this clause will be added
      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` - the location of the expression in the query source
      Returns:
        the compiled Namespace instruction
      Throws:
        `XPathException` - in the event of a syntax error

    - #### 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` - the location of the expression in the query source
      Returns:
        the compiled instruction
      Throws:
        `XPathException` - in the event of a syntax error

    - #### isNamespaceTestAllowed

          protected boolean isNamespaceTestAllowed()

      Ask whether the syntax namespace-node() is allowed in a node kind test.
      Overrides:
        `isNamespaceTestAllowed` in class `ExpressionParser`
      Returns:
        true if XQuery 3.0 syntax is permitted

    - #### parseSwitchExpression

          protected Expression parseSwitchExpression()
                                              throws XPathException

      Parse a Switch Expression. This construct is XQuery-3.0-only. SwitchExpr ::= "switch" "(" Expr ")" SwitchCaseClause+ "default" "return" ExprSingle SwitchCaseClause ::= ("case" ExprSingle)+ "return" ExprSingle
      Overrides:
        `parseSwitchExpression` in class `ExpressionParser`
      Returns:
        the expression that results from the parsing
      Throws:
        `XPathException` - if a static error is found

    - #### 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`

    - #### parseRevalidationDeclaration

          protected void parseRevalidationDeclaration()
                                               throws XPathException

      Parse the "declare revalidation" declaration (XQuery Update). Syntax: <"declare" "revalidation"> ("strict" | "lax" | "skip")
      Overrides:
        `parseRevalidationDeclaration` in class `QueryParser`
      Throws:
        `XPathException`

    - #### parseUpdatingFunctionDeclaration

          protected void parseUpdatingFunctionDeclaration()
                                                   throws XPathException

      Parse an updating function declaration (allowed in XQuery Update only)
      Overrides:
        `parseUpdatingFunctionDeclaration` in class `QueryParser`
      Throws:
        `XPathException` - if parsing fails or if updating functions are not allowed

    - #### parseExprSingle

          public Expression parseExprSingle()
                                     throws XPathException

      Parse an ExprSingle
      Overrides:
        `parseExprSingle` in class `ExpressionParser`
      Returns:
        the resulting subexpression
      Throws:
        `XPathException` - if any error is encountered

Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.