Skip to content

Latest commit

 

History

History
815 lines (408 loc) · 14 KB

File metadata and controls

815 lines (408 loc) · 14 KB

XML Path Language (XPath) 3.1

https://www.w3.org/TR/xpath-31/

1 Introduction

2 Basics

  • EQName - but not in all cases handling namespaces properly yet

2.1 Expression Context

2.1.1 Static Context

  • XPath 1.0 compatibility mode. No implementation plans

  • Statically known namespaces

  • Default element/type namespace

  • Default function namespace

  • In-scope schema definitions. No schema support at all yet

  • In-scope variables

  • Context item static type. No static typing at all yet

  • Statically known function signatures. Only built-in functions

  • Statically known collations

  • Default collation

  • Statically known documents.

  • Statically known collections.

  • Statically known default collection type

  • Statically known decimal formats

2.1.2 Dynamic Context

  • Context item

  • Context position

  • Context size

  • Variable values

  • Named functions. Not sure how this is dynamic?

  • Current dateTime

  • Implicit timezone

  • Default language

  • Default calendar

  • Default place

  • Available documents

  • Available text resources

  • Available collections

  • Default collection

  • Available URI collections

  • Default URI collection

  • Environment variables

2.2. Processing Model

  • Type annotation in XDM. No schema support yet, everything untypedAtomic

2.2.2 Schema Import Processing

2.2.3 Expression Processing

2.2.3.1 Static Analysis Phase

  • Static error if name is unknown.

  • Normalization of operation tree to make atomization and effective boolean value extraction explicit. We don't do it this way, but we do extract this information. We may consider making this explicit in the IR if it helps with static analysis.

  • Static typing feature. No static typing yet. Would be nice, but not required for conformance. Saxon doesn't have it and it would introduce compatibility problems if implemented.

2.2.3.2 Dynamic Evaluation Phase

  • Raise type error if operand has dynamic type that is incorrect.

2.2.4 Consistency Constraints

2.3 Error Handling

2.3.1 Kinds of errors

  • Static errors

  • Dynamic errors

2.3.2 Identifying and Reporting Errors

  • Unique error codes

2.3.3 Handling Dynamic Errors

  • Dynamic errors are raised

  • error function. Not complete yet

2.3.4 Errors and Optimization

No optimization yet

2.4 Concepts

2.4.1 Document Order

  • Nodes have document order

2.4.2 Atomization

  • Atomic value is returned

  • Typed value of node is returned Only untypedAtomic without schema support

  • Function raises error May be wrong error code

  • If item is array, atomize each item

Atomization is applied to:

  • Arithmetic expressions

  • Comparison expressions

  • Inline function call arguments

  • Inline function call returns

  • Built-in function calls

  • Cast expressions

2.4.3 Effective Boolean Value

  • Empty sequence returns false

  • Sequence with first item node, true

  • Singleton of type xs:boolean returns boolean

  • Singleton derived from xs:boolean returns boolean

  • Singleton of type xs:string, xs:untypedAtomic returns true if length > 0

  • Singleton of xs:anyURI is true if length > 0

  • Singleton of numeric type, returns true if not zero

  • Singleton of numeric type returns true if not NaN

  • Type error in other cases

Used in:

  • Logical expressions

  • fn:not

  • In certain predicates such as a[b]

  • Conditional expressions if

  • Quantified expressions

  • XPath 1.0 mode for general comparisons

2.4.4 Input sources

  • Input sources support via variety of functions

  • Input via variable or context item

2.4.5 URI Literals

  • Verification of valid URI in BracedURILiteral

  • Whitespace normalization of URI literal

2.4.6 Resolving a Relative URI Reference

  • Resolving a relative URI reference

2.5 Types

  • Schema types

  • Generalized atomic type

  • pure union type

2.5.1 Predefined Schema Types

  • xs:untyped

  • xs:untypedAtomic But not yet in inline function definitions

  • xs:dayTimeDuration

  • xs:yearMonthDuration

  • xs:anyAtomicType But not yet in inline function definitions

  • xs:error

2.5.2 Namespace-sensitive types

  • xs:QName

  • xs:NOTATION

2.5.3 Typed Value and String Value

  • Untyped nodes are xs:untypedAtomic

  • Typed value for node besides xs:untypedAtomic

  • String value for node

  • Detailed rules of getting typed value for nodes as described here

2.5.4 SequenceType Syntax

  • Parsing sequence types

2.5.5 SequenceType Matching

derives-from pseudo function

  • error if ET not present in in scope-schema definitions

  • AT is ET

  • ET is base type of AT

  • ET is a pure union type of which AT is a member type

  • Recursion via intermediate type MT

2.5.5.1 Matching a SequenceType and a Value

  • no postfix, xs:int

  • optional postfix, xs:int?

  • 0 or more items postfix, xs:int*

  • 1 or more items postfix, xs:int+

2.5.5.2 Matching an ItemType and an Item

  • Matching with EQName

  • item()

  • node()

  • text()

  • processing-instruction()

  • processing-instruction(N)

  • comment()

  • namespace-node()

  • document-node()

  • item type that is a test

  • map(K, V)

  • map(*)

  • array(T)

  • array(*)

2.5.5.3 Element Test

  • Use in type system

  • Use in NodeTest

  • element() and element(*)

  • element(ElementName)

  • element(ElementName, TypeName)

  • element(ElementName, TypeName?)

  • element(*, TypeName)

  • element(*, TypeName?)

2.5.5.4 Schema Element test

  • Schema element test

2.5.5.5 Attribute test

  • attribute() and attribute(*)

  • attribute(AttributeName)

  • attribute(AttributeName, TypeName)

  • attribute(*, TypeName)

2.5.5.6 Schema attribute test

  • Schema attribute test

2.5.5.7 Function test

  • function(*)

  • function() with argument types and return value

2.5.5.8 Map Test

  • Map test But details for instance of still to be done

2.5.5.9 Array Test

  • Array test

2.5.6 SequenceType Subtype Relationships

2.5.6.1 The judgement subtype(A, B)

  • The judgement subtype(A, B)

2.5.6.2 The judgement subtype-itemtype(Ai, Bi)

Note: detailed rules of 36 items, may spell it out when implementing.

  • The judgement subtype-itemtype(Ai, Bi)

2.5.6 xs:error

  • xs:error type

2.6 Comments

  • Comments are parsed and ignored

3 Expressions

3.1 Primary Expressions

3.1.1 Literals

  • Integer literals

  • Decimal literals

  • Double literals

  • String literals

3.1.2 Variable references

  • Variable references

  • Variable scoping

3.1.3 Parenthesized Expressions

  • Parenthesized expressions

3.1.4 Context Item Expression

  • Context item expression .

3.1.5 Static Function Calls

  • Static function calls

  • Static function call argument type checking

  • Partial function application

3.1.5.1 Evaluation Static and Dynamic Function Calls

  • Static function lookup

  • Dynamic function lookup

  • Application of function conversion rules for inline function arguments

  • Application of function conversion rules for built-in functions. In as much as implemented

  • Partial function application

  • map function

  • inline function evaluation

  • inline function evaluation conversion rules for return value

  • non-local variable bindings for inline functions

  • argument values for built-in functions

  • non-local variable bindings for built-in functions

  • static and dynamic context for built-in functions

3.1.5.2 Function Conversion Rules

  • XPath 1.0 compatibility mode

  • Atomization for built-in functions

  • untypedAtomic cast to expected function. Casting still limited

  • numeric item type promotion

  • anyURI type promotion

  • TypedFunctionTest causes function coercion

  • Type error if coercion fails

3.1.5.3 Function Coercion

  • Function coercion

3.1.6 Named Function References

  • Named function references

3.1.7 Inline Function Expressions

  • Inline function expressions

  • Non-local variable bindings

  • Type signature support

  • Function coercion

3.1.8 Enclosed Expressions

  • Enclosed expressions

3.2 Postfix expressions

3.2.1 Filter expressions

  • Filter expressions

  • Predicate if numeric is compared to context position

  • Predicate as boolean value otherwise

3.2.2 Dynamic Function Calls

  • Dynamic function calls

3.3 Path Expressions

  • / at beginning

  • // at beginning

  • treat as in / and // (but only needed for static typing)

3.3.1 Relative Path Expressions

  • Relative path expressions

3.3.1.1 Path operator (/)

  • Path operator /

3.3.2 Steps

3.3.2.1

  • child

  • descendant

  • parent

  • ancestor

  • following-sibling

  • preceding-sibling

  • following

  • preceding

  • attribute

  • self

  • descendant-or-self

  • ancestor-or-self

  • namespace But not required for conformance

3.3.2.2 Node tests

  • Name test

  • Wildcard name test

  • Kind test (see 2.5.4 and 2.5.5)

3.3.3 Predicates within Steps

  • Predicates within steps

3.3.4 Unabbreviated Syntax

  • Unabbreviated syntax

3.3.5 Abbreviated Syntax

  • Abbreviated syntax

3.4. Sequence Expressions

  • sequence constructions

  • range expressions

3.4.2 Combining node sequences

  • Union

  • Intersection

3.5 Arithmetic Expressions

  • +

  • -

  • *

  • div

  • idiv

  • mod

  • unary +

  • unary -

  • XPath 1.0 compatibility mode operand evaluation

  • Atomization during operand evaluation

3.6 String concatenation

  • String concatenation ||

3.7 Comparison Expressions

3.7.1. Value Comparisons

  • Atomization

  • Empty sequence means empty sequence result

  • Atomization length > 1 means type error

  • untypedAtomic cast to string

  • Values are of different types: xs:string/xs:anyURI

  • Values are of different types: xs:decimal/xs:float

  • Values are of different types xs:decimal, xs:float, xs:double

3.7.2 General Comparisons

  • XPath 1.0 compatibility mode

  • Atomization for each operand

  • Both untypedAtomic are cast to xs:string

  • untypedAtomic cast to xs:double

  • untypedAtomic cast to xs:daytimeDuration

  • untypedAtomic cast to xs:yearMonthDuration

  • untypedAtomic cast from primitive base type

3.7.3 Node Comparisons

  • is operator

  • << operator

  • >> operator

3.8 Logical epxressions

  • or

  • and

  • XPath 1.0 compatibility mode

3.9 For Expressions

  • For expressions

3.10 Let Expressions

  • Let expressions

3.11 Maps and Arrays

3.11.1 Maps

3.11.1.1 Map Constructors

  • Map constructors

3.11.1.2 Map lookup using Function Call Syntax

  • Map lookup using function call syntax

3.11.2 Arrays

3.11.2.1 Array Constructors

  • Array constructors

3.11.2.2 Array Lookup using Function Call Syntax

  • Array lookup using function call syntax

3.11.3 The Lookup Operator ? for Maps and Arrays

3.11.3.1 Unary Lookup

  • Unary Lookup

3.11.3.2 Postfix Lookup

  • Postfix Lookup

3.12 Conditional Expressions

  • Conditional expressions

3.13 Quantified Expressions

  • some

  • every

3.14 Expressions on SequenceTypes

3.14.1 Instance of

  • instance of

3.14.2 Cast

  • cast as

3.14.3 Castable

  • castable as

3.14.4 Constructor functions

  • Constructor functions

3.14.5 Treat

  • treat as no effect without stating typing, maybe should do instance of

3.15 Simple map operator (!)

  • Simple map operator

3.16 Arrow operator (=>)

  • Arrow operator

A XPath 3.1 Grammar

A.1 EBNF

  • Grammar (a few details remain)

A.1.1 Notation

A.1.2 Extra grammatical constraints

  • Leading-lone-slash

  • xml-version

  • reserved-function-names

  • occurrence-indicators

A.1.3 Grammar notes

  • parens

  • comments

A.2 Lexical structure

A.2.1 Terminal Symbols

  • Terminal symbols

A.2.2 Terminal Delimination

  • distinguish delimiting terminal symbols from non-delimiting ones

  • comment and whitespace symbol separators

  • symbol separator between two non-delimiting terminal symbols

  • symbol separator after NCName and "." and "-"

  • symbol separator between numeric literal and "." and vice versa

A.2.3 End of line handling

TDB

A.2.3.1 XML 1.0 end of line handling

A.2.3.2 XML 1.1 end of line handling

A.2.4 Whitespace rules

  • whitespace rules

A.2.4.2 Explicit whitespace handling

  • explicit whitespace handling inside various literals

A.3 Reserved function names

  • reserved function names

A.4. Precedence order (non-normative)

  • Implemented grammar so should follow precedence order

B Type Promotion and Operator Mapping

B.1 Type Promotion

  • Numeric type promotion for operators

  • Numeric type promotion for function calls

  • URI type promotion for operators

  • URI type promotion for function calls

  • subtype substitution, see 2.5.5.1

B.2 Operator Mapping

  • Operator mapping for numeric arithmetic

  • Operator mapping for date time arithmetic

  • Complete handling of all operator mapping in big table

C Context Components

C.1 Static Context Components

See static context components in 2.1.1

C.2 Dynamic Context Components

See dynamic context components in 2.1.2

D Implementation-Defined items