- From: Kay, Michael <Michael.Kay@softwareag.com>
- Date: Wed, 21 Jan 2004 23:43:39 +0100
- To: "Ian Davis" <ijdavis@softbase.math.uwaterloo.ca>, <public-qt-comments@w3.org>
Personal response: > > 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. "/" is a higher-order operator. Although you can think of A/B as having similar semantics to "for . in A return B", there is a crucial difference: path expressions eliminate duplicate nodes and return results in document order (which is very necessary for document-oriented XML applications). Because duplicates and document order are concepts only relevant to nodes, not to atomic values, the "/" operator is restricted to operate on nodes. Some people also felt that this restriction reduced the risk of using "/" as a division operator by mistake. > > (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.] The operation is left-to-right, so it parses as (X/Y)/Z. In fact, "/" is distributive in the vast majority of cases, but there are exceptions as you note. > > For consider the xpath expression X/1/<text>{.}</text> This isn't legal because "1" isn't a node. > > (3) What are the rules for something like X/range 15 to 10/Y. The expression (15 to 10) returns an empty sequence, so unless you do static typing this expression is actually legal, and returns an empty sequence. But if you wrote (10 to 15) you would get a type error, because the operands of "/" must be nodes. Michael Kay
Received on Wednesday, 21 January 2004 17:46:03 UTC