This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 29683 - [XP31] Map lookup through function-call syntax does not explain what happens if the key does not exist
Summary: [XP31] Map lookup through function-call syntax does not explain what happens ...
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XPath 3.1 (show other bugs)
Version: Member-only Editors Drafts
Hardware: PC Windows NT
: P2 minor
Target Milestone: ---
Assignee: Jonathan Robie
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-02 09:46 UTC by Abel Braaksma
Modified: 2016-07-20 13:58 UTC (History)
1 user (show)

See Also:


Attachments

Description Abel Braaksma 2016-06-02 09:46:43 UTC
Section 3.11.1.2 Map Lookup using Function Call Syntax in FO31 does not explain what happens if

1) the key does not exist (should it through an error, or behave like map:get?)
2) the key is not comparable using the collation (behave like map:get?)

Perhaps we should normatively link this section to the semantics of map:get, or conversely, move the semantics of map:get to this section and link back from map:get to this section.

Alternatively, using this syntax may raise an error for non-existing map keys, but I doubt that was the intend.

Note: sections 3.11.3.1 Unary Lookup and 3.11.3.2 Postfix Lookup do not seem to explain this either.
Comment 1 Abel Braaksma 2016-06-02 10:06:15 UTC
Note, the example in FO31 section 17.5.3 fn:json-to-xml suggests that $m(x), where $m is a map, should return the empty sequence. Checking this code was what brought me to reporting this, as I had expected map:exists($c0chars, $char) in there somewhere.

This rule is implied from the lines with $replacement in the code below:

    ....
       let 
         $c0chars := map {
           '\u0000':'[NUL]',
           '\u0001':'[SOH]',
           '\u0002':'[STX]',
           ...
           '\u001E':'[RS]',
           '\u001F':'[US]'
         },
         $replacement := $c0chars($char)
      return 
        if (exists($replacement))
    ....
Comment 2 Michael Kay 2016-06-02 10:43:36 UTC
The reference in

Section 3.11.1.2 Map Lookup using Function Call Syntax in FO31

should be to 3.11.1.2 in *XP31*.

I agree that the semantics of $M($K) should be defined as equivalent to map:get($M, $K).
Comment 3 Jonathan Robie 2016-06-07 15:22:03 UTC
(In reply to Michael Kay from comment #2)

> I agree that the semantics of $M($K) should be defined as equivalent to
> map:get($M, $K).

Yes.  And for arrays, $A($K) should be defined as array:get($A, $K).
Comment 4 Jonathan Robie 2016-06-14 15:36:46 UTC
Resolved by accepting comment #2 and comment #3.
Comment 5 Abel Braaksma 2016-07-20 13:58:45 UTC
Checked, looks good, thanks.