Although the draft (unpublished) grammar for map expressions says they are primaries, which would make this construct legal, Saxon has implemented map{} at the same level of the grammar as validate{} and try{}, which are not primaries, and therefore have to be wrapped in parentheses to allow them to be followed by an argument list or predicate. I don't think it's worth changing this until the grammar gets finalized by W3C.

Michael Kay
Saxonica

On 27/02/2012 21:30, Jakub Malý wrote:

Hi,

when using an abbreviated syntax for map:get, the following expression is evaluated by Saxon correctly:

let $m := map{'x' := 5, 'y' := 'hi'} return $m('x') eq 5

but this one is rejected as syntactically incorrect:

map{'x' := 5, 'y' := 'hi'}('x') eq 5

I have to write an additional pair of parentheses:

(map{'x' := 5, 'y' := 'hi'})('x') eq 5

 

Is this the desired behavior?

 

It surprised me a little, since both of the following expressions are accepted:

function($x) {$x + 1}(2)

(function($x) {$x + 1})(2)

 

Jakub.



Jakub Malý

 

Ph. D. candidate

XML Research Group

Department of Software Engineering

Faculty of Mathematics and Physics
Charles University in Prague, Czech Republic
www.jakubmaly.cz

 



------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2


_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help