FS semantics of XPath normalization

My questions are with respect to the 12 November 2004 working draft of
the XQuery 1.0 and XPath 2.0 Formal Semantics.
[http://www.w3.org/TR/xquery-semantics]

My concerns relate to the syntax of an XPath that allows atomic values
to be used where a XPath step may occur.

(1) It is observed in 3.5.3 that 1/foobar "would raise a dynamic error because
a path expression may not be applied to an atomic value". Is this always to be
considered the case or would something like 1/<text>{.}</text> be
considered a valid XQuery expression, evaluating to the element node
<text>1</text>.  It is not clear if '/' is intended to be viewed as a
syntactic abbreviation for the normalised query, or as an operator with
inherent restrictions on what types of operand it accepts.

(2) At the beginning of section 4.2 normalisation
of two step operations separated by a '/' is described.  But it is not
made very clear if X/Y/Z is normalized by first normalizing X/Y or by
first normalizing Y/Z.  This is significant because the / operator is
not distributive. [The XQuery grammar is also somewhat ambiguous here
because a step may be a filter expression but a filter expression may
itself be an arbitrary XQuery expression and thus one step or more than
one step long.]

For consider the xpath expression X/1/<text>{.}</text>

It seems logical to normalize this XPath in the (X/1)/<text>{.}</text> order.
Doing so we first perform the following normalisation:

let:$fs:sequence := [X] return
   let $fs:sequence := fn:count($fs:sequence) return
      for $fs:dot at $ts:position in $fs:sequence return
         [1]Expr

I think the intent of this normalisation is to produce a sequence of as
many 1's, as there are members in the set $fs:sequence.

This sequence of 1's are then presented to fs:distinct-doc-order which
expects its operand to be of type node*.  Thus at this point a typing
exception is raised.

If however one performs normalisation in the sequence X/(1/<text>{.}</text>)
then (1/<text>{.}</text>) evaluates to <text>1</text> reducing the XPath to
X/<text>1</text>. This can be normalised and subsequently evaluated without
any exception being thrown as explained in (1)..

(3) What are the rules for something like X/range 15 to 10/Y.  That is does
normalisation of this query result in no error being thrown on the grounds
that applying fs:distinct-doc-order to an empty sequence is valid (at run
time) or invalid on the grounds that static typing of fs:distinct-doc-order
expects type node* as its operand, not integer*, or itself dependent on
whether or not an internal static optimiser reduces range 15 to 10 => ()
... ie. the empty set?

Clarification leading to a better understanding of the desired behaviour of
engines that implement XPath expressions would be greatly appreciated.

Thanks, Ian Davis

Received on Wednesday, 21 January 2004 16:31:45 UTC