Streamability and XPath 3.1

This note addresses what we need to do to make streamability well-defined for processors that support XPath 3.1.

General: Streamability of Maps and Arrays

(perhaps add this as a general statement somewhere).

The rules for maps and arrays are designed to ensure that the entries in a map, and the members of an array, cannot contain nodes from a streamed document. This is achieved by using operand usage navigation for the operands of the relevant expressions and functions.

19.2 Determining the Static Type

In the list introduced by “The mapping is as follows”, change “

 • FunctionTest and MapTest map to U{function(*)}
to
 • FunctionTest, MapTest and ArrayTest map to U{function(*)}

We have already added new XPath 3.1 constructs as an additional table towards the end of the section, but this needs slight amendment because the Arrow expression is now a first-class expression in its own right rather than a type of PostfixExpr. Furthermore, lookup expressions are now supported in XSLT 3.0 whether or not the XPath 3.1 feature is enabled, so these should move into the main table.

19.8.8 Classifying Expressions

The table of expressions needs the same additions as in 19.2: Unary lookup, Postfix lookup, arrow expressions, square and curly array constructors.

For square and curly array constructors, the GSR applies with operand usage navigation for all the operands, which can be expressed using the proformas [N, N, …] and {N, N, …}.

For an arrow expression X => F(X, Y) the streamability is the same as that of the equivalent static or dynamic function call F(X, Y, Z).

For a postfix lookup, the GSR applies. Given E?L, E has usage inspection (by analogy with dynamic function calls), and L is a higher-order operand with usage absorption. Where L is a wildcard (E?*), there is only one operand E, with usage inspection.

For a unary lookup, ?L has the same streamability as the postfix lookup expression .?L. 

19.8.9 Classifying calls to built-in functions

New 3.1 functions need to be added to the list. I think they will all be straightforwardly definable using the “proforma” technique. The list here is generated from the function catalog used when generating the XPath 3.0, XPath 3.1, and XSLT 3.0 specifications. The XPath 3.0 and XSLT 3.0 catalogs have been annotated with operand usages. The XP30 usages need to be transferred to the XP31 spec, and usages added for functions that are new in XP31.

For the array functions, the appropriate proformas appear to be:

array:size(A)
array:get(A, A)
array:append(A, N)
array:subarray(A, A, A)
array:remove(A, A)
array:insert-before(A, A, N)
array:head(A)
array:tail(A)
array:reverse(A)
array:join(A)
array:for-each(N, I) (I think map:for-each should also be (N, I))
array:filter(N, I)
array:fold-left(N, A, I)
array:fold-right(N, A, I)
array:for-each-pair(N, N, I)
array:sort(N, I)
array:flatten(A)

The other new functions in 3.1 are:

parse-ietf-date(A)
parse-json(A)
json-doc(A)
sort(N, I)
load-xquery-module(A, A)
transform(A, A)
contains-token(A, A)
random-number-generator(A)
tokenize(A)
trace(A)

Michael Kay
Saxonica

Received on Monday, 14 September 2015 10:53:44 UTC