View Old View New View Both View Only Previous Next

This draft contains only sections that have differences from the version that it modified.

W3C

XML Path Language (XPath) 4.0 WG Review Draft

W3C Editor's Draft 2 February12 March 2026

This version:
https://qt4cg.org/specifications/xpath-40/
Most recent version of XPath:
https://qt4cg.org/specifications/xpath-40/
Most recent Recommendation of XPath:
https://www.w3.org/TR/2017/REC-xpath-31-20170321/
Editor:
Michael Kay, Saxonica <mike@saxonica.com>

Please check the errata for any errors or issues reported since publication.

See also translations.


Abstract

XPath 4.0 is an expression language that allows the processing of values conforming to the data model defined in [XQuery and XPath Data Model (XDM) 4.0]. The name of the language derives from its most distinctive feature, the path expression, which provides a means of hierarchic addressing of the nodes in an XML tree. As well as modeling the tree structure of XML, the data model also includes atomic items, function items, maps, arrays, and sequences. This version of XPath supports JSON as well as XML, and adds many new functions in [XQuery and XPath Functions and Operators 4.0].

XPath 4.0 is a superset of XPath 3.1. A detailed list of changes made since XPath 3.1 can be found in J Change Log.

Status of this Document

This is a draft prepared by the QT4CG (officially registered in W3C as the XSLT Extensions Community Group). Comments are invited.


3 Types

As noted in 2.1.2 Values, every value in XPath 4.0 is regarded as a sequence of zero, one, or more items. The type system of XPath 4.0, described in this section, classifies the kinds of value that the language can handle, and the operations permitted on different kinds of value.

The type system of XPath 4.0 is related to the type system of [XML Schema 1.0] or [XML Schema 1.1] in two ways:

This chapter of the specification starts by defining sequence types and item types, which describe the range of values that can be bound to variables, used in expressions, or passed to functions. It then describes how these relate to schema types, that is, the simple and complex types defined in an XSD schema.

3.1 Sequence Types

[Definition: A sequence type is a type that can be expressed using the SequenceType syntax. Sequence types are used whenever it is necessary to refer to a type in an XPath 4.0 expression. The term sequence type suggests that this syntax is used to describe the type of an XPath 4.0 value, which is always a sequence.]

[Definition: An item type is a type that can be expressed using the ItemType syntax, which forms part of the SequenceType syntax. Item types match individual items.] In most cases, the set of items matched by an item type consists either exclusively of atomic items, exclusively of nodes, or exclusively of function itemsDM. Exceptions include the generic types item(), which matches all items, xs:error, which matches no items, and choice item types, which can match any combination of types.

Whenever it is necessary to refer to a type in an XPath 4.0 expression, the SequenceType syntax is used.

SequenceType::=("empty-sequence" "(" ")")
| (ItemTypeOccurrenceIndicator?)
ItemType::=AnyItemTest | TypeName | KindTest | FunctionType | MapType | ArrayType | RecordType | EnumerationType | ChoiceItemType
OccurrenceIndicator::="?" | "*" | "+"
/* xgc: occurrence-indicators */

In many situations the terms item type and sequence type are used interchangeably to refer either to the type itself, or to the syntactic construct that designates the type: so in the expression $x instance of xs:string*, the construct xs:string* uses the SequenceType syntax to designate a sequence type whose instances are sequences of strings. When more precision is required, the specification is careful to use the terms item type and sequence type to refer to the actual types, while using the production names ItemType and SequenceType to refer to the syntactic designators of these types.

[Definition: A sequence type designator is a syntactic construct conforming to the grammar rule SequenceType. A sequence type designator is said to designate a sequence type.]

[Definition: An item type designator is a syntactic construct conforming to the grammar rule ItemType. An item type designator is said to designate an item type.]

Note:

Two item type designators may designate the same item type. For example, element() and element(*) are equivalent, as are attribute(A) and attribute(A, xs:anySimpleType).

With the exception of the special type empty-sequence(), a sequence type consists of an item type that constrains the type of each item in the sequence, and a cardinality that constrains the number of items in the sequence. Apart from the item type item(), which permits any kind of item, item types divide into node types (such as element()), generalized atomic types (such as xs:integer) and function types (such as function() as item()*).

Lexical QNames appearing in a sequence type have their prefixes expanded to namespace URIs by means of the statically known namespaces and (where applicable) the default namespace for elements and types. Equality of QNames is defined by the eq operator.

Item types representing element and attribute nodes may specify the required type annotations of those nodes in the form of a schema type. Thus the item type element(*, us:address) denotes any element node whose type annotation is (or is derived from) the schema type named us:address.

The occurrence indicators +, *, and ? bind to the last ItemType in the SequenceType, as described in the occurrence-indicators constraint.

3.1.2 Sequence Type Matching

[Definition: SequenceType matching compares a value with an expected sequence type. ] For example, an instance of expression returns true if a given value matches a given sequence type, and false if it does not.

An XPath 4.0 implementation must be able to determine relationships among the types in type annotations in an XDM instance and the types in the in-scope schema definitions (ISSD).

[Definition: The use of a value that has a dynamic type that is a subtype of the expected type is known as subtype substitution.] Subtype substitution does not change the actual type of a value. For example, if an xs:integer value is used where an xs:decimal value is expected, the value retains its type as xs:integer.

The definition of SequenceType matching relies on a pseudo-function named derives-from(AT, ET), which takes an actual simple or complex schema type AT and an expected simple or complex schema type ET, and either returns a boolean value or raises a type error [err:XPTY0004]. This function is defined as follows:

  • derives-from(AT, ET) raises a type error [err:XPTY0004] if ET is not present in the in-scope schema definitions (ISSD).

  • derives-from(AT, ET) returns true if any of the following conditions applies:

    • AT is ET

    • ET is the base type of AT

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

    • There is a type MT such that derives-from(AT, MT) and derives-from(MT, ET)

  • Otherwise, derives-from(AT, ET) returns false

The rules for SequenceType matching are given below, with examples (the examples are for purposes of illustration, and do not cover all possible cases).

An OccurrenceIndicator specifies the number of items in a sequence, as follows:

  • ? matches zero or one items

  • * matches zero or more items

  • + matches one or more items

As a consequence of these rules, any sequence type whose OccurrenceIndicator is * or ? matches a value that is an empty sequence.

3.1.3 Schema Type Relationships

Some item types are defined in terms of schema types, and the matching rules for such item types depend on the rules defining relationships between schema types in the XSD specification.

[Definition: A schema typeS1 is said to derive fromschema typeS2 if any of the following conditions is true:

]

Note:

The XML Schema specification does not completely specify the circumstances under which S1 and S2 are considered to be the same type. For example, if both are anonymous union types with the same member types, but defined in different places in the schema, then schema processors have discretion whether to treat them as the same type.

3.2 Item Types

ItemTypeItemType::=AnyItemTest | TypeName | KindTest | FunctionType | MapType | ArrayType | RecordType | EnumerationType | ChoiceItemType
AnyItemTest::="item" "(" ")"
TypeName::=EQName
KindTest::=DocumentTest
| ElementTest
| AttributeTest
| SchemaElementTest
| SchemaAttributeTest
| PITest
| CommentTest
| TextTest
| NamespaceNodeTest
| AnyKindTest
DocumentTest::="document-node" "(" (ElementTest | SchemaElementTest | NameTestUnion)? ")"
ElementTestElementTest::="element" "(" (NameTestUnion ("," TypeName "?"?)?)? ")"
SchemaElementTestSchemaElementTest::="schema-element" "(" ElementName ")"
AttributeTestAttributeTest::="attribute" "(" (NameTestUnion ("," TypeName)?)? ")"
SchemaAttributeTestSchemaAttributeTest::="schema-attribute" "(" AttributeName ")"
ElementName::=EQName
AttributeName::=EQName
PITest::="processing-instruction" "(" (NCName | StringLiteral)? ")"
CommentTest::="comment" "(" ")"
NamespaceNodeTest::="namespace-node" "(" ")"
TextTest::="text" "(" ")"
AnyKindTest::="node" "(" ")"
FunctionTypeFunctionType::=AnyFunctionType
| TypedFunctionType
AnyFunctionTypeAnyFunctionType::=("function" | "fn") "(" "*" ")"
TypedFunctionTypeTypedFunctionType::=("function" | "fn") "(" (SequenceType ** ",") ")" "as" SequenceType
ChoiceItemType::="(" (ItemType ++ "|") ")"
MapTypeMapType::=AnyMapType | TypedMapType
RecordTypeRecordType::=AnyRecordType | TypedRecordType
ArrayTypeArrayType::=AnyArrayType | TypedArrayType
EnumerationTypeEnumerationType::="enum" "(" (StringLiteral ++ ",") ")"

This section defines the syntax and semantics of different ItemTypes in terms of the values that they match.

Note:

For an explanation of the EBNF grammar notation (and in particular, the operators ++ and **), see A.1 EBNF.

An item type designator written simply as an EQName (that is, a TypeName) is interpreted as follows:

  1. If the name is written as a lexical QName, then it is expanded using the in-scope namespaces in the static context. If the name is an unprefixed NCName, then it is expanded according to the default namespace for elements and types.

  2. If the name matches a named item type in the static context, then it is taken as a reference to the corresponding item type. The rules that apply are the rules for the expanded item type definition.

  3. Otherwise, it must match the name of a type in the in-scope schema types in the static context: specifically, an atomic type or a pure union type. See 3.5 Schema Types for details.

    Note:

    A name in the xs namespace will always fall into this category, since the namespace is reserved. See 2.1.3 Namespaces and QNames.

  4. If the name cannot be resolved to a type, a static error is raised [err:XPST0051].

3.2.2 Atomic Types

Atomic types in the XPath 4.0 type system correspond directly to atomic types as defined in the [XML Schema 1.0] or [XML Schema 1.1] type system.

Atomic types are either built-in atomic types such as xs:integer, or user-defined atomic types imported from a schema. Atomic types are identified by a QName: see 2.1.3 Namespaces and QNames.

Note:

A schema may also include anonymous atomic types. Such types are not usable directly in XPath 4.0, though they may appear as the values of type annotations on nodes.

[Definition: A generalized atomic type is an item type whose instances are all atomic items. Generalized atomic types include (a) atomic types, either built-in (for example xs:integer) or imported from a schema, (b) pure union types, either built-in (xs:numeric and xs:error) or imported from a schema, (c) choice item types if their alternatives are all generalized atomic types, and (d) enumeration types. ].

A generalized atomic type may be designated by an ItemType in any of the following ways:

An atomic item A matches the generalized atomic typeGAT if the type annotation of A (call it derives fromT) satisfies the condition derives-from(T, GAT)GAT.

Example: The ItemTypexs:decimal matches any value of type xs:decimal. It also matches any value of type shoesize, if shoesize is an atomic type derived by restriction from xs:decimal.

Example: Suppose ItemTypedress-size is a union type that allows either xs:decimal values for numeric sizes (for example: 4, 6, 10, 12), or one of an enumerated set of xs:strings (for example: small, medium, large). The ItemTypedress-size matches any of these values.

Note:

The names of list types such as xs:IDREFS are not accepted in this context, but can often be replaced by a generalized atomic type with an occurrence indicator, such as xs:IDREF+.

3.2.7 Node Types

Changes in 4.0  

  1. Element and attribute tests can include alternative names: element(chapter|section), attribute(role|class).   [Issue 107 PR 286 17 January 2023]

  2. The NodeTest in an AxisStep now allows alternatives: ancestor::(section|appendix)  [Issue 107 PR 286 17 January 2023]

  3. The syntax document-node(N), where N is a NameTestUnion, is introduced as an abbreviation for document-node(element(N)). For example, document-node(*) matches any well-formed XML document (as distinct from a document fragment).   [Issue 1593  24 November 2024]

Some of the constructs described in this section include a TypeName. This appears as T in:

  • element(N, T)

  • attribute(N, T)

  • document-node(element(N, T))

In these constructs, the type name T is expanded using the in-scope namespaces in the static context, using the default namespace for elements and types if it is unprefixed. The resulting QName must identify a type in the in-scope schema definitions. This can be any schema type: either a simple type, or (except in the case of attributes) a complex type. If it is a simple type then it can be an atomic, union, or list type. It can be a built-in type (such as xs:integer) or a user-defined type. It must however be the name of a type defined in a schema; it cannot be a named item type.

3.2.7.2 Element Test

Changes in 4.0  

  1. Element and attribute tests of the form element(N) and attribute(N) now allow N to be any NameTest, including a wildcard. The forms element(A|B) and attribute(A|B) are also allowed.   [Issue 107 PR 286 17 January 2023]

  2. Setting the default namespace for elements and types to the special value ##any causes an unprefixed element name to act as a wildcard, matching by local name regardless of namespace.

ElementTest::="element" "(" (NameTestUnion ("," TypeName "?"?)?)? ")"
NameTestUnion::=(NameTest ++ "|")
NameTestNameTest::=EQName | Wildcard
WildcardWildcard::="*"
| (NCName ":*")
| ("*:" NCName)
| (BracedURILiteral "*")
/* ws: explicit */
TypeNameTypeName::=EQName

An ElementTest is used to match an element node by its name and/or type annotation.

An unprefixed EQName within the NameTestUnion is interpreted according to the default namespace for elements and types. The name need not be present in the in-scope element declarations.

If the default namespace for elements and types has the special value ##any, then an unprefixed name N is interpreted as a wildcard *:N.

It is always possible to match no-namespace names explicitly by using the form Q{}N

An unprefixed TypeName is interpreted according to the default namespace for elements and types. The TypeName must be present in the in-scope schema types [err:XPST0008]

If the default namespace for elements and types has the special value ##any, then an unprefixed type name T is interpreted as Q{http://www.w3.org/2001/XMLSchema}T.

Note:

Substitution groups do not affect the semantics of ElementTest.

An ElementTestET matches an item E if the following conditions are satisfied:

  1. E is an element node.

  2. If ET includes a NameTestUnion, then the name of the element node E matches one or more of the NameTests in the NameTestUnion. A name N matches a NameTestNT if one of the following conditions is true:

    1. NT is *

    2. NT is *:local and the local part of N is local.

    3. NT is prefix:* and the namespace URI of N matches the namespace URI bound to prefix in the static context.

    4. NT is BracedURILiteral* and the namespace URI of N matches the namespace URI found in the BracedURILiteral.

    5. NT is an EQName equal to N.

  3. If ET includes a TypeNameT, then the type annotation of the element node E derives fromis Teither the schema type identified by that type name, or a type derived from that type by restriction.

  4. If E has the nilled property, then ET either includes no TypeName, or includes a TypeName followed by the symbol ?.

Here are some examples of ElementTests:

  1. element() and element(*) match any single element node, regardless of its name or type annotation.

  2. element(person) matches any element node whose name is person, in the default namespace for elements and types.

  3. element(doctor|nurse) matches any element node whose name is doctor or nurse, in the default namespace for elements and types.

  4. element(xhtml:*) matches any element node whose name is in the namespace bound to the prefix xhtml.

  5. element(xhtml:*|svg:*|mathml:*) matches any element node whose name is one of the three namespaces identified, specifically the namespaces bound to the prefixes xhtml, svg, and mathml.

  6. element(Q{http://www.w3.org/2000/svg}*) matches any element node whose name is in the SVG namespace.

  7. element(*:html) matches any element node whose local name is "html", in any namespace.

  8. element(person, surgeon) matches a non-nilled element node whose name is person and whose type annotation is surgeon (or is derived from surgeon).

  9. element(person, surgeon?) matches a nilled or non-nilled element node whose name is person and whose type annotation is surgeon (or is derived from surgeon).

  10. element(*, surgeon) matches any non-nilled element node whose type annotation is surgeon (or is derived from surgeon), regardless of its name.

  11. element(*, surgeon?) matches any nilled or non-nilled element node whose type annotation is surgeon (or is derived from surgeon), regardless of its name.

Where a TypeName is included in an ElementTestT, and element node will only match the test if it has been validated against a schema that defines type T; furthermore, T must be present in the in-scope schema definitions of the static context of the ElementTest. Although it is guaranteed that type T will have compatibleDM definitions in the schema that was used for validation and in the in-scope schema definitions, it is not guaranteed that revalidation using the in-scope schema definitions would succeed. For example, if substitution group membership varies between the two schemas, the element node may contain children or descendants that the in-scope schema definitions would not allow.

Note:

Technically, element(p|q) is not the same type as the choice item type (element(p)|element(q)). However, (a) they match exactly the same set of element nodes, and (b) each is a subtype of the other, so in practice they are indistinguishable.

3.2.7.3 Schema Element Test
SchemaElementTest::="schema-element" "(" ElementName ")"
ElementNameElementName::=EQName

A SchemaElementTest matches an element node against a corresponding element declaration found in the in-scope element declarations.

The ElementName of a SchemaElementTest has its prefixes expanded to a namespace URI by means of the statically known namespaces, or if unprefixed, the is interpreted according to the default namespace for elements and types. If this has the special value "##any", an unprefixed name represents a name in no namespace. If the ElementName specified in the SchemaElementTest is not found in the in-scope element declarations, a static error is raised [err:XPST0008].

A SchemaElementTest matches a candidate element node if all of the following conditions are satisfied:

  1. Either:

    1. The name N of the candidate node matches the specified ElementName, or

    2. The name N of the candidate node matches the name of an element declaration that is a member of the actual substitution group headed by the declaration of element ElementName.

    Note:

    The term “actual substitution group” is defined in [XML Schema 1.1]. The actual substitution group of an element declaration H includes those element declarations P that are declared to have H as their direct or indirect substitution group head, provided that P is not declared as abstract, and that P is validly substitutable for H, which means that there must be no blocking constraints that prevent substitution.

  2. The schema element declaration named N is not abstract.

  3. derives-from( AT, ET )AT derives fromis ETtrue, where AT is the type annotation of the candidate node and ET is the schema type declared in the schema element declaration named N.

  4. If the schema element declaration named N is not nillable, then the nilled property of the candidate node is false.

Example: The SchemaElementTestschema-element(customer) matches a candidate element node in the following two situations:

  1. customer is a top-level element declaration in the in-scope element declarations; the name of the candidate node is customer; the element declaration of customer is not abstract; the type annotation of the candidate node is the same as or derived from the schema type declared in the customer element declaration; and either the candidate node is not nilled, or customer is declared to be nillable.

  2. customer is a top-level element declaration in the in-scope element declarations; the name of the candidate node is client; client is an actual (non-abstract and non-blocked) member of the substitution group of customer; the type annotation of the candidate node is the same as or derived from the schema type declared for the client element; and either the candidate node is not nilled, or client is declared to be nillable.

In the case where the schema X used to validate an element node E (whose name is N) differs from the schema Y represented by the in-scope schema definitions in the static context of the SchemaElementTest, the following considerations apply:

  • In applying the test AT derives-from( AT , ET ), note that AT will necessarily be present in X, but not necessarily in Y. However, ET will necessarily be present in both; and because the two schemas must be compatibleDM, ET will be the present in both schemas, will have the same definition in both, and will be the declared type of N in both. The test can therefore be applied from knowledge of type AT as defined in schema X.

  • The test as to whether the element name N is a member of the actual substitution group is performed entirely by reference to schema Y. Although the two schemas are compatible, substitution group membership can vary.

3.2.7.4 Attribute Test

Changes in 4.0  

  1. Element and attribute tests of the form element(N) and attribute(N) now allow N to be any NameTest, including a wildcard. The forms element(A|B) and attribute(A|B) are also allowed.   [Issue 107 PR 286 17 January 2023]

AttributeTest::="attribute" "(" (NameTestUnion ("," TypeName)?)? ")"
NameTestUnionNameTestUnion::=(NameTest ++ "|")
NameTestNameTest::=EQName | Wildcard
WildcardWildcard::="*"
| (NCName ":*")
| ("*:" NCName)
| (BracedURILiteral "*")
/* ws: explicit */
TypeNameTypeName::=EQName

An AttributeTest is used to match an attribute node by its name and/or type annotation.

An unprefixed EQName within the NameTestUnion refers to a name in no namespace. The name need not be present in the in-scope attribute declarations.

An unprefixed TypeName is interpreted according to the default namespace for elements and types. The TypeName must be present in the in-scope schema types [err:XPST0008]

An AttributeTestAT matches an item A if the following conditions are satisfied:

  1. A is an attribute node.

  2. If AT includes a NameTestUnion, then the name of the attribute node A matches one or more of the NameTests in the NameTestUnion. A name N matches a NameTestNT if one of the following conditions is true:

    1. NT is *

    2. NT is *:local and the local part of N matches local.

    3. NT is prefix:* and the namespace URI of N matches the namespace URI bound to prefix in the static context.

    4. NT is BracedURILiteral* and the namespace URI of N matches the namespace URI found in the BracedURILiteral.

    5. NT is an EQName equal to N.

  3. If AT includes a TypeNameT, then the type annotation of the attribute node A derives fromis Teither the schema type identified by that type name, or a type derived from that type by restriction.

Here are some examples of AttributeTests:

  • attribute() and attribute(*) match any single attribute node, regardless of its name or type annotation.

  • attribute(price) matches any attribute node whose name is price (in no namespace), regardless of its type annotation.

  • attribute(price|discount) matches any attribute node whose name is price or discount (in no namespace).

  • attribute(xlink:*) matches any attribute node whose name is in the namespace bound to the prefix xlink.

  • element(Q{http://www.w3.org/2000/svg}*) matches any attribute node whose name is in the SVG namespace.

  • attribute(*:default-collation) matches any attribute node whose local name is default-collation, regardless of namespace, and regardless of type annotation.

  • attribute(*:price|*:discount) matches any attribute node whose local name is price or discount, regardless of namespace, and regardless of type annotation.

  • attribute(price, currency) matches an attribute node whose name is price (in no namespace) and whose type annotation is currency (or is derived from currency).

  • attribute(xlink:*, xs:string) matches any attribute node whose name is in the namespace bound to the prefix xlink, and whose type annotation is xs:string or a type derived from xs:string.

  • attribute(*, currency) matches any attribute node whose type annotation is currency (or is derived from currency), regardless of its name.

Unlike the situation with an ElementTest, few problems arise if the attribute was validated using a different schema. This is because simple types can never be derived by extension, and attributes do not have substitution groups.

Note:

Technically, attribute(p|q) is not the same type as the choice item type (attribute(p)|attribute(q)). However, (a) they match exactly the same set of attribute nodes, and (b) each is a subtype of the other, so in practice they are indistinguishable.

3.2.7.5 Schema Attribute Test
SchemaAttributeTest::="schema-attribute" "(" AttributeName ")"
AttributeNameAttributeName::=EQName

A SchemaAttributeTest matches an attribute node against a corresponding attribute declaration found in the in-scope attribute declarations.

The AttributeName of a SchemaAttributeTest has its prefixes expanded to a namespace URI by means of the statically known namespaces. If unprefixed, an AttributeName is in no namespace. If the AttributeName specified in the SchemaAttributeTest is not found in the in-scope attribute declarations, a static error is raised [err:XPST0008].

A SchemaAttributeTest matches a candidate attribute node if both of the following conditions are satisfied:

  1. The name of the candidate node matches the specified AttributeName.

  2. derives-from(ATderives fromAT, ET) is true, where AT is the type annotation of the candidate node and ET is the schema type declared for attribute AttributeName in the in-scope attribute declarations.

Example: The SchemaAttributeTestschema-attribute(color) matches a candidate attribute node if color is a top-level attribute declaration in the in-scope attribute declarations, the name of the candidate node is color, and the type annotation of the candidate node is the same as or derived from the schema type declared for the color attribute.

Unlike the situation with a SchemaElementTest, few problems arise if the attribute was validated using a different schema. This is because attributes do not have substitution groups.

3.3 Subtype Relationships

Changes in 4.0  

  1. The presentation of the rules for the subtype relationship between sequence types and item types has been substantially rewritten to improve clarity; no change to the semantics is intended.  [Issue 196 PR 202 25 October 2022]

[Definition: Given two sequence types or item types, the rules in this section determine if one is a subtype of the other. If a type A is a subtype of type B, it follows that every value matched by A is also matched by B.]

Note:

The relationship subtype(A, A) is always true: every type is a subtype of itself.

Note:

The converse is not necessarily true: we cannot infer that if every value matched by A is also matched by B, then A is a subtype of type B. For example, A might be defined as the set of strings matching the regular expression [A-Z]*, while B is the set of strings matching the regular expression [A-Za-z]*; no subtype relationship holds between these types.

The rules for deciding whether one sequence type is a subtype of another are given in 3.3.1 Subtypes of Sequence Types. The rules for deciding whether one item type is a subtype of another are given in 3.3.2 Subtypes of Item Types.

Note:

The subtype relationship is not acyclic. There are cases where subtype(A, B) and subtype(B, A) are both true. This implies that A and B have the same value space, but they can still be different types. For example this applies when A is a union type with member types xs:string and xs:integer, while B is a union type with member types xs:integer and xs:string. These are different types ("23" cast as A produces a string, while "23" cast as B produces an integer, because casting is attempted to each member type in order) but both types have the same value space.

3.3.2 Subtypes of Item Types

We use the notation A ⊆ B, or itemtype-subtype(A, B) to indicate that an item typeA is a subtype of an item type B. This section defines the rules for deciding whether any two item types have this relationship.

The rules in this section apply to item types, not to item type designators. For example, if the name STR has been defined in the static context as a named item type referring to the type xs:string, then anything said here about the type xs:string applies equally whether it is designated as xs:string or as STR, or indeed as the parenthesized forms (xs:string) or (STR).

References to named item types are handled as described in 3.3.2.11 Named Item Types.

The relationship A ⊆ B is true if and only if at least one of the conditions listed in the following subsections applies:

3.3.2.3 Atomic and Union Types

Given item types A and B, AB is true if any of the following apply:

  1. A and B are generalized atomic types, and derives-from(A, derives fromB) returns true.

    The derives-from relationship is defined in 3.1.2 Sequence Type Matching.

    Examples:
    • xs:integer ⊆ xs:decimal because xs:integer is derived by restriction from xs:decimal.

    • xs:decimal ⊆ xs:numeric because xs:numeric is a pure union type that includes xs:decimal as a member type.

    • enum("red") ⊆ xs:string because the singleton enumeration type enum("red") is defined to be an atomic type derived from xs:string.

    • enum("red") ⊆ enum("red", "green") because the enumeration type enum("red", "green") is defined to be a union type that has the generalized atomic type enum("red") as a member type.

  2. A is a pure union type, and every type T in the transitive membership of A satisfies TB.

    Examples:
    • (xs:short | xs:long) ⊆ xs:integer because xs:short ⊆ xs:integer and xs:long ⊆ xs:integer.

    • (P | Q) ⊆ (P | Q | R) because P ⊆ (P | Q | R) and Q ⊆ (P | Q | R).

    • enum("red", "green") ⊆ xs:string because the enumeration type enum("red") ⊆ xs:string and enum("green") ⊆ xs:string.

    • enum("red", "green") ⊆ enum("red", "green", "blue") because enum("red") ⊆ enum("red", "green", "blue") and enum("green") ⊆ enum("red", "green", "blue").

    • enum("red", "green", "blue") ⊆ (enum("red", "green") | enum("blue")) because each of the types enum("red"), enum("green"), and enum("blue") is a subtype of one of the two members of the union type.

3.3.2.5 Node Types: Element Tests

[Definition: In these rules, if MU and NU are NameTestUnions, then MUwildcard-matchesNU is true if every name that matches MU also matches NU.]

More specifically, this is the case if for every NameTestM in MU there is a NameTestN in NU where at least one of the following applies:

  1. M and N are the same NameTest.

  2. M is an EQName and N is a Wildcard that matches M.

  3. N is the Wildcard*.

Given item types A and B, AB is true if any of the following apply.

  1. A is an ElementTest and B is either element() or element(*)

  2. All the following are true:

    1. A is either element(An) or element(An, T) or element(An, T?) for any type T

    2. B is either element(Bn) or element(Bn, xs:anyType?)

    3. Anwildcard-matchesBn

    Examples:
    • element(title) ⊆ element(*)

    • element(title, xs:string) ⊆ element(*)

    • element(title|heading, xs:string) ⊆ element(*)

    • element(title, xs:string) ⊆ element(title|heading)

    • element(title, xs:string?) ⊆ element(*)

    • element(title|heading, xs:string) ⊆ element(*)

    • element(title) ⊆ element(title, xs:anyType?)

    • element(title, xs:integer) ⊆ element(title|heading, xs:anyType?)

    • element(title, xs:string?) ⊆ element(title, xs:anyType?)

    • element(my:title|your:title) ⊆ element(*:title)

    • element(my:title|my:heading) ⊆ element(my:*)

  3. All the following are true:

    1. A is element(An, At).

    2. B is element(Bn, Bt).

    3. Anwildcard-matchesBn.

    4. derives-from(At, Bt).

      Atderives fromBt.

    Examples:
    • element(size, xs:integer) ⊆ element(size, xs:decimal)

    • element(size, xs:integer) ⊆ element(size|größe, xs:decimal)

    • element(size, xs:integer) ⊆ element(*, xs:decimal)

    • element(*, xs:integer) ⊆ element(*, xs:decimal)

    • element(my:*, xs:integer) ⊆ element(*, xs:decimal)

  4. All the following are true:

    1. A is either element(An, At) or element(An, At?)

    2. B is element(Bn, Bt?)

    3. Anwildcard-matchesBn

    4. derives-from(At, Bt).

      Atderives fromBt.

    Examples:
    • element(size, xs:integer) ⊆ element(size, xs:decimal?)

    • element(size, xs:integer?) ⊆ element(*, xs:decimal?)

    • element(*, xs:integer) ⊆ element(*, xs:decimal?)

    • element(my:*, xs:integer?) ⊆ element(*, xs:decimal?)

  5. All the following are true:

    1. A is schema-element(An)

    2. B is schema-element(Bn)

    3. Every element declaration that is an actual member of the substitution group of An is also an actual member of the substitution group of Bn.

    Note:

    The fact that P is a member of the substitution group of Q does not mean that every element declaration in the substitution group of P is also in the substitution group of Q. For example, Q might block substitution of elements whose type is derived by extension, while P does not.

  6. A is element(A1|A2|..., T) (where T may be absent), and for each An, element(An, T) ⊆ B.

    Examples:
    • element(a|b) ⊆ (element(a)|element(b)|element(c))

    • element(a|b, xs:integer) ⊆ (element(a, xs:decimal) | element(b, xs:integer))

3.3.2.6 Node Types: Attribute Tests

Given item types A and B, AB is true if any of the following apply:

  1. A is an AttributeTest and B is either attribute() or attribute(*)

  2. All the following are true:

    1. A is either attribute(An) or attribute(An, T) for any type T.

    2. B is either attribute(Bn) or attribute(Bn, xs:anyAtomicType)

    3. Anwildcard-matchesBn

    Examples:
    • attribute(code) ⊆ attribute(*)

    • attribute(code|status) ⊆ attribute(*)

    • attribute(code, xs:untypedAtomic) ⊆ attribute(*)

    • attribute(code|status, xs:string) ⊆ attribute(code, xs:anyAtomicType)

    • attribute(my:code|your:code) ⊆ attribute(*:code)

    • attribute(my:code|my:status) ⊆ attribute(my:*)

  3. All the following are true:

    1. A is attribute(An, At)

    2. B is attribute(Bn, Bt)

    3. Anwildcard-matchesBn

    4. derives-from(At, Bt).

      Atderives fromBt.

    Examples:
    • attribute(*, xs:ID) ⊆ attribute(*, xs:string)

    • attribute(my:*, xs:ID) ⊆ attribute(*, xs:string)

    • attribute(code, xs:ID) ⊆ attribute(code|status, xs:string)

    • attribute(code, xs:ID) ⊆ attribute(*, xs:string)

    • attribute(code, xs:ID) ⊆ attribute(*:code, xs:ID)

    • attribute(my:code|my:status, xs:ID) ⊆ attribute(my:*, xs:string)

  4. All the following are true:

    1. A is schema-attribute(An)

    2. B is schema-attribute(Bn)

    3. the expanded QName of An equals the expanded QName of Bn

  5. A is attribute(A1|A2|..., T) (where T may be absent), and for each An, attribute(An, T) ⊆ B.

    Examples:
    • attribute(a|b) ⊆ (attribute(a)|attribute(b)|attribute(c))

    • attribute(a|b, xs:integer) ⊆ (attribute(a, xs:decimal) | attribute(b))

G Glossary (Non-Normative)

anonymous function

An anonymous function is a function item with no name. Anonymous functions may be created, for example, by evaluating an inline function expression or by partial function application.

application function

Application functions are function definitions written in a host language such as XQuery or XSLT whose syntax and semantics are defined in this family of specifications. Their behavior (including the rules determining the static and dynamic context) follows the rules for such functions in the relevant host language specification.

argument expression

An argument to a function call is either an argument expression or an ArgumentPlaceholder (?); in both cases it may either be supplied positionally, or identified by a name (called a keyword).

arity range

A function definition has an arity range, which is a range of consecutive non-negative integers. If the function definition has M required parameters and N optional parameters, then its arity range is from M to M+N inclusive.

array

An array is a function item that associates a set of positions, represented as positive integer keys, with values.

associated value

The value associated with a given key is called the associated value of the key.

atomic item

An atomic item is a value in the value space of an atomic type, as defined in [XML Schema 1.0] or [XML Schema 1.1].

atomic type

An atomic type is a simple schema type whose {variety} is atomic.

atomization

Atomization of a sequence is defined as the result of invoking the fn:data function, as defined in Section 2.1.4 fn:dataFO.

available documents

Available documents. This is a mapping of strings to document nodes. Each string represents the absolute URI of a resource. The document node is the root of a tree that represents that resource using the data model. The document node is returned by the fn:doc function when applied to that URI.

available item collections

Available collections. This is a mapping of strings to sequences of items. Each string represents the absolute URI of a resource. The sequence of items represents the result of the fn:collection function when that URI is supplied as the argument.

available text resources

Available text resources. This is a mapping of strings to text resources. Each string represents the absolute URI of a resource. The resource is returned by the fn:unparsed-text function when applied to that URI.

available uri collections

Available URI collections. This is a mapping of strings to sequences of URIs. The string represents the absolute URI of a resource which can be interpreted as an aggregation of a number of individual resources each of which has its own URI. The sequence of URIs represents the result of the fn:uri-collection function when that URI is supplied as the argument.

axis step

An axis step returns a sequence of nodes that are reachable from a starting node via a specified axis. Such a step has two parts: an axis, which defines the "direction of movement" for the step, and a node test, which selects nodes based on their kind, name, and/or type annotation .

binary

In the operator mapping tables, the term binary refers to the types xs:hexBinary and xs:base64Binary.

binding collection

The result of evaluating the binding expression in a for expression is called the binding collection

choice item type

A choice item type defines an item type that is the union of a number of alternatives. For example the type (xs:hexBinary | xs:base64Binary) defines the union of these two primitive atomic types, while the type (map(*) | array(*)) matches any item that is either a map or an array.

coercion rules

The coercion rules are rules used to convert a supplied value to a required type, for example when converting an argument of a function call to the declared type of the function parameter.

collation

A collation is a specification of the manner in which strings and URIs are compared and, by extension, ordered. For a more complete definition of collation, see Section 5.3 Comparison of stringsFO.

comma operator

One way to construct a sequence is by using the comma operator, which evaluates each of its operands and concatenates the resulting sequences, in order, into a single result sequence.

complex terminal

A complex terminal is a variable terminal whose production rule references, directly or indirectly, an ordinary production rule.

constructor function

The constructor function for a given simple type is used to convert instances of other simple types into the given type. The semantics of the constructor function call T($arg) are defined to be equivalent to the expression $arg cast as T?.

content expression

In an enclosed expression, the optional expression enclosed in curly brackets is called the content expression.

context dependent

A function definition is said to be context dependent if its result depends on the static or dynamic context of its caller. A function definition may be context-dependent for some arities in its arity range, and context-independent for others: for example fn:name#0 is context-dependent while fn:name#1 is context-independent.

context node

When the context value is a single item, it can also be referred to as the context item; when it is a single node, it can also be referred to as the context node.

context position

The context position is the position of the context value within the series of values currently being processed.

context size

The context size is the number of values in the series of values currently being processed.

context value

The context value is the value currently being processed.

current dateTime

Current dateTime. This information represents an implementation-dependent point in time during the processing of an expression, and includes an explicit timezone. It can be retrieved by the fn:current-dateTime function. If called multiple times during the execution of an expression, this function always returns the same result.

data model

XPath 4.0 operates on the abstract, logical structure of an XML document or JSON object rather than its surface syntax. This logical structure, known as the data model, is defined in [XQuery and XPath Data Model (XDM) 4.0].

decimal-separator

decimal-separator(M, R) is used to separate the integer part of the number from the fractional part. The default value for both the marker and the rendition is U+002E (FULL STOP, PERIOD, .) .

default calendar

Default calendar. This is the calendar used when formatting dates in human-readable output (for example, by the functions fn:format-date and fn:format-dateTime) if no other calendar is requested. The value is a string.

default collation

Default collation. This identifies one of the collations in statically known collations as the collation to be used by functions and operators for comparing and ordering values of type xs:string and xs:anyURI (and types derived from them) when no explicit collation is specified.

default collection

Default collection. This is the sequence of items that would result from calling the fn:collection function with no arguments.

default function namespace

Default function namespace. This is either a namespace URI, or absentDM. The namespace URI, if present, is used for any unprefixed QName appearing in a position where a function name is expected.

default language

Default language. This is the natural language used when creating human-readable output (for example, by the functions fn:format-date and fn:format-integer) if no other language is requested. The value is a language code as defined by the type xs:language.

default namespace for elements and types

Default namespace for elements and types. This is either a namespace URI, or the special value "##any", or absentDM. This indicates how unprefixed QNames are interpreted when they appear in a position where an element name or type name is expected.

default place

Default place. This is a geographical location used to identify the place where events happened (or will happen) when processing dates and times using functions such as fn:format-date, fn:format-dateTime, and fn:civil-timezone, if no other place is specified. It is used when translating timezone offsets to civil timezone names, and when using calendars where the translation from ISO dates/times to a local representation is dependent on geographical location. Possible representations of this information are an ISO country code or an Olson timezone name, but implementations are free to use other representations from which the above information can be derived. The only requirement is that it should uniquely identify a civil timezone, which means that country codes for countries with multiple timezones, such as the United States, are inadequate.

default URI collection

Default URI collection. This is the sequence of URIs that would result from calling the fn:uri-collection function with no arguments.

delimiting terminal symbol

The delimiting terminal symbols are: !!=#$()**:,...::*:::=<<<===!>=>=?>>>=>>????[@[]```{{|||}}×÷AposStringLiteralBracedURILiteral{<-+QuotStringLiteral}///StringLiteral

derives from

A schema typeS1 is said to derive fromschema typeS2 if any of the following conditions is true:

digit

digit(M) is a character used in the picture string to represent an optional digit; the default value is U+0023 (NUMBER SIGN, #) .

document order

Informally, document order is the order in which nodes appear in the XML serialization of a document.

dynamically known function definitions

Dynamically known function definitions. This is a set of function definitions. It includes the statically known function definitions as a subset, but may include other function definitions that are not known statically.

dynamic context

The dynamic context of an expression is defined as information that is needed for the dynamic evaluation of an expression, beyond any information that is needed from the static context.

dynamic error

A dynamic error is an error that must be detected during the dynamic evaluation phase and may be detected during the static analysis phase.

dynamic evaluation phase

The dynamic evaluation phase is the phase during which the value of an expression is computed.

dynamic function call

A dynamic function call consists of a base expression that returns the function and a parenthesized list of zero or more arguments (argument expressions or ArgumentPlaceholders).

dynamic function call

A dynamic function call is an expression that is evaluated by calling a function item, which is typically obtained dynamically.

dynamic type

Every value matches one or more sequence types. A value is said to have a dynamic typeT if it matches (or is an instance of) the sequence type T.

effective boolean value

The effective boolean value of a value is defined as the result of applying the fn:boolean function to the value, as defined in Section 7.3.1 fn:booleanFO.

empty sequence

A sequence containing zero items is called an empty sequence.

enclosed expression

An enclosed expression is an instance of the EnclosedExpr production, which allows an optional expression within curly brackets.

entry

Each key / value pair in a map is called an entry.

enumeration type

An EnumerationType accepts a fixed set of string values.

environment variables

Environment variables. This is a mapping from names to values. Both the names and the values are strings. The names are compared using an implementation-defined collation, and are unique under this collation. The set of environment variables is implementation-defined and may be empty.

error value

In addition to its identifying QName, a dynamic error may also carry a descriptive string and one or more additional values called error values.

Executable Base URI

Executable Base URI. This is an absolute URI used to resolve relative URIs during the evaluation of expressions; it is used, for example, to resolve a relative URI supplied to the fn:doc or fn:unparsed-text functions.

expanded QName

An expanded QName is a triple: its components are a prefix, a local name, and a namespace URI. In the case of a name in no namespace, the namespace URI and prefix are both absent. In the case of a name in the default namespace, the prefix is absent.

exponent-separator

exponent-separator(M, R) is used to separate the mantissa from the exponent in scientific notation. The default value for both the marker and the rendition is U+0065 (LATIN SMALL LETTER E, e) .

expression context

The expression context for a given expression consists of all the information that can affect the result of the expression.

external function

External functions can be characterized as functions that are neither part of the processor implementation, nor written in a language whose semantics are under the control of this family of specifications. The semantics of external functions, including any context dependencies, are entirely implementation-defined. In XSLT, external functions are called Section 24.1 Extension Functions XT30.

filter expression

A filter expression is an expression in the form E1[E2]: its effect is to return those items from the value of E1 that satisfy the predicate in E2.

fixed focus

A fixed focus is a focus for an expression that is evaluated once, rather than being applied to a series of values; in a fixed focus, the context value is set to one specific value, the context position is 1, and the context size is 1.

focus

The first three components of the dynamic context (context value, context position, and context size) are called the focus of the expression.

focus function

A focus function is an inline function expression in which the function signature is implicit: the function takes a single argument of type item()* (that is, any value), and binds this to the context value when evaluating the function body, which returns a result of type item()*.

function coercion

Function coercion wraps a function item in a new function whose signature is the same as the expected type. This effectively delays the checking of the argument and return types until the function is called.

function definition

A function definition contains information used to evaluate a static function call, including the name, parameters, and return type of the function.

function item

A function item is an item that can be called using a dynamic function call.

generalized atomic type

A generalized atomic type is an item type whose instances are all atomic items. Generalized atomic types include (a) atomic types, either built-in (for example xs:integer) or imported from a schema, (b) pure union types, either built-in (xs:numeric and xs:error) or imported from a schema, (c) choice item types if their alternatives are all generalized atomic types, and (d) enumeration types.

Gregorian

In the operator mapping tables, the term Gregorian refers to the types xs:gYearMonth, xs:gYear, xs:gMonthDay, xs:gDay, and xs:gMonth.

grouping-separator

grouping-separator(M, R) is used to separate groups of digits (for example as a thousands separator). The default value for both the marker and the rendition is U+002C (COMMA, ,) .

guarded

An expression E is said to be guarded by some governing condition C if evaluation of E is not allowed to fail with a dynamic error except when C applies.

host language

A host language for XPath is any environment that provides capabilities for XPath expressions to be defined and evaluated, and that supplies a static and dynamic context for their evaluation.

ignorable whitespace

Ignorable whitespace consists of any whitespace characters that may occur between terminals, unless these characters occur in the context of a production marked with a ws:explicit annotation, in which case they can occur only where explicitly specified (see A.3.5.2 Explicit Whitespace Handling).

implausible

Certain expressions, while not erroneous, are classified as being implausible, because they achieve no useful effect.

implementation defined

Implementation-defined indicates an aspect that may differ between implementations, but must be specified by the implementer for each particular implementation.

implementation dependent

Implementation-dependent indicates an aspect that may differ between implementations, is not specified by this or any W3C specification, and is not required to be specified by the implementer for any particular implementation.

implicit timezone

Implicit timezone. This is the timezone to be used when a date, time, or dateTime value that does not have a timezone is used in a comparison or arithmetic operation. The implicit timezone is an implementation-defined value of type xs:dayTimeDuration. See Section 3.2.7.3 Timezones XS1-2 or Section 3.3.7 dateTime XS11-2 for the range of valid values of a timezone.

infinity

infinity(R) is the string used to represent the double value infinity (INF); the default value is the string "Infinity"

inline function expression

An inline function expression, when evaluated, creates an anonymous function defined directly in the inline function expression.

in-scope attribute declarations

In-scope attribute declarations. Each attribute declaration is identified either by an expanded QName (for a top-level attribute declaration) or by an implementation-dependent attribute identifier (for a local attribute declaration).

in-scope element declarations

In-scope element declarations. Each element declaration is identified either by an expanded QName (for a top-level element declaration) or by an implementation-dependent element identifier (for a local element declaration).

in-scope named item types

In-scope named item types. This is a mapping from expanded QName to named item types.

in-scope namespaces

The in-scope namespaces property of an element node is a set of namespace bindings, each of which associates a namespace prefix with a URI.

in-scope schema definitions

In-scope schema definitions is a generic term for all the element declarations, attribute declarations, and schema type definitions that are in scope during static analysis of an expression.

in-scope schema type

In-scope schema types. Each schema type definition is identified either by an expanded QName (for a named type) or by an implementation-dependent type identifier (for an anonymous type). The in-scope schema types include the predefined schema types described in 3.5 Schema Types.

in-scope variables

In-scope variables. This is a mapping from expanded QName to type. It defines the set of variables that are available for reference within an expression. The expanded QName is the name of the variable, and the type is the static type of the variable.

item

An item is either an atomic item, a node, or a function item.

item type

An item type is a type that can be expressed using the ItemType syntax, which forms part of the SequenceType syntax. Item types match individual items.

item type designator

An item type designator is a syntactic construct conforming to the grammar rule ItemType. An item type designator is said to designate an item type.

kind test

An alternative form of a node test called a kind test can select nodes based on their kind, name, and type annotation.

lexical QName

A lexical QName is a name that conforms to the syntax of the QName production

literal

A literal is a direct syntactic representation of an atomic item.

literal terminal

A literal terminal is a token appearing as a string in quotation marks on the right-hand side of an ordinary production rule.

map

A map is a function that associates a set of keys with values, resulting in a collection of key / value pairs.

mapping arrow operator

The mapping arrow operator=!> applies a function to each item in a sequence.

may

MAY means that an item is truly optional.

member

The values of an array are called its members.

minus-sign

minus-sign(R) is the string used to mark negative numbers; the default value is U+002D (HYPHEN-MINUS, -) .

must

MUST means that the item is an absolute requirement of the specification.

must not

MUST NOT means that the item is an absolute prohibition of the specification.

named function reference

A named function reference is an expression (written name#arity) which evaluates to a function item, the details of the function item being based on the properties of a function definition in the static context.

named item type

A named item type is an ItemType identified by an expanded QName.

namespace-sensitive

The namespace-sensitive types are xs:QName, xs:NOTATION, types derived by restriction from xs:QName or xs:NOTATION, list types that have a namespace-sensitive item type, and union types with a namespace-sensitive type in their transitive membership.

name test

A node test that consists only of an EQName or a Wildcard is called a name test.

NaN

NaN(R) is the string used to represent the double value NaN (not a number); the default value is the string "NaN"

node

A node is an instance of one of the node kinds defined in Section 5 NodesDM.

node test

A node test is a condition on the name, kind (element, attribute, text, document, comment, or processing instruction), and/or type annotation of a node. A node test determines which nodes contained by an axis are selected by a step.

non-delimiting terminal symbol

The non-delimiting terminal symbols are: ancestorancestor-or-selfandarrayasatattributecastcastablechildcommentdescendantdescendant-or-selfdivdocument-nodeelementelseempty-sequenceenumeqeveryexceptfnfollowingfollowing-or-selffollowing-siblingfollowing-sibling-or-selfforfunctiongegtidivifininstanceintersectisitemitemskeykeysleletltmapmembermodnamespacenamespace-nodenenodeoforotherwisepairsparentprecedingpreceding-or-selfpreceding-sibling-or-selfprocessing-instructionrecordreturnsatisfiesschema-attributeschema-elementselfsometextthentotreatunionvaluevaluesBinaryIntegerLiteralDecimalLiteralDoubleLiteralHexIntegerLiteralIntegerLiteralNCNameQNameURIQualifiedName

numeric

When referring to a type, the term numeric denotes the types xs:integer, xs:decimal, xs:float, and xs:double which are all member types of the built-in union type xs:numeric.

operator function

For each operator and valid combination of operand types, the operator mapping tables specify a result type and an expression that invokes an operator function; the operator function implements the semantics of the operator for the given types.

ordinary production rule

An ordinary production rule is a production rule in A.1 EBNF that is not annotated ws:explicit.

partial function application

A static or dynamic function call is a partial function application if one or more arguments is an ArgumentPlaceholder.

partially applied function

A partially applied function is a function created by partial function application.

path expression

A path expression consists of a series of one or more steps, separated by / or //, and optionally beginning with / or //. A path expression is typically used to locate nodes within trees.

pattern-separator

pattern-separator(M) is a character used to separate positive and negative sub-pictures in a picture string; the default value is U+003B (SEMICOLON, ;) .

percent

percent(M, R) is used to indicate that the number is written as a per-hundred fraction; the default value for both the marker and the rendition is U+0025 (PERCENT SIGN, %) .

per-mille

per-mille(M, R) is used to indicate that the number is written as a per-thousand fraction; the default value for both the marker and the rendition is U+2030 (PER MILLE SIGN, ) .

predicate truth value

The predicate truth value of a value $V is the result of the expression if ($V instance of xs:numeric+) then ($V = position()) else fn:boolean($V).

primary expression

Primary expressions are the basic primitives of the language. They include literals, variable references, context value references, and function calls. A primary expression may also be created by enclosing any expression in parentheses, which is sometimes helpful in controlling the precedence of operators.

principal node kind

Every axis has a principal node kind. If an axis can contain elements, then the principal node kind is element; otherwise, it is the kind of nodes that the axis can contain.

pure union type

A pure union type is a simple type that satisfies the following constraints: (a) {variety} is union, (b) the {facets} property is empty, (c) no type in the transitive membership of the union type has {variety}list, and (d) no type in the transitive membership of the union type is a type with {variety}union having a non-empty {facets} property

resolve

To resolve a relative URI$rel against a base URI $base is to expand it to an absolute URI, as if by calling the function fn:resolve-uri($rel, $base).

reverse document order

The node ordering that is the reverse of document order is called reverse document order.

same key

Two atomic items K1 and K2 have the same key value if fn:atomic-equal(K1, K2) returns true, as specified in Section 13.2.1 fn:atomic-equalFO

schema type

A schema type is a complex type or simple type as defined in the [XML Schema 1.0] or [XML Schema 1.1] specifications, including built-in types as well as user-defined types.

sequence

A sequence is an ordered collection of zero or more items.

sequence arrow operator

The sequence arrow operator=> applies a function to a supplied sequence.

sequence concatenation

The sequence concatenation of a number of sequences S1, S2, ... Sn is defined to be the sequence formed from the items of S1, followed by the items from S2, and so on, retaining order.

sequence type

A sequence type is a type that can be expressed using the SequenceType syntax. Sequence types are used whenever it is necessary to refer to a type in an XPath 4.0 expression. The term sequence type suggests that this syntax is used to describe the type of an XPath 4.0 value, which is always a sequence.

sequence type designator

A sequence type designator is a syntactic construct conforming to the grammar rule SequenceType. A sequence type designator is said to designate a sequence type.

SequenceType matching

SequenceType matching compares a value with an expected sequence type.

serialization

Serialization is the process of converting an XDM instance to a sequence of octets (step DM4 in Figure 1.), as described in [XSLT and XQuery Serialization 4.0].

singleton

A sequence containing exactly one item is called a singleton.

singleton focus

A singleton focus is a fixed focus in which the context value is a singleton item.

stable

Document order is stable, which means that the relative order of two nodes will not change during the processing of a given expression, even if this order is implementation-dependent.

statically known collations

Statically known collations. This is an implementation-defined mapping from URI to collation. It defines the names of the collations that are available for use in processing expressions.

statically known decimal formats

Statically known decimal formats. This is a mapping from QNames to decimal formats, with one default format that has no visible name, referred to as the unnamed decimal format. Each format is available for use when formatting numbers using the fn:format-number function.

statically known function definitions

Statically known function definitions. This is a set of function definitions.

statically known namespaces

Statically known namespaces. This is a mapping from prefix to namespace URI that defines all the namespaces that are known during static processing of a given expression.

static analysis phase

The static analysis phase depends on the expression itself and on the static context. The static analysis phase does not depend on input data (other than schemas).

Static Base URI

Static Base URI. This is an absolute URI, used to resolve relative URIs during static analysis.

static context

The static context of an expression is the information that is available during static analysis of the expression, prior to its evaluation.

static error

An error that can be detected during the static analysis phase, and is not a type error, is a static error.

static function call

A static function call consists of an EQName followed by a parenthesized list of zero or more arguments.

static type

The static type of an expression is the best inference that the processor is able to make statically about the type of the result of the expression.

step

A step is a part of a path expression that generates a sequence of items and then filters the sequence by zero or more predicates. The value of the step consists of those items that satisfy the predicates, working from left to right. A step may be either an axis step or a postfix expression.

string value

The string value of a node is a string and can be extracted by applying the Section 2.1.3 fn:stringFO function to the node.

substantively disjoint

Two sequence types are deemed to be substantively disjoint if (a) neither is a subtype of the other (see 3.3.1 Subtypes of Sequence Types) and (b) the only values that are instances of both types are one or more of the following:

  • The empty sequence, ().

  • The empty map, {}.

  • The empty array, [].

substitution group

Substitution groups are defined in Section 2.2.2.2 Element Substitution Group XS1-1 and Section 2.2.2.2 Element Substitution Group XS11-1. Informally, the substitution group headed by a given element (called the head element) consists of the set of elements that can be substituted for the head element without affecting the outcome of schema validation.

subtype

Given two sequence types or item types, the rules in this section determine if one is a subtype of the other. If a type A is a subtype of type B, it follows that every value matched by A is also matched by B.

subtype substitution

The use of a value that has a dynamic type that is a subtype of the expected type is known as subtype substitution.

symbol

Each rule in the grammar defines one symbol, using the following format:

symbol ::= expression
symbol separators

Whitespace and Comments function as symbol separators. For the most part, they are not mentioned in the grammar, and may occur between any two terminal symbols mentioned in the grammar, except where that is forbidden by the /* ws: explicit */ annotation in the EBNF, or by the /* xgc: xml-version */ annotation.

system function

System functions include the functions defined in [XQuery and XPath Functions and Operators 4.0], functions defined by the specifications of a host language, constructor functions for atomic types, and any additional functions provided by the implementation. System functions are sometimes called built-in functions.

terminal

A terminal is a symbol or string or pattern that can appear in the right-hand side of a rule, but never appears on the left-hand side in the main grammar, although it may appear on the left-hand side of a rule in the grammar for terminals.

type annotation

Each element node and attribute node in an XDM instance has a type annotation (described in Section 2.8 Schema InformationDM). The type annotation of a node is a reference to a schema type.

typed value

The typed value of a node is a sequence of atomic items and can be extracted by applying the Section 2.1.4 fn:dataFO function to the node.

type error

A type error may be raised during the static analysis phase or the dynamic evaluation phase. During the static analysis phase, a type error occurs when the static type of an expression does not match the expected type of the context in which the expression occurs. During the dynamic evaluation phase, a type error occurs when the dynamic type of a value does not match the expected type of the context in which the value occurs.

type promotion

Under certain circumstances, an atomic item can be promoted from one type to another.

URI

Within this specification, the term URI refers to a Universal Resource Identifier as defined in [RFC3986] and extended in [RFC3987] with the new name IRI.

value

In the data model, a value is always a sequence.

variable reference

A variable reference is an EQName preceded by a $-sign.

variable terminal

A variable terminal is an instance of a production rule that is not itself an ordinary production rule but that is named (directly) on the right-hand side of an ordinary production rule.

variable values

Variable values. This is a mapping from expanded QName to value. It contains the same expanded QNames as the in-scope variables in the static context for the expression. The expanded QName is the name of the variable and the value is the dynamic value of the variable, which includes its dynamic type.

warning

In addition to static errors, dynamic errors, and type errors, an XPath 4.0 implementation may raise warnings, either during the static analysis phase or the dynamic evaluation phase. The circumstances in which warnings are raised, and the ways in which warnings are handled, are implementation-defined.

whitespace

A whitespace character is any of the characters defined by [http://www.w3.org/TR/REC-xml/#NT-S].

wildcard-matches

In these rules, if MU and NU are NameTestUnions, then MUwildcard-matchesNU is true if every name that matches MU also matches NU.

XDM instance

The term XDM instance is used, synonymously with the term value, to denote an unconstrained sequence of items.

XPath 1.0 compatibility mode

XPath 1.0 compatibility mode.This value is true if rules for backward compatibility with XPath Version 1.0 are in effect; otherwise it is false.

xs:anyAtomicType

xs:anyAtomicType is an atomic type that includes all atomic items (and no values that are not atomic). Its base type is xs:anySimpleType from which all simple types, including atomic, list, and union types, are derived. All primitive atomic types, such as xs:decimal and xs:string, have xs:anyAtomicType as their base type.

xs:dayTimeDuration

xs:dayTimeDuration is derived by restriction from xs:duration. The lexical representation of xs:dayTimeDuration is restricted to contain only day, hour, minute, and second components.

xs:error

xs:error is a simple type with no value space. It is defined in Section 3.16.7.3 xs:error XS11-1 and can be used in the 3.1 Sequence Types to raise errors.

xs:untyped

xs:untyped is used as the type annotation of an element node that has not been validated, or has been validated in skip mode.

xs:untypedAtomic

xs:untypedAtomic is an atomic type that is used to denote untyped atomic data, such as text that has not been assigned a more specific type.

xs:yearMonthDuration

xs:yearMonthDuration is derived by restriction from xs:duration. The lexical representation of xs:yearMonthDuration is restricted to contain only year and month components.

zero-digit

zero-digit(M) is the character used in the picture string to represent the digit zero; the default value is U+0030 (DIGIT ZERO, 0) . This character must be a digit (category Nd in the Unicode property database), and it must have the numeric value zero. This property implicitly defines the ten Unicode characters that are used to represent the values 0 to 9 in the function output: Unicode is organized so that each set of decimal digits forms a contiguous block of characters in numerical sequence. Within the picture string any of these ten character can be used (interchangeably) as a place-holder for a mandatory digit. Within the final result string, these ten characters are used to represent the digits zero to nine.