XQuery 1.0:XML查询语言 工作草案-5
TransWiki - an Open Translation Project(OTP)
摘要_文档状态_目录 第1节 第2节 3.1~3.3节 3.4~3.6节 3.7节 3.8~3.13节 第4节 附录A 附录B,C,D 附录E,F,G,H,I
| Table of contents |
A XQuery Grammar
A.1 EBNF
The following grammar uses the same simple Extended Backus-Naur Form (EBNF) notation as [XML 1.0 (http://www.w3.org/TR/2004/WD-xquery-20040723/#XML)] with the following minor differences. The notation "< ... >" is used to indicate a grouping of terminals that together may help disambiguate the individual symbols. To help readability, this "< ... >" notation is absent in the EBNF in the main body of this document. This appendix is the normative version of the EBNF.
Comments on grammar productions are between '/*' and '*/' symbols - please note that these comments are normative. A 'gn:' prefix means a 'Grammar Note', and is meant as a clarification for parsing rules, and is explained in A.1.1 Grammar Notes. A 'ws:' prefix explains the whitespace rules for the production, the details of which are explained in A.2.2 Whitespace Rules
| [1] | Module (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-Module) | ::= | VersionDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-VersionDecl)? (MainModule (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-MainModule) | LibraryModule (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-LibraryModule)) | |
| [2] | VersionDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-VersionDecl) | ::= | <"xquery" "version" StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral)> Separator (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Separator) | |
| [3] | MainModule (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-MainModule) | ::= | Prolog (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Prolog) QueryBody (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QueryBody) | |
| [4] | LibraryModule (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-LibraryModule) | ::= | ModuleDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ModuleDecl) Prolog (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Prolog) | |
| [5] | ModuleDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ModuleDecl) | ::= | <"module" "namespace"> NCName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-NCName) "=" StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral) Separator (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Separator) | |
| [6] | Prolog (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-Prolog) | ::= | (Setter (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Setter) Separator (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Separator))* ((Import (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Import) | NamespaceDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-NamespaceDecl) | VarDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-VarDecl) | FunctionDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-FunctionDecl)) Separator (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Separator))* | |
| [7] | Setter (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-Setter) | ::= | XMLSpaceDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-XMLSpaceDecl) | DefaultCollationDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-DefaultCollationDecl) | BaseURIDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-BaseURIDecl) | ConstructionDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ConstructionDecl) | DefaultNamespaceDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-DefaultNamespaceDecl) | DefaultOrderingDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-DefaultOrderingDecl) | |
| [8] | Import (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-Import) | ::= | SchemaImport (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-SchemaImport) | ModuleImport (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ModuleImport) | |
| [9] | Separator (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-Separator) | ::= | ";" | |
| [10] | NamespaceDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-NamespaceDecl) | ::= | <"declare" "namespace"> NCName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-NCName) "=" StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral) | |
| [11] | XMLSpaceDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-XMLSpaceDecl) | ::= | <"declare" "xmlspace"> ("preserve" | "strip") | |
| [12] | DefaultNamespaceDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-DefaultNamespaceDecl) | ::= | (<"declare" "default" "element"> | <"declare" "default" "function">) "namespace" StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral) | |
| [13] | DefaultOrderingDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-DefaultOrderingDecl) | ::= | <"declare" "ordering"> ("ordered" | "unordered") | |
| [14] | DefaultCollationDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-DefaultCollationDecl) | ::= | <"declare" "default" "collation"> StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral) | |
| [15] | BaseURIDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-BaseURIDecl) | ::= | <"declare" "base-uri"> StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral) | |
| [16] | SchemaImport (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-SchemaImport) | ::= | <"import" "schema"> SchemaPrefix (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-SchemaPrefix)? StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral) (<"at" StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral)> ("," StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral))*)? | |
| [17] | SchemaPrefix (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-SchemaPrefix) | ::= | ("namespace" NCName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-NCName) "=") | (<"default" "element"> "namespace") | |
| [18] | ModuleImport (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ModuleImport) | ::= | <"import" "module"> ("namespace" NCName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-NCName) "=")? StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral) (<"at" StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral)> ("," StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral))*)? | |
| [19] | VarDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-VarDecl) | ::= | <"declare" "variable" "$"> VarName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-VarName) TypeDeclaration (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-TypeDeclaration)? ((":=" ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExprSingle)) | "external") | |
| [20] | ConstructionDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ConstructionDecl) | ::= | <"declare" "construction"> ("preserve" | "strip") | |
| [21] | FunctionDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-FunctionDecl) | ::= | <"declare" "function"> <QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) "("> ParamList (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ParamList)? (")" | (<")" "as"> SequenceType (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-SequenceType))) (EnclosedExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-EnclosedExpr) | "external") | |
| [22] | ParamList (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ParamList) | ::= | Param (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Param) ("," Param (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Param))* | |
| [23] | Param (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-Param) | ::= | "$" VarName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-VarName) TypeDeclaration (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-TypeDeclaration)? | |
| [24] | EnclosedExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-EnclosedExpr) | ::= | "{" Expr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Expr) "}" | |
| [25] | QueryBody (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-QueryBody) | ::= | Expr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Expr) | |
| [26] | Expr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-Expr) | ::= | ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExprSingle) ("," ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExprSingle))* | |
| [27] | ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ExprSingle) | ::= |
FLWORExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-FLWORExpr) |
|
| [28] | FLWORExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-FLWORExpr) | ::= | (ForClause (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ForClause) | LetClause (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-LetClause))+ WhereClause (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-WhereClause)? OrderByClause (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-OrderByClause)? "return" ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExprSingle) | |
| [29] | ForClause (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ForClause) | ::= | <"for" "$"> VarName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-VarName) TypeDeclaration (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-TypeDeclaration)? PositionalVar (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-PositionalVar)? "in" ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExprSingle) ("," "$" VarName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-VarName) TypeDeclaration (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-TypeDeclaration)? PositionalVar (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-PositionalVar)? "in" ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExprSingle))* | |
| [30] | PositionalVar (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-PositionalVar) | ::= | "at" "$" VarName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-VarName) | |
| [31] | LetClause (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-LetClause) | ::= | <"let" "$"> VarName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-VarName) TypeDeclaration (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-TypeDeclaration)? ":=" ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExprSingle) ("," "$" VarName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-VarName) TypeDeclaration (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-TypeDeclaration)? ":=" ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExprSingle))* | |
| [32] | WhereClause (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-WhereClause) | ::= | "where" Expr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Expr) | |
| [33] | OrderByClause (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-OrderByClause) | ::= | (<"order" "by"> | <"stable" "order" "by">) OrderSpecList (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-OrderSpecList) | |
| [34] | OrderSpecList (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-OrderSpecList) | ::= | OrderSpec (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-OrderSpec) ("," OrderSpec (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-OrderSpec))* | |
| [35] | OrderSpec (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-OrderSpec) | ::= | ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExprSingle) OrderModifier (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-OrderModifier) | |
| [36] | OrderModifier (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-OrderModifier) | ::= | ("ascending" | "descending")? (<"empty" "greatest"> | <"empty" "least">)? ("collation" StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral))? | |
| [37] | QuantifiedExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-QuantifiedExpr) | ::= | (<"some" "$"> | <"every" "$">) VarName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-VarName) TypeDeclaration (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-TypeDeclaration)? "in" ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExprSingle) ("," "$" VarName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-VarName) TypeDeclaration (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-TypeDeclaration)? "in" ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExprSingle))* "satisfies" ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExprSingle) | |
| [38] | TypeswitchExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-TypeswitchExpr) | ::= | <"typeswitch" "("> Expr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Expr) ")" CaseClause (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-CaseClause)+ "default" ("$" VarName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-VarName))? "return" ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExprSingle) | |
| [39] | CaseClause (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-CaseClause) | ::= | "case" ("$" VarName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-VarName) "as")? SequenceType (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-SequenceType) "return" ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExprSingle) | |
| [40] | IfExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-IfExpr) | ::= | <"if" "("> Expr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Expr) ")" "then" ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExprSingle) "else" ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExprSingle) | |
| [41] | OrExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-OrExpr) | ::= | AndExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-AndExpr) ( "or" AndExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-AndExpr) )* | |
| [42] | AndExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-AndExpr) | ::= | ComparisonExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ComparisonExpr) ( "and" ComparisonExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ComparisonExpr) )* | |
| [43] | ComparisonExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ComparisonExpr) | ::= |
RangeExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-RangeExpr) ( (ValueComp (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ValueComp) |
|
| [44] | RangeExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-RangeExpr) | ::= | AdditiveExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-AdditiveExpr) ( "to" AdditiveExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-AdditiveExpr) )? | |
| [45] | AdditiveExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-AdditiveExpr) | ::= | MultiplicativeExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-MultiplicativeExpr) ( ("+" | "-") MultiplicativeExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-MultiplicativeExpr) )* | |
| [46] | MultiplicativeExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-MultiplicativeExpr) | ::= | UnionExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-UnionExpr) ( ("*" | "div" | "idiv" | "mod") UnionExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-UnionExpr) )* | |
| [47] | UnionExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-UnionExpr) | ::= | IntersectExceptExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-IntersectExceptExpr) ( ("union" | "|") IntersectExceptExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-IntersectExceptExpr) )* | |
| [48] | IntersectExceptExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-IntersectExceptExpr) | ::= | InstanceofExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-InstanceofExpr) ( ("intersect" | "except") InstanceofExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-InstanceofExpr) )* | |
| [49] | InstanceofExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-InstanceofExpr) | ::= | TreatExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-TreatExpr) ( <"instance" "of"> SequenceType (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-SequenceType) )? | |
| [50] | TreatExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-TreatExpr) | ::= | CastableExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-CastableExpr) ( <"treat" "as"> SequenceType (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-SequenceType) )? | |
| [51] | CastableExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-CastableExpr) | ::= | CastExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-CastExpr) ( <"castable" "as"> SingleType (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-SingleType) )? | |
| [52] | CastExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-CastExpr) | ::= | UnaryExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-UnaryExpr) ( <"cast" "as"> SingleType (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-SingleType) )? | |
| [53] | UnaryExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-UnaryExpr) | ::= | ("-" | "+")* ValueExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ValueExpr) | |
| [54] | ValueExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ValueExpr) | ::= | ValidateExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ValidateExpr) | PathExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-PathExpr) | |
| [55] | GeneralComp (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-GeneralComp) | ::= | "=" | "!=" | "<" | "<=" | ">" | ">=" | /* gn: lt (http://www.w3.org/TR/2004/WD-xquery-20040723/#parse-note-lt) */ |
| [56] | ValueComp (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ValueComp) | ::= | "eq" | "ne" | "lt" | "le" | "gt" | "ge" | |
| [57] | NodeComp (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-NodeComp) | ::= | "is" | "<<" | ">>" | |
| [58] | ValidateExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ValidateExpr) | ::= | (<"validate" "{"> | (<"validate" ValidationMode (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ValidationMode)> "{")) Expr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Expr) "}" | /* gn: validate (http://www.w3.org/TR/2004/WD-xquery-20040723/#parse-note-validate) */ |
| [59] | PathExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-PathExpr) | ::= |
("/" RelativePathExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-RelativePathExpr)?) |
/* gn: leading-lone-slash (http://www.w3.org/TR/2004/WD-xquery-20040723/#parse-note-leading-lone-slash) */ |
| [60] | RelativePathExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-RelativePathExpr) | ::= | StepExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StepExpr) (("/" | "//") StepExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StepExpr))* | |
| [61] | StepExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-StepExpr) | ::= | AxisStep (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-AxisStep) | FilterExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-FilterExpr) | |
| [62] | AxisStep (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-AxisStep) | ::= | (ForwardStep (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ForwardStep) | ReverseStep (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ReverseStep)) PredicateList (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-PredicateList) | |
| [63] | ForwardStep (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ForwardStep) | ::= | (ForwardAxis (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ForwardAxis) NodeTest (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-NodeTest)) | AbbrevForwardStep (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-AbbrevForwardStep) | |
| [64] | ForwardAxis (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ForwardAxis) | ::= |
<"child" "::"> |
|
| [65] | AbbrevForwardStep (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-AbbrevForwardStep) | ::= | "@"? NodeTest (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-NodeTest) | |
| [66] | ReverseStep (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ReverseStep) | ::= | (ReverseAxis (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ReverseAxis) NodeTest (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-NodeTest)) | AbbrevReverseStep (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-AbbrevReverseStep) | |
| [67] | ReverseAxis (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ReverseAxis) | ::= |
<"parent" "::"> |
|
| [68] | AbbrevReverseStep (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-AbbrevReverseStep) | ::= | ".." | |
| [69] | NodeTest (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-NodeTest) | ::= | KindTest (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-KindTest) | NameTest (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-NameTest) | |
| [70] | NameTest (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-NameTest) | ::= | QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) | Wildcard (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Wildcard) | |
| [71] | Wildcard (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-Wildcard) | ::= |
"*" |
/* ws: explicit (http://www.w3.org/TR/2004/WD-xquery-20040723/#ws-explicit) */ |
| [72] | FilterExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-FilterExpr) | ::= | PrimaryExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-PrimaryExpr) PredicateList (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-PredicateList) | |
| [73] | PredicateList (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-PredicateList) | ::= | Predicate (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Predicate)* | |
| [74] | Predicate (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-Predicate) | ::= | "[" Expr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Expr) "]" | |
| [75] | PrimaryExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-PrimaryExpr) | ::= | Literal (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Literal) | VarRef (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-VarRef) | ParenthesizedExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ParenthesizedExpr) | ContextItemExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ContextItemExpr) | FunctionCall (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-FunctionCall) | Constructor (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Constructor) | OrderedExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-OrderedExpr) | UnorderedExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-UnorderedExpr) | |
| [76] | Literal (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-Literal) | ::= | NumericLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-NumericLiteral) | StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral) | |
| [77] | NumericLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-NumericLiteral) | ::= | IntegerLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-IntegerLiteral) | DecimalLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-DecimalLiteral) | DoubleLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-DoubleLiteral) | |
| [78] | VarRef (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-VarRef) | ::= | "$" VarName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-VarName) | |
| [79] | ParenthesizedExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ParenthesizedExpr) | ::= | "(" Expr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Expr)? ")" | |
| [80] | ContextItemExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ContextItemExpr) | ::= | "." | |
| [81] | OrderedExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-OrderedExpr) | ::= | <"ordered" "{"> Expr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Expr) "}" | |
| [82] | UnorderedExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-UnorderedExpr) | ::= | <"unordered" "{"> Expr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Expr) "}" | |
| [83] | FunctionCall (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-FunctionCall) | ::= | <QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) "("> (ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExprSingle) ("," ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExprSingle))*)? ")" | /* gn: parens (http://www.w3.org/TR/2004/WD-xquery-20040723/#parse-note-parens) */ |
| /* gn: reserved-function-names (http://www.w3.org/TR/2004/WD-xquery-20040723/#parse-note-reserved-function-names) */ | ||||
| [84] | Constructor (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-Constructor) | ::= |
DirectConstructor (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-DirectConstructor) |
|
| [85] | DirectConstructor (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-DirectConstructor) | ::= |
DirElemConstructor (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-DirElemConstructor) |
|
| [86] | DirElemConstructor (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-DirElemConstructor) | ::= | "<" QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) DirAttributeList (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-DirAttributeList) ("/>" | (">" DirElemContent (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-DirElemContent)* "</" QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) S (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-S)? ">")) | /* ws: explicit (http://www.w3.org/TR/2004/WD-xquery-20040723/#ws-explicit) */ |
| /* gn: lt (http://www.w3.org/TR/2004/WD-xquery-20040723/#parse-note-lt) */ | ||||
| [87] | DirAttributeList (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-DirAttributeList) | ::= | (S (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-S) (QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) S (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-S)? "=" S (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-S)? DirAttributeValue (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-DirAttributeValue))?)* | /* ws: explicit (http://www.w3.org/TR/2004/WD-xquery-20040723/#ws-explicit) */ |
| [88] | DirAttributeValue (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-DirAttributeValue) | ::= |
('"' (EscapeQuot (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-EscapeQuot) | QuotAttrValueContent (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QuotAttrValueContent))* '"') |
/* ws: explicit (http://www.w3.org/TR/2004/WD-xquery-20040723/#ws-explicit) */ |
| [89] | QuotAttrValueContent (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-QuotAttrValueContent) | ::= |
QuotAttrContentChar (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QuotAttrContentChar) |
|
| [90] | AposAttrValueContent (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-AposAttrValueContent) | ::= |
AposAttrContentChar (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-AposAttrContentChar) |
|
| [91] | DirElemContent (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-DirElemContent) | ::= |
DirectConstructor (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-DirectConstructor) |
|
| [92] | CommonContent (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-CommonContent) | ::= | PredefinedEntityRef (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-PredefinedEntityRef) | CharRef (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-CharRef) | "Template:"" | EnclosedExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-EnclosedExpr) | |
| [93] | DirCommentConstructor (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-DirCommentConstructor) | ::= | "<!--" DirCommentContents (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-DirCommentContents) "-->" | /* ws: explicit (http://www.w3.org/TR/2004/WD-xquery-20040723/#ws-explicit) */ |
| [94] | DirCommentContents (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-DirCommentContents) | ::= | ((Char (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Char) - '-') | <'-' (Char (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Char) - '-')>)* | /* ws: explicit (http://www.w3.org/TR/2004/WD-xquery-20040723/#ws-explicit) */ |
| [95] | DirPIConstructor (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-DirPIConstructor) | ::= | "<?" PITarget (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-PITarget) (S (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-S) DirPIContents (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-DirPIContents))? "?>" | /* ws: explicit (http://www.w3.org/TR/2004/WD-xquery-20040723/#ws-explicit) */ |
| [96] | DirPIContents (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-DirPIContents) | ::= | (Char (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Char)* - (Char* '?>' Char*)) | /* ws: explicit (http://www.w3.org/TR/2004/WD-xquery-20040723/#ws-explicit) */ |
| [97] | CDataSection (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-CDataSection) | ::= | "<![CDATA[" CDataSectionContents (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-CDataSectionContents) "]]>" | /* ws: explicit (http://www.w3.org/TR/2004/WD-xquery-20040723/#ws-explicit) */ |
| [98] | CDataSectionContents (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-CDataSectionContents) | ::= | (Char (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Char)* - (Char* ']]>' Char*)) | /* ws: explicit (http://www.w3.org/TR/2004/WD-xquery-20040723/#ws-explicit) */ |
| [99] | ComputedConstructor (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ComputedConstructor) | ::= |
CompDocConstructor (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-CompDocConstructor) |
|
| [100] | CompDocConstructor (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-CompDocConstructor) | ::= | <"document" "{"> Expr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Expr) "}" | |
| [101] | CompElemConstructor (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-CompElemConstructor) | ::= | (<"element" QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) "{"> | (<"element" "{"> Expr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Expr) "}" "{")) CompElemBody (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-CompElemBody)? "}" | |
| [102] | CompElemBody (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-CompElemBody) | ::= | (LocalNamespaceDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-LocalNamespaceDecl) | ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExprSingle)) ("," (LocalNamespaceDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-LocalNamespaceDecl) | ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExprSingle)))* | |
| [103] | LocalNamespaceDecl (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-LocalNamespaceDecl) | ::= | "namespace" NCName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-NCName)? "{" StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral) "}" | |
| [104] | CompAttrConstructor (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-CompAttrConstructor) | ::= | (<"attribute" QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) "{"> | (<"attribute" "{"> Expr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Expr) "}" "{")) Expr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Expr)? "}" | |
| [105] | CompTextConstructor (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-CompTextConstructor) | ::= | <"text" "{"> Expr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Expr) "}" | |
| [106] | CompCommentConstructor (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-CompCommentConstructor) | ::= | <"comment" "{"> Expr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Expr) "}" | |
| [107] | CompPIConstructor (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-CompPIConstructor) | ::= | (<"processing-instruction" NCName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-NCName) "{"> | (<"processing-instruction" "{"> Expr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Expr) "}" "{")) Expr (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Expr)? "}" | |
| [108] | SingleType (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-SingleType) | ::= | AtomicType (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-AtomicType) "?"? | |
| [109] | TypeDeclaration (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-TypeDeclaration) | ::= | "as" SequenceType (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-SequenceType) | |
| [110] | SequenceType (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-SequenceType) | ::= |
(ItemType (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ItemType) OccurrenceIndicator (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-OccurrenceIndicator)?) |
|
| [111] | OccurrenceIndicator (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-OccurrenceIndicator) | ::= | "?" | "*" | "+" | |
| [112] | ItemType (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ItemType) | ::= | AtomicType (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-AtomicType) | KindTest (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-KindTest) | <"item" "(" ")"> | |
| [113] | AtomicType (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-AtomicType) | ::= | QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) | |
| [114] | KindTest (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-KindTest) | ::= |
DocumentTest (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-DocumentTest) |
|
| [115] | AnyKindTest (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-AnyKindTest) | ::= | <"node" "("> ")" | |
| [116] | DocumentTest (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-DocumentTest) | ::= | <"document-node" "("> (ElementTest (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ElementTest) | SchemaElementTest (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-SchemaElementTest))? ")" | |
| [117] | TextTest (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-TextTest) | ::= | <"text" "("> ")" | |
| [118] | CommentTest (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-CommentTest) | ::= | <"comment" "("> ")" | |
| [119] | PITest (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-PITest) | ::= | <"processing-instruction" "("> (NCName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-NCName) | StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral))? ")" | |
| [120] | AttributeTest (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-AttributeTest) | ::= | <"attribute" "("> (AttribNameOrWildcard (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-AttribNameOrWildcard) ("," TypeName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-TypeName))?)? ")" | |
| [121] | AttribNameOrWildcard (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-AttribNameOrWildcard) | ::= | AttributeName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-AttributeName) | "*" | |
| [122] | SchemaAttributeTest (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-SchemaAttributeTest) | ::= | <"schema-attribute" "("> AttributeDeclaration (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-AttributeDeclaration) ")" | |
| [123] | AttributeDeclaration (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-AttributeDeclaration) | ::= | AttributeName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-AttributeName) | |
| [124] | ElementTest (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ElementTest) | ::= | <"element" "("> (ElementNameOrWildcard (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ElementNameOrWildcard) ("," TypeName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-TypeName) "?"?)?)? ")" | |
| [125] | ElementNameOrWildcard (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ElementNameOrWildcard) | ::= | ElementName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ElementName) | "*" | |
| [126] | SchemaElementTest (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-SchemaElementTest) | ::= | <"schema-element" "("> ElementDeclaration (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ElementDeclaration) ")" | |
| [127] | ElementDeclaration (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ElementDeclaration) | ::= | ElementName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ElementName) | |
| [128] | AttributeName (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-AttributeName) | ::= | QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) | |
| [129] | ElementName (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ElementName) | ::= | QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) | |
| [130] | TypeName (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-TypeName) | ::= | QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) |
| [131] | IntegerLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-IntegerLiteral) | ::= | Digits (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Digits) | |
| [132] | DecimalLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-DecimalLiteral) | ::= | ("." Digits (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Digits)) | (Digits (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Digits) "." [0-9]*) | /* ws: explicit (http://www.w3.org/TR/2004/WD-xquery-20040723/#ws-explicit) */ |
| [133] | DoubleLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-DoubleLiteral) | ::= | (("." Digits (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Digits)) | (Digits (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Digits) ("." [0-9]*)?)) [eE] [+-]? Digits (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Digits) | /* ws: explicit (http://www.w3.org/TR/2004/WD-xquery-20040723/#ws-explicit) */ |
| [134] | StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-StringLiteral) | ::= | ('"' (PredefinedEntityRef (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-PredefinedEntityRef) | CharRef (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-CharRef) | ('"' '"') | [^"&])* '"') | ("'" (PredefinedEntityRef (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-PredefinedEntityRef) | CharRef (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-CharRef) | ("'" "'") | [^'&])* "'") | /* ws: explicit (http://www.w3.org/TR/2004/WD-xquery-20040723/#ws-explicit) */ |
| [135] | PITarget | ::= | [http://www.w3.org/TR/REC-xml/#NT-PITarget [1] (http://www.w3.org/TR/REC-xml#NT-PITarget)]XML | /* 'gn: xml-version' */ |
| [136] | VarName (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-VarName) | ::= | QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) | |
| [137] | ValidationMode (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ValidationMode) | ::= | "lax" | "strict" | |
| [138] | Digits (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-Digits) | ::= | [0-9]+ | |
| [139] | PredefinedEntityRef (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-PredefinedEntityRef) | ::= | "&" ("lt" | "gt" | "amp" | "quot" | "apos") ";" | /* ws: explicit (http://www.w3.org/TR/2004/WD-xquery-20040723/#ws-explicit) */ |
| [140] | CharRef | ::= | [http://www.w3.org/TR/REC-xml/#NT-CharRef [2] (http://www.w3.org/TR/REC-xml#NT-CharRef)]XML | /* 'gn: xml-version' */ |
| [141] | EscapeQuot (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-EscapeQuot) | ::= | '""' | |
| [142] | EscapeApos (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-EscapeApos) | ::= | "" | |
| [143] | ElementContentChar (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ElementContentChar) | ::= | Char (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Char) - [{}<&] - [{}<&] | |
| [144] | QuotAttrContentChar (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-QuotAttrContentChar) | ::= | Char (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Char) - ["{}<&] - ["{}<&] | |
| [145] | AposAttrContentChar (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-AposAttrContentChar) | ::= | Char (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Char) - ['{}<&] - ['{}<&] | |
| [146] | Pragma (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-Pragma) | ::= | "(::" S (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-S)? "pragma" S (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-S) QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) (S (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-S) ExtensionContents (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExtensionContents))? "::)" | /* ws: explicit (http://www.w3.org/TR/2004/WD-xquery-20040723/#ws-explicit) */ |
| [147] | MUExtension (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-MUExtension) | ::= | "(::" S (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-S)? "extension" S (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-S) QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) (S (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-S) ExtensionContents (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExtensionContents))? "::)" | /* ws: explicit (http://www.w3.org/TR/2004/WD-xquery-20040723/#ws-explicit) */ |
| [148] | ExtensionContents (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ExtensionContents) | ::= | (Char (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Char)* - (Char* '::)' Char*)) | |
| [149] | Comment (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-Comment) | ::= | "(:" (CommentContents (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-CommentContents) | Comment (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Comment))* ":)" | /* ws: explicit (http://www.w3.org/TR/2004/WD-xquery-20040723/#ws-explicit) */ |
| /* gn: comments (http://www.w3.org/TR/2004/WD-xquery-20040723/#parse-note-comments) */ | ||||
| [150] | CommentContents (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-CommentContents) | ::= | (Char (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Char)+ - (Char* ':)' Char*)) | |
| [151] | QName | ::= | [http://www.w3.org/TR/REC-xml-names/#NT-QName [3] (http://www.w3.org/TR/REC-xml-names/#NT-QName)]Names | /* 'gn: xml-version' */ |
| [152] | NCName | ::= | [http://www.w3.org/TR/REC-xml-names/#NT-NCName [4] (http://www.w3.org/TR/REC-xml-names/#NT-NCName)]Names | /* 'gn: xml-version' */ |
| [153] | S | ::= | [http://www.w3.org/TR/REC-xml/#NT-S [5] (http://www.w3.org/TR/REC-xml#NT-S)]XML | /* 'gn: xml-version' */ |
| [154] | Char | ::= | [http://www.w3.org/TR/REC-xml/#NT-Char [6] (http://www.w3.org/TR/REC-xml#NT-Char)]XML | /* 'gn: xml-version' */ |
The following term definitions will be helpful in defining precisely this exposition.
[Definition: Each rule in the grammar defines one symbol, in the form]
symbol ::= expression
[Definition: A terminal is a single unit of the grammar that can not be further subdivided, and is specified in the EBNF by a character or characters in quotes, or a regular expression.] The following expressions are used to match strings of one or more characters in a terminal:
- xN
where N is a hexadecimal integer, the expression matches the character in ISO/IEC 10646 whose canonical (UCS-4) code value, when interpreted as an unsigned binary number, has the value indicated. The number of leading zeros in the #xN form is insignificant; the number of leading zeros in the corresponding code value is governed by the character encoding in use and is not significant for XML.
[a-zA-Z], [#xN-#xN]
matches any Char (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Char) with a value in the range(s) indicated (inclusive).
[abc], [#xN#xN#xN]
matches any Char (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Char) with a value among the characters enumerated. Enumerations and ranges can be mixed in one set of brackets.
[^a-z], [^#xN-#xN]
matches any Char (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Char) with a value outside the range indicated.
[^abc], [^#xN#xN#xN]
matches any Char (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Char) with a value not among the characters given. Enumerations and ranges of forbidden values can be mixed in one set of brackets.
"string"
matches a literal string matching that given inside the double quotes.
'string'
matches a literal string matching that given inside the single quotes.
[7] (http://example.org/TR/REC-example/#NT-Example)
matches a production defined in the external specification as per the provided reference. For the purposes of this secification, the entire unit is defined as a terminal.
[Definition: A production combines symbols to form more complex patterns. ] The following productions serve as examples, where A and B represent simple expressions:
(expression)
expression is treated as a unit and may be combined as described in this list.
A?
matches A or nothing; optional A.
A B
matches A followed by B. This operator has higher precedence than alternation; thus A B | C D is identical to (A B) | (C D).
A | B
matches A or B but not both.
A - B
matches any string that matches A but does not match B.
A+
matches one or more occurrences of A.Concatenation has higher precedence than alternation; thus A+ | B+ is identical to (A+) | (B+).
A*
matches zero or more occurrences of A. Concatenation has higher precedence than alternation; thus A* | B* is identical to (A*) | (B*)
A.1.1 Grammar Notes
This section contains general notes on the EBNF productions, which may be helpful in understanding how to create a parser based on this EBNF, how to read the EBNF, and generally call out issues with the syntax. The notes below are referenced from the right side of the production, with the notation: /* gn: <id> */.
grammar-note: parens
A look-ahead of one character is required to distinguish function patterns from a QName or keyword followed by a Pragma, MUExtension or Comment. For example: address (: this may be empty :) may be mistaken for a call to a function named "address" unless this lookahead is employed. Another example is for (: whom the bell :) $tolls = 3 return $tolls, where the keyword "for" must not be mistaken for a function name.
grammar-note: lt
Token disambiguation of the overloaded "<" pattern is defined in terms of positional lexical states (http://www.w3.org/TR/2004/WD-xquery-20040723/#lexical-structure). The "<" comparison operator can not occur in the same places as a "<" tag open pattern. The "<" comparison operator can only occur in the OPERATOR (http://www.w3.org/TR/2004/WD-xquery-20040723/#OPERATOR) state and the "<" tag open pattern can only occur in the DEFAULT (http://www.w3.org/TR/2004/WD-xquery-20040723/#DEFAULT) and the ELEMENT_CONTENT (http://www.w3.org/TR/2004/WD-xquery-20040723/#ELEMENT_CONTENT) states. (These states are only a specification tool, and do not mandate an implementation strategy for this same effect.)
grammar-note: validate
The ValidateExpr in the exposition, which does not use the "< ... >" token grouping, presents the production in a much simplified, and understandable, form. The ValidateExpr presented in the appendix is technically correct, but structurally hard to understand, because of limitations of the "< ... >" token grouping.
grammar-note: leading-lone-slash
The "/" presents an issue because it occurs either as a stand alone unit or as a leading prefix that expects a pattern that will be recognized in the DEFAULT (http://www.w3.org/TR/2004/WD-xquery-20040723/#DEFAULT) state to follow such as a QName or "*". Both of these patterns also may occur as patterns which are recognized in the OPERATOR (http://www.w3.org/TR/2004/WD-xquery-20040723/#OPERATOR) state. Thus, expressions such as "/ * 5" can easily be confused with the path expression "/*". Therefore, a stand-alone slash on the right hand side of an operator, will need to be parenthesized in order to stand alone, as in "(/) * 5". "5 * /", on the other hand, is legal syntax.
grammar-note: comments
Expression comments are allowed inside expressions everywhere that ignorable whitespace (http://www.w3.org/TR/2004/WD-xquery-20040723/#IgnorableWhitespace) is allowed. Note that expression comments are not allowed in constructor content.
Comments can nest within each other, as long as all "(:" and ":)" patterns are balanced, no matter where they occur within the outer comment.
Note:
Lexical analysis may typically handle nested comments by incrementing a counter for each "(:" pattern, and decrementing the counter for each ":)" pattern. The comment does not terminate until the counter is back to zero.
Following are some illustrative examples:
for (: set up loop :) $i in $x return $i will parse correctly, ignoring the comment.
5 instance (: strange place for a comment :) of xs:integer will also parse correctly, ignoring the comment.
<eg (: an example:)> $i//title </eg> will cause a syntax error.
<eg> (: an example:) </eg> will parse correctly, but characters inside the element is element content, and not an expression comment.
See Comments, Pragmas and Extensions for further information and examples.
grammar-note: xml-version
An implementation's choice to support the [XML 1.0 (http://www.w3.org/TR/2004/WD-xquery-20040723/#XML)] and [XML Names (http://www.w3.org/TR/2004/WD-xquery-20040723/#XMLNAMES)], or [XML 1.1 (http://www.w3.org/TR/2004/WD-xquery-20040723/#XML1.1)] and [XML Names 1.1 (http://www.w3.org/TR/2004/WD-xquery-20040723/#XMLNAMES11)] lexical specification determines the external document from which to obtain the definition for this production. For convenience, XML 1.0 references are always used. In some cases, the XML 1.0 and XML 1.1 definitions may be exactly the same. Also please note that these external productions follow the whitespace rules of their respective specifications, and not the rules of this specification, in particular A.2.2.1 Default Whitespace Handling. Thus prefix : localname is not a valid QName for purposes of this specification, just as it is not permitted in a textual XML document. Also, comments are not permissible on either side of the colon.
grammar-note: reserved-function-names
Some unprefixed function names may be confused with expression syntax by the parser. For instance, if(foo) could either be a function name invocation or an incomplete IfExpr (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-IfExpr). Therefore it is not legal syntax for a user to invoke functions with these names. See A.3 Reserved Function Names for a list of these names.
A.2 Lexical structure
It is implementation-defined (http://www.w3.org/TR/2004/WD-xquery-20040723/#dt-implementation-defined) whether the lexical rules of [XML 1.0 (http://www.w3.org/TR/2004/WD-xquery-20040723/#XML)] and [XML Names (http://www.w3.org/TR/2004/WD-xquery-20040723/#XMLNAMES)]are followed, or alternatively, the lexical rules of [XML 1.1 (http://www.w3.org/TR/2004/WD-xquery-20040723/#XML1.1)] and [XML Names 1.1 (http://www.w3.org/TR/2004/WD-xquery-20040723/#XMLNAMES11)] are followed.
Note:
Implementations that support the full [XML 1.1 (http://www.w3.org/TR/2004/WD-xquery-20040723/#XML1.1)] character set may wish, for purposes of interoperability, to provide a mode that follows only the [XML 1.0 (http://www.w3.org/TR/2004/WD-xquery-20040723/#XML)] and [XML Names (http://www.w3.org/TR/2004/WD-xquery-20040723/#XMLNAMES)] lexical rules.
When patterns are simple string matches, the strings are embedded directly into the EBNF. In other cases, named terminals are used.
It is up to an implementation to decide on the exact tokenization strategy, which may be different depending on the parser construction. In the EBNF, the notation "< ... >" is used to indicate a grouping of terminals that together may help disambiguate the individual symbols.
This document uses lexical states (http://www.w3.org/TR/2004/WD-xquery-20040723/#lexical-state) to assist with terminal symbol recognition. The states specify lexical constraints and transitions based on grammatical positioning. The rules for calculating these states are given in the A.2.4 Lexical Rules section. The specification of these states in this document does not imply any tokenization strategy on the part of implementations.
When tokenizing, the longest possible match that is valid in the current lexical state is preferred .
All keywords are case sensitive. Keywords are not reserved—that is, any QName may duplicate a keyword except as noted in A.3 Reserved Function Names.
A.2.1 Terminal Types
The entire set of terminals (http://www.w3.org/TR/2004/WD-xquery-20040723/#terminal) in XQuery 1.0 may be divided into two major classes, those that can act as token delimiters, and those that can not.
[Definition: A delimiting terminal may delimit adjacent non-delimiting terminals (http://www.w3.org/TR/2004/WD-xquery-20040723/#non-delimiting-token). Delimiting terminals are only recognized in the appropriate lexical states (http://www.w3.org/TR/2004/WD-xquery-20040723/#lexical-state) as specificed by A.2.4 Lexical Rules. ] The following is the list of delimiting terminals:
"<?", "?>", "::", "*", "$", "?", ")", "(", "{", ":", "/", "//", "=", "!=", "<=", "<<", ">=", ">>", ":=", "<", ">", "-", "+", "|", "@", "[", "]", ",", ";", "%%%", """, ".", "..", "<![CDATA[", "]]>", PredefinedEntityRef (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-PredefinedEntityRef), CharRef (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-CharRef), "/>", "</", "Template:", "", EscapeQuot (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-EscapeQuot), EscapeApos (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-EscapeApos), "'", Pragma (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Pragma), "(::", "::)", Comment (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Comment), "(:", ":)", "<!--", "-->", S (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-S), "}"
[Definition: Non-delimiting terminals generally start and end with alphabetic characters or digits. Adjacent non-delimiting terminals must be delimited by a delimiting terminal (http://www.w3.org/TR/2004/WD-xquery-20040723/#delimiting-token). Non-delimiting terminals are only recognized in the appropriate lexical states (http://www.w3.org/TR/2004/WD-xquery-20040723/#lexical-state) as specificed by A.2.4 Lexical Rules. ] The following is the list of non-delimiting terminals:
DecimalLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-DecimalLiteral), DoubleLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-DoubleLiteral), StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral), "xquery", "version", "at", "module", "namespace", "child", "descendant", "parent", "attribute", "self", "descendant-or-self", "ancestor", "following-sibling", "preceding-sibling", "following", "preceding", "ancestor-or-self", "declare", "function", "ordering", "ordered", "unordered", "external", "or", "and", "div", "idiv", "mod", "in", ValidationMode (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ValidationMode), "construction", "satisfies", "return", "then", "else", "default", "xmlspace", "base-uri", "preserve", "strip", "to", "where", "collation", "intersect", "union", "except", "as", "case", "instance", "of", "castable", "item", "element", "schema-element", "schema-attribute", "processing-instruction", "comment", "text", "empty", "import", "schema", "is", "eq", "ne", "gt", "ge", "lt", "le", "some", "every", "for", "let", "cast", "treat", "validate", Digits (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Digits), "document-node", "document", "node", "if", "typeswitch", "order", "by", "stable", "ascending", "descending", "greatest", "least", "variable", ExtensionContents (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ExtensionContents), CommentContents (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-CommentContents), "pragma", "extension", QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName), NCName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-NCName)
A.2.2 Whitespace Rules
A.2.2.1 Default Whitespace Handling
[Definition: Whitespace characters are defined by [http://www.w3.org/TR/REC-xml#NT-S [8] (http://www.w3.org/TR/REC-xml#NT-S)] when these characters occur outside of a StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-StringLiteral).]
[Definition: Unless otherwise specified (see A.2.2.2 ExplicitSpecial Whitespace Handling), Ignorable whitespace may occur between terminals (http://www.w3.org/TR/2004/WD-xquery-20040723/#terminal), and is not significant to the parse tree. For readability, whitespace may be used in most expressions even though not explicitly notated in the EBNF. All allowable whitespace that is not explicitly specified in the EBNF is ignorable whitespace, and converse, this term does not apply to whitespace that is explicitly specified. ] Whitespace is allowed before the first token and after the last token of a module. Whitespace is optional between delimiting terminals. Whitespace is required to prevent two adjacent non-delimiting terminal (http://www.w3.org/TR/2004/WD-xquery-20040723/#non-delimiting-token) from being (mis-)recognized as one. Comments (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-Comment), Pragmas (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-Pragma), and MUExtensions (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-MUExtension) may also act as "whitespace" to prevent two adjacent tokens from being recognized as one.. Some illustrative examples are as follows:
foo- foo is a syntax error. "foo-" would be recognized as a QName. The parser would then expect a match in the OPERATOR state for "foo", but would find none.
foo -foo parses the same as foo - foo, two QNames separated by a subtraction operator. The parser would match the first "foo" as a QName. The parser would then expect a to match in the OPERATOR state, which is satisfied by "-" (but not "-foo"). The last foo would then be matched as another QName.
foo(: This is a comment :)- foo also parses the same as foo - foo. This is because the comment prevents the two adjacent tokens from being recognized as one.
Editorial note |
|
In the current test parser, the above fails. So this may need more investigation. |
|
foo-foo parses as a single QName. This is because "-" is a valid character in a QName. When used as an operator after the characters of a name, the "-" must be separated from the name, e.g. by using whitespace or parentheses.
10div 3 results in a syntax error, since the "10" and the "div" would both be non-delimiting terminals (http://www.w3.org/TR/2004/WD-xquery-20040723/#non-delimiting-token) and must be separated by delimiting terminals (http://www.w3.org/TR/2004/WD-xquery-20040723/#delimiting-token) in order to be recognized.
10 div3 also results in a syntax error, since the "div" and the "3" would both be non-delimiting terminals (http://www.w3.org/TR/2004/WD-xquery-20040723/#non-delimiting-token) and must be separated by delimiting terminals (http://www.w3.org/TR/2004/WD-xquery-20040723/#delimiting-token) in order to be recognized.
10div3 also results in a syntax error, since the "10", "div" and the "3" would all be non-delimiting terminals (http://www.w3.org/TR/2004/WD-xquery-20040723/#non-delimiting-token) and must be separated by delimiting terminals (http://www.w3.org/TR/2004/WD-xquery-20040723/#delimiting-token) in order to be recognized.
A.2.2.2 Explicit Whitespace Handling
Explict whitespace notation is specified with the EBNF productions, when it is different from the default rules, as follows. These notations do not inherit. In other words, if EBNF rule is marked as /* ws: explicit */, the rule does not automatically apply to all the 'child' EBNF productions of that rule.
ws:explicit
"ws: explicit" means that the EBNF notation S explicitly notates where whitespace is allowed. In productions with this notation, A.2.2.1 Default Whitespace Handling does not apply. Comments (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-Comment), Pragmas (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-Pragma), and MUExtensions (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-MUExtension) are also not allowed in these productions.
Whitespace is not freely allowed in the direct Constructor productions, but is specified explicitly in the grammar, in order to be more consistent with XML.
A.2.3 Comments, Pragmas and Extensions
Pragmas (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-Pragma) and MUExtensions (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-MUExtension) may be used anywhere that ignorable whitespace (http://www.w3.org/TR/2004/WD-xquery-20040723/#IgnorableWhitespace) is allowed. Within a Pragma or MUExtension, the extension content may consist of any sequence of characters that does not include the sequence "::)". Pragmas, and MUExtensions are not allowed to nest. Comments are allowed to nest, though the content of a comment must have balanced comment delimiters without regard to structure. Some illustrative examples:
(: is this a comment? ::) is a legal Comment.
(: can I comment out a (:: pragma foo ::) like this? :) is a legal Comment. The inner pragma is seen as a nested comment in this case.
(: is this a comment? ::) or an error? :) must produce a syntax error. Any unbalanced nesting of "(:" and ":)" will result in an error.
(: what about a partial (:: pragma? :) must produce a syntax error. Any unbalanced nesting of "(:" and ":)" will result in an error.
(:: pragma foo with a comment (: is this ok? :) or not ::) is a legal Pragma. The inner "comment" is seen as part of the extension content in this case.
(:: pragma foo with a comment (: is this a comment? ::) or an error? :) ::) is a syntax error. "::)" patterns are not allowed inside pragma's and extensions.
(:: pragma foo with a comment (: what about a partial (:: pragma? :) ::) is a legal Pragma. The inner "comment" and "(::" are seen as part of the extension content in this case.
(: commenting out a (: comment :) may be confusing, but often helpful :) is a legal Comment, since balanced nesting of comments is allowed.
"this is just a string :)" is a legal expression. However, (: "this is just a string :)" :) will cause a syntax error. Likewise, "this is another string (:" is a legal expression, but (: "this is another string (:" :) will cause a syntax error. It is a limitation of nested comments that literal content can cause unbalanced nesting of comments.
A.2.4 Lexical Rules
The lexical contexts and transitions between lexical contexts is described in terms of a series of states and transitions between those states.
[Definition: A lexical state is a condition where a defined set of patterns are recognized.] The tables below define the complete lexical rules for XQuery. Each two column table corresponds to a lexical state and lists in the first column the tokens thatare recognized when in that state. Any token not listed should result in a syntax error when in that state. When a given token is recognized in the given state, the transition to the next state and/or a lexical action is given in the right column. [Definition: A lexical action is an action that occurs as an side-effect of a pattern recognition.] Following are a list of lexical actions used in the tables:
pushState()
The current state, before the transition, is pushed onto an abstract stack.
pushState(STATE)
A STATE parameter is pushed onto an abstract stack.
popState()
The most recently pushed state is removed from the top of the stack, and becomes the current state.
input_stream.backup(n)
This is a special action that backs up the character stream by n characters. See the description of the OCCURRENCEINDICATOR state (http://www.w3.org/TR/2004/WD-xquery-20040723/#OCCURRENCEINDICATOR) for more information.
(maintain state)
This simply means that the current state is maintained with no modification.
The lexical states have, in many cases, close connection to the parser productions. However, just because a token is recognized in a certain lexical state, does not mean it will be legal in the current EBNF production.
The lexical states where whitespace has explicit specification are as follows: START_TAG (http://www.w3.org/TR/2004/WD-xquery-20040723/#START_TAG), END_TAG (http://www.w3.org/TR/2004/WD-xquery-20040723/#END_TAG), ELEMENT_CONTENT (http://www.w3.org/TR/2004/WD-xquery-20040723/#ELEMENT_CONTENT), XML_COMMENT (http://www.w3.org/TR/2004/WD-xquery-20040723/#XML_COMMENT), PROCESSING_INSTRUCTION (http://www.w3.org/TR/2004/WD-xquery-20040723/#PROCESSING_INSTRUCTION), PROCESSING_INSTRUCTION_CONTENT (http://www.w3.org/TR/2004/WD-xquery-20040723/#PROCESSING_INSTRUCTION_CONTENT), CDATA_SECTION (http://www.w3.org/TR/2004/WD-xquery-20040723/#CDATA_SECTION), QUOT_ATTRIBUTE_CONTENT (http://www.w3.org/TR/2004/WD-xquery-20040723/#QUOT_ATTRIBUTE_CONTENT), and APOS_ATTRIBUTE_CONTENT (http://www.w3.org/TR/2004/WD-xquery-20040723/#APOS_ATTRIBUTE_CONTENT).
Note:
There is no requirement for a lexer/parser to be implemented in terms of lexical states—these are only a way to specify the behavior. The only requirement is to produce results that are consistent with the results of these tables.
The DEFAULT State
This state is for patterns that occur at the beginning of an expression or subexpression.
Pattern | Transition To State | ||
|---|---|---|---|
| DecimalLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-DecimalLiteral), "..", ".", DoubleLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-DoubleLiteral), IntegerLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-IntegerLiteral), NotNumber, <NCName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-NCName) ":" "*">, QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName), ")", <"*" ":" NCName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-NCName)>, "*", StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral), <"declare" "construction">, <"declare" "ordering"> |
|
||
| <"declare" "default" "collation">, <"declare" "namespace">, <"declare" "base-uri">, <"module" "namespace"> |
|
||
| <"declare" "default" "element">, <"declare" "default" "function">, <"import" "schema">, <"import" "module"> |
|
||
| "$", <"for" "$">, <"let" "$">, <"some" "$">, <"every" "$"> |
|
||
| <"declare" "variable" "$"> |
|
||
| <")" "as"> |
|
||
| <"element" "(">, <"attribute" "(">, <"schema-element" "(">, <"schema-attribute" "(">, <"comment" "(">, <"text" "(">, <"node" "(">, <"document-node" "("> |
|
||
| <"processing-instruction" "("> |
|
||
| "<!--" |
|
||
| "<?" |
|
||
| "<![CDATA[" |
|
||
| "<" |
|
||
| <"declare" "xmlspace"> |
|
||
| "}" |
|
||
| <"validate" "{">, <"validate" ValidationMode (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ValidationMode)> |
|
||
| <"typeswitch" "("> |
|
||
| <"element" "{">, <"attribute" "{"> |
|
||
| <"attribute" QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) "{">, "namespace" NCName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-NCName)? "{", <"element" QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) "{">, <"document" "{">, <"text" "{">, <"processing-instruction" "{">, <"processing-instruction" NCName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-NCName) "{">, <"comment" "{"> |
|
||
| <"declare" "function"> |
|
||
| "(:" |
|
||
| "(::" |
|
||
| ";" |
|
||
| "{", <"ordered" "{">, <"unordered" "{"> |
|
||
| <"xquery" "version" StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral)>, <"at" StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral)>, "@", <"ancestor-or-self" "::">, <"ancestor" "::">, <"attribute" "::">, <"child" "::">, <"descendant-or-self" "::">, <"descendant" "::">, <"following-sibling" "::">, <"following" "::">, <"parent" "::">, <"preceding-sibling" "::">, <"preceding" "::">, <"self" "::">, ",", <"if" "(">, "(", "-", "+", <QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) "(">, "//", "/" |
|
The OPERATOR State
This state is for patterns that are defined for operators.
Pattern | Transition To State | ||
|---|---|---|---|
| "{" |
|
||
| ";", "then", "else", "external", "and", "at", ":=", ",", "div", "=", "except", "eq", "ge", "gt", "le", "lt", "ne", ">=", ">>", ">", "idiv", "intersect", "in", "is", "[", "<=", "<<", "<", "-", "mod", "*", "!=", <"order" "by">, <"stable" "order" "by">, "or", "+", "return", "satisfies", "//", "/", "to", "union", "|", "where", ("preserve" | "strip"), "ordered", "unordered" |
|
||
| <"castable" "as">, <"cast" "as"> |
|
||
| <"instance" "of">, <"treat" "as">, "case", "as", <")" "as"> |
|
||
| "}" |
|
||
| "$", <"for" "$">, <"let" "$"> |
|
||
| "(:" |
|
||
| "(::" |
|
||
| "?", "]", "collation", ")", "ascending", "descending", <"empty" "greatest">, <"empty" "least">, StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral), "default", NotOperatorKeyword |
|
The NAMESPACEDECL State
This state occurs inside of a namespace declaration, and is needed to recognize a NCName that is to be used as the prefix, as opposed to allowing a QName to occur. (Otherwise, the difference between NCName and QName are ambiguous.)
Pattern | Transition To State | ||
|---|---|---|---|
| StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral) |
|
||
| "(:" |
|
||
| "(::" |
|
||
| "=", NCName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-NCName) |
|
The NAMESPACEKEYWORD State
This state occurs at places where the keyword "namespace" is expected, which would otherwise be ambiguous compared to a QName. QNames can not occur in this state.
Pattern | Transition To State | ||
|---|---|---|---|
| StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral) |
|
||
| "namespace" |
|
||
| "(:" |
|
||
| "(::" |
|
||
| <"default" "element"> |
|
The XMLSPACE_DECL State
This state occurs at places where the keywords "preserve" and "strip" is expected to support "declare xmlspace". QNames can not occur in this state.
Pattern | Transition To State | ||
|---|---|---|---|
| "preserve", "strip" |
|
||
| "(:" |
|
||
| "(::" |
|
The SINGLETYPE State
This state distinguishes tokens that can occur only inside the SingleType production.
Pattern | Transition To State | ||
|---|---|---|---|
| QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) |
|
||
| "(:" |
|
The ITEMTYPE State
This state distinguishes tokens that can occur only inside the ItemType production.
Pattern | Transition To State | ||
|---|---|---|---|
| "$" |
|
||
| <"empty" "(" ")"> |
|
||
| "(:" |
|
||
| "(::" |
|
||
| <"element" "(">, <"attribute" "(">, <"schema-element" "(">, <"schema-attribute" "(">, <"comment" "(">, <"text" "(">, <"node" "(">, <"document-node" "("> |
|
||
| <"processing-instruction" "("> |
|
||
| QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName), <"item" "(" ")"> |
|
||
| ";", "then", "else" |
|
||
| "external", "and", <"at" StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral)>, "at", ":=", ",", "div", "=", "except", "eq", "ge", "gt", "le", "lt", "ne", ">=", ">>", ">", "idiv", "intersect", "in", "is", "[", "(", "<=", "<<", "<", "-", "mod", "!=", <"order" "by">, <"stable" "order" "by">, "or", "return", "satisfies", "to", "union", "|", "where" |
|
||
| <"castable" "as">, <"cast" "as"> |
|
||
| <"instance" "of">, <"treat" "as">, "case", "as", <")" "as"> |
|
The KINDTEST State
Pattern | Transition To State | ||
|---|---|---|---|
| "{" |
|
||
| ")" |
|
||
| "*", QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) |
|
||
| <"element" "(">, <"schema-element" "("> |
|
||
| "(:" |
|
The KINDTESTFORPI State
Pattern | Transition To State | ||
|---|---|---|---|
| ")" |
|
||
| "(:" |
|
||
| NCName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-NCName), StringLiteral (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-StringLiteral) |
|
The CLOSEKINDTEST State
Pattern | Transition To State | ||
|---|---|---|---|
| ")" |
|
||
| "," |
|
||
| "{" |
|
||
| "?" |
|
||
| "(:" |
|
The OCCURRENCEINDICATOR State
This special state is needed to distinguish occurrence indicators that appear in the SequenceType production. For instance, compare "foo instance of baz*" to "baz*foo". In the first case, the "*" is interpreted as an occurrence indicator, and in the second case, it must be interpreted as a multiplication operator. But, when in the OCCURRENCEINDICATOR state, if anything else other than "?", "*", and "+", those symbols must be interpreted in the OPERATOR state. For instance, this would occur with the expression "foo instance of baz and $x", with the operator "and". This backing up of the lexical characters in order to reset the state, is symbolized by the notation "input_stream.backup(1)". NotOccurrenceIndicator is a special symbol for any character that is not an occurrence indicator.
Pattern | Transition To State | ||
|---|---|---|---|
| [NotOccurrenceIndicator] |
|
||
| "?", "*", "+" |
|
||
| "(:" |
|
The VARNAME State
This state differentiates variable names from qualified names. This allows only the pattern of a QName to be recognized when otherwise ambiguities could occur.
Pattern | Transition To State | ||
|---|---|---|---|
| VarName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-VarName) |
|
||
| "(:" |
|
||
| "(::" |
|
The START_TAG State
This state allows attributes in the native XML syntax, and marks the beginning of an element construction. Element constructors also push the current state, popping it at the conclusion of an end tag. In the START_TAG state, the string ">" is recognized as a token which is associated with the transition to the original state.
Pattern | Transition To State | |
|---|---|---|
| "/>" |
|
|
| ">" |
|
|
| '"' |
|
|
| "'" |
|
|
| S (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-S), QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName), "=" |
|
The ELEMENT_CONTENT State
This state allows XML-like content, without these characters being misinterpreted as expressions. The character "{" marks a transition to the DEFAULT state, i.e. the start of an embedded expression, and the "}" character pops back to the ELEMENT_CONTENT state. To allow curly braces to be used as character content, a double left or right curly brace is interpreted as a single curly brace character. The string "</" is interpreted as the beginning of an end tag, which is associated with a transition to the END_TAG state.
Pattern | Transition To State | ||
|---|---|---|---|
| "</" |
|
||
| "{" |
|
||
| "<!--" |
|
||
| "<?" |
|
||
| "<![CDATA[" |
|
||
| "<" |
|
||
| PredefinedEntityRef (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-PredefinedEntityRef), CharRef (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-CharRef), "Template:", "", ElementContentChar (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-ElementContentChar) |
|
The END_TAG State
When the end tag is terminated, the state is popped to the state that was pushed at the start of the corresponding start tag.
Pattern | Transition To State | |
|---|---|---|
| ">" |
|
|
| S (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-S), QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) |
|
The XML_COMMENT State
The "<--" token marks the beginning of an XML Comment, and the "-->" token marks the end. This allows no special interpretation of other characters in this state.
Pattern | Transition To State | |
|---|---|---|
| "-->" |
|
|
| (Char (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Char) - '-'), <'-' (Char (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Char) - '-')> |
|
The EXPR_COMMENT State
The "(:" token marks the beginning of an expression Comment, and the ":)" token marks the end. This allows no special interpretation of other characters in this state.
Pattern | Transition To State | ||
|---|---|---|---|
| ":)" |
|
||
| "(:" |
|
||
| "(::" |
|
||
| Char (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Char) |
|
The EXT_CONTENT State
This state occurs for the content of must-understand extension.
Pattern | Transition To State | |
|---|---|---|
| "::)" |
|
|
| Char (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Char), S (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-S) |
|
The EXT_KEY State
The "(::" token marks the beginning of an expression extension, which must be followed by a keyword.
Pattern | Transition To State | |
|---|---|---|
| "pragma", "extension" |
|
|
| S (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-S) |
|
The EXT_NAME State
This state recognizes extension names and transitions to the extension content state.
Pattern | Transition To State | |
|---|---|---|
| QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) |
|
|
| S (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-S) |
|
The PROCESSING_INSTRUCTION State
In this state, only patterns that are legal in a processing instruction name are recognized.
Pattern | Transition To State | |
|---|---|---|
| S (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-S) |
|
|
| "?>" |
|
|
| PITarget (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-PITarget) |
|
The PROCESSING_INSTRUCTION_CONTENT State
In this state, only characters are that are legal in processing instruction content are recognized.
Pattern | Transition To State | |
|---|---|---|
| "?>" |
|
|
| Char (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Char) |
|
The CDATA_SECTION State
In this state, only lexemes that are legal in a CDATA section are recognized.
Pattern | Transition To State | |
|---|---|---|
| "]]>" |
|
|
| Char (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-Char) |
|
The QUOT_ATTRIBUTE_CONTENT State
This state allows content legal for attributes. The character "{" marks a transition to the DEFAULT state, i.e. the start of an embedded expression, and the "}" character pops back to the original state. To allow curly braces to be used as character content, a double left or right curly brace is interpreted as a single curly brace character. This state is the same as APOS_ATTRIBUTE_CONTENT, except that apostrophes are allowed without escaping, and an unescaped quote marks the end of the state.
Pattern | Transition To State | ||
|---|---|---|---|
| '"' |
|
||
| "{" |
|
||
| EscapeQuot (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-EscapeQuot), PredefinedEntityRef (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-PredefinedEntityRef), CharRef (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-CharRef), "Template:", "", QuotAttrContentChar (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QuotAttrContentChar) |
|
The APOS_ATTRIBUTE_CONTENT State
This state is the same as QUOT_ATTRIBUTE_CONTENT, except that quotes are allowed, and an unescaped apostrophe marks the end of the state.
Pattern | Transition To State | ||
|---|---|---|---|
| "'" |
|
||
| "{" |
|
||
| EscapeApos (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-EscapeApos), PredefinedEntityRef (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-PredefinedEntityRef), CharRef (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-CharRef), "Template:", "", AposAttrContentChar (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-AposAttrContentChar) |
|
A.3 Reserved Function Names
The following is a list of names that must not be used as user function names in an unprefixed form, because these functions could be confused with expression syntax. Users should not have unprefixed invocations of functions with these names, and if they want to protect themselves from future changes they should use the prefixed form, or put a distinctive string in their function names.
attribute
comment
document-node
element
empty
if
item
node
processing-instruction
text
type
typeswitch
A.4 Precedence Order
The grammar defines built-in precedence, which is summarised here. Operators that have a lower precedence number can not be contained by operators with a higher precedence number. Operators may contain other operators with the same precedence number on the right-hand-side. In the cases where a number of operators are at the same precedence level, the operators are applied from left to right.
The operators in order of increasing precedence are:
| 1 | (comma) |
| 2 | for (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-FLWORExpr), some, every (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-QuantifiedExpr), typeswitch (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-TypeswitchExpr), if (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-IfExpr) |
| 3 | or (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-OrExpr) |
| 4 | and (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-AndExpr) |
| 5 | eq, ne, lt, le, gt, ge (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ValueComp), =, !=, <, <=, >, >= (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-GeneralComp), is (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-NodeComp), <<, >> (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-NodeComp) |
| 6 | to (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-RangeExpr) |
| 7 | +, - (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-AdditiveExpr) |
| 8 | *, div, idiv, mod (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-MultiplicativeExpr) |
| 9 | -(unary), +(unary) (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-UnaryExpr) |
| 10 | union, | (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-UnionExpr) |
| 11 | intersect, except (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-IntersectExceptExpr) |
| 12 | instance of (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-InstanceofExpr) |
| 13 | treat (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-TreatExpr) |
| 14 | castable (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-CastableExpr) |
| 15 | cast (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-CastExpr) |
| 16 | validate (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ValidateExpr), /, // (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-PathExpr) |
| 17 | [ (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-PredicateList)], ( ) (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ParenthesizedExpr) |


