diff --git a/specifications/xpath-functions-40/src/function-catalog.xml b/specifications/xpath-functions-40/src/function-catalog.xml index 45f2e37ab..178e0c5f7 100644 --- a/specifications/xpath-functions-40/src/function-catalog.xml +++ b/specifications/xpath-functions-40/src/function-catalog.xml @@ -615,6 +615,157 @@ $node ! ( + + + + + + + + deterministic + context-independent + focus-independent + + +

Returns information about the type of a value, as a string.

+
+ +

The function returns a string, whose lexical form will always match + the grammar of SequenceType, representing a sequence type that matches + $value.

+

If $value is the empty sequence, the function returns the string "empty-sequence()".

+

Otherwise, the returned string is the concatenation of:

+ +

A string representing the distinct item types that are present in $value, + formed as follows:

+ +

For each item in $value, construct a string representing its item type + as described below.

+

Eliminate duplicate strings from this list by applying the fn:distinct-values + function, forming a sequence of strings $ss.

+

If $ss contains only one string, use that string.

+

Otherwise, return the result of the expression `({fn:string-join($ss, "|")})`.

+
+
+

An occurrence indicator: absent if $value contains exactly one item, or + "+" if it contains more than one item.

+
+

The string representing the type of an individual item J is constructed as follows:

+ +

If J is a node, the result is one of the following + strings, determined by the node kind of the node (see ):

+

+ "document-node()" + "element()" + "attribute()" + "text()" + "processing-instruction()" + "comment()" + "namespace-node()" +

+
+ +

If J is an atomic item, the result is a string chosen as follows:

+ +

Let T be the type denoted by the type annotation of J.

+

If T is an anonymous type, set T to the base type of T, and + repeat until a type is reached that is not anonymous.

+

If the name of T is in the namespace http://www.w3.org/2001/XMLSchema, + return the string "xs:local" where local is the local part of the + name of T.

+

Otherwise, return the name of T in the form of a + URIQualifiedName (that is, "Q{uri}local", + or "Q{}local" if the name is in no namespace).

+
+
+

If J is a function item:

+ +

If J is an array, return "array(*)".

+

If J is a map, return "map(*)".

+

Otherwise, return "function(*)".

+
+
+
+
+ + +

If the $value argument is omitted and the context value is absent, the function raises + type error .

+ +
+ +

In general, an item matches more than one type, and there are cases where there is no single matching type that + is more specific than all the others. This is especially true with functions, maps, and arrays. This function therefore + selects one of the types that matches the item, which is not necessarily the most specific type.

+ +

This function should not be used as a substitute for an instance of test. The precise type annotation + of the result of an expression is not always predictable, because processors are free to deliver a more specific type + than is mandated by the specification. For example, if $n is of type xs:positiveInteger, + then the result of abs($n) is guaranteed to be an instance of xs:integer, but an + implementation might reasonably return the supplied value unchanged: that is, a value whose actual type + annotation is xs:positiveInteger. Similarly the type annotation of the value returned by + position() might be xs:long rather than xs:integer.

+ +

Implementations should, however, refrain from exposing types that are purely internal. + For example, an implementation might have an optimized internal representation for strings consisting entirely + of ASCII characters, or for single-character strings; if this is the case then the type annotation returned by this function + should be a user-visible supertype such as xs:string.

+
+ + + +

One

+

Two

+ Three + +]]> +
+ + + type-of($e//*[@id = 'alpha']) + "element()" + + + type-of($e//*) + "element()+" + + + type-of($e//@id[. = 'gamma']) + "attribute()" + + + type-of($e//node()[.='3.14159']) + "processing-instruction()" + + + type-of($e//no-such-node) + "empty-sequence()" + + + type-of($e//doc/child::node()) + "(element()|processing-instruction())+" + + + type-of(1) + "xs:integer" + + + type-of(1 to 5) + "xs:integer+" + + + type-of((1, 1.2, 2)) + "(xs:integer|xs:decimal)+" + + +
+ +

New in 4.0

+
+
+ @@ -22230,7 +22381,7 @@ declare function transitive-closure ( then the result of abs($n) is guaranteed to be an instance of xs:integer, but an implementation might reasonably return the supplied value unchanged: that is, a value whose actual type annotation is xs:positiveInteger. Similarly the type annotation of the value returned by - position() might have a type annotation of xs:long rather than xs:integer.

+ position() might be xs:long rather than xs:integer.

Implementations should, however, refrain from exposing types that are purely internal. For example, an implementation might have an optimized internal representation for strings consisting entirely diff --git a/specifications/xpath-functions-40/src/xpath-functions.xml b/specifications/xpath-functions-40/src/xpath-functions.xml index 73e77229c..965882645 100644 --- a/specifications/xpath-functions-40/src/xpath-functions.xml +++ b/specifications/xpath-functions-40/src/xpath-functions.xml @@ -1415,9 +1415,7 @@ This includes all the built-in datatypes defined in . - - - + @@ -9161,6 +9159,9 @@ return + + +