Re: [XQuery] 3.2 Path expressions returning non-nodes

The "!" operator looks interesting, though is more than the simple  
extension we'd like. There is already a differentiation between  
AxisSteps and FilterSteps. The problem is although the grammar allows  
FilterSteps at the end of a path, they are currently valid only when no  
AxisSteps have been taken, or if the result of the filter is a node.  
The rule seems simple:
If the path ends with an AxisStep, proceed as usual (eliminate  
duplicate nodes and return in sequence order)
If the path ends with a FilterStep, order the sequence in the same  
order as the result from the primary expression.

Note that we're not proposing the change of E1; it still must always be  
a sequence of nodes.

--Sarah

On Feb 3, 2004, at 12:55 PM, Michael Kay wrote:

> I agree with you that a mapping operator of this kind is desirable, and
> have raised a public comment to that effect, because the requirement
> keeps coming up:
>
> http://lists.w3.org/Archives/Public/public-qt-comments/2003Dec/ 
> 0061.html
>
> I don't think it's right to overload "/" with this functionality. The
> "/" operator causes elimination of duplicates and sorting into document
> order, and there are cases where this is absolutely necessary when
> processing nodes; it's hard to overload the semantics so that this only
> happens when the arguments are nodes (all nodes? some nodes?), and it
> doesn't make sense when the arguments are atomic values.
>
> In previous discussions among some XSL WG members, we have discussed
> using "!" for this mapping operator. (In very early discussions on the
> XPath task force I proposed "\", which was quite rightly ruled out).
>
> Michael Kay
>
>
>> -----Original Message-----
>> From: public-qt-comments-request@w3.org
>> [mailto:public-qt-comments-request@w3.org] On Behalf Of Sarah Wilkin
>> Sent: 03 February 2004 19:15
>> To: public-qt-comments@w3.org
>> Subject: [XQuery] 3.2 Path expressions returning non-nodes
>>
>>
>>
>> 3.2 Path Expressions
>> "Each evaluation of E2 must result in a (possibly empty) sequences of
>> nodes; otherwise a type error is raised. [err:XP0019]"
>>
>> We feel XQuery is limited by its focus on nodes. The evaluation of E2
>> should be able to contain nodes or atomic values.
>>
>> The main purpose of this is to allow for a function at the end of a
>> path. Generally this saves writing a loop. For example:
>>
>> let $root := <b><a>   foo  bar</a><a>baz     faz</a></b>
>> return $root/a/normalize-space(.)
>>
>> instead of
>> let $root := <b><a>   foo  bar</a><a>baz     faz</a></b>
>> let $seq := $root/a
>> let $result := for $item in $seq
>> 	return normalize-space($item)
>> return $result
>>
>> In addition, without this functionality ugly workarounds are required
>> to obtain the value of context functions. For example:
>> ("a", "b", "c" )/text{ position() }
>>
>> instead of the straightforward:
>> ("a", "b", "c" )/position()
>>
>> --Sarah
>>
>

Received on Tuesday, 3 February 2004 17:55:25 UTC