Re: nodes or atomic values in predicate steps

Philippe,

The normalization rule you mention applies only to ForwardSteps, which 
always
return a sequence of nodes.

There is another normalization rule which applies to PrimaryExpr (See 
Section
4.3.2 Filter Expressions):

[PrimaryExpr PredicateList "[" Expr "]"]Expr
==
let $fs:sequence := [PrimaryExpr PredicateList]Expr return
let $fs:last := fn:count($fs:sequence) return
for $fs:dot at $fs:position in $fs:sequence return
   if [Expr]Predicates then $fs:dot else ()

Primary expressions can return any kind of items, and that rule does not 
force
to sort by document order and remove duplicates.

- Jerome

www-ql-request@w3.org wrote on 03/17/2005 04:48:57 AM:

> 
> Hi,
> 
> I am confused by the normalization of path expressions that have end 
with a 
> predicate step (e.g. doc("x")/a/b[c]
> 
> The normalization of filter expressions in the FS, enforces the result 
of the 
> step to be a node sequence (because of the fs:distinct-doc-order call).
> For instance, for a numerical predicate it goes as follows:
> 
> [ForwardStep PredicateList "[" Numeric "]"]Expr
>   ==
>   let $fs:sequence := 
> fs:apply-ordering-mode(fs:distinct-doc-order( [ForwardStep 
> PredicateList]Expr )) return
>   fn:subsequence($fs:sequence,Numeric,1)
> 
> But from the XPath 2.0 draft I understand that the result can be a 
> sequence of 
> nodes or a sequence of atomic values:
> 
> from (http://www.w3.org/TR/xpath20/#id-path-expressions)
> 
> Each operation E1/E2 is evaluated as follows: Expression E1 is 
evaluated, and 
> if the result is not a (possibly empty) sequence of nodes, a type error 
is 
> raised. Each node resulting from the evaluation of E1 then serves in 
turn to 
> provide an inner focus for an evaluation of E2, as described in 2.1.2 
Dynamic 
> Context. The sequences resulting from all the evaluations of E2 are 
combined 
> as follows:
> 
> (1) If every evaluation of E2 returns a (possibly empty) sequence of 
nodes, 
> these sequences are combined, and duplicate nodes are eliminated based 
on 
> node identity. The resulting node sequence is returned in document 
order.
> 
> (2) If every evaluation of E2 returns a (possibly empty) sequence of 
atomic 
> values, these sequences are concatenated, in order, and returned.
> 
> (3) Otherwise (that is, if the multiple evaluations of E2 return at 
least one 
> node and at least one atomic value), a type error is 
raised.[err:XP0018].
> 
> I'm wondering wheather the distinct-doc-order call in the FS should 
> in fact be 
> a distinct-doc-order-or-atomic-sequence call.
> 
> Thanks,
> Ph
> -- 
> Philippe Michiels
> Universiteit Antwerpen
> ADReM (Advanced Database Research and Modelling)
> http://www.adrem.ua.ac.be/~michiels
> 

Received on Thursday, 17 March 2005 16:54:00 UTC