[xquery-talk] simple map operator

Michael Kay mike at saxonica.com
Mon Jul 9 02:26:50 PDT 2012


A!B is a RelativePathExpr in the BNF grammar, but so are 29, count($x), 
and (1 to 10)[3].

Similarly, the way the grammar works, "a and b" is an instance of 
OrExpr, and 2+2 is an instance of ValueComp.

So you need to distinguish the names of productions in the grammar, 
which affect the precedence of expressions, from the semantics of the 
operators appearing in those expressions. Generally productions are 
named after the lowest-precedence operator that is allowed to appear in 
the expression.

In fact, since XPath 3.0 was last published, we have decided to change 
the precedence of the new "!" operator to be lower than the precedence 
of "/", so this will change.

As for my book, see the discussion of the terminological problems around 
the phrase "path expression" on the first page of chapter 9; also see 
page 523. In common parlance, a "path expression" is an expression that 
uses the "/" operator, just as an "or expression" is one that uses the 
"or" operator; but that doesn't correspond to the BNF symbols PathExpr 
and OrExpr.

The term "sequence expression" is used as a chapter heading in my book, 
as a convenient title for the set of constructs I chose to describe in 
that chapter, but it is not a term that appears in the XPath language 
specification itself.

Michael Kay
Saxonica


On 09/07/2012 09:43, Jens Østergaard Petersen wrote:
> Thanks, Michael,
>
> If the simple map operator "does not locate any special nodes within trees, but works on sequences of items you specify by expressions", does that not make it into a sequence expression in the terms of Michael Kay's Reference, Chapter 10 (which also has "/" as a simple mapping expression when it works on atomic values)? Also, the draft defines a path expression as something that "can be used to locate nodes within trees", so I still wonder what the meaning behind this categorisation is.
>
> Cheers,
>
> Jens
>
> On Jul 9, 2012, at 10:01 AM, Michael Seiferle wrote:
>
>> Hi Jens,
>>
>> they are relative, such that each step (E1 ! E2) will serve as the input sequence E'1 for the next operation (E'1 ! E'2), hence:
>>
>>> <foo>
>>>   <bar>hello</bar>
>>>   <bar>world</bar>
>>>   <bar>and</bar>
>>>   <bar>hello</bar>
>>>   <bar>universe</bar>
>>> </foo>/bar ! (: here we locate each <bar /> child of <foo /> :)
>>>     upper-case(.) !  (: we return a sequence of their text() in upper-case :)
>>>           substring(.,2,string-length(.)) (: we return a sequence of the upper case text and strip the first character :)
>> the map operator redefines the context items (inner focus) for each subsequent operation.
>>
>> So it does not locate any special nodes within trees, but works on sequences of items you specify by expressions, for example:
>>> (1 to 5) ! (. + 1) ! (. * 2)
>> will work as well and returns (4, 6, 8, 10, 12).
>>
>> Hope this helped to clear things up a little :-).
>> I guess others on this list will correct me if I got something wrong.
>>
>> Kind regards
>>
>> Michael
>>
>>
>>
>> Am 09.07.2012 um 09:41 schrieb Jens Østergaard Petersen:
>>
>>> Hi,
>>>
>>> Can anyone explain to me why the XQuery 3.0 simple map operator <http://www.w3.org/TR/xquery-30/#id-map-operator> is a relative path expression? Which nodes within trees does it locate?
>>>
>>> Thanks in advance for any enlightenment,
>>>
>>> Jens
>>> _______________________________________________
>>> talk at x-query.com
>>> http://x-query.com/mailman/listinfo/talk
>
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk
>




More information about the talk mailing list