- From: Charles Brooking <charles.brooking@research.canon.com.au>
- Date: Tue, 26 Apr 2005 15:16:05 +1000
- To: www-ql@w3.org
- Message-ID: <426DCE95.1040806@research.canon.com.au>
Hi all I have some questions about variable references appearing in path expressions and, in particular, how node identity, variable binding, and element constructors actually "work" in this context. Insights into this would be appreciated! Consider the path expression $a/$b. If $a is a singleton, then the expression is equivalent to $b. However, if $a is not a singleton, then a query such as let $a := (<a1/>, <a2/>, <a3/>), $b := (1, 2, 3) return $a/$b will return (1, 2, 3, 1, 2, 3, 1, 2, 3) determined by evaluating $b in the context of each node from $a, and concatenating the resulting sequences of atomic values. When combining node sequences obtained by evaluating a step in a path expression, however, duplicate nodes are eliminated based on node identity. According to the XQuery 1.0 and XPath 2.0 Data Model, atomic values do not have identity, which is why they are simply concatenated. However, will let $a := (<a1/>, <a2/>, <a3/>), $b := (<b1/>, <b2/>, <b3/>) return $a/$b return (<b1/>, <b2/>, <b3/>, <b1/>, <b2/>, <b3/>, <b1/>, <b2/>, <b3/>) because the expression bound to $b constructs unique elements each time it is evaluated? Or should (<b1/>, <b2/>, <b3/>) be returned? This might be the case if the expression bound to $b is only evaluated once (ie when it is bound, before considering the "return" expression) and the constructed elements <b1/>, <b2/>, and <b3/> do actually have an identity. This raises another question: do constructed nodes even have an identity, or does the concept apply only to nodes from a document? Later Charlie
Received on Tuesday, 26 April 2005 05:16:18 UTC