| START | ::= | QueryList <EOF> |
| QueryList | ::= | Module ( "%%%" ( Module )? )* |
| Module | ::= | ( VersionDecl )? ( LibraryModule | MainModule ) |
| VersionDecl | ::= | "xquery" ( "version" <StringLiteral> ( "encoding" <StringLiteral> )? ) Separator |
| MainModule | ::= | Prolog QueryBody |
| LibraryModule | ::= | ModuleDecl Prolog |
| ModuleDecl | ::= | "module" "namespace" NCName "=" URILiteral Separator |
| Prolog | ::= | ( ( DefaultNamespaceDecl | Setter | NamespaceDecl | Import ) Separator )* ( ( VarDecl | FunctionDecl | OptionDecl ) Separator )* |
| Setter | ::= | ( BoundarySpaceDecl | DefaultCollationDecl | BaseURIDecl | ConstructionDecl | OrderingModeDecl | EmptyOrderDecl | CopyNamespacesDecl ) |
| Import | ::= | ( SchemaImport | ModuleImport ) |
| Separator | ::= | ";" |
| NamespaceDecl | ::= | "declare" "namespace" NCName "=" URILiteral |
| BoundarySpaceDecl | ::= | "declare" "boundary-space" ( "preserve" | "strip" ) |
| DefaultNamespaceDecl | ::= | "declare" "default" ( "element" | "function" ) "namespace" URILiteral |
| OptionDecl | ::= | "declare" "option" QName <StringLiteral> |
| OrderingModeDecl | ::= | "declare" "ordering" ( "ordered" | "unordered" ) |
| EmptyOrderDecl | ::= | "declare" "default" "order" "empty" ( <Greatest> | <Least> ) |
| CopyNamespacesDecl | ::= | "declare" "copy-namespaces" PreserveMode "," InheritMode |
| PreserveMode | ::= | ( "preserve" | "no-preserve" ) |
| InheritMode | ::= | ( "inherit" | "no-inherit" ) |
| DefaultCollationDecl | ::= | "declare" "default" "collation" URILiteral |
| BaseURIDecl | ::= | "declare" "base-uri" URILiteral |
| SchemaImport | ::= | "import" "schema" ( SchemaPrefix )? URILiteral ( "at" URILiteral ( "," URILiteral )* )? |
| SchemaPrefix | ::= | ( ( "namespace" NCName "=" ) | ( "default" "element" "namespace" ) ) |
| ModuleImport | ::= | "import" "module" ( "namespace" NCName "=" )? URILiteral ( "at" URILiteral ( "," URILiteral )* )? |
| VarDecl | ::= | "declare" "variable" "$" QName ( TypeDeclaration )? ( ( ":=" ExprSingle ) | ( <External> ) ) |
| ConstructionDecl | ::= | "declare" "construction" ( "strip" | "preserve" ) |
| FunctionDecl | ::= | "declare" "function" QName "(" ( ParamList )? ")" ( "as" SequenceType )? ( EnclosedExpr | <External> ) |
| ParamList | ::= | Param ( "," Param )* |
| Param | ::= | "$" QName ( TypeDeclaration )? |
| EnclosedExpr | ::= | <Lbrace> Expr <Rbrace> |
| QueryBody | ::= | Expr |
| Expr | ::= | ExprSingle ( "," ExprSingle )* |
| ExprSingle | ::= | ( FLWORExpr10 | QuantifiedExpr | TypeswitchExpr | IfExpr | OrExpr ) |
| FLWORExpr10 | ::= | ( ( ForClause | LetClause ) )+ ( WhereClause )? ( OrderByClause )? "return" ExprSingle |
| ForClause | ::= | "for" "$" VarName ( TypeDeclaration )? ( PositionalVar )? "in" ExprSingle ( "," "$" VarName ( TypeDeclaration )? ( PositionalVar )? "in" ExprSingle )* |
| PositionalVar | ::= | "at" "$" VarName |
| LetClause | ::= | "let" ( "$" VarName ( TypeDeclaration )? ) ":=" ExprSingle ( "," ( "$" VarName ( TypeDeclaration )? ) ":=" ExprSingle )* |
| WhereClause | ::= | "where" ExprSingle |
| OrderByClause | ::= | ( ( "order" "by" ) | ( "stable" "order" "by" ) ) OrderSpecList |
| OrderSpecList | ::= | OrderSpec ( "," OrderSpec )* |
| OrderSpec | ::= | ExprSingle OrderModifier |
| OrderModifier | ::= | ( ( <Ascending> | <Descending> ) )? ( "empty" ( <Greatest> | <Least> ) )? ( "collation" URILiteral )? |
| QuantifiedExpr | ::= | ( "some" | "every" ) "$" VarName ( TypeDeclaration )? "in" ExprSingle ( "," "$" VarName ( TypeDeclaration )? "in" ExprSingle )* "satisfies" ExprSingle |
| TypeswitchExpr | ::= | "typeswitch" "(" Expr ")" ( CaseClause )+ "default" ( "$" VarName )? "return" ExprSingle |
| CaseClause | ::= | "case" ( "$" VarName "as" )? SequenceType "return" ExprSingle |
| IfExpr | ::= | "if" "(" Expr ")" "then" ExprSingle "else" ExprSingle |
| OperatorExpr | ::= | OrExpr |
| OrExpr | ::= | AndExpr ( "or" AndExpr )* |
| AndExpr | ::= | ComparisonExpr ( "and" ComparisonExpr )* |
| ComparisonExpr | ::= | RangeExpr ( ( ValueComp | GeneralComp | NodeComp ) RangeExpr )? |
| RangeExpr | ::= | AdditiveExpr ( "to" AdditiveExpr )? |
| AdditiveExpr | ::= | MultiplicativeExpr ( ( <Plus> | <Minus> ) MultiplicativeExpr )* |
| MultiplicativeExpr | ::= | UnionExpr ( ( "*" | "div" | "idiv" | "mod" ) UnionExpr )* |
| UnionExpr | ::= | IntersectExceptExpr ( ( "union" | "|" ) IntersectExceptExpr )* |
| IntersectExceptExpr | ::= | InstanceofExpr ( ( "intersect" | "except" ) InstanceofExpr )* |
| InstanceofExpr | ::= | TreatExpr ( ( "instance" "of" SequenceType ) )? |
| TreatExpr | ::= | CastableExpr ( ( "treat" "as" SequenceType ) )? |
| CastableExpr | ::= | CastExpr ( ( "castable" "as" SingleType ) )? |
| CastExpr | ::= | UnaryExpr ( ( "cast" "as" SingleType ) )? |
| UnaryExpr | ::= | ( ( <Minus> | <Plus> ) )* ValueExpr |
| ValueExpr | ::= | ( ValidateExpr | PathExpr | ExtensionExpr ) |
| GeneralComp | ::= | ( "=" | "!=" | <LessThanOpOrTagO> | "<=" | ">" | ">=" ) |
| ValueComp | ::= | ( "eq" | "ne" | "lt" | "le" | "gt" | "ge" ) |
| NodeComp | ::= | ( "is" | "<<" | ">>" ) |
| ValidateExpr | ::= | "validate" ( ValidationMode )? <Lbrace> Expr <Rbrace> |
| ValidationMode | ::= | ( "lax" | "strict" ) |
| ExtensionExpr | ::= | ( Pragma )+ <Lbrace> ( Expr )? <Rbrace> |
| Pragma | ::= | <PragmaOpen> ( <S> )? QName ( <SForPragma> PragmaContents )? <PragmaClose> |
| PragmaContents | ::= | ( <ExtensionContentChar> )* |
| PathExpr | ::= | ( ( <Slash> ( RelativePathExpr )? ) | ( <SlashSlash> RelativePathExpr ) | RelativePathExpr ) |
| RelativePathExpr | ::= | StepExpr ( ( <Slash> | <SlashSlash> ) StepExpr )* |
| StepExpr | ::= | ( FilterExpr | AxisStep ) |
| AxisStep | ::= | ( ReverseStep | ForwardStep ) PredicateList |
| ForwardStep | ::= | ( ( ForwardAxis NodeTest ) | AbbrevForwardStep ) |
| ForwardAxis | ::= | ( ( "child" "::" ) | ( "descendant" "::" ) | ( "attribute" "::" ) | ( "self" "::" ) | ( "descendant-or-self" "::" ) | ( "following-sibling" "::" ) | ( "following" "::" ) ) |
| AbbrevForwardStep | ::= | ( "@" )? NodeTest |
| ReverseStep | ::= | ( ( ReverseAxis NodeTest ) | AbbrevReverseStep ) |
| ReverseAxis | ::= | ( ( "parent" "::" ) | ( "ancestor" "::" ) | ( "preceding-sibling" "::" ) | ( "preceding" "::" ) | ( "ancestor-or-self" "::" ) ) |
| AbbrevReverseStep | ::= | ".." |
| NodeTest | ::= | ( KindTest | NameTest ) |
| NameTest | ::= | ( QName | Wildcard ) |
| Wildcard | ::= | ( "*" | <NCNameColonStar> | <StarColonNCName> ) |
| FilterExpr | ::= | PrimaryExpr PredicateList |
| PredicateList | ::= | ( Predicate )* |
| Predicate | ::= | "[" Expr "]" |
| PrimaryExpr | ::= | ( Literal | VarRef | ParenthesizedExpr | ContextItemExpr | FunctionCall | OrderedExpr | UnorderedExpr | Constructor ) |
| Literal | ::= | ( NumericLiteral | <StringLiteral> ) |
| NumericLiteral | ::= | ( <IntegerLiteral> | <DecimalLiteral> | <DoubleLiteral> ) |
| VarRef | ::= | "$" VarName |
| VarName | ::= | QName |
| ParenthesizedExpr | ::= | "(" ( Expr )? ")" |
| ContextItemExpr | ::= | "." |
| OrderedExpr | ::= | "ordered" <Lbrace> Expr <Rbrace> |
| UnorderedExpr | ::= | "unordered" <Lbrace> Expr <Rbrace> |
| FunctionCall | ::= | FunctionQName "(" ( ExprSingle ( "," ExprSingle )* )? ")" |
| Constructor | ::= | ( DirectConstructor | ComputedConstructor ) |
| DirectConstructor | ::= | ( DirElemConstructor | DirCommentConstructor | DirPIConstructor ) |
| DirElemConstructor | ::= | ( <LessThanOpOrTagO> | <StartTagOpen> ) <TagQName> DirAttributeList ( <EmptyTagClose> | ( <StartTagClose> ( DirElemContent )* <EndTagOpen> <EndTagQName> ( <S> )? <EndTagClose> ) ) |
| DirAttributeList | ::= | ( <S> ( <TagQName> ( <S> )? <ValueIndicator> ( <S> )? DirAttributeValue )? )* |
| DirAttributeValue | ::= | ( ( <OpenQuot> ( ( <EscapeQuot> | QuotAttrValueContent ) )* <CloseQuot> ) | ( <OpenApos> ( ( <EscapeApos> | AposAttrValueContent ) )* <CloseApos> ) ) |
| QuotAttrValueContent | ::= | ( <QuotAttrContentChar> | CommonContent ) |
| AposAttrValueContent | ::= | ( <AposAttrContentChar> | CommonContent ) |
| DirElemContent | ::= | ( DirectConstructor | CDataSection | CommonContent | <ElementContentChar> ) |
| CommonContent | ::= | ( <PredefinedEntityRef> | <CharRef> | <LCurlyBraceEscape> | <RCurlyBraceEscape> | EnclosedExpr ) |
| DirCommentConstructor | ::= | ( <XmlCommentStartForElementContent> | <XmlCommentStart> ) DirCommentContents <XmlCommentEnd> |
| DirCommentContents | ::= | ( ( <CommentContentChar> | <CommentContentCharDash> ) )* |
| DirPIConstructor | ::= | ( <ProcessingInstructionStartForElementContent> | <ProcessingInstructionStart> ) <PITarget> ( <SForPI> DirPIContents )? <ProcessingInstructionEnd> |
| DirPIContents | ::= | ( <PIContentChar> )* |
| CDataSection | ::= | ( <CdataSectionStartForElementContent> | <CdataSectionStart> ) CDataSectionContents <CdataSectionEnd> |
| CDataSectionContents | ::= | ( <CDataSectionChar> )* |
| ComputedConstructor | ::= | ( CompDocConstructor | CompElemConstructor | CompAttrConstructor | CompTextConstructor | CompCommentConstructor | CompPIConstructor ) |
| CompDocConstructor | ::= | "document" <Lbrace> Expr <Rbrace> |
| CompElemConstructor | ::= | "element" ( QName | ( <Lbrace> Expr <Rbrace> ) ) <Lbrace> ( ContentExpr )? <Rbrace> |
| ContentExpr | ::= | Expr |
| CompAttrConstructor | ::= | "attribute" ( QName | ( <Lbrace> Expr <Rbrace> ) ) <Lbrace> ( Expr )? <Rbrace> |
| CompTextConstructor | ::= | "text" <Lbrace> Expr <Rbrace> |
| CompCommentConstructor | ::= | "comment" <Lbrace> Expr <Rbrace> |
| CompPIConstructor | ::= | "processing-instruction" ( NCName | ( <Lbrace> Expr <Rbrace> ) ) <Lbrace> ( Expr )? <Rbrace> |
| SingleType | ::= | AtomicType ( "?" )? |
| TypeDeclaration | ::= | "as" SequenceType |
| SequenceType | ::= | ( ( "empty-sequence" "(" ")" ) | ( ItemType ( OccurrenceIndicator )? ) ) |
| OccurrenceIndicator | ::= | ( "?" | "*" | <Plus> ) |
| ItemType | ::= | ( KindTest | ( "item" "(" ")" ) | AtomicType ) |
| AtomicType | ::= | QName |
| KindTest | ::= | ( DocumentTest | ElementTest | AttributeTest | SchemaElementTest | SchemaAttributeTest | PITest | CommentTest | TextTest | AnyKindTest ) |
| AnyKindTest | ::= | "node" "(" ")" |
| DocumentTest | ::= | "document-node" "(" ( ( ElementTest | SchemaElementTest ) )? ")" |
| TextTest | ::= | "text" "(" ")" |
| CommentTest | ::= | "comment" "(" ")" |
| PITest | ::= | "processing-instruction" "(" ( ( NCName | <StringLiteral> ) )? ")" |
| AttributeTest | ::= | "attribute" "(" ( AttribNameOrWildcard ( "," TypeName )? )? ")" |
| AttribNameOrWildcard | ::= | ( AttributeName | "*" ) |
| SchemaAttributeTest | ::= | "schema-attribute" "(" AttributeDeclaration ")" |
| AttributeDeclaration | ::= | AttributeName |
| ElementTest | ::= | "element" "(" ( ElementNameOrWildcard ( "," TypeName ( "?" )? )? )? ")" |
| ElementNameOrWildcard | ::= | ( ElementName | "*" ) |
| SchemaElementTest | ::= | "schema-element" "(" ElementDeclaration ")" |
| ElementDeclaration | ::= | ElementName |
| AttributeName | ::= | QName |
| ElementName | ::= | QName |
| TypeName | ::= | QName |
| URILiteral | ::= | <StringLiteral> |
| NCName | ::= | QName |
| QName | ::= | ( FunctionQName | "attribute" | "comment" | "document-node" | "element" | "empty-sequence" | "if" | "item" | "node" | "processing-instruction" | "schema-attribute" | "schema-element" | "text" | "typeswitch" ) |
| FunctionQName | ::= | ( <QNameToken> | <QNameForPragma> | <Ascending> | <Descending> | <External> | <Greatest> | <Least> | "ancestor" | "ancestor-or-self" | "and" | "as" | "at" | "base-uri" | "boundary-space" | "by" | "case" | "cast" | "castable" | "child" | "collation" | "construction" | "copy-namespaces" | "declare" | "default" | "descendant" | "descendant-or-self" | "div" | "document" | "else" | "empty" | "encoding" | "eq" | "every" | "except" | "following" | "following-sibling" | "for" | "function" | "ge" | "gt" | "idiv" | "import" | "in" | "inherit" | "instance" | "intersect" | "is" | "lax" | "le" | "let" | "lt" | "mod" | "module" | "namespace" | "ne" | "no-inherit" | "no-preserve" | "of" | "option" | "or" | "order" | "ordered" | "ordering" | "parent" | "preceding" | "preceding-sibling" | "preserve" | "return" | "satisfies" | "schema" | "self" | "some" | "stable" | "strict" | "strip" | "then" | "to" | "treat" | "union" | "unordered" | "validate" | "variable" | "version" | "where" | "xquery" ) |